akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}

vector<int> Zalgo(const vector<ll>& S){
  vector<int> Z(S.size());
  Z[0] = S.size();
  int i = 1, j = 0;
  while (i < S.size()) {
    while (i+j < S.size() && S[j] == S[i+j]) ++j;
    Z[i] = j;
    if (j == 0) { ++i; continue;}
    int k = 1;
    while (i+k < S.size() && k+Z[k] < j) Z[i+k] = Z[k], ++k;
    i += k; j -= k;
  }
  return Z;
}

int main(void){
  fast_io
  ll n;cin>>n;
  vector<ll> A_(n),B_(n),A(n),B(3*n-1);
  rep(i,n){
    cin>>A_[i];
  }
  rep(i,n){
    cin>>B_[i];
  }

  rep(i,n){
    B[i] = A_[(i+1)%n]^A_[i];
    B[i+n] = B_[(i+1)%n]^B_[i];
    if(i!=n-1) B[i+n*2] = B[i+n];
  }
  rep(i,B.size()){
    //cout<<B[i]<<" ";
  }
  //cout<<endl;
  vector<pair<int,int>> op;

  vector<int> ans = Zalgo(B);
  rep(i,ans.size()){
    if(i < n) continue;
    if(ans[i] >= n){
      op.push_back({(3*n-i)%n, ((A_[0])^(B_[i-n]))});
    }
  }
  sort(all(op));
  rep(i,op.size()){
    cout<<op[i].first<<" "<<op[i].second<<endl;
  }
  return 0;
}

Measured memory_bytes: 16880
#include<bits/stdc++.h>
#define YY "YES\n"
#define NN "NO\n"
#define LL long long
using namespace std;

int n,m,ar[20001],a[20001],b[20001];

int main(){
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>ar[i];
	}
	for (int i=1;i<=n;i++){
		a[i]=i*n;
		b[i]=(n-i+1)*n;
	}
	for (int i=1;i<=n;i++){
		b[ar[i]]+=(i-1);
	}
	for (int i=1;i<n;i++) cout<<a[i]<<" ";
	cout<<a[n]<<"\n";
	for (int i=1;i<n;i++) cout<<b[i]<<" ";
	cout<<b[n]<<"\n";
}

Measured memory_bytes: 3864
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

int main(){

    ll N; cin >> N;

    cout << (N-1)*N/2 << endl;

}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;

int main(){
  
  int X,Y,Z;
  cin >> X >> Y >> Z;
  int haba = X-Z;
  int hitori = Y+Z;
  int ans = 0;
  for(int i=0;;i++){
    if(haba<hitori) break;
    haba -= hitori;
    ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8')

const s = stdin.split('\n')[0]

let ans = Infinity

for (let i = 0; i < s.length - 2; i++) {
  const num = Number(s[i]+s[i+1]+s[i+2])
  const d = Math.abs(753-num)
  ans = d < ans ? d : ans
}

console.log(ans)


Measured memory_bytes: 7372
H,W = map(int,input().split())
s=[list(input()) for _ in range(H)]

for i in range(H):
    s[i].append(".")
    s[i].insert(0,".")

add_list = ["." for _ in range(W+2)]
s.append(add_list)
s.insert(0,add_list)

Flag = "Yes"

for i in range(H):
    for j in range(W):
        if (s[i][j]=="#" and (s[i][j+1]=="." and s[i][j-1]=="." and s[i+1][j]=="." and s[i-1][j]==".")):
            Flag = "No"
            break
print(Flag)


Measured memory_bytes: 3064
#include <stdio.h>
int x[10000];
int main(void)
{
    int i = 0;
    do{
        scanf("%d", &x[i]);
    }while(x[i++]);
    for(i = 0; x[i]; i++){
        printf("Case %d: %d\n", i + 1, x[i]);
    }
    return (0);
}


Measured memory_bytes: 2024
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec W(N); cin >> W;
    int S = 0;
    REP(i, N) S += W[i];
    int t = 0, ans = INF;
    REP(i, N){
        t += W[i];
        Min(ans, llabs(S - 2 * t));
    }
    Out(ans);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)

#define ALL(v) v.begin(), v.end()

int main() {
  std::cout << std::fixed << std::setprecision(20);
  int64_t N;
  cin >> N;
  vector<int64_t> A(N);
  REP(i,N) cin >> A[i];
  sort(ALL(A));
  if(A[0] == 0){
    cout << 0 << endl;
      return 0;
  }

  int64_t limit = pow(10,18);
  int64_t ans = 1;
  REP(i,N){
    if(ans > (limit/A[i])){
      cout << -1 << endl;
      return 0;
    }
    ans *= A[i];
  }
      
  cout << ans << endl;

  
}

Measured memory_bytes: 4048
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;

    ll gcd(ll a,ll b){
        if(a%b == 0)return b;
        else return gcd(b,a%b);
      }


    int main(){
      int n;
      cin>>n;
      VEC(ll,a,n);
      sort(a.begin(),a.end(),greater<ll>());
      ll ans = a[0];
      REP(i,1,n-1){
        ans = gcd(a[i],ans);
        if(ans == 1){
          cout<<ans<<endl;
          return 0;
        }
      }
      cout<<ans<<endl;
    }
      


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long n = sc.NextLong();
        long[] a = sc.LongArray();

        long sum = a.Sum();

        long answer = long.MaxValue;

        long left = 0;
        for (long i = 0; i < n; i++)
        {
            left += a[i];
            long right = sum - left;

            answer = Math.Min(answer, Math.Abs(left - right));
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 47996
def operation_of_foa(input_seq, times)
	operated_seq = Array.new
	input_seq.each { |x| operated_seq << input_seq.count(x) }
	if operated_seq == input_seq
		return [operated_seq, times-1]
	else
		operation_of_foa(operated_seq, times+1)
	end
end

def print_seq(seq, times)
	puts times
	seq.each.with_index { |x,i| print (i.zero? ? x : " #{x}") }
	puts ""
end

while gets
	n = $_.to_i
	break if n == 0
	input_seq = gets.chomp.split.map(&:to_i)
	print_seq(*operation_of_foa(input_seq, 1))
end

Measured memory_bytes: 6120
import numpy as np

n = int(input())

answers = [[[] for i in range(n)] for j in range(n)]
answers[0][0] = "a"
alphabets = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
if n == 1:
    print("a")
else:
    for i in range(n-1):
        for j in range(n):
            b_ans = answers[i][j]
            for one_ans in b_ans:
                for k in range(j+1):
                    answers[i+1][j].append(one_ans + alphabets[k])
                answers[i+1][j+1].append(one_ans + alphabets[j+1])
    all_answers = []
    for i in range(n):
        for single_ans in answers[n-1][i]:
            all_answers.append(single_ans)
    ans = sorted(all_answers)
    for print_ans in ans:
        print(print_ans)


Measured memory_bytes: 25492
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)
#define fcout cout << fixed << setprecision(10)

using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    string S;
    cin >> S;

    map<char, int> map;
    REP(i, S.size()) { map[S[i]]++; }

    int minc = INF;
    int maxc = 0;

    string t = "abc";
    REP(i, t.size()) {
        char c = t[i];
        minc = min(minc, map[c]);
        maxc = max(maxc, map[c]);
    }

    maxc - minc <= 1 ? cout << "YES" << endl : cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<ll(n);i++)

int main() {
    ll n, k;
    cin >> n >> k;
    vector<int>h(n);
    ll ans = 0;
    rep(i, n) {
        cin >> h[i];
        ans += h[i];
    }
    sort(h.begin(), h.end(), greater<int>());
    rep(i, min(k,n)){
        ans -= h[i];
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

int n, m;
vector<int> k;
vector<vector<int>> s;
vector<int> p;

ll		check(vector<int> v)
{
	ll ret = 1;
	for (int i = 0; i < m; i++)
	{
		int on = 0;
		for (int j = 0; j < k[i]; j++)
		{
			if (v[s[i][j]])
				on++;
		}
		if (on % 2 != p[i])
			ret = 0;
	}
	return (ret);
}

ll		dfs(int d, vector<int> v)
{
	if (d == n)
		return (check(v));
	ll ret = 0;
	ret += dfs(d+1, v);
	v[d] = 1;
	ret += dfs(d+1, v);
	return (ret);
}

int     main()
{
	cin >> n >> m;
	k.resize(m);
	s.resize(m);
	p.resize(m);
	for (int i = 0; i < m; i++)
	{
		cin >> k[i];
		s[i].resize(k[i]);
		for (int j = 0; j < k[i]; j++)
		{
			int tmp;
			cin >> tmp;
			tmp--;
			s[i][j] = tmp;
		}
	}
	for (int i = 0; i < m; i++)
	{
		cin >> p[i];
	}
	vector<int> v(n, 0);
	ll ans = dfs(0, v);
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;
char s[100005];
int main() {
    scanf("%s", s);
    char first = s[0];
    int n = strlen(s);
    char end = s[1];
    
    char isFailed = true;
    for (int i = 2; i < n ; ++i) {
        if (i % 2 == 0 && s[i] == first);
        else if (i % 2 == 1 && s[i] == end);
        else {
            isFailed = false;
        }
    }

    int numOfMove = n - 1 - (first == s[n - 1]);
    if (isFailed || numOfMove % 2 == 1) puts("Second");
    else puts("First");

    return 0;
}


Measured memory_bytes: 3860
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author jignesh1604
 */

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>

using namespace std;

class CSqrtInequality {
public:
    long double srt(long double n) {
        long double low , high ;
        while(low <= high) {
            long double mid = (low + high) / 2 ;
            if(abs(mid*mid - n) <= 1) {
                return mid ;
            }
            if(mid*mid < n) {
                low = mid + 1 ;

            }
            else {
                high = mid - 1 ;
            }
        }
    }
    void solve(std::istream &in, std::ostream &out) {
        long long int a, b, c;
        in >> a >> b >> c;
        if(c <=a || c <= b) {
            out << "No\n";
        }
        else {
            if(4*a*b < (c - a - b) * (c - a - b)) out << "Yes\n" ;
            else out << "No\n" ;
        }
    }
};

int main() {
	CSqrtInequality solver;
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int A,B,C,D,E,F;
int a,b;
bool dp[3005][3005];
bool verif(int a,int b)
{
    return (a*E>=b*100)&&a+b<=F;
}
int main()
{
    cin>>A>>B>>C>>D>>E>>F;
    int dx[]={100*A,100*B,0};
    int dy[]={C,D,0};
    dp[0][0]=1;
    a=100*A;
    for(int i=0;i<=F;i++)
    {
        for(int j=0;j<=F-i;j++)
        {
            if(!verif(i,j))continue;
            for(int k=0;k<3;k++)
            {
                for(int l=0;l<3;l++)
                {
                    if(i>=dx[k]&&j>=dy[l])dp[i][j]|=dp[i-dx[k]][j-dy[l]];
                }
            }
            if(dp[i][j]&&j)
            {
                if(b*i<=j*a)
                {
                    a=i;
                    b=j;
                }
            }
        }
    }
    cout<<a+b<<" "<<b;
    return 0;
}


Measured memory_bytes: 8704
N = int(input())
A = [[list(map(int, input().split())) for _ in range(int(input()))] for _ in range(N)]

res = 0
for k in range(1 << N):
    bits = [(k >> i) & 1 for i in range(N)]
    flag = True
    for i, a in enumerate(A):
        if bits[i] == 0:
            continue
        for x, y in a:
            if bits[x - 1] == y:
                continue
            flag = False
    if flag:
        res = max(res, sum(bits))

print(res)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
main() {
	int n,k; cin >> n >> k;
	long long  mn = INT_MAX,sum = 0;
	vector<int> v(n);
	bool flag = 0;
	for (int i = 0;i < n; i++) {
		cin >> v[i];
		if (v[i] >= 0) flag = 1;
	}
	if (n == k) {
		int s = 1;
		for (int i = 0;i < n; i++)
			s= 1ll*s*v[i]%mod;
		cout << (s+mod)%mod <<'\n';
		return 0;
	}
	if (flag == 0) {
		if (k % 2 == 1) 
		sort(v.rbegin(),v.rend());
		else sort(v.begin(),v.end());
		int s = 1;
		for (int i = 0; i < k; i++) {
			s = 1ll*s*v[i]%mod;
		}
		cout << (s+mod)%mod;
		return 0;
	}
	sort(v.begin(),v.end(),[&](int a,int b) {
		return abs(a) > abs(b);
	});
	int x = 0;
	int pd = -1,g = -1;
	for (int i = 0;i < k; i++) {
		if (v[i] < 0) x++;
		if (v[i] <= 0) g = i;
		if (v[i] >= 0) pd = i;
	}
	if (v[k-1] == 0) {
		cout <<0;
		return 0;
	}
	if (x % 2 == 0) {
		int s = 1;
		for (int i = 0; i < k; i++) {
			s = 1ll*s*v[i]%mod;
		}
		cout << (s+mod)%mod;
		return 0;
	}
	int id1 = -1,id2 = -1;
	for (int i = k; i < n; i++) {
	if (v[i] >= 0 && id1 == -1) { id1 = i;}
	if (v[i] <= 0 && id2 == -1) {id2 = i;}
	}
	if (id1 == -1 || (pd != -1 && id2 != -1 && 1ll*abs(v[id2])*abs(v[g]) > 1ll*abs(v[pd])*v[id1])) {
		 swap(v[pd],v[id2]);
	}
	else swap(v[id1],v[g]);
	int s = 1;
		for (int i = 0; i < k; i++) {
			s = 1ll*s*v[i]%mod;
		}
	cout << (s + mod)%mod;
}

Measured memory_bytes: 3960
int main(void){
	char c,lc;
	int t;
	t=0;
	lc=getchar();
	while(1){
		if(c=='\n')
			break;
		c=getchar();
		if(c==lc){
			t++;
			if(c=='0')
				lc='1';
			else
				lc='0';
		}
		else{
			lc=c;
		}
	}
	printf("%d",t);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
int solve(vector<int> vec,int n)
{
  vector<int> dp(n+1);
  dp[1]=0;
  for(int i=2;i<=n;i++)
  {
    int option1 = abs(vec[i]-vec[i-1])+dp[i-1];
    int option2 =(i==2)?inf: abs(vec[i]-vec[i-2])+dp[i-2];
    dp[i]=min(option1,option2);
  }
  return dp[n];
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int n;
  cin>>n;
  vector<int> vec(n+1);
  for(int i=1;i<=n;i++)
  {
    cin>>vec[i];
  }
  cout<<solve(vec,n);
  return 0;
}


Measured memory_bytes: 1408
function Main(s){
  s = s.split("\n");
  var k = +s[1];
  s = s[0];
  var a = 96;
  var sl = s.length;
  var ans = {};
  var j;
  loop:
  while(a <= 122){
    a++;
    var n = s.indexOf(String.fromCharCode(a));
    while(n !== -1){
      for(j = 0; j < k; j++){
        if(n + j >= sl)break;
        ans[s.slice(n, n + j + 1)] = 1;
      }
      n = s.indexOf(String.fromCharCode(a), n+1);
    }
    j = 0;
    var ans2 = [];
    for(i in ans){
      j++;
      ans2.push(i)
    }
    if(j >= k){
      ans2.sort();
      console.log(ans2[k-1]);
      break loop;
    }
  }
}

Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 23092
#include <iostream>

int main()
{
    int a,b,c;
    int count = 0;
    std::cin >> a >> b >> c;
    
    for(int i = a; i <= b; i++)
    {
        int test = c%i;
        if(test==0)
        {
            count++;
        }
    }
    
    std::cout << count << std::endl;
    
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
#define INF (1e9)

int main() {
    ll N, A, B;
    string S;
    cin >> N >> A >> B >> S;

    ll T = 0;  // 現在予選の通過が確定した参加者
    ll U = 0;  // 海外の学生
    for (int i = 0; i < N; i++) {
        int s = S[i] - 'a';
        if (s == 0 && T < A + B) {
            T++;
        } else if (s == 1 && T < A + B && U < B) {
            T++;
            U++;
        } else {
            cout << "No" << endl;
            continue;
        }
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 896
#include <stdio.h>

// answer[0]: gcd
// answer[0]: lcm
void alg ( unsigned long a, unsigned long b, unsigned long* answer )
{
    unsigned long tmp, pg[2];

    if ( a > b )
    {
        pg[0] = a;
        pg[1] = b;
    }
    else
    {
        pg[0] = b;
        pg[1] = a;
    }

    while ( ( pg[0] %= pg[1] ) > 0 )
    {
        tmp = pg[0];
        pg[0] = pg[1];
        pg[1] = tmp;
    }

    answer[0] = pg[1];
    answer[1] = a * b / answer[0];
}

int main ( void )
{
    unsigned long data_a, data_b, result[2];

    while ( scanf("%lu %lu", &data_a, &data_b ) != EOF )
    {
        alg( data_a, data_b, result );
        printf( "%lu %lu\n", result[0], result[1] );
    }

    return 0;
}

Measured memory_bytes: 604
#include<iostream>
using namespace std;

int main() {
  int N, M, A, R=0;
  cin >> N >> M;
  for(int i = 0; i < M; ++i) {
    cin >> A;
    R+=A;
  }
  cout << (N < R ? -1 : N - R) << endl;
  return 0;
}

Measured memory_bytes: 3188
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(){
  double x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  //cout << sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)) << endl;
  printf("%.5f\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
  return 0;
}



Measured memory_bytes: 3200
/*
Author-KUSHAGRA SINGH
Birla Institute of Technology Mesra
CS K18
*/
 
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
//#define mp make_pair
#define pb emplace_back
#define vll vector<ll>
#define vpll vector< pair <ll,ll> >
#define pll pair <ll,ll>
#define pq priority_queue< int >
#define khtm "\n"
#define F first
#define S second
#define fr(i,a,n) for(i=a;i<n;i++)
#define ALL(x) x.begin(), x.end()
#define frr(i,a,n) for(i=n-1;i>=a;i--)
#define mod 1000000007
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase ll T; cin>>T; while(T--)
const int MAX = 1e6 +2;
 
/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 
ll i,j,k,l,m,r,n;
 
 
ll a[MAX];
//ll dp[2006];
vpll v;
 
ll dp[205][100005];
 
ll rec(ll pos, ll rem){
	if(pos==n)
		return 0;
	if(dp[pos][rem]==-1){
		dp[pos][rem]=0;
		if(rem>=v[pos].F){
			dp[pos][rem] = max(v[pos].S + rec(pos+1,rem-v[pos].F), rec(pos+1,rem));
		}
		else{
			dp[pos][rem] = rec(pos+1,rem);
		}
	}
	return dp[pos][rem];
}
 
int main()
{
 

fast
memset(dp,-1, sizeof dp);
cin>>n>>k;
// vpll v;
fr(i,0,n){
	cin>>l>>r;
	v.pb(l,r);
}
 
// cout<<"Hey stupid robber, you can get ";
cout<<rec(0,k)<<khtm;
 
 
    return 0;
} 


Measured memory_bytes: 162048
h, w = map(int, input().split())
ns = []
for _ in range(h):
    ns.append([i % 2 for i in map(int, input().split())])
ans = []
for i in range(h-1):
    for j in range(w):
        if ns[i][j]:
            ans.append('{} {} {} {}'.format(i+1, j+1, i + 2, j+1))
            ns[i + 1][j] = (ns[i + 1][j] + 1) % 2
for j in range(w - 1):
    if ns[-1][j]:
        ans.append('{} {} {} {}'.format(h, j + 1, h, j + 2))
        ns[-1][j+1] = (ns[-1][j+1]+1) % 2
print(len(ans))
for i in ans:
    print(i)



Measured memory_bytes: 69340
from operator import itemgetter

N = int(input())
SP = []
for i in range(N):
    s, p = input().split()
    p = int(p)
    SP.append([i, s, p])

D = {}
for i, s, p in SP:
    if not D.get(s):
        D[s] = []
    D[s].append([i, p])

for k, v in D.items():
    v.sort(key=itemgetter(1), reverse=True)

S = sorted(D.keys())
# print(D)
# print(S)

for si in S:
    ds = D.get(si)
    for i, v in ds:
        print(i + 1)


Measured memory_bytes: 3064
# coding: utf-8
# Your code here!

def insertionSort(A, N):
    for i in range(1, N):
            #print("sorting")
            v = A[i]
            j = i - 1
            while j >= 0 and A[j] > v:
                A[j + 1] = A[j]
                j -= 1
            A[j + 1] = v
            
            for k in range(N-1):
                print(str(A[k]), end = " ")
            print(A[N-1])

N = int(input())
A = list(map(int, input().split())) 
#for i in range(N - 1):
 #   A[i] = int(A[i])

for k in range(N-1):
     print(str(A[k]), end = " ")
print(A[N-1])

insertionSort(A, N)


Measured memory_bytes: 5984
#include<bits/stdc++.h>

using namespace std;
int main(){
    long long int a,h;
    int div,rem,sum=0;
    cin>>h>>a;
    if(h%a!=0){
        sum=(h/a)+1;
    }
    else{
        sum=h/a;
    }
    cout<<sum<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    ll t,n,k,l,r;
    string s; cin>>s;
    ll res =0 ;
    for(ll i=0;i<s.size();i++){
        res +=(s[i]-'0');
        res %=9;
    }
    if(!res)cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 3748
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

int main(){
	int a=get(),b=get(),c=get(),x=get(),y=get();
	LL ans= 1e14;
	fo(d,0,max(x,y)){
		LL tmp=1ll*c*2*d+1ll*max(0,x-d)*a+1ll*max(0,y-d)*b;
		if (tmp<ans)ans=tmp;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
int main()
{
    int n;
    cin >> n;
    vi v(100001, 0);
    rep(i, n)
    {
        int a;
        cin >> a;
        if (a - 1 >= 0)
        {
            v[a - 1]++;
        }
        v[a]++;
        if (a + 1 <= 1e5)
        {
            v[a + 1]++;
        }
    }
    sort(all(v));
    reverse(all(v));
    cout << v[0] << endl;
    return 0;
}

Measured memory_bytes: 640
a = list(input())
b = list(input())
c = list(input())


turn = a[0]

while turn:
    if turn == 'a':
        if not a:
            print('A')
            exit()
        turn = a[0]
        a.remove(a[0])
    elif turn == 'b':
        if not b:
            print('B')
            exit()
        turn = b[0]
        b.remove(b[0])
    else:
        if not c:
            print('C')
            exit()
        turn = c[0]
        c.remove(c[0])


Measured memory_bytes: 3064
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max({a * c, b * d, a * d, b * c}) << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int A, B, C, D;
	cin >> A >> B >> C >> D;
	while(true){
		C -= B;
		if(C <= 0){
			cout << "Yes" << endl;
			return 0;
		}
		A -= D;
		if(A <= 0){
			cout << "No" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
const int MAXN=400010,P=998244353;
int n,m,inv,sum,a[MAXN],b[MAXN],e[MAXN];
int qpow (int a,int b) {
	int res=1;
	while (b) {
		if (b&1) {res=(1ll*res*a)%P;}
		a=(1ll*a*a)%P,b>>=1;
	}
	return res;
}
void fwt (int a[],int lim,int type) {
	for (int i=1;i<lim;i<<=1) {
		for (int j=0;j<lim;j+=(i<<1)) {
			for (int k=0;k<i;k++) {
				int x=(a[j+k]+a[j+k+i])%P,y=(a[j+k]-a[j+k+i]+P)%P;
				a[j+k]=(1ll*x*(type==1?1:inv))%P,a[j+k+i]=(1ll*y*(type==1?1:inv))%P;
			}
		}
	}
	return;
}
int main () {
	scanf("%d",&n);
	m=(1<<n),inv=(P+1)/2;
	for (int i=0;i<m;i++) {scanf("%d",&a[i]);sum=(sum+a[i])%P;}
	for (int i=1;i<m;i++) {b[i]=P-1;}
	b[0]=m-1,sum=qpow(sum,P-2);
	for (int i=0;i<m;i++) {a[i]=(1ll*a[i]*sum)%P;}
	a[0]=(a[0]-1+P)%P;
	fwt(b,m,1),fwt(a,m,1);
	for (int i=1;i<m;i++) {e[i]=(1ll*b[i]*qpow(a[i],P-2))%P;}
	fwt(e,m,-1);
	int delt=P-e[0];
	for (int i=0;i<m;i++) {printf("%d\n",(e[i]+delt)%P);}
	return 0;
}

Measured memory_bytes: 6400
#include<iostream>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
int main(){ 
  ll n,max_i,min_i,ma_n=0,mi_n=0;
  bool is_p=false;
  vector<pair<ll,ll>> ans;
  cin >> n;
  ll a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]>0){
      ma_n=max(a[i],ma_n);
    }else{
      mi_n=min(a[i],mi_n);
    }
  }
  if(ma_n>abs(mi_n)){
    is_p=true;
  }else{
    is_p=false;
  }
  if(is_p==true){
    max_i=0;
    for(int i=0;i<n;i++){
      if(a[max_i]<a[i]){
        max_i=i;
      }
    }
    ans.push_back(make_pair(0,max_i));
    ans.push_back(make_pair(0,max_i));
    for(int i=1;i<n;i++){
      ans.push_back(make_pair(i,i-1));
      ans.push_back(make_pair(i,i-1));
    }
  }else{
    min_i=0;
    for(int i=0;i<n;i++){
      if(a[min_i]>a[i]){
        min_i=i;
      }
    }
    ans.push_back(make_pair(n-1,min_i));
    for(int i=n-2;i>=0;i--){
      ans.push_back(make_pair(i,i+1));
      ans.push_back(make_pair(i,i+1));
    }
  }
  cout << ans.size()<<endl;
  for(int i=0;i<ans.size();i++){
    cout << ans[i].second+1<<" "<<ans[i].first+1<<endl;
  }
  /*
  for(int i=0;i<n;i++) cout << a[i]<<" ";
  cout << endl;
  */
}


Measured memory_bytes: 384
N=int(input())
B=list(map(int,input().split()))
A=[B[0]]


for i in range(N-2):
    A.append(min(B[i],B[i+1]))
A.append(B[N-2])
sum_A=0
for i in A:
    sum_A+=i
print(sum_A)



Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
string s;
main()
{
	cin>>s;
	int a=0,b=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='0')
		{
			if(i%2)a++;
			if(i%2<1)b++;
		}
		else
		{
			if(i%2)b++;
			if(i%2<1)a++;
		}
	}
	cout<<min(a,b)<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   ll n;cin >>n;
   string s;cin >>s;
   string x,y;
   ll ans=0;
    for (int i = 0; i < n; ++i) {
        x=s.substr(0,i);
        y=s.substr(i,n-i);
        ll now=0;
        map<char,ll>mp;
        for (int j = 0; j < x.size(); ++j) {
            char key=x[j];
            if(mp[key]>0)continue;
            mp[key]++;
            for (int k = 0; k < y.size(); ++k) {
                if(key==y[k]){
                    now++;
                    break;
                }
            }
        }
        ans=max(ans,now);
    }
    cout <<ans <<endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main()
{
	string s,t;
	while(cin >> s >> t){
		int ans = 0;
		for(int i = 0;i < 3;i++)
			if(s[i] == t[i])	
				ans++; 
		cout << ans << endl;
	}
	return 0;	
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;

int main(){
  int N;
  cin >> N;
  int sum = 0;
  int maxL = 0;
  for(int i = 0; i < N; i++){
    int L;
    cin >> L;
    maxL = max(L,maxL);
    sum += L;
  }
  if(sum - maxL > maxL){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;


int main() {
    string S;
    cin >> S;
    if (S == "SUN") {
        cout << 7 << endl;
    } else if (S == "MON") {
        cout << 6 << endl;
    } else if (S == "TUE") {
        cout << 5 << endl;
    } else if (S == "WED") {
        cout << 4 << endl;
    } else if (S == "THU") {
        cout << 3 << endl;
    } else if (S == "FRI") {
        cout << 2 << endl;
    } else if (S == "SAT") {
        cout << 1 << endl;
    }

}

Measured memory_bytes: 256
W,H,N = map(int,input().split())
X=Y=0


for i in range(N):
    x,y,a = map(int,input().split())
    
    if a==1:
        X = max(X,x)
       
    elif a==2:
        W = min(W,x)
        
    elif a==3:
        Y = max(Y,y)
    else:
        H = min(H,y)
print(max(W-X,0)*max(H-Y,0))

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;

int ans[365],c[26],s[365][26],last[26],csum,nowscore,newscore;
const int INF=1e9,d=365,starttemp=4000,endtemp=100;
double temperature,prob;
const double TIMELIMIT=1.97*CLOCKS_PER_SEC;

#define REP(i,n) for(int i=0;i<n;i++)

void FIN(bool a){
  if(a){
    ofstream fout("output.txt");
    REP(i,d)fout<<ans[i]+1<<"\n";
    fout.close();
    exit(0);
  }
  REP(i,d)cout<<ans[i]+1<<"\n";
  exit(0);
}
/*
int score(){
  int res=0;
  memset(last,-1,sizeof(last));
  REP(day,d){
    res+=s[day][ans[day]];
    last[ans[day]]=day;
    REP(i,26)res-=c[i]*(day-last[i]);
  }
  return res;
}
*/
int score(){//上のがO(26*365)、こっちがO(365)のスコア計算
  int res=0,minus=csum;
  memset(last,-1,sizeof(last));
  REP(day,d){
    res+=s[day][ans[day]];
    minus-=c[ans[day]]*(day-last[ans[day]]);
    last[ans[day]]=day;
    res-=minus;
    minus+=csum;
  }
  return res;
}
void swap(){
  int RAND=rand();
  int day=RAND%(d-1);
  RAND^=newscore;
  int diff=RAND%min(d-day-1,10)+1;
  swap(ans[day],ans[day+diff]);
  newscore=score();
  prob=exp((newscore-nowscore)/temperature);
  if(prob>(rand()%INF)/(double)INF)nowscore=newscore;
  else swap(ans[day],ans[day+diff]);
}
void onechange(){
  int day=rand()%365;
  REP(i,26){
    int tmp=ans[day];
    ans[day]=i;
    newscore=score();
    prob=exp((newscore-nowscore)/temperature);
    if(prob>(rand()%INF)/(double)INF)nowscore=newscore;
    else ans[day]=tmp;
  }
}

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  clock_t start=clock();
  memset(last,-1,sizeof(last));
  cin>>c[0];
  REP(i,26){cin>>c[i];csum+=c[i];}
  REP(i,d)REP(j,26)cin>>s[i][j];
  REP(day,d){
    int idx,mx=-INF;
    REP(i,26){
      int A=c[i]*((day-last[i])*2+6)*7+s[day][i];
      if(mx<A)mx=A,idx=i;
    }
    ans[day]=idx,last[idx]=day;
  }
  nowscore=score();
  while(true){
    clock_t nowt=clock();
    const double Time=static_cast<double>(nowt-start);
    if(Time>TIMELIMIT)FIN(0);
    temperature=starttemp+(double)(endtemp-starttemp)*Time/TIMELIMIT;
    REP(_,50)
      if((_^newscore)&1)swap();
      else onechange();
  }
}


Measured memory_bytes: 4188
def main():
    s, t = input(), input()

    used, dic = [0] * 512, {}
    for i in range(26):
        dic[chr(ord('a')+i)] = chr(ord('a')+i)

    for i, j in zip(s, t):
        if dic[i] == j:
            used[ord(i)] = 1
            continue

        for k, v in dic.items():
            if v == j:
                if used[ord(k)]:
                    print("No")
                    exit()
                dic[k] = i

        if used[ord(i)] and dic[i] != j:
            print("No")
            exit()

        dic[i], used[ord(i)] = j, 1

    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Apple_and_Peach
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            for (int i = 0; i < input.Length; ++i)
            {
                if (input[i] == 'a' && input[i + 1] == 'p' && input[i + 2] == 'p' && input[i + 3] == 'l' && input[i + 4] == 'e')
                {
                    Console.Write("peach"); i += 4;
                }
                else if (input[i] == 'p' && input[i + 1] == 'e' && input[i + 2] == 'a' && input[i + 3] == 'c' && input[i + 4] == 'h')
                {
                    Console.Write("apple"); i += 4;
                }
                else Console.Write(input[i]);
            }
            Console.WriteLine();

            
        }
    }
}



Measured memory_bytes: 15808
//ここで手段を選ばないゲスな精神が？

//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();

	int A[1001][1000];
	rep1(i, N) {
		rep(j, N - 1) A[i][j] = getint();
		A[i][N - 1] = 0;
	}
	int* k[1001];
	rep1(i, N) k[i] = A[i];
	int k2[1001] = {};
	k2[0] = 1e9;
	int V[2][1001], kazu = N;
	rep1(i, N) V[0][i] = i;

	int kotae = 0;
	while (kazu && kotae < 80000) {
		kotae++;
		int dotti = kotae & 1;
		int kari = 0;
		rep (i, kazu) {
			int v = V[!dotti][i];
			if (k2[v] < kotae) {
				int a = *k[v];
				if (k2[a] < kotae && *k[a] == v) {
					V[dotti][kari++] = v;
					k[v]++;
					k2[v] = kotae;
					V[dotti][kari++] = a;
					k[a]++;
					k2[a] = kotae;
				}
			}
		}
		kazu = kari;
	}

	int OK = 1;
	rep1(i, N) if (k[i] - A[i] != N - 1) OK = 0;
	if (kotae == 80000) printf("%d", N* (N - 1) / 2);
	else if (!OK) printf("-1"); 
	else printf("%d", kotae - 1);

	Would you please return 0;
}

Measured memory_bytes: 4224
#include "bits/stdc++.h"

using namespace std;



int main() {
	long long n = 100;
	long long X;
	cin >> X ;
	int nAns = 0;
	while (X > n) {
		++nAns;
		n += n / 100;
	}
	cout << nAns << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    map<char, set<long long>> char_pos;
    int n = (int)s.size(), m = (int)t.size();
    for (int i = 0; i < n; ++i) {
        char_pos[s[i]].insert((long long) i);
    }
    long long pos = -1;
    for (char c : t) {
        if (char_pos[c].size() == 0) {
            cout << -1 << endl;
            return 0;
        }
        auto it = char_pos[c].upper_bound(pos % n);
        if (it == char_pos[c].end()) {
            pos = (pos/n)*n + n + *char_pos[c].begin();
        } else {
            pos = (pos/n)*n + *it;
        }
    }
    cout << pos+1 << endl;
    return 0;
}


Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main() {
    ll N;
    cin >> N;
    string S;
    cin >> S;
    if(N%2 == 1) cout << "No" <<endl;
    else {
        bool can = false;
        int n = N/2;
        for(int i = 0;i < n;i++){
            if(S.at(i) == S.at(i+n)){
                can = true;
            }
            else {
                can = false;
                break;
            }
        }
        if(can) cout << "Yes" <<endl;
        else cout << "No" <<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <int, int> ii;

const int mod = 1e9 + 7;
const ll INF = (1LL<<50);
const double EPSILON = 0.001;
const int N = 200005;
int v[30][30];
int cost[30];
int n, m, x;
ll solve(int idx, int mask){
	vi sum(m);
	for(int i = 0; i <= n; i++){
		if((1<<i)&mask){
			for(int j = 0; j <= m; j++){
				sum[j] += v[i][j];
			}
		}
	}
	int fins = 1;
	for(int j = 0; j < m; j++){
		if(sum[j] < x)fins = 0;
	}
	if(fins){
		return 0;
	} else if(idx == n){
		return mod;
	}
	ll ans = solve(idx+1, mask); // ignore
	ans = min(ans, solve(idx+1, mask + (1<<idx)) + cost[idx]);
	return ans;
}
int main(){
	fastio;
	cin >> n >> m >> x;
	for(int i = 0; i < n; i++){
		cin >> cost[i];
		for(int j = 0; j < m; j++){
			cin >> v[i][j];
		}
	}
	ll ans = solve(0,0);
	if(ans >= mod){
		cout << -1 << "\n";
	}else
		cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S,T;
    cin>>S;
    cin>>T;
    for(int i=0;i<S.size();++i)
    {
        if(S[i]!=T[i])
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}



Measured memory_bytes: 3624
X, K, D = map(int, input().split())
mid = abs(X)
if K*D > mid:
    mm = mid // D
    K = K - mm
    mid = mid - mm * D
    if K % 2 == 0:
        print(mid)
    else:
        print(abs(mid - D))
else:
    print(mid - K * D)

Measured memory_bytes: 9144
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 2000000000000000000
#define lli long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n,W,sum=0,ans=0;
    cin>>n>>W;
    lli w[n], v[n], dp[100001];
    for(int i=0; i<n; i++)
    {
        cin>>w[i]>>v[i];
        sum+=v[i];
    }
    for(int i=0; i<=sum; i++)
        dp[i]=inf;
    dp[0]=0;
    for(int i=0; i<n; i++)
    {
        for(lli j=sum-v[i]; j>=0; j--)
            dp[j+v[i]]=min(dp[j+v[i]], w[i]+dp[j]);
    }
    for(lli i=0; i<=sum; i++)
    {
        if(dp[i]<=W)
            ans=max(ans, i);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4400
#include<cmath>
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define repr(i,n) for(lint i=(lint)(n);i>0;--i)
#define reps(i,a,b) for(lint i=a;i<=(lint)(b);i++)
typedef long long lint;
typedef long double ld;
using namespace std;
const ld PI = acos(-1.0);

int main(){
    ld N, K;
    cin >> N >> K;
    ld p = 0.0;
    reps(i, 1, (lint)(MIN(N, K-1)))
    {
        p += powl(0.5, ceil(logl(K/(ld)(i)) / logl(2.0)));
    }
    if (N>=K) p += (ld)(N - K + 1);
    cout << setprecision(20) << p / (ld)(N) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin >> N;
    ll ans = 0;
    REPS(i, 1, N) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3676
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"


int main() {
	string S, T;
	cin >> S >> T;
	for (int i = 0; i < S.length(); ++i) {
		if (S[i] != T[i]) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(void)
{
	int a,b,k,i;
	scanf("%d %d %d",&a,&b,&k);
	int ans[101],j=0;
	for(i=1;i<=100;i++){
		if((a%i==0) && (b%i==0)){
			//printf("%d\n",i);
			ans[j]=i;
			j++;
		}
	}
	printf("%d\n",ans[j-k]);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, c;
  	cin >> n;
  	for (int i = 0; i<n; i++){
    	int l, r;
      	cin >> l >> r;
      	c += (r-l+1);
    }
  	cout << c << endl;
}

Measured memory_bytes: 256