akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 

using namespace std;

#define ll long long

const int N = (int)1e4 + 7;

int a[N], b[N];

main() {    
	int n; scanf("%d", &n);
	ll sum = 0, sum1 = 0, c = 0;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		sum += a[i];
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d", &b[i]);
		sum1 += b[i];
		if (b[i] > a[i]) {
			c += (b[i] - a[i] + 1) / 2;
		}
	}
	if (c <= sum1 - sum) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<vector<ll>> a(n,vector<ll>(n));
    vector<vector<ll>> dp(n,vector<ll>(n,inf));
    rep(i,n){
        dp[i][i]=0;
        rep(j,n){
            cin>>a[i][j];
            dp[i][j]=a[i][j];
        }
    }
    rep(k,n)rep(i,n)rep(j,n) chmin(dp[i][j],dp[i][k]+dp[k][j]);
    rep(i,n){
        rep(j,n){
            if(dp[i][j]!=a[i][j]){
                cout<<-1<<endl;
                return 0;
            }
        }
    }
    ll ans=0;
    rep(i,n){
        FOR(j,i+1,n){
            bool flag=false;
            rep(k,n){
                if(i==k || j==k) continue;
                if(dp[i][j]==dp[i][k]+dp[k][j]){
                    flag=true;
                    break;
                }
            }
            if(!flag) ans+=dp[i][j];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

typedef long long ll;

int gcd(int a, int b) {return a%b == 0 ? b : gcd(b, a%b);}

int main() {
    int K;
    cin >> K;
    vector<int> g(K*K);
    for (int i=0;i<K;i++){
        for (int j=0;j<K;j++){
            g[i*K+j] = gcd(i+1,j+1);
        }
    }
    ll sum = 0;
    for (int i=0;i<K;i++){
        for (int j=0;j<K*K;j++){
            sum += gcd(i+1,g[j]);
        }
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3684
def resolve():
    N = int(input())
    V = [int(i) for i in input().split()]
    C = [int(i) for i in input().split()]
    ans = 0
    for i in range(N):
        if V[i] > C[i]:
            ans += V[i] - C[i]
    print(ans)


resolve()


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

ll solve() {
    ll T1, T2, A1, A2, B1, B2;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    ll c1 = A1 - B1;
    ll c2 = A2 - B2;
    ll d = c1 * T1 + c2 * T2;
    if ( d == 0 ) return -1;
    if ( d < 0 ) {
        d = -d, c1 = -c1, c2 = -c2;
    }
    if ( c1 > 0 ) return 0;
    ll f = -c1 * T1;
    ll r = f / d;
    ll ans = 1 + 2*r;
    if ( r * d == f ) ans--;
    return ans;
}

int main() {
    auto ans = solve();
    if ( ans < 0 ) cout << "infinity" << "\n";
    else cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int sum,i,a,f=0;
  while(scanf("%d",&sum)&&sum!=0){
  for(f=0,i=0;i<9;i++){
    scanf("%d",&a);
    f+=a;
  }
  printf("%d\n",sum-f);
  }
  return(0);
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 2e5 + 9, M = 3e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;



int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n, idx;
  string str;
  cin >> n;
  map<string, vector<pair<int, int>>> mp;
  for (int i = 1; i <= n; ++i) {
    cin >> str >> idx;
    mp[str].push_back({-idx, i});
  }
  for(auto it: mp) {
    sort(it.second.begin(), it.second.end());
    for(auto ii: it.second)
      cout << ii.second << '\n';
  }
  return 0;
}


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

struct packet {
    int t, s, d;

    packet() {}
    ~packet() {}

    packet(int a, int b, int c): t(a), s(b), d(c) {}

    bool operator < (const packet& o) const {
        return t < o.t;
    }
};

int solve(int& N, int& M, vector<packet>& data) {
    sort(begin(data), end(data));
    vector<int> status(N + 1, 0);

    status[1] = 1;

    for(packet& p: data) {
        status[p.d] = max(status[p.d], status[p.s]);
    }

    int ret = 0;
    for(int& v: status) {
        ret += v;
    }

    return ret;
}

int main() {
    int N, M;
    vector<packet> data;
    while(true) {
        cin >> N >> M;
        if(N == 0) break;
        data.resize(M);
        for(packet& d : data) {
            cin >> d.t >> d.s >> d.d;
        }

        cout << solve(N, M, data) << endl;
    }
    return 0;
}

Measured memory_bytes: 1532
#include <stdio.h>

int main(void)
{
  char s[10], t[10], u[10];
  int a, b, ch = 0, i;
  
  scanf("%s %s", s, t);
  scanf("%d %d", &a, &b);
  scanf("%s", u);
  
  for( i= 0; u[i] != '\0'; i++ ){
    if( s[i] != u[i] ){
      //printf("%d\n", i);
      ch = 1;
    }
  }
  
  if( ch == 0 ){
    a--;
  } else {
    b--;
  }
  
  printf("%d %d\n", a, b);
  return 0;
}

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

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            ulong x = UInt64.Parse(Console.ReadLine());
            ulong reigai11 = 1;
            ulong divided = x / 11;
            ulong residue = x % 11;
            ulong onemore = residue / 7;
            if (residue == 0) reigai11 = 0; 
            Console.WriteLine(divided*2+onemore+reigai11);
            
        }
    }
}


Measured memory_bytes: 2776
#include<stdio.h>
int main(){
int s=100000;
int n,i;
scanf("%d",&n);
for(i=0;i<n;i++){
s=s+s/20;
if(s%1000!=0) s=s-s%1000+1000;
}
printf("%d\n",s);
return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

int d[100010],ans = -INF;
vector<int> G[100010];

void dfs(int v,int par,int depth){
	d[v] = depth;
	for(int to : G[v]){
		if(to == par) continue;
		dfs(to,v,depth + 1);
	}
}

void dfs2(int v,int par,int depth){
	chmax(ans,d[v] - 1);
	for(int to : G[v]){
		if(to == par) continue;
		if(depth + 1 >= d[to]) continue;
		dfs2(to,v,depth + 1);
	}
}

signed main(){
	int n,u,v;
	cin >> n >> u >> v; u--;v--;
	for(int i = 0;i < n - 1;i++){
		int a,b;
		cin >> a >> b; a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(v,-1,0);
	dfs2(u,-1,0);
	cout << ans << endl;
}


Measured memory_bytes: 10496
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
  int n;
  cin>>n;
  long long mx=(long long)1e18;
  long long ans=1;
  long long ara[n+5];
  bool zero=false;
  for(int i=1;i<=n;i++)
  {
    cin>>ara[i];
    if(ara[i]==0)zero=true;
  }
  if(zero)
  {
    puts("0");
    return 0;
  }
  
  for(int i=1;i<=n;i++)
  {
    if(ans>mx/ara[i])
    {
      puts("-1");
      return 0;
    }
    else ans*=ara[i];
  }
  cout<<ans<<endl;
  return 0;
}
    


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

int main(){
	int n,sum,kg,x,y,z;
	while(cin >> n && n){
		sum = 0;
		for(int i=0;i<n;i++){
			cin >> x >> y >> z >> kg;
			x=x+y+z;
			sum += (x>160||kg>25)?0:
				(x>140||kg>20)?1600:
				(x>120||kg>15)?1400:
				(x>100||kg>10)?1200:
				(x>80||kg>5)?1000:
				(x>60||kg>2)?800:
				600;
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
int n;
vi a;
vpii v;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  a.resize(n*n);
  FOR(i, 1, n+1){
    int x;
    cin >> x;
    v.pb(pii(x-1, i));
  }
  sort(rng(v));
  int idx = 0;
  for(pii p: v){
    a[p.fi] = p.se;
    int c = 1;
    while(c < p.se){
      if(a[idx] == p.se){
        cout << "No" << endl;
        return 0;
      }
      if(a[idx] == 0){
        c++;
        a[idx] = p.se;
      }
      idx++;
    }
  }
  reverse(rng(v));
  idx = n*n - 1;
  for(pii p: v){
    a[p.fi] = p.se;
    int c = p.se;
    while(c < n){
      if(a[idx] == p.se){
        cout << "No" << endl;
        return 0;
      }
      if(a[idx] == 0){
        c++;
        a[idx] = p.se;
      }
      idx--;
    }
  }
  cout << "Yes" << endl << join(a) << endl;
  return 0;
}

Measured memory_bytes: 4104
#include<bits/stdc++.h>
using namespace std ;
#define MX 2010
#define _pb push_back
#define _mp make_pair
int n ;
int a[MX] ;
vector<int> v;
int cp ;

int main()
{
    int ans ;
    int app[MX] ;
    while(cin >> n)
    {
        memset(app, 0, sizeof(app)) ;
        ans = 0 ;
        int hand ;
        for(int i=0; i<n; i++)
        {
            cin >> hand ;
            v._pb(hand) ;
        }
        sort(v.begin(), v.end()) ;
        for(int i=0; i<n-2; i++)
        {
            for(int j=i+1; j<n-1; j++)
            {
                //cout << i << ' ' << j << '\n' ;
                int pos = upper_bound(v.begin(), v.end(), v[i]+v[j]-1)-v.begin() ;
                ans += max(pos-1-j,0) ;
            }
        }
        cout << ans << '\n' ;
    }
    return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
long long a[200010], ans = 0, ans1 = 0;
int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] -= i + 1;
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++)
		ans += abs(a[i] - a[n / 2]);
	if (n % 2) ans1 = ans + 1;
	else for (int i = 0; i < n; i++)
		ans1 += abs(a[i] - a[n / 2 - 1]);
	cout << min(ans, ans1) << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;

int n, data[51];
ll dp[51];

int solve(){

  for(int i = 0 ; i < 51 ; i++ ){
    dp[i] = 1ll << i;
  }
  for(int day = 0 ; day < 30 ; day++ ){
    for(int i = 0 ; i < n ; i++ ){
      if( (data[i] >> day) & 1){ //Happyだね
        for(int j = n - 1 ; j > i ; j-- ){
          if( (data[j] >> day) & 1){ // さらにHappyだね
            dp[i] = dp[j] = ( dp[i] | dp[j] );
          }
        }
      }
    }
    for(int i = 0 ; i < n ; i++ ){
      if( dp[i] == (1ll << n) - 1) return day + 1;
    }
  }
  return -1;
}

int main(){

  while(cin >> n , n){
    fill_n( data, 51, 0);
    for(int i = 0 ; i < n ; i++ ){
      int q;
      cin >> q;
      while( q-- ){
        int day;
        cin >> day;
        day--;
        data[i] |= 1 << day;
      }
    }
    cout << solve() << endl;
  }
}

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

int main(){
	int a, b;
	cin >> a >> b;
	int mult = a * b;
	int sum = a + b;
	int sub = a-b;
	int ans = max(mult, sum);
	ans = max(ans, sub);
	cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256
cell = Array[9]

3.times do |i|
  cell[i*3],cell[i*3+1],cell[i*3+2] = gets.split(" ").map(&:to_i)
end

flg = true

if cell[0] - cell[3] != cell[1] - cell[4]
  flg = false
end

if cell[1] - cell[4] != cell[2] - cell[5]
  flg = false
end

if cell[3] - cell[6] != cell[4] - cell[7]
  flg = false
end

if cell[4] - cell[7] != cell[5] - cell[8]
  flg = false
end

if cell[0] - cell[6] != cell[1] - cell[7]
  flg = false
end

if cell[1] - cell[7] != cell[2] - cell[8]
  flg = false
end

puts flg ? "Yes" : "No"

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  pair<int, int> v;
  v.first = x2 - x1;
  v.second = y2 - y1;
  int x3,y3,x4,y4;
  x3 = x2 - v.second;
  y3 = y2 + v.first;
  x4 = x3 - v.first;
  y4 = y3 - v.second;

  printf("%d %d %d %d\n",x3,y3,x4,y4);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string N;
bool f(string a) {
    if (a.length() < N.length()) {
        return 1;
    }
    if (a.length() > N.length()) {
        return 0;
    }
    return a <= N;
}
int main () {
    cin >> N;
    int K;
    cin >> K;
    vector<string> A[3][110];
    long long ans;
    ans = 0;
    for (int i = 1; i < 10; i++) {
        for (int j = 0;; j++) {
            string g = to_string(i)+string(j, '0');
            if (f(g)) {
                A[0][g.length()].push_back(g);
                ans++;
            }
            else {
                break;
            }
        }
    }
    if (K == 1) {
        cout << ans << endl;
    }
    ans = 0;
    for (int i = 0; i <= N.length(); i++) {
        for (int j = 0; i+j <= N.length(); j++) {
            for (auto x: A[0][i]) {
                for (auto y: A[0][j]) {
                    auto g = x+y;
                    if (f(g)) {
                        A[1][g.length()].push_back(g);
                        ans++;
                    }
                }
            }
        }
    }
    if (K == 2) {
        cout << ans << endl;
    }
    ans = 0;
    for (int i = 0; i <= N.length(); i++) {
        for (int j = 0; i+j <= N.length(); j++) {
            if (i + j < N.length()) {
                ans += A[0][i].size() * A[1][j].size();
                continue;
            }
            for (auto x: A[0][i]) {
                for (auto y: A[1][j]) {
                    auto g = x+y;
                    if (f(g)) {
                        ans++;
                    }
                }
            }
        }
    }
    if (K == 3) {
        cout << ans << endl;
    }
}

Measured memory_bytes: 52864
s=input()
s=s[:-1]

if len(s)%2==1:
    s=s[:-1]
while len(s)>=0:
    l=len(s)//2
    if s[:l]==s[l:]:
        break
    s=s[:-1]
    s=s[:-1]
print(len(s))


Measured memory_bytes: 8964
P = list(map(int, input().split()))

P.sort()

A, B, C = P

r = 0

while A < B:
    A += 2
    r += 1

if A > B:
    r += 1
    B += 1
    C += 1

if A == B:
    r += C - A
    A  = C
    B  = C

print(r)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
typedef long long ll;
const ll mod = 1e9 + 7;
int main(){
    int h, w;
    cin >> h >> w;
    vector<vector<char> > a(h+1, vector<char>(w+1));
    rep(i,h)rep(j,w)cin >> a[i+1][j+1];
    vector<vector<ll> > dp(h + 1, vector<ll>(w + 1, 0));
    dp[1][1] = 1;
    REP(i,1,h+1)REP(j,1,w+1)if(!(i == 1 && j == 1)){
        if(a[i][j] == '#'){
            //cout << i-1 << " " << j-1 << endl;
            dp[i][j] = 0;
        }
        else {
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
            //cout << dp[i-1][j] << " " << dp[i][j-1] << " " << dp[i][j] << endl;
        }
    }
    cout << dp[h][w] << endl;
    //rep(i,h+1)rep(j,w+1)cout << dp[i][j] << ((j < w)?" ":"\n");
    //rep(i,h)rep(j,w)cout << a[i][j] << ((j < w-1)?"":"\n");
    return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }

int main(void){
  string s; cin >> s;
  map<char,int> m;
  FOR(i,0,s.length()-1){
    ++m[s[i]];
  }

  FOR(i,0,25){
    if(m[(char)('a'+i)]==0){
      s += (char)('a'+i);
      cout << s << endl;
      return 0;
    }
  }

  FORD(i,25,0){
    --m[s[i]];
    int index = (int)(s[i]-'a');
    FOR(j,index+1,25){
      if(m[(char)('a'+j)]==0){
        string ans;
        FOR(k,0,i-1) {
          ans += s[k];
        }
        ans += (char)('a'+j);
        cout << ans << endl;
        return 0;
      }
    }
  }

  cout << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define ff first
#define ss second
#define nl '\n'
//////////////////////////////////////////////////

const ll INF = (ll)1e12;

void dfs(int u, ll del, ll x[], int vis[], vector<vector<pair<int,ll> > > &g) {
  x[u] = del;
  vis[u] = 1;
  for(auto &e: g[u]) {
    int v = e.ff, d = e.ss;
    if( not vis[v] ) {
      dfs(v, del + d, x, vis, g);
    } else {
      if( x[v] != -INF and x[v] != x[u] + d ) {
	cout << "No" << nl;
	exit(0);
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); srand(time(0));
  
  int n, m;
  cin >> n >> m;
  vector< vector<pair<int, ll> > > g(n);
  
  for(int i=0;i<m;i++) {
    int l, r;
    ll d;
    cin >> l >> r >> d;
    l--, r--;    
    g[l].emplace_back(r,d);
    g[r].emplace_back(l,-d);
  }
  
  ll x[n]; fill(x, x+n, -INF);
  
  int vis[n];
  fill(vis, vis+n, 0);
  for(int i=0;i<n;i++)
    if( vis[i] == 0 ){
      dfs(i, 0, x, vis, g);
    }
  
  cout << "Yes" << nl;  
  return 0;
}
/* -*- -*- */


Measured memory_bytes: 19712
#include <stdio.h>
#include <stdlib.h>

int f(int X, int Y){
	if(X > Y){
		return X - Y;
	}
	else if(X < Y){
		return Y - X;
	}
	else{
		return X;
	}
}

int main(){
	int N, i, j;
	scanf("%d", &N);
	int **A = (int **)malloc(sizeof(int) * (N + 1));
	for(i = 0; i <= N; i++){
		A[i] = (int *)malloc(sizeof(int) * (1 << i));
	}
	for(j = 0; j < (1 << N); j++){
		scanf("%d", &A[N][j]);
	}
	for(i = N - 1; i >= 0; i--){
		for(j = 0; j < (1 << i); j++){
			A[i][j] = f(A[i + 1][2 * j], A[i + 1][2 * j + 1]);
		}
	}
	printf("%d\n", A[0][0]);
	return 0;
}

Measured memory_bytes: 2176
import java.util.*;

public class Main {
	final static long MOD = 1000000007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.next().length();

		long[][] dp = new long[2][N+1];
		dp[0][0] = 1;
		for(int i=0; i<N; i++) {
			Arrays.fill(dp[(i+1)%2], 0);
			for(int j=0; j<=i; j++) {
				dp[(i+1)%2][j+1] = (dp[(i+1)%2][j+1] + dp[i%2][j]*2)%MOD;
				dp[(i+1)%2][Math.max(0, j-1)] = (dp[(i+1)%2][Math.max(0, j-1)] + dp[i%2][j])%MOD;
			}
		}
		long ans = dp[N%2][M];
		long div2 = (MOD+1)/2;
		for(int i=0; i<M; i++)
			ans = (ans * div2)%MOD;
		
		System.out.println(ans);
		
		sc.close();
	}
	
}


Measured memory_bytes: 10676
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {

	answer := 0

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	M, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	D, _ := strconv.Atoi(sc.Text())

	for m := 1; m <= M; m++ {
		for d := 1; d <= D; d++ {
			if m == (d%10)*(d/10) && d > 9 && d%10 >= 2 && d/10 >= 2 {
				answer++
			}
		}
	}

	fmt.Println(answer)
}

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

int main() {
    int A, B;
    cin >> A >> B;

    if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
    
    return 0;
}


Measured memory_bytes: 256
# EduDPA - Frog 1
def main():
    n = int(input())
    A = tuple(map(int, input().rstrip().split()))
    dp = [0, abs(A[1] - A[0])] + [float("inf")] * (n - 2)
    for i in range(2, n):
        dif1 = dp[i - 2] + abs(A[i] - A[i - 2])
        dif2 = dp[i - 1] + abs(A[i] - A[i - 1])
        dp[i] = min(dif1, dif2)
    print(dp[-1])


if __name__ == "__main__":
    main()

Measured memory_bytes: 14108
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val ab = Array.fill(2)(sc.nextInt)

    if (ab(1) % 2 == 0 || ab(0) % 2 == 0) "Even" else "Odd"
  }
}


Measured memory_bytes: 25408
from math import sqrt
from collections import namedtuple

Point = namedtuple('Point', 'x y')

def rot60(p):
    return Point(C60 * p.x - S60 * p.y, S60 * p.x + C60 * p.y)

def koch(n, p1, p2):
    if n == 0: return
    s = Point((2*p1.x + p2.x)/3, (2*p1.y + p2.y)/3)
    t = Point((p1.x + 2*p2.x)/3, (p1.y + 2*p2.y)/3)
    q = rot60(Point((p2.x - p1.x)/3, (p2.y - p1.y)/3))
    u = Point(s.x + q.x, s.y + q.y)

    koch(n - 1, p1, s)
    print(f.format(s.x, s.y))

    koch(n - 1, s, u)
    print(f.format(u.x, u.y))

    koch(n - 1, u, t)
    print(f.format(t.x, t.y))

    koch(n - 1, t, p2)


C60 = 1 / 2
S60 = sqrt(3) / 2
f = '{:8f} {:8f}'

n = int(input())
print(f.format(0, 0))
koch(n, Point(0, 0), Point(100, 0))
print(f.format(100, 0))

Measured memory_bytes: 6868
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

constexpr int64 MOD = 1000000007;

constexpr int INF = 1 << 29;

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

/*
 * @ princess
 * $ soldier
 * % hatch
 * . empty
 * # wall
 */

struct S {
    int x, y, dist;
    S() {}
    S(int a, int b, int c): x(a), y(b), dist(c) {}
};

int H, W;
string arr[222];

int visited[222][222];

int p_dist = INF;
int s_dist = INF;

void dfs(int x, int y, int dist = 0) {
    visited[x][y] = true;
    if (arr[x][y] == '@') {
        s_dist = dist;
    } else if (arr[x][y] == '$') {
        p_dist = min(p_dist, dist);
    }
    for (int j = 0; j < 4; ++j) {
        int nx = x + dx[j], ny = y + dy[j];
        if (nx < 0 || H <= nx || ny < 0 || W <= ny) { continue; }
        if (arr[nx][ny] != '#' && !visited[nx][ny]) {
            dfs(nx, ny, dist+1);
        }
    }
}

int main() {
    cin >> H >> W;
    for (int j = 0; j < H; ++j) {
        cin >> arr[j];
    }
    for (int j = 0; j < H; ++j) { fill(visited[j], visited[j]+W, 0); }


    int sx, sy;
    
    for (int j = 0; j < H; ++j) {
        int val = arr[j].find('%');
        if (val != -1) {
            sx = j; sy = val;
            break;
        }
    }


    const string result = [&]() {
        int p_dist = INF;
        int s_dist = INF;
        queue<S> que;
        que.emplace(sx, sy, 0);
        visited[sx][sy] = true;
        while (!que.empty()) {
            S p = que.front(); que.pop();
            int x = p.x, y = p.y;
            if (arr[x][y] == '@') {
                p_dist = p.dist;
            } else if (arr[x][y] == '$') {
                s_dist = min(s_dist, p.dist);
            }
            if (p_dist < p.dist) {
                break;
            }
            for (int j = 0; j < 4; ++j) {
                int nx = x + dx[j], ny = y + dy[j];
                if (nx < 0 || H <= nx || ny < 0 || W <= ny) { continue; }
                if (arr[nx][ny] != '#' && !visited[nx][ny]) {
                    visited[nx][ny] = true;
                    que.emplace(nx, ny, p.dist+1);
                }
            }
        }
        return p_dist < s_dist ? "Yes" : "No";
    }();

    cout << result << endl;
    return 0;
}

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

int main(){
	string s, t;
	int n, ans = 0;
	cin >> s >> n;
	for(int i = 0; i < n; ++i){
		cin >> t;
		if((t + t).find(s) != string::npos){ ++ans; }
	}
	cout << ans << '\n';
}

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


#define ll long long
#define pb push_back
#define mp make_pair
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, a, b) for(int i = (a); i > (b); --i)

typedef pair <int,int> ii;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <ll> vl;

const int mod = 1e9+7;
const int inf = 2e18+5;


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;cin>>n;
  vi a(n+1),b(n);
  
  loop(i,0,n+1) {cin>>a[i];}
  loop(i,0,n) {cin>>b[i];}
  
  ll kill=0;
  loop(i,0,n){
    if(b[i]>=a[i]){kill+=a[i];b[i]-=a[i];a[i]=0;}  
    else {kill+=b[i];a[i]-=b[i];b[i]=0;}  
    if(b[i]>=a[i+1]){kill+=a[i+1];b[i]-=a[i+1];a[i+1]=0;}  
    else {kill+=b[i];a[i+1]-=b[i];b[i]=0;}  
   
  }
  cout<<kill;  
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

#define INF 1145141919

int N, M;
int S[20][200000];
int C[20];
int dp[1<<20];

int main() {
  cin >> N >> M;
  for (int i=0; i<N; i++) {
    int s; cin >> s;
    s--;
    S[s][i]++;
    C[s]++;
  }
  for (int i=0; i<M; i++) {
    for (int j=1; j<N; j++) S[i][j] += S[i][j-1];
  }

  for (int i=0; i<(1<<M); i++) dp[i] = INF;
  dp[0] = 0;
  for (int i=0; i<(1<<M); i++) {
    int t = 0;
    for (int j=0; j<M; j++) if (i & (1<<j)) t += C[j];
    for (int j=0; j<M; j++) {
      if (i & (1<<j)) continue;
      int s = C[j] - (S[j][t+C[j]-1] - S[j][t-1]);
      dp[i|(1<<j)] = min(dp[i|(1<<j)], dp[i] + s);
    }
  }
  cout << dp[(1<<M)-1] << "\n";
  return 0;
}

Measured memory_bytes: 14976
#include<stdio.h>
int main(void){
	int a,b,c,i,count = 0;
	scanf("%d %d %d",&a,&b,&c);
	for( i = a;i <= b;i++ ){
		if( c%i == 0 ){
			count++;
		}
	}
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 596
K,N = list(map(int,input().split()))
A = list(map(int,input().split()))

distence_list = [x for x in [ A[i+1] - A[i] for i in range(len(A)-1)]]

m = max(distence_list)

x = K - A[-1] + A[0]

if m > x:
  print(K-m)
else:
  print(A[-1] - A[0])


Measured memory_bytes: 25920
#include <stdio.h>

int main()
{
  int N;
  scanf("%d", &N);
  
  int A[N-1], ans[N], i;
  for(i=0; i<N-1; i++){
    scanf("%d", &A[i]);
    ans[i] = 0;
  }
  ans[N-1] = 0;
  
  for(i=0; i<N-1; i++){
    ans[A[i]-1]++;
  }
  
  for(i=0; i<N; i++){
    printf("%d\n", ans[i]);
  }
  
  return 0;
}

Measured memory_bytes: 3288
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

typedef vector<ll> vec;

int main()
{
  int N, C;
  cin >> N >> C;
  vector<vec> imos(30 + 1, vec(100000 + 1, 0));
  REP(i, N)
  {
    int s, t, c;
    cin >> s >> t >> c;
    imos[c][s]++;
    imos[c][t]--;
  }
  REP1(ch, C)
  REP(i, 100000)
  {
    if (imos[ch][i + 1] == 1)
    {
      imos[ch][i]++;
      imos[ch][i + 1]--;
    }
  }
  REP1(ch, C)
  REP(i, 100000)
  imos[ch][i + 1] += imos[ch][i];
  ll ans = 0;
  REP(i, 100000)
  {
    ll tmp = 0;
    REP1(ch, C)
    tmp += imos[ch][i];
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 25344
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
    Q[tail]=x;
    tail=(tail+1)%LEN;
}

P dequeue(){
    P x=Q[head];
    head = (head+1)%LEN;
    return x;
}

int min(int a, int b) {return a<b?a:b;}
int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head=1; tail=n+1;
  
  while (head!=tail){
      u=dequeue();
      c=min(q,u.t);
      u.t-=c;
      elaps+=c;
      if(u.t>0) enqueue(u);
      else{
          printf("%s %d\n", u.name, elaps);
      }
  }

  
  return 0;
}


Measured memory_bytes: 12888
#include <iostream>
#define ll long long
#define MAXN 55
using namespace std;
ll a[MAXN];

int main() {
	ios::sync_with_stdio(0);
	ll k, m;
	cin >> k;
	for(int i = 1; i <= 50; i++)
		a[i] += 49 + k / 50;
	m = k % 50;
	for(int i = 1; i <= m; i++) a[i] += (51-m);
	for(int i = m+1; i <= 50; i++) a[i] -= m;
	cout << "50" << endl;
	for(int i = 1; i <= 50; i++)
		cout << a[i] << " ";
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

	int a = scan.nextInt();
	int b = scan.nextInt();
	int x = scan.nextInt();

	if(x >= a && x <= (a+b)){
	    System.out.println("YES");
	}else{
	    System.out.println("NO");
	}
    }
}


Measured memory_bytes: 22996
import Foundation
func toTuple<T>(_ args: [T]) -> (T, T, T, T) { (args[0], args[1], args[2], args[3]) }
func readInts() -> [Int] { readLine()!.split(separator: " ").map { Int($0)! } }

let (n, m, x, y) = toTuple(readInts())
let xi = readInts().sorted(by: >)
let yi = readInts().sorted()
var z = -100
var ok = false
while !ok && z <= 100 {
  ok = xi[0] < z && yi[0] >= z && x < z && z <= y
  z += 1
}
print(ok ? "No War" : "War")

Measured memory_bytes: 13716
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

typedef struct{
    int n; //ブロック中の文字数
    char c; //ブロックの文字
    int begin;
    int end;
}block;

void array_blocked(char* S, int N, block* A){
    int a=0;
    int count=1;

    A[a].begin=0;

    for(int i=1;i<N;i++){
        if(S[i-1]==S[i]){
            count++;
        }
        else{
            A[a].n=count;
            A[a].c=S[i-1];
            A[a].end=i-1;
            a++;
            A[a].begin=i;
            count=1;
        }
    }
    A[a].n=count;
    A[a].c=S[N-1];
    A[a].end=N-1;
    return;
}

int main(void){
    int N,K;
    scanf("%d%d",&N,&K);

    char S[N+1];
    scanf("%s",S);

    block* B;
    NEW(B,N+1);
    array_blocked(S,N,B);

    //ブロックの数
    int blo=0;
    while(B[blo].n!=0){
        //printf("char %c num %d begin %d end %d\n",B[blo].c, B[blo].n, B[blo].begin, B[blo].end);
        blo++;
    }

    int A[blo];
    for(int i=0;i<blo;i++){
        A[i]=0;

        //B[end]まで足す
        int end;
        if(B[i].c=='0'){
            end=i+2*(K-1)+1;
            end=MIN(end,blo-1);
        }
        else{
            end=i+2*K;
            end=MIN(end,blo-1);
        }

        A[i]=B[end].end-B[i].begin+1;
    }

    int ans=0;
    for(int i=0;i<blo;i++){
        if(A[i]>=ans) ans=A[i];
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p) pom(a,p-2,p)

////////////////////////////////////////////////////////////////////////////////////////
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

bool fuck(char c){
    return (c == 'a' || c == 't' || c == 'c' || c == 'o' || c == 'd' || c == 'e' || c == 'r' || c == '@');
}

int main(){
    ll n,m;cin>>n>>m;
    vector<pair<ll,ll>> p;
    rep(i,0,m){
        ll a,b;cin>>a>>b;
        a--;b--;
        p.pb(mp(a,b));
    }
    ll ball[n];rep(i,0,n)ball[i]=1;
    ll seen[n];rep(i,0,n)seen[i]=false;seen[0]=true;
    rep(i,0,m){
        ball[p[i].fi]--;
        ball[p[i].se]++;
        if(seen[p[i].fi]) seen[p[i].se] = true;
        if(ball[p[i].fi] == 0 && seen[p[i].fi]) seen[p[i].fi] = false;
    }
    ll res = 0;
    rep(i,0,n)if(seen[i])res++;
    cout << res << ednl;
}




Measured memory_bytes: 3440
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map { it.toInt() }
    var i = 1
    var ans = 0
    repeat(n) {
        if (a[it] != i) ans++
        else i++
    }
    if (ans == n) println(-1)
    else println(ans)
}


Measured memory_bytes: 78972
//#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;

// ?????¬???????????¬??????
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), c.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<double> vd;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<long, long> pil;


// ??°?????????????????¬??????
typedef int Weight;

struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) {}
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;


int main() {
  int n;
  vi v;
  scanf("%d", &n);
  rep(i, n) {
    int num;
    scanf("%d", &num);
    v.push_back(num);
  }
  reverse(v.begin(), v.end());
  rep(i, n) {
    printf("%d", v[i]);
    if (i<n-1) printf(" ");
  }
  printf("\n");
  return 0;
}

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

int main()
{
  int  n, flag = 1;
  cin>>n;
  
  vector<int> arr(n);
  
  for(int i=0; i<n; i++)
    cin>>arr[i];
    
  sort(arr.begin(), arr.end());
  
  for(int i = 1; i<arr.size(); i++)
    if(arr[i] == arr[i-1])
    {
        flag = 0;
        break;
    }
    
    if(flag == 0)
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<endl;
  return 0;
}

Measured memory_bytes: 1152
import math
from functools import reduce

def gcd_list(numbers):
  return reduce(math.gcd, numbers)

N,X = map(int,input().split())
x_list = [X] + list(map(int,input().split()))
x_list.sort()

dist = [0] * (N + 1)
for i in range(N):
  dist[i] += x_list[i+1] - x_list[i]
  
ans = gcd_list(dist)
print(ans)

Measured memory_bytes: 20476
def f(i,j,h,w,l):
    c=0
    for m in [-1,0,1]:
        for n in [-1,0,1]:
            if not m and not n:continue
            if 0<=i+m<h and 0<=j+n<w and l[i+m][j+n]=="#":
                c+=1
    return c

h,w=map(int,input().split())
l=[input() for _ in range(h)]
for i in range(h):
    for j in range(w):
        if l[i][j]==".":
            print(f(i,j,h,w,l),end="")
        else:
            print(l[i][j],end="")
    print("")


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

const int INF = 1145141919;
const long long INFL = 1LL<<60;

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;
}

int main()
{
	long long int N;
	cin >> N;
	long long int A[110000];
	for (long long int i = 0; i < N; ++i)
	{
		cin >> A[i];
	}
	sort(A, A + N);
	long long int ans = 0;
	long long int ans2 = 0;
	long long int ansA[110000];
	long long int ansB[110000];
	for (long long int i = 0; i < (N/2)*2; ++i)
	{
		ansA[i] = (i % 2 == 0?A[N-1-i/2]:A[i/2]);
		ansB[i] = (i % 2 == 1?A[N-1-i/2]:A[i/2]);
	}
	for (long long int i = 0; i < (N/2)*2-1; ++i)
	{
		ans += abs(ansA[i]-ansA[i+1]);
		ans2 += abs(ansB[i]-ansB[i+1]);
	}
	if(N % 2 != 0)
	{
		// cout << max(abs(ansA[0] - A[N/2]), abs(ansA[N-1] - A[N/2])) << endl;
		ans += max(abs(ansA[0] - A[N/2]), abs(ansA[N-2] - A[N/2]));
		ans2 += max(abs(ansB[0] - A[N/2]), abs(ansB[N-2] - A[N/2]));
	}
	else
	{
		ans -= abs(ansA[N-2]-ansA[N-1]);
		ans += max(abs(ansA[N-2]-ansA[N-1]),abs(ansA[0]-ansA[N-1]));
		ans2 -= abs(ansB[N-2]-ansB[N-1]);
		ans2 += max(abs(ansB[N-2]-ansB[N-1]),abs(ansB[0]-ansB[N-1]));
	}
	cout << max(ans, ans2) << endl;
}

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

const int N = 1e5+5;
int n,m,k,c[N],ans[N],tot;
vector<int> g[N];

void dfs(int v, int at){
    tot++;
    for(auto u:g[v]){
        if(!c[u]){
            c[u]=at;
            dfs(u,at);
        }
    }
}

int main(){
    scanf("%d %d %d", &n,&m,&k);
    for(int i = 0;i<m;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    for(int i = 1;i<=n;i++){
        if(!c[i]){
            tot=0;
            c[i]=i;
            dfs(i,i);
            ans[i] = tot-1;
        }
        else ans[i] = ans[c[i]];  
    }
    for(int i = 0;i<k;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        if(c[a]==c[b]){
            ans[a]--;
            ans[b]--;
        }
    }
    for(int i = 1;i<=n;i++){
        printf("%d ", ans[i]-g[i].size());
    }
    printf("\n");
}

Measured memory_bytes: 7424
n=int(input())
v =list(map(int,input().split()))
v.sort()
x = v[0]
if n > 2:
        for i in range(1,n):
            x += v[i]*2**(i-1)

        ans = x/2**(n-1)
        print(ans)

else:
        print((x+v[1])/2)

Measured memory_bytes: 9136
/**
*   author:  akifpathan
*   created: Sunday 27.09.2020 06:13:17 PM
**/

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#ifdef LOCAL
#include "debug.h"
#else
#include<bits/stdc++.h>
using namespace std;
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> 
using ordered_set= tree<T, null_type, 
		less<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
template<class T> 		
using ordered_mset= tree<T, null_type, 
		less_equal<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
		
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	


struct seg_tree
{
	vector<int>ara;
	vector<int>Tree;
	
	seg_tree(int n)
	{
		ara.resize(n+1);
		Tree.resize(4*n+1);
	}
	
	auto func(auto a,auto b)
	{
		//for sum: return a+b
		//for min: return min(a,b)
		//for max: return max(a,b)
		return max(a,b);
	}
	
	void build(int l,int r,int at)
	{
		if(l==r)
		{
			Tree[at]=ara[l];
			return;
		}
		
		int mid=(l+r)/2;
		
		build(l,mid,at*2);
		build(mid+1,r,at*2+1);
		
		Tree[at]=func(Tree[at*2],Tree[at*2+1]);
	}
	
	//make ara[i]=val by default, for increment use Tree[at]+=val
	void update(int l,int r,int indx,int val,int at)
	{
		if(l==r)
		{
			Tree[at]=val;
			return;
		}
		
		int mid=(l+r)/2;
		
		if(indx<=mid) update(l,mid,indx,val,at*2);
		else update(mid+1,r,indx,val,at*2+1);
		
		Tree[at]=func(Tree[at*2],Tree[at*2+1]);
	}
	
	int query(int tL,int tR,int rL,int rR,int at)
	{
		if(tL>rR || tR<rL) return 0;
		if(tL>=rL && tR<=rR) return Tree[at];
		
		int mid=(tL+tR)/2;
		
		int a=query(tL,mid,rL,rR,at*2);
		int b=query(mid+1,tR,rL,rR,at*2+1);
		
		return func(a,b);
	}
	
};

const int mx=3e5+5;

void solve()
{
	int n,k;
	cin>>n>>k;
	
	seg_tree st(mx);
	
	for(int i=1;i<=n;i++) 
	{
		cin>>st.ara[i];
		st.ara[i]++;
	}
	
	for(int i=n;i>0;i--)
	{
		int l=max(1,st.ara[i]-k);
		int r=min(mx,st.ara[i]+k);
		
		int maxi=st.query(1,mx,l,r,1)+1;
		
		int indx=st.ara[i];
		int now=st.query(1,mx,indx,indx,1);
		
		if(now<maxi) st.update(1,mx,indx,maxi,1);
		
		now=st.query(1,mx,indx,indx,1);
		
		debug(indx,l,r,now,maxi);
	}
	
	cout<<st.query(1,mx,1,mx,1);
}		

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int testcase=1;
	//cin>>testcase;
	
	for(int i=1;i<=testcase;i++)
	{
		//cout<<"Case "<<i<<": ";
		solve();
	}
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}



Measured memory_bytes: 8996
K=int(input())
A,B=list(map(int,input().split()))
n=int(A/K)
m=int(B/K)
if K==1:
  print("OK")
elif A/K-n==0.0 or B/K-m==0.0:
  print("OK")
elif m-n>=1:
  print("OK")
else:
  print("NG")

Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, from, to) for (int i = from; i < (to); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<pair<int, int>> vii;

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

    int n, a, b;
    cin >> n >> a >> b;
    if (abs(a-b) % 2 == 1) {
        cout << "Borys" << endl;
    } else {
        cout << "Alice" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 50
int p[N];
int g1[] = {1 , 3 , 5 , 7 , 8 , 10 , 12};
int g2[] = {4 , 6 , 9 , 11};
int g3[] = {2};

int par(int x) {
    return p[x] == x ? x : p[x] = par(p[x]);
}

void join(int u , int v) {
    p[par(u)] = par(v);
}

bool sameSet(int u , int v) {
    return par(u) == par(v);
}

int main() {
    for (int i = 0 ; i < N ; i++) p[i] = i;
    for (int i = 1 ; i < 7 ; i++) join(g1[i] , g1[i - 1]);
    for (int i = 1 ; i < 4 ; i++) join(g2[i] , g2[i - 1]);
    int x,y; scanf("%d%d" , &x , &y);
    printf(sameSet(x , y) ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int n;
ll a[maxn];
void GG()
{
    cout<<-1<<endl; exit(0);
}
int main()
{
    fastio();
    cin>>n;
    rep(i,1,n) cin>>a[i];
    ll x = 0;
    rep(i,3,n) x ^= a[i];
    ll t = a[1] + a[2];
    ll b = (t-x)>>1;
    if(t<x || ((t-x)&1) || (b&x)) GG();
    per(i,62,0){
        if ((x>>i)&1){
            ll tmp = 1LL<<i;
            if((b|tmp) <= a[1])b |= tmp;
        }
    }
    if(b>0 && b<=a[1]) cout<<a[1]-b<<endl;
    else GG();
    return 0;
}


Measured memory_bytes: 3652