akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define fi first
#define se second
#define pii pair<int,int>
//#define int long long
#define endl '\n'
#define pll pair<long long,long long>
//#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
int dx[]={0,0,1,-1};
int dy[]={-1,1,0,0};
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    string s[n];
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(s[i][j]!='.')continue;
            queue<pii>q;
            int dist[n][m];
            memset(dist,-1,sizeof(dist));
            dist[i][j]=0;
            q.push({i,j});
            while(!q.empty()){
                auto p=q.front();
                q.pop();
                ans=max(ans,dist[p.fi][p.se]);
                for(int i=0;i<4;i++){
                    if(p.fi+dx[i]<n&&p.fi+dx[i]>=0&&p.se+dy[i]<m&&p.se+dy[i]>=0){
                        if(dist[p.fi+dx[i]][p.se+dy[i]]==-1&&s[p.fi+dx[i]][p.se+dy[i]]=='.'){
                            dist[p.fi+dx[i]][p.se+dy[i]]=dist[p.fi][p.se]+1;
                            q.push({p.fi+dx[i],p.se+dy[i]});
                        }
                    }
                }
            }
            //cout<<i<<" "<<j<<" "<<ans<<endl;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(long long i=0;i<(n);i++)
#define rep2(i,m,n) for(long long i=(m);i<(n);i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back




int main(){


    int n;
    cin>>n;

    vi data(n);
    rep(i,n){
        int tmp;
        cin>>tmp;
        data.at(i)=tmp;
    }

    int cnt=0;

    rep(i,n){
        if (i%2==0 and data.at(i)%2==1){
            cnt++;
        }
    }

    cout<<cnt<<endl;





    









}








            






Measured memory_bytes: 3516
[h,w]=[int(i) for i in input().split()]
n=int(input())
a=[[int(i),x+1] for (x,i) in enumerate(input().split())]
a=sorted(a,key=lambda x:x[0])
a=a[::-1]
cc=[]
for i in a:
 for j in range(i[0]):
   cc.append(str(i[1]))
c=[[0 for i in range(w)]for j in range(h)]
def dfs(u,v):
    S=[]
    c[u][v]=cc.pop()
    S.append([u,v])
    while len(S):
        v=S.pop()
        for i in [[0,1],[1,0],[-1,0],[0,-1]]:
            if 0<=v[0]+i[0]<h and 0<=v[1]+i[1]<w and c[v[0]+i[0]][v[1]+i[1]]==0:
                c[v[0]+i[0]][v[1]+i[1]]=cc.pop()
                S.append([v[0]+i[0],v[1]+i[1]])
                break
dfs(0,0)
for i in range(h):
 print(" ".join(c[i][:]))

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

int main()
{
  long long N;
  cin >> N;
  
  vector<long long> a;
  rep(i, 3 * N)
  {
    long long tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  
  sort(a.begin(), a.end());
  
  long long sum = 0;
  rep(i, N)
  {
    sum += a[N + 2 * i];
  }
  
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 5488
//$ darklife_12
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <cstring>
#include <bits/stdc++.h>
#include <iostream>
#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
#define enterarray(a,n) for(int i=0;i<(int)(n);++i)cin>>a[i];
#define ins insert
const int MOD =998244353;
const int MX = int(2e6+9);
using namespace std;
int even(ll num){
    if(num%2==0)return 1;
    else return 0;
}
void printvector(vector<int> v){
    int i;
    for0(i,v.size())cout<<v[i]<<" ";
}
void solve()              
{
    ll n,m,i,j,k;
    long long a[200005],b[200005];
    ll ans=0,res;
    bool flag=true;
    vector<int> v;
    string s,s2;
  //  set<int> s;
    cin>>n;
    cin>>s;
    ll r=0,w=0;
    for0(i,n){
        if(s[i]=='R')r++;
        else w++;
    }
    for0(i,r){
        if(s[i]=='W')ans++;
    }
    cout<<min(w,ans);
}
 
int main()
{
    FAST;
   int t;
    t=1;
    while(t--)
    {
        solve();
       cout<<"\n";
    }
}

Measured memory_bytes: 3736
from math import *
from fractions import *
from sys import stdout, stderr, version_info
def fprintf(fs, s, *argv):
    fs.write(s.format(*argv))

def printf(s, *argv):
    fprintf(stdout, s, *argv)

if version_info[0] == 2:
    input = raw_input

def gets(type=int, sep=' '):
    return map(type, input().split(sep))

def _lcm(a,b):
    return a // gcd(a,b) * b

def num2(a):
    cnt = 0
    while(a % 2 == 0):
        cnt += 1
        a /= 2
    return cnt

def main():
    n,m = gets()
    a = gets()
    lcm = 1
    cnt2 = -1
    for ai in a:
        lcm = _lcm(lcm,ai)
        n2 = num2(ai)
        if (cnt2 != -1 and cnt2 != n2):
            printf('0\n');
            return
        cnt2 = n2

    fprintf(stderr, 'lcm: {}\n', lcm)

    lo, hi = -1, m+1
    while (lo+1 < hi):
        mid = (lo+hi)//2
        if ((mid*2+1) * lcm//2 <= m):
            lo = mid
        else:
            hi = mid

    printf('{}\n', hi)

main()


Measured memory_bytes: 12656
//naveen mall
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb               push_back
#define sz(c)            (int)c.size()
#define len(c)           (int)c.length()
#define vec              vector
#define int              long long int
#define all(c)           c.begin(), c.end()
#define rall(c)          c.rbegin(), c.rend()
#define trav(a,i)        for(auto i: a)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define invect(v,n)       for(int i=0;i<n;i++ ){int arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        fl(i,0,n){int aset;cin>>aset;s.insert(aset);}
#define display(c)        trav(c,i) cout<<i<<" ";cout<<"\n";
#define F                 first
#define S                 second
#define pii               pair<int,int>
#define PB                pop_back
#define endl              "\n"
#define what(x) cerr <<  #x << " is " << x << endl;
int sum() { return 0; }template<typename T,typename... Args>T sum(T a, Args... args) { return a + sum(args...); }


void solve()
{   
	
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int ans=0;
	if(a+b>=k)
		 {
		 	ans=min(a,k);

		 }
		 else
		 {
		 	ans=a-(k-(a+b));
		 }
		 cout<<ans;




}
signed main()
{fast
    int t;
 t=1;
 
 //  cin>>t;
  while(t--)
     {
      solve();
     }
 
 
 
}

Measured memory_bytes: 3636
k = int(input())

num = 0
res = 0
cnt = [0] * k
while True:
    num = (num * 10 % k + 7) % k
    res += 1

    if num == 0:
        print(res)
        break

    if cnt[num] == 1:
        print(-1)
        break

    cnt[num] += 1

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

#define int long long
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;

#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

#define len(a) ((int) (a).size())
#define all(a) (a).begin(), (a).end()

const int INF = 1e18;

bool check(int a, int b) {
    return INF / b >= a;
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        if (a[i] == 0) {
            cout << "0\n";
            return 0;
        }
    }
    int ans = 1;
    for (auto elem : a) {
        if (check(ans, elem)) ans *= elem; else {
            cout << "-1\n";
            return 0;
        }
    }
    cout << ans << '\n';
    return 0;
}


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

int main() {
  int a[3][3];
  REP(i,3) REP(j,3) cin >> a[i][j];
  int n; cin >> n;
  int b;
  REP(i,n) {
    cin >> b;
    REP(i,3) { REP(j,3) { if (a[i][j] == b) a[i][j] = 0; } }
  }

  int bingo = 0;
  REP(i,3) {
    if (a[i][0] == 0 && a[i][1] == 0 && a[i][2] == 0) bingo = 1;
    if (a[0][i] == 0 && a[1][i] == 0 && a[2][i] == 0) bingo = 1;
  }
  if (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) bingo = 1;
  if (a[2][0] == 0 && a[1][1] == 0 && a[0][2] == 0) bingo = 1;

  cout << (bingo ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
int main() {
ll n,m;
cin>>n>>m;
ll aa=0;
ll counter=0;
if(n>=m/2){
cout<<m/2<<endl;}
else {
counter+=n;
m=m-2*n;
counter+=m/4;
cout<<counter<<endl;}}

Measured memory_bytes: 256
from collections import defaultdict
H = defaultdict(lambda: 0)
H[0] = 1
N = int(input())
for _ in range(N):
    i = int(input())
    for ni,nv in H.copy().items():
        H[ni+i] = 1
K = reversed(sorted(list(H.keys())))
ans = 0
for j in K:
    if j%10 != 0:
        ans = j
        break
print(ans)

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){

  int n;
  cin >> n;
  vector<int> v(4,0);
  REP(i,n){
    int x;cin >> x;
    v[x%4]++;
  }
  if(v[1] + v[3] <= v[0] || (v[2] == 0 && v[1] + v[3] <= v[0]+1))cout << "Yes" << endl;
  else cout << "No" << endl;




  

  return 0;
}


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

const double PI = acos(-1);
double A, B, X;

bool check(double theta){
    double Area;
    if(tan(theta) < B/A){
        double z = B - A * tan(theta);
        Area = (z + B) * A / 2;
    }else{
        double x = B / tan(theta);
        Area = x * B / 2;
    }
    return Area >= X;
}

int main(){
    cin >> A >> B >> X;
    X /= A;
    double ok = 0, ng = PI/2;
    for(int t=0; t<200; t++){
        double mid = (ok+ng)/2;
        (check(mid) ? ok : ng) = mid;
    }
    cout << fixed << setprecision(10) << (ok * 180 / PI) << endl;
    return 0;
}


Measured memory_bytes: 512
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
30 100
---+/
/+---test
12 100
---+/
/+---test
0 100
---+/

void main(string[] args) {
  long A, B;
  readf(" %d %d ", &A, &B);

  (A >= 13? B: A >= 6? B/2: 0).writeln;
}


Measured memory_bytes: 256
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
int N;
int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	int d = 0;
	int p = N;
	while (p > 0) {
		d += p % 10;
		p /= 10;
	}
	cout << (N % d == 0 ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n; cin >> n;
	cout << (n+1)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

bool solve(const int N, const vector<int> &sdir, const vector<int> &tdir, 
	   const int cur, const int len) 
{
  int left = cur, right = cur;
  REP(i,N) {

    if(sdir[i] > 0) right++;
    else if(sdir[i] < 0) left--;

    if(right > len) return false;
    if(left <= 0) return false;

    if(tdir[i] > 0) {
      left++;
    }else if(tdir[i] < 0) {
      right--;
    }
    left = min(left, len);
    right = max(right, 1);

#ifdef DEBUG
    cout << i << " " << left << " " << right << ":" ;
    cout << nmax << " " << pmax << " " << len << endl;
    cout << endl;
#endif
#ifdef DEBUG
#endif


  }
  return true;
}

int main() {
  int H, W, N; cin>>H>>W>>N;
  int sr, sc; cin>>sr>>sc;
  string S, T; cin>>S>>T;
  vector<int> sh(N,0), th(N,0), sw(N,0), tw(N,0) ;
  REP(i,N) {
    switch (S[i]) {
    case 'L': sw[i]=-1; break;
    case 'R': sw[i]=+1; break;
    case 'U': sh[i]=-1; break;
    case 'D': sh[i]=+1; break;
    }
    switch (T[i]) {
    case 'L': tw[i]=-1; break;
    case 'R': tw[i]=+1; break;
    case 'U': th[i]=-1; break;
    case 'D': th[i]=+1; break;
    }

  }
  bool ans1 = solve(N, sh, th, sr, H);
  bool ans2 = solve(N, sw, tw, sc, W);
  cout << ((ans1 && ans2)  ? "YES" : "NO") << endl;
  return 0;
}


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

int main() {
  int h, w, d;
  cin>>h>>w>>d;
  map<int, pair<int, int> > m;

  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      int a;
      cin>>a;
      m[a] = make_pair(i, j);
    }
  }
  map<pair<int, int>, int> acc;
  for (int i=1;i<=d; ++i) {
    acc[make_pair(i, i)] = 0;
    auto cur = m[i];
    for (int j=i+d; j<=h*w; j+=d) {
      auto next = m[j];
      int dist = abs(cur.first - next.first) + abs(cur.second - next.second);
      acc[make_pair(i, j)] = acc[make_pair(i, j-d)] + dist;
      cur = next;
    }
  }
  int q;
  cin>>q;
  for (int i=0; i<q; i++) {
    int l, r;
    cin>>l>>r;
    cout<<acc[make_pair((l-1)%d+1, r)] - acc[make_pair((l-1)%d+1, l)]<<endl;
  }
}

Measured memory_bytes: 12416
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;
typedef long long ll;
int main(){
  ll a,b,c,d,ans=0;cin>>a>>b>>c>>d;
    ll x=max(c,d),y=min(c,d);
  ll r=x%y;
  while(r!=0){
    x = y;
    y = r;
    r = x % y;
  }
  x=c*d/y;
  ans+=b/c;ans+=b/d;ans-=b/x;
  ans-=(a-1)/c;ans-=(a-1)/d;ans+=(a-1)/x;
  cout << b-a-ans+1<< endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,p;
    cin>>n>>p;
    int a[n];
    long long dp[n+1][2]={};
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        cin>>a[i];
        for(int j=0;j<2;j++){
            dp[i+1][j]+=dp[i][j];
            dp[i+1][(j+a[i])%2]+=dp[i][j];
        }
    }
    cout<<dp[n][p]<<endl;
    return 0;
}

Measured memory_bytes: 3648
s = input()
diff_0 = 0
diff_1 = 0
for i in range(len(s)):
  if i % 2 == 0 and s[i] == '0':
    diff_1 += 1
  elif i % 2 == 0 and s[i] == '1':
    diff_0 += 1
  elif i % 2 == 1 and s[i] == '0':
    diff_0 += 1
  elif i% 2 == 1 and s[i] == '1':
    diff_1 += 1
print(min(diff_0, diff_1))

Measured memory_bytes: 3188
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    auto graph = new long[long][](N);
    foreach (_; 0 .. M)
    {
        long l, r, d;
        scan(l, r, d);
        l--;
        r--;
        graph[l][r] = d;
        graph[r][l] = -d;
    }
    auto p = new long[](N);
    p[] = -long.min;
    bool ans = true;
    void solve(long x)
    {
        if (p[x] == long.min)
            p[x] = 0;
        foreach (k, v; graph[x])
        {
            if (p[k] == long.min)
            {
                p[k] = p[x] + v;
                solve(k);
            }
            else
            {
                if (p[k] - p[x] != v)
                {
                    ans = false;
                    return;
                }
            }

        }
    }

    foreach (i; 0 .. N)
        solve(i);
    writeln(ans ? "Yes" : "No");
}


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

const int nax = 2e5;
int a[nax], b[nax];

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];

  queue<int> q;
  auto add = [&](int i) {
    int x = i ? b[i-1] : b[n-1];
    int y = b[i];
    int z = i+1 < n ? b[i+1] : b[0];
    if (y-x-z >= a[i]) {
      q.push(i);
    }
  };
  for (int i = 0; i < n; i++) {
    add(i);
  }
  ll ans = 0;
  while (q.size()) {
    int i = q.front();
    q.pop();
    int x = i ? b[i-1] : b[n-1];
    int y = b[i];
    int z = i+1 < n ? b[i+1] : b[0];
    int k = (y-a[i])/(x+z);
    ans += k;
    b[i] -= (x+z)*k;
    add(i ? i-1 : n-1);
    add(i+1 < n ? i+1 : 0);
  }
  /*for (int i = 0; i < n; i++)
    cout << a[i] << ' ';cout << endl;
  for (int i = 0; i < n; i++)
  cout << b[i] << ' ';cout << endl;*/
  for (int i = 0; i < n; i++)
    if (b[i] != a[i]) {
      cout << -1 << endl;
      return 0;
    }
  cout << ans << endl;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  string X,Y;
  cin>>X>>Y;
  if(X>Y){
    cout<<">";
  }else if(X==Y){
    cout<<"=";
  }else{
    cout<<"<";
  }

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
 
class Program{
    static void Main(){
        int[] inputs = Console.ReadLine().Split(' ')
                                         .Select(val => int.Parse(val))
                                         .ToArray();
        Dice dc = new Dice(inputs);
        int qn = int.Parse(Console.ReadLine());
        int[] ans = new int[qn];
        for (int i = 0; i < qn; i++)
        {
            int[] q = Console.ReadLine().Split(' ')
                                             .Select(val => int.Parse(val))
                                             .ToArray();
            char firstOrder = 'N';
            if(new int[]{2, 3}.Contains(dc.IndexOf(q[0]))) firstOrder = 'W';
            while(dc.rables[0] != q[0]) dc.Move(firstOrder);
            while(dc.rables[1] != q[1]) dc.Move('R');
            ans[i] = dc.rables[2];
        }
        foreach (int item in ans)
        {
            Console.WriteLine(item);
        }
    }

    class Dice
    {
        public int[] rables {get; set;}
        //[0]???[1]??????[2]???[3]???[4]?\\[5]???
        public Dice(int[] iarr){
            rables = new int[6];
            Array.Copy(iarr, 0, this.rables, 0, iarr.Length);
        }

        public int IndexOf(int num){
            for (int i = 0; i < rables.Length; i++)
            {
                if(rables[i] == num) return i;
            }
            return -1;
        }

        public void Move(char direction){
            int tmp;
            switch (direction)
            {
                case 'N':   //?\\??????
                    tmp = rables[0];
                    rables[0] = rables[1];
                    rables[1] = rables[5];
                    rables[5] = rables[4];
                    rables[4] = tmp;
                    break;
                case 'W':   //?????????
                    tmp = rables[0];
                    rables[0] = rables[2];
                    rables[2] = rables[5];
                    rables[5] = rables[3];
                    rables[3] = tmp;
                    break;
                case 'S':   //?????????
                    tmp = rables[0];
                    rables[0] = rables[4];
                    rables[4] = rables[5];
                    rables[5] = rables[1];
                    rables[1] = tmp;
                    break;
                case 'E':   //?????????
                    tmp = rables[0];
                    rables[0] = rables[3];
                    rables[3] = rables[5];
                    rables[5] = rables[2];
                    rables[2] = tmp;
                    break;
                default:
                    tmp = rables[1];
                    rables[1] = rables[2];
                    rables[2] = rables[4];
                    rables[4] = rables[3];
                    rables[3] = tmp;
                    break;
            }
        }
    }
}

Measured memory_bytes: 9652
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int main() {
    long long n,m;string s;
    while(cin>>n>>m>>s){
    	int a[200000],v=0;memset(a,0,sizeof(a));
    	for(int i=0;i<s.length();i++){
    		a[i]=v;
    		if(s[i]=='A'&&s[i+1]=='C'){
    			a[i+1]=v+1;i++;v++;
			}
		}
		cout<<endl;
		for(int i=0;i<m;i++){
			int x,y;cin>>x>>y;
			cout<<a[y-1]-a[x-1]<<endl;
		}
	}
    return 0;
}

Measured memory_bytes: 1856
#!/usr/bin/env ruby
require 'set'

def main
    s = gets.chomp
    while s.to_s.size > 0 do
        if s[0,7] == "dreamer"
            if s[5,5] == "erase"
                s = s[5..-1]
            else
                s = s[7..-1]
            end
        elsif s[0,6] == "eraser"
            s = s[6..-1]
        elsif s[0,5] == "dream"
            s = s[5..-1]
        elsif s[0,5] == "erase"
            s = s[5..-1]
        else
            puts "NO"
            return
        end
    end
    puts "YES"
end

main

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> d(n + 1);
  rep(i, n) {
    d[a[i]] = i;
  }
  int maxlen = 0;
  int len = 0;
  for (int i = 1; i < n; ++i) {
    if (d[i] < d[i + 1]) {
      len++;
    } else {
      len = 0;
    }
    chmax(maxlen, len);
  }

  cout << n - maxlen - 1 << endl;
}

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

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

	int a,b;
	cin>>a>>b;
	if(b%a) cout<<b-a<<"\n";
	else cout<<b+a<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void){
    int a, b;
    char op;


    while(1){
        scanf("%d %c %d", &a, &op, &b);
        if(op == '?') break;
        else if(op == '-') printf("%d\n", a-b);
        else if(op == '+') printf("%d\n", a+b);
        else if(op == '*') printf("%d\n", a*b);
        else if(op == '/') printf("%d\n", a/b);
    }


    return 0;

}


Measured memory_bytes: 2044
#include <iostream>
#include <string>

using namespace std;

struct TreeNode {
    int value;
    TreeNode* left;
    TreeNode* right;

    TreeNode(int x): value(x), left(nullptr), right(nullptr) {}
};

TreeNode* insert(TreeNode* root, TreeNode* node) {
    if (root == nullptr)
        root = node;
    else {
        if (node->value < root->value)
            root->left = insert(root->left, node);
        else
            root->right = insert(root->right, node);
    }
    return root;
}

bool find(TreeNode* root, int value) {
    if (root == nullptr)
        return false;
    if (root->value == value)
        return true;
    else if (value < root->value)
        return find(root->left, value);
    else
        return find(root->right, value);
}

void preorder(TreeNode* root) {
    if (root == nullptr)
        return;
    cout << " " << root->value;
    preorder(root->left);
    preorder(root->right);
}

void inorder(TreeNode* root) {
    if (root == nullptr)
        return;
    inorder(root->left);
    cout << " " << root->value;
    inorder(root->right);
}

void deleteNodes(TreeNode* root) {
    if (root == nullptr)
        return;
    deleteNodes(root->left);
    deleteNodes(root->right);
    delete root;
}

int main() {
    int m;
    cin >> m;

    string s;
    int k;
    TreeNode* root = nullptr;
    for (int i = 0; i < m; i++) {
        cin >> s;
        if (s == "insert") {
            cin >> k;
            TreeNode* node = new TreeNode(k);
            root = insert(root, node);
        }
        else if (s == "find") {
            cin >> k;
            if (find(root, k))
                cout << "yes" << endl;
            else
                cout << "no" << endl;
        }
        else if (s == "print") {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 15516
import java.util.Scanner;

public class Main {
	  public static void main(String args[]){
		    Scanner sc = new Scanner(System.in);

            int n = sc.nextInt();
            int[] a = new int[n];
            int[] count = new int[n];
            for(int i = 0; i < n; i++){
                a[i] = sc.nextInt();
                count[i] = 0;
                while(a[i] % 2 == 0){
                    a[i] /= 2;
                    count[i]++;
                }
            }
            int mincount = count[0];
            for(int i = 0; i < n; i++){
                if(mincount > count[i]){
                    mincount = count[i];
                }
            }
            System.out.println(mincount);
            sc.close();
		  }
}

Measured memory_bytes: 21844
if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    mod = A[0]
    flag = True
    while flag:
        for i in range(0, N):
            if A[i]%mod == 0:
                if i == N -1:
                    flag = False
                continue
            else:
                mod = A[i]%mod
                A[i] = mod
                break 
    print(mod)

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

int main() {

    char x[1001];
    while(true){
    
        // 1. input end check.
        scanf("%s", x);
        if(x[0] == '0') break;
        
        // 2. calculate sum of numbers.
        int ans = 0;
        for(int i = 0; i < strlen(x); i++) ans += x[i] - '0';
        
        // 3. output answer.
        printf("%d\n", ans);
    
    }
    
    return 0;
    
}


Measured memory_bytes: 3204
#include <stdio.h>
#include <vector>
#include <utility>
#include <queue>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, n, a, b, max = 0, cnt = 1;
  scanf("%lld", &n);
  vector< pair<ll, ll> > vec[n];
  pair<ll, ll> now;
  ll ans[n - 1];
  bool flg[n];
  for(i = 0; i < n - 1; ++i) {
    scanf("%lld%lld", &a, &b);
    vec[--a].push_back(make_pair(--b, i));
    vec[b].push_back(make_pair(a, i));
  }
  for(i = 0; i < n; ++i) if(vec[i].size() > max) max = vec[i].size();
  printf("%lld\n", max);
  for(i = 0; i < n; ++i) flg[i] = true;
  queue< pair<ll, ll> > q;
  q.push(make_pair(0, 0));
  while(q.size()) {
    now = q.front(), q.pop();
    flg[now.first] = false;
    cnt = 1;
    for(i = 0; i < vec[now.first].size(); ++i) if(flg[vec[now.first][i].first]) {
      if(cnt == now.second) cnt++;
      ans[vec[now.first][i].second] = cnt, q.push(make_pair(vec[now.first][i].first, cnt));
      cnt++;
    }
  }
  for(i = 0; i < n - 1; ++i) printf("%lld\n", ans[i]);
  return 0;
}

Measured memory_bytes: 8960
#include <stdio.h>

int main(void) {
	// your code goes here
	int time, h, m, s;
	
	scanf("%d\n", &time);
	
	if(time < 0 || time >= 86400) {
		return 0;
	}
	
	s = time % 60;
	m = (time / 60) % 60;
	h = time / 3600;
	
	printf("%d:%d:%d\n", h, m, s);
	
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
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; }
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << "-1" << endl;return 0
#define MM <<" "<<
#define Endl endl


signed main(){
    int N;
    int A[214514],B[214514];
    cin >> N;
    REP(i,N){
        cin >> A[i];
    }
    REP(i,N){
        cin >> B[i];
    }
    bool end[214514]={};
    priority_queue<pair<int,int>> P;
    REP(i,N){
        if(A[i]>B[i]){
            GOODBYE;
        }else if(A[i]==B[i]){
            end[i]=true;
        }else{
            P.push({B[i],i});
        }
    }
    int Ans=0;
    while(!P.empty()){
        pair<int,int> t=P.top();
        P.pop();
        int s=(P.top().first);
        int j=t.second;
        int K=(B[(j+1)%N]+B[(j-1+N)%N]);
        
        int kai=(int)((t.first-A[j])/K);
        t.first-=K*(kai);
        if(t.first==B[j]){
            GOODBYE;
        }
        B[j]=t.first;
        if(A[j]>B[j]){
            GOODBYE;
        }else if(A[j]!=B[j]){
            P.push({B[j],j});
        }else{
            end[j]=true;
        }
        Ans+=kai;
        //REP(i,N){cout << B[i];if(end[i]==true)cout << "x";cout << " ";}cout << endl;
    }
    cout << Ans << endl;
    return 0;
}   


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

int d1[200005],d2[200005];
int d3[200005],d4[200005];
int n,x,y,siz[200005],col[200005],fa[200005];
long long ans=0;
int tot=0,h[200005];
struct Edge{
	int x,next;
}e[400005];
char ch[200005];

inline void add_edge(int x,int y){
	e[++tot].x=y;
	e[tot].next=h[x],h[x]=tot;
}

void dfs1(int x,int father){
	siz[x]=col[x],fa[x]=father;
	d3[x]=col[x]?0:1e9;
	for(int i=h[x];i;i=e[i].next){
		if(e[i].x==father)continue;
		dfs1(e[i].x,x);
		siz[x]+=siz[e[i].x];
		d1[x]=max(d1[x],d1[e[i].x]+1);
		if(siz[e[i].x])
			d3[x]=min(d3[x],d1[e[i].x]+1);
	}
}

void dfs2(int x,int father){
	if(father)d4[x]=d2[x]-1;
	int maxn=0,sec=0;
	for(int i=h[x];i;i=e[i].next){
		if(e[i].x==father)continue;
		if(d1[e[i].x]+1>maxn)
			sec=maxn,maxn=d1[e[i].x]+1;
		else sec=max(sec,d1[e[i].x]+1);
	}
	for(int i=h[x];i;i=e[i].next){
		if(e[i].x==father)continue;
		if(d1[e[i].x]+1==maxn)
			d2[e[i].x]=max(d2[x],sec)+1;
		else d2[e[i].x]=max(d2[x],maxn)+1;
		dfs2(e[i].x,x);
	}
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		add_edge(x,y);
		add_edge(y,x);
	}
	scanf("%s",ch+1);
	for(int i=1;ch[i];i++)
		col[i]=ch[i]-'0';
	dfs1(1,0),dfs2(1,0);
	for(int i=1;i<=n;i++){
		int minv,maxv;
		minv=min(d3[i],siz[1]==siz[i]?(int)1e9:d2[i]);
		maxv=max(d1[i],d2[i])-1;
		for(int j=h[i];j;j=e[j].next){
			if(e[j].x==fa[i])maxv=min(maxv,d1[i]+1);
			else maxv=min(maxv,d4[e[j].x]+1);
		}
		if(maxv>=minv)ans+=1LL*maxv-minv+1;
	}
	printf("%lld",ans+1);
}

Measured memory_bytes: 19328
from collections import deque

s = input()
q = int(input())
query = [input().split() for i in range(q)]

d = deque(['S'])

#d = ['S']

rev = False

for i in range(q):
    if query[i][0] == '1':
        rev = not rev
        continue
    
    if not rev:
        if query[i][0] == '2':
            if query[i][1] == '1':
                d.appendleft(query[i][2])
            else:
                d.append(query[i][2])
    else:
        if query[i][0] == '2':
            if query[i][1] == '1':
                d.append(query[i][2])
            else:
                d.appendleft(query[i][2])

#ans = deque()
if rev:
    #d = ''.join(list(reversed(d)))
    s = s[::-1]



while len(d):
    if rev:
        tmp = d.pop()
    else:
        tmp = d.popleft()
    if tmp == 'S':
        #ans.append(s)
        print(s,end='')
    else:
        print(tmp,end='')
        #ans.append(tmp)

#print(*ans,sep='')


Measured memory_bytes: 42860
N=int(input())
mod=10**9+7
a,f=1,1
l=2
b,c,d,e,g,h,i,j,k=0,0,0,0,0,0,0,0,0

for p in range(N-1):
    A=(d+e+i+l)%mod
    B=(a+g)%mod
    C=(b+j)%mod
    D=(b+j)%mod
    E=(a+h)%mod
    F=(c+d+f+k+l)%mod
    G=(b+c+f+j+k)%mod
    H=(a+g+h)%mod
    I=(a+g+h)%mod
    J=(h)%mod
    K=(i)%mod
    L=(c+d+2*e+2*f+2*i+k+2*l)%mod
    a,b,c,d,e,f,g,h,i,j,k,l=A,B,C,D,E,F,G,H,I,J,K,L
print((a+b+c+d+e+f+g+h+i+j+k+l)%mod)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <cstring>
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
    ll N;
    ll i;
    ll all = 0;

    cin >> N;

    for(i=1; i<=N; i++) {
        if(i%3!=0 && i%5!=0) {
            all += i;
        }
    }

    cout << all;

}

Measured memory_bytes: 3636
from sys import stdin
 
n = int(stdin.readline().rstrip())
data = list(map(int, stdin.readline().rstrip().split()))
 
def is_s(hens):
  m = max(hens)
  hens.remove(m)
  if m < sum(hens):
  	return "Yes"
  else:
    return "No"
 
print(is_s(data))

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

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


Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>
 
using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
 
 
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
 
//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll a,b;
	cin>>a>>b;
	vector<ll> v(3,1);

	v[a-1]--;
	v[b-1]--;
	int ans=0;
	for(int i=0;i<3;i++){
		if(v[i]==1){
			ans=i+1;
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    const int mod=998244353;
    int n,s;
    cin>>n>>s;
    int a[n];
    vector<vector<long long>>dp(n+1,vector<long long>(s+1));
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        cin>>a[i];
        for(int j=0;j<=s;j++){
            dp[i+1][j]=(dp[i+1][j]+dp[i][j]*2)%mod;
            if(j+a[i]<=s)dp[i+1][j+a[i]]=(dp[i+1][j+a[i]]+dp[i][j])%mod;
        }
    }
    cout<<dp[n][s]<<endl;
    return 0;
}

Measured memory_bytes: 73724
(let* ((n (read))
       (m (read))
       (lmax 0)
       (rmin (1+ n)))
  (loop :for i :from 1 :to m
        :for l := (read)
        :for r := (read)
        :do (setf lmax (max lmax l))
        :do (setf rmin (min rmin r)))
  (let ((c (- rmin lmax -1)))
    (format t "~A~%" (if (< 0 c) c 0))))


Measured memory_bytes: 77112
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int ri()
{
	register int x=0;register bool f=0;register char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=1;ch=getchar();}
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();};
	return f?-x:x;
}
void wi(int x)
{
	if(x<0)	x=-x,putchar('-');
	if(x>9)	wi(x/10);
	putchar('0'+x%10);
}
const int N=2005;
int a[N],q[N],t[N],v[N];
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n=ri(),k=ri(),Q=ri(),x,i,j,p,u,ans=2e9;
	for(i=1;i<=n;i++)	a[i]=ri();
	for(i=1;i<=n;i++)
	{
		x=a[i];q[0]=0;
		for(j=1;j<=n;j++)	v[j]=a[j]<x;
		for(j=1;j<=n;j=u+1)
		{
			while(v[j])	j++;
			for(u=j,t[0]=0;u<=n&&v[u]==0;u++)	t[++t[0]]=a[u];
			if(t[0]<k)	continue;
			nth_element(t+1,t+t[0]-k+1,t+1+t[0]);
			for(p=1;p<=t[0]-k+1;p++)	q[++q[0]]=t[p];
		}
		if(q[0]<Q)	continue;
		nth_element(q+1,q+Q,q+1+q[0]);
		ans=min(ans,q[Q]-x);
	}
	wi(ans);putchar('\n');
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
typedef long long ll;

int main(void) {
    int a, b;
    scanf("%d%d", &a, &b);

    if(a <= b) {
        for(int i = 0; i < b; i++) {
            printf("%d", a);
        }
    } else {
        for(int i = 0; i < a; i++) {
            printf("%d", b);
        }
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 1736
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {
        void solve(InputReader in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();
            int C = in.nextInt();

            int ans;
            if (A == B) {
                ans = C;
            } else if (B == C) {
                ans = A;
            } else {
                ans = B;
            }

            out.println(ans);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

Measured memory_bytes: 21460
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;
import java.util.TreeMap;

class Edge{
	int a,b,c;
	public Edge(int A,int B,int C){
		a=A;
		b=B;
		c=C;
	}
}
class Main{
	static Scanner s=new Scanner(System.in);

	static int gInt(){
		return Integer.parseInt(s.next());
	}

	public static void main(String[]$){
		final long INIT=Long.MAX_VALUE;

		TreeMap<Integer,List<Edge>>a=new TreeMap<>();
		int n=gInt(),m=gInt();
		long[] pos=new long[n];
		Arrays.fill(pos,INIT);

		for(int q=0;q<m;++q){
			int l=gInt()-1,r=gInt()-1,d=gInt();
			a.computeIfAbsent(l,(i)->new ArrayList<>(1)).add(new Edge(l,r,d));
			a.computeIfAbsent(r,(i)->new ArrayList<>(1)).add(new Edge(r,l,-d));
		}

		Deque<Edge> d=new ArrayDeque<>();
		while(!a.isEmpty()){
			d.addAll(a.pollFirstEntry().getValue());
			while(!d.isEmpty()){
				Edge o=d.poll();
				if(pos[o.a]==INIT){
					pos[o.a]=0;
				}
				if(pos[o.b]==INIT){
					pos[o.b]=pos[o.a]+o.c;
					List<Edge> v=a.remove(o.b);
					if(v!=null)
						d.addAll(v);
				}
				if(pos[o.b]-pos[o.a]!=o.c){
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 120624
#include <iostream>
using namespace std;
typedef long long ll;

const ll INF = 100000000000000;

ll l[2005][2005];

int main()
{
    int n;
    ll x;
    cin >> n >> x;
    ll a[2005];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        l[i][i] = INF;
        for(int j = 1; j <= n; j++) l[i][(i + j) % n] = min(l[i][(i + j - 1) % n], a[(i + j - 1) % n]);
    }
    ll ans = INF;
    for(ll k = 0; k < n; k++){
        ll s = k * x;
        for(int i = 0; i < n; i++){
            s += l[(i + n - k) % n][(i + 1) % n];
        }
        ans = min(ans, s);
    }
    cout << ans << endl;
}


Measured memory_bytes: 34912
function Main(input) {
  const numbers = input.split(' ').map(n => Number(n));
  const x = numbers[0];
  const t = numbers[1];

  if (x <= t) {
    console.log('0');
  } else {
    console.log(x - t);
  }
}

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

Measured memory_bytes: 21192
#include <iostream>
using namespace std;
 
int main() {
	string a,b;
	cin>>a>>b;
	if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0]){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}


Measured memory_bytes: 256
# ABC146b


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)

    # map(int,input().split())
    alphabet = list('abcdefghijklmnopqrstuvwxyz'.upper())
    # print('abcdefghijklmnopqrstuvwxyz'.upper().index('A'))
    n = int(input())
    s = input()[:-1]
    # print(alphabet)
    for i in s:
        #print(i, alphabet.index(i))
        print(alphabet[(alphabet.index(i)+n) % 26], end='')


if __name__ == '__main__':
    main()


Measured memory_bytes: 4468
#include <stdio.h>

int main(void)
{
  int n;
  int total;

  // 入力
  scanf("%d", &n);

  if (n % 2 == 0) {
    total = n / 2;
  } else {
    total = n / 2 + 1;
  }

  // 出力
  printf("%d\n", total);

  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
using namespace std;
using ll = long long int;

typedef pair<int,int> P;

const int INF=-100000;
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};


int main(void){
    int H,W;
    cin >> H >> W;
    
    vector<string> inp(H);
    for(int i=0;i<H;i++){
        string s;
        cin >> s;
        //for(int k=0;k<W;k++){
            inp[i]=s;
        //}
    }
    int max=0;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            queue<P> q;
            if(inp[i][j]=='#')continue;
            vector<vector<int>> dist(H,vector<int>(W,INF));
            //x,yはdistanceで行ける
            auto push=[&](int x,int y,int distance){
                if(dist[x][y]!=INF)return;
                dist[x][y]=distance;
                q.push(P(x,y));
            };
            push(i,j,0);
            while(!q.empty()){
                int x = q.front().first;
                int y = q.front().second;
                q.pop();
                for(int d=0;d<4;d++){
                    int afx=x+dx[d];int afy=y+dy[d];
                    if(afx>=0 && afx<H && afy>=0 && afy<W){
                        if(inp[afx][afy]=='#')continue;
                        push(afx,afy,dist[x][y]+1);
                    }
                }
            }
            for(int i=0;i<H;i++){
               for(int j=0;j<W;j++){
                   if(inp[i][j]=='#')continue;
                   if(max<dist[i][j])max=dist[i][j];
               }
            }
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
#define v_inputrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)

int main(){
    string s;
    cin >> s;
    int n = s.length();
    ll sum = 0;
    ll tmp = 0;

    for(ll i = 0 ; i < (1 << n - 1) ; i++){
        for(int j = 0 ; j <= n - 1 ; j++){
            ll mask = 1 << j;
            tmp = tmp * 10 + (s.at(j) - '0');

            if(j == n - 1){
                sum += tmp;
                tmp = 0;
                break;
            }

            if(mask & i){
                sum += tmp;
                tmp = 0;
            }

        }
    }

    cout << sum;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int n, a[100000], nr;
    cin>>n;
    for(int i=1; i<=n; ++i){
        cin>>nr;
        a[nr]=i;
    }
    for(int i=1; i<=n; ++i)
        cout<<a[i]<<" ";
    return 0;
}


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

int main(){
  int n;
  string s; 
  cin >> n >> s;
  int count = 0;
  int ans = 0;
  rep(i,n){
    if(s[i] == 'I'){
      ++count;
      ans = max(ans,count);
    }
    else{
      --count;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256