akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1; i>=a; i--)

int main(){
    //freopen("test.txt", "r", stdin);
    ll m,n; cin>>m>>n;
    string a,b; cin>>a>>b;

    ll t = __gcd(m,n);
    m/=t; n/=t;


    rep(i,0,t){
        if(a[i*m]!=b[i*n]) {cout<<-1; return 0;}
    }
    cout<<n*m*t;

    return 0;
}


Measured memory_bytes: 512
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
pre = B[0] - min(A[0], B[0])
ans = min(A[0], B[0])
for i in range(1, N):
    ans += min(pre, A[i])
    A[i] -= min(pre, A[i])
    ans += min(B[i], A[i])
    pre = B[i] - min(B[i], A[i])

ans += min(pre, A[N])
print(ans)




Measured memory_bytes: 82148
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  LL x; cin>>x;
  LL z = 100;
  LL count = 0;
  while(z<x){
  	z = (z) + (z/100);
  	count++;
  }
  cout<<count<<endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

	vector<int> a(n);
	rep(i, n) cin >> a[i];

	sort(a.begin(), a.end(), greater<int>());

	int alice = 0;
	int bob = 0;
	rep(i, n){
		if(i % 2 == 0){
			alice += a[i];
		}else{
			bob += a[i];
		}
	}

	cout << alice - bob << endl;

}


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

class class_GridColor{
public:
	class_GridColor(){};
	virtual ~class_GridColor(){};

	void Init(int h, int w);
	void Add(int c);
	void Print();

protected:
	vector<int> Box;
	int Addr=0;
	int H=0;
	int W=0;
};

void class_GridColor::Init(int h,int w){
	H=h;
	W=w;
	Box.resize(H*W);
	Addr = 0;
}

void class_GridColor::Add(int c){
	int y,x;
	y = Addr / W;
	x = Addr % W;
	if ( (y%2)==1 ){
		x = W-x-1;
	}
	int a = y * W + x;
	Box[a] = c;
	Addr++;
}

void class_GridColor::Print(){
	for(int y=0;y<H;y++){
		for(int x=0;x<W;x++){
			int a = y * W + x;
			printf("%d ",Box[a]);
		}
		printf("\n");
	}
}


int main(int argc , char **argv)
{
	(void)argc;
	(void)argv;
	class_GridColor gc;

	int h,w;
	cin >> h >> w;
	gc.Init(h,w);

	int n;
	cin >> n;
	for(int i=1; i<=n; i++){
		int a;
		cin >> a;
		for(int z=0;z<a;z++){
			gc.Add(i);
		}
	}

	gc.Print();

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];

  sort(ALL(a));

  vector<ll> sum(n);
  ll s = 0;
  REP(i,n){
    s += a[i];
    sum[i] = s;
  }

  int cnt = 0;
  REP(i,n-1){
    if(sum[i]*2 >= a[i+1]) cnt++;
    else cnt = 0;
    //cout << cnt << " ";
  }
  //cout << endl;

  //if(cnt == 0) cout << 1 << endl;
  cout << cnt+1 << endl;

  //
  // // for(auto x: a) cout << x << endl;
  // for(auto x: sum) cout << x << endl;
  //
  // int f = upper_bound(ALL(sum), *a.rbegin()) - sum.begin();

  //cout << n - f + 1 << endl;

  return 0;
}


Measured memory_bytes: 4556
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
using namespace std;


int main() {
    int a, b;
    char sign;
    cin >> a >> sign >> b;
    if(sign == '+'){
        cout << a+b << endl;
    }
    else{
        cout << a-b << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int c = Integer.parseInt(sc.next());
        if (a == b && b != c) {
            System.out.println("Yes");
        } else if (b == c && a != b) {
            System.out.println("Yes");
        } else if (a == c && a != b) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cins(int, n, b);
    b.insert(b.begin(), 0);
    vc<int> ans;
    
    while(b.size() > 1){
        for(int j = (int)b.size()-1; j > 0; j --){
            if(b[j] == j){
                b.erase(b.begin() + j);
                ans.push_back(j);
                goto next;
            }
        }
        Cout(-1);
        return 0;
        next:;
    }
    Reverse(ans);
    for(int &x : ans) Cout(x);
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
const int mxn = 1e5 + 1;
vector<int> friends[mxn], blocks[mxn];
int f[mxn] = {0};
vector<set<int>> comps;
set<int> temp;

void dfs(int i, int j){
	f[i] = j;
	temp.insert(i);
	for(auto &x : friends[i]){
		if(!f[x]){
			dfs(x, j);
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m, k;cin>>n>>m>>k;
	for(int i = 0; i < m; ++i){
		int x, y;cin>>x>>y;
		friends[x].push_back(y);
		friends[y].push_back(x);
	}
	for(int i = 0; i < k; ++i){
		int x, y;cin>>x>>y;
		blocks[x].push_back(y);
		blocks[y].push_back(x);
	}
	int j = 1;
	for(int i = 1; i<=n; ++i){
		if(!f[i]){
			temp.clear();
			dfs(i, j);
			comps.push_back(temp);
			j++;
		}
	}
	for(int i = 1; i <=n; ++i){
		int id = f[i];
		ll ans = comps[id - 1].size() - 1;
		for(auto x : friends[i]){
			if(id==f[x]) ans--;
		}
		for(auto x : blocks[i]){
			if(id==f[x]) ans--;
		}
		cout<<max(0LL, ans)<<" ";
	}
	return 0;
}



Measured memory_bytes: 21624
#include<bits/stdc++.h>
using namespace std;
int cnt[10]={0,2,5,5,4,5,6,3,7,6};
int dp[10007];
int vis[17];
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    memset(dp,-1,sizeof(dp));
    dp[0]=0;
    while(m--){
        int x;
        scanf("%d",&x);
        vis[x]=1;
        for(int i=cnt[x];i<=n;i++)
            dp[i]=max(dp[i],dp[i-cnt[x]]+1);
    }
    int tmp=n;
    while(tmp){
        for(int i=9;i;i--){
            if(vis[i]&&tmp>=cnt[i]&&dp[tmp-cnt[i]]==dp[tmp]-1){
                printf("%d",i);
                tmp-=cnt[i];
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
         
        int r = stdIn.nextInt();
        int c = stdIn.nextInt();
         
        int[][] h = new int[r+1][c+1];
         
        for(int i = 0; i < r; i++) {
            int rsum = 0;
            for(int j = 0; j < c; j++) {
                int tmp = stdIn.nextInt();
                rsum += tmp;
                h[i][j] = tmp;
            }
            h[i][c] = rsum;
        }
         
        for(int i = 0; i < c+1; i++) {
            int rsum = 0;
            for(int j = 0; j < r; j++) {
                rsum += h[j][i];
            }
            h[r][i] = rsum;
        }
         
        for(int i = 0; i < r+1; i++) {
            for(int j = 0; j < c; j++) {
                System.out.print(h[i][j] + " ");
            }
            System.out.println(h[i][c]);
        }
    }
}


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

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

Measured memory_bytes: 3092
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N, K;
  while (cin >> N >> K) {
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    ll ans = 1ll << 62;
    for (int m = 0; m < (1 << N); m++) {
      if (__builtin_popcount(m) != K) continue;
      ll mx = 0;
      ll cost = 0;
      for (int i = 0; i < N; i++) {
        if ((m >> i) & 1) {
          ll t = max(mx + 1, a[i]);
          cost += t - a[i];
          mx = t;
        } else {
          mx = max(mx, a[i]);
        }
      }
      ans = min(ans, cost);
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int main(){
 int n,buf,max,min;
 long sum;
 scanf("%d",&n);
  
 scanf("%d",&buf);
 max=min=sum=buf;
 
 for(int i=1;i<n;i++){
  scanf("%d",&buf);
  if(buf>max){max=buf;}
  if(buf<min){min=buf;}
  sum += buf;
 }
 
 printf("%d %d %ld\n",min,max,sum);
}

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

using namespace std;

int main()
{
int n;
cin>>n;
long long a;
map<long long,int>m;
for (int i=0;i<n;i++)
{
    cin>>a;
    if (m[a]!=0)
    {
        cout<<"NO";
        return 0;
    }
    m[a]++;
}
cout<<"YES";
    return 0;
}


Measured memory_bytes: 12800
#include<iostream>
#include<string>
#include<algorithm>
#include <vector>

using namespace std;
int main(void){
    string str;

    cin >> str;
    if(str.at(5)>'0')cout << "TBD" << endl;
    else if(str.at(6)>'4')cout << "TBD" << endl;
    else cout << "Heisei" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e9
#define INFLL 1ull<<60u
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    string s;
    cin >> s;
    string former,back;
    int query; cin >> query;
    bool is_reversed = false;
    vector<pair<bool,char>> sec_query;
    REP(_,query) {
        int q; cin >> q;
        if(q == 1) is_reversed = !is_reversed;
        else {
            int f;
            char c;
            cin >> f >> c; f--;
            sec_query.emplace_back(f,c);
            bool is_back = f ^ is_reversed;
            if(!is_back) former.insert(former.begin(),c);
            else back.push_back(c);
        }
    }
    auto x = former+s+back;
    if(is_reversed) reverse(ALL(x));
    cout << x << endl;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 4556
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+5;
int n,m,a[maxn];
int main()
{
  cin>>n>>m;
  int cnt=0;
  for(int i=1;i<=m;i++){
    cin>>a[i];
    cnt+=a[i];
  }
  if(n-cnt<0){
    cout<<"-1";
    return 0;
  }
  cout<<n-cnt;
  return 0;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main {
    static long INF = 1000000000000000L;
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        int[][] ans = new int[h][w];
        
        int r = 0;
        int c = 0;
        int count = 0;
        int now = 0;
        while (true) {
            ans[r][c] = now;
            if (r % 2 == 0) {
                c++;
                if (c == w) {
                    c = w - 1;
                    r++;
                }
            } else {
                c--;
                if (c == -1) {
                    c = 0;
                    r++;
                }
            }
            
            array[now]--;
            if (array[now] == 0) now++;
            
            count++;
            if (count == h*w) break;
        }
        
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                System.out.print(ans[i][j]+1);
                
                if (j != w - 1) {
                    System.out.print(" ");
                } else {
                    System.out.println();
                }
            }
        }
    }
}


Measured memory_bytes: 32624
import java.util.*;
import java.awt.geom.*;
import java.io.*;

public class Main{
	int INF = 1 << 24;
	
	class State implements Comparable<State>{
		int pos, bit;
		double cost;

		public State(int pos, double cost, int bit) {
			this.pos = pos;
			this.cost = cost;
			this.bit = bit;
		}

		@Override
		public int compareTo(State o) {
			if(this.cost < o.cost) return -1;
			if(this.cost > o.cost) return 1;
			return 0;
		}
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int tick = sc.nextInt();
			int n = sc.nextInt();
			int m = sc.nextInt();
			int s = sc.nextInt();
			int g = sc.nextInt();
			if((tick|n|m|s|g) == 0) break;
			s--;
			g--;
			int [] data = new int[tick];
			for(int i = 0; i < tick; i++){
				data[i] = sc.nextInt();
			}
			int [][] pass = new int[n][n];
			for(int i = 0; i < n; i++){
				Arrays.fill(pass[i], INF);
				pass[i][i] = 0;
			}
			for(int i = 0; i < m; i++){
				int from = sc.nextInt() - 1;
				int to = sc.nextInt() - 1;
				int dis = sc.nextInt();
				pass[from][to] = dis;
				pass[to][from] = dis;
			}
			
			PriorityQueue<State> open = new PriorityQueue<Main.State>();
			open.add(new State(s, 0, 0));
			double  [][] close = new double[n][1 << tick];
			for(int i = 0; i < n; i++){
				Arrays.fill(close[i], INF);
			}
			close[s][0] = 0.0;
			double ans = INF;
			while(! open.isEmpty()){
				State now = open.poll();
				if(now.pos == g){
					ans = now.cost;
					break;
				}
				
				for(int i = 0; i < n; i++){
					if(pass[now.pos][i] == INF) continue;
					for(int j = 0; j < tick; j++){
						if((now.bit & (1 << j)) == 0){
							int nextB = now.bit | (1 << j);
							double nextcost = now.cost + (double)pass[now.pos][i] / data[j];
							
							if(close[i][nextB] <= nextcost) continue;
							close[i][nextB] = nextcost;
							open.add(new State(i, nextcost, nextB));
						}
					}
				}
			}
			if(ans == INF){
				System.out.println("Impossible");
			}
			else{
				System.out.printf("%.3f\n", ans);
			}
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 40312
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int power(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


const int maxn = (int) 1e5 + 10;
int n;

int col[maxn];

vector<pair<int, int> > st;

set<pair<int, int> > edges[2];

void adde(int iter, int s, int t) {
  s = col[s], t = col[t];
  if (s > t) {
    swap(s, t);
  }
  if (edges[!iter].count(mp(s, t))) {
    st.pb(mp(s, t));
    edges[!iter].erase(mp(s, t));
    return;
  }
  edges[iter].insert(mp(s, t));
}

vector<int> *inside[maxn];
vector<vector<int> > es[2];

int read() {
  if (scanf("%d", &n) < 1) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    col[i] = i;
    inside[i] = new vector<int>(1, i);
  }
  st.clear();
  edges[0].clear();
  edges[1].clear();

  for (int iter = 0; iter < 2; ++iter) {
    es[iter] = vector<vector<int> >(n);
    for (int i = 0; i < n - 1; ++i) {
      int s, t;
      scanf("%d%d", &s, &t);
      --s, --t;
      adde(iter, s, t);

      es[iter][s].pb(t);
      es[iter][t].pb(s);
    }
  }
  return 1;
}

void solve() {
  for (int l = 0; l < sz(st); ++l) {
    int s = st[l].first, t = st[l].second;
    s = col[s], t = col[t];
    if (sz(*inside[s]) > sz(*inside[t])) {
      swap(s, t);
    }

    auto &vs = *inside[s], &vt = *inside[t];

    vector<pair<int, int> > toadd[2];

    for (int x : vs) {
      for (int type = 0; type < 2; ++type) {
        for (int y : es[type][x]) {
          int cx = col[x], cy = col[y];
          if (cx > cy) {
            swap(cx, cy);
          }
          auto now = mp(cx, cy);
          if (edges[type].count(now)) {
            edges[type].erase(now);
            toadd[type].pb(now);
          }
        }
      }
    }

    for (int x : vs) {
      col[x] = t;
      vt.pb(x);
    }

    for (int type = 0; type < 2; ++type) {
      for (auto p : toadd[type]) {
        adde(type, p.first, p.second);
      }
    }
  }
  if (sz(st) < n - 1) {
    printf("NO\n");
    return;
  }
  printf("YES\n");
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 29944
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;

    int                      in_N;
    int                      in_M;
    HashMap<String, Integer> input;

    int     cnt;
    Integer value;
    int     ans;

    try
    {
      in_stream = new BufferedReader(new InputStreamReader(System.in));

      /*----------------
       * 引数
       *----------------*/
      input = new HashMap<String, Integer>();

      in_str = new String(in_stream.readLine());
      in_N   = Integer.parseInt(in_str);

      for(cnt=0; cnt<in_N; cnt++)
      {
        in_str = new String(in_stream.readLine());

        if(input.containsKey(in_str))
        {
          value = input.get(in_str);
          value++;
          input.put(in_str, value);
        }
        else
        {
          input.put(in_str, 1);
        }
      }

      in_str = new String(in_stream.readLine());
      in_M   = Integer.parseInt(in_str);

      for(cnt=0; cnt<in_M; cnt++)
      {
        in_str = new String(in_stream.readLine());

        if(input.containsKey(in_str))
        {
          value = input.get(in_str);
          value--;
          input.put(in_str, value);
        }
        else
        {
          input.put(in_str, -1);
        }
      }


      /*----------------
       * 計算
       *----------------*/
      ans = 0;

      for(String key : input.keySet())
      {
        value = input.get(key);
        if(ans < value)
        {
          ans = value;
        }
      }

      System.out.println("" + ans);
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}


Measured memory_bytes: 21460
N=int(input())
A=list(map(int, input().split()))
ball=[0]*N
for i in range(N-1,-1,-1):
    #i+1>=N//2+1
    if i>=N//2:
        ball[i]=A[i]
    else:
        now=0
        n=2
        while (i+1)*n-1<N:
            now+=ball[(i+1)*n-1]
            n+=1
        if now%2!=A[i]:
            ball[i]=1
print(sum(ball))
for i,b in enumerate(ball):
    if b!=0:
        print(i+1, end=" ")

Measured memory_bytes: 7148
N, M = map(int,input().split())
a = [int(input()) for i in range(M)]
dp = [1 for i in range(N+1)]
for i in a:
    dp[i] = 0

for i in range(2, N+1):
    if dp[i]:
        dp[i] = (dp[i-2] + dp[i-1]) % (10**9 + 7)

print(dp[-1])
    


Measured memory_bytes: 7848
# coding: utf-8
import sys
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 銀貨を何枚持っているかの状態数、N*2501の都市, dijkstra
N, M, S = lr()
limit = 2500
S = min(S, limit)
graph = [[] for _ in range((N+1) * (limit+1))]  # 1-indexed
for _ in range(M):
    u, v, a, b = lr()
    for x in range(a, limit+1):
        graph[u*(limit+1) + x].append(((v*(limit+1)+x-a), b))
        graph[v*(limit+1) + x].append(((u*(limit+1)+x-a), b))

for i in range(N):
    i += 1
    c, d = lr()
    for x in range(limit-c+1):
        graph[i*(limit+1) + x].append((i*(limit+1) + x + c, d))

def dijkstra(start):
    INF = 10 ** 15
    dist = [INF] * ((N+1) * (limit+1))
    dist[start] = 0
    que = [(0, start)]
    while que:
        d, prev = heappop(que)
        if dist[prev] < d:
            continue
        for next, time in graph[prev]:
            d1 = d + time
            if dist[next] > d1:
                dist[next] = d1
                heappush(que, (d1, next))
    return dist

dist = dijkstra(1*(limit+1)+S)
for i in range(2, N+1):
    answer = min(dist[i*(limit+1):(i+1)*(limit+1)])
    print(answer)


Measured memory_bytes: 95268
#include <cmath>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

#include <numeric>
#include <set>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

int n;
int x;

vi a;

set<int> b;

void input() {
  b.clear();

  cin >> n >> x;

  a.resize(n);
  for (auto&& i : a)
    cin >> i;
}

void solve() {
  for (auto&& i : a)
    b.insert(abs(i - x));

  int ans = *b.cbegin();

  for (auto&& i : b)
    ans = gcd(ans, i);

  cout << ans << '\n';
}

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  _times = 3;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}


Measured memory_bytes: 8124
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    string s;
    cin >> s;
    for(char i : s) {
        if(i == '1'){
            cout << '9';
        }else{
            cout << '1';
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 760
fun main(args: Array<String>) {
    val n = readLine()!!.split(" ").map { it.toInt() }[0]
    val a = readLine()!!.split(" ").map { it.toInt() }
    var m = 0
    val flagArray = Array(n+1){ 0 }
    val bArray = Array(n+1) { 0 }.toMutableList()
    for (i in n downTo 1){
        if (flagArray[i] % 2 != a[i-1]) {
            bArray[i] = i
            m++
            for (j in 1 until n) {
                if (j * j > i) break
                if (i % j == 0) {
                    flagArray[j]++
                    val x = i / j
                    if (x != j) flagArray[x]++
                }
            }
        }
    }
    bArray.removeAll{ it == 0 }
    val index = bArray.size
    println(m)
    for (i in 0 until index){
        print("${bArray[i]} ")
    }
}

Measured memory_bytes: 75776
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

 vector<bool> arr;

void Eratosthenes(int N){
    arr.resize(N+1);
	for(int i = 0; i < N; i++){
		arr[i] = 1;
	}
    arr[0] = 0; arr[1] = 0;
	for(int i = 2; i < sqrt(N); i++){
		if(arr[i]){
			for(int j = 0; i * (j + 2) < N; j++){
				arr[i *(j + 2)] = 0;
			}
		}
	}

}

int main(){
 int Q; cin >> Q;
 Eratosthenes(100000010);
  int sum[1000010]; sum[0] = 0; sum[1] = 0;
  for(int i = 2; i < 1000010; i++){
    if(arr[i] && arr[(i+1)/2]){sum[i] = sum[i-1] + 1;}
    else{ sum[i] = sum[i-1];}}
  //sum[x] はx以下の条件を満たす整数の総数
  for(int i = 0; i < Q; i++){
    int l,r; cin >> l >> r;
       cout << sum[r] - sum[l-1] << endl;}
  return 0;}


Measured memory_bytes: 16768
using System;
using System.Linq;
using System.Collections.Generic;

public class Prime{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        //Console.WriteLine("{0}: {1}", n, string.Join(" ", PrimeFactors(n)));
		Console.WriteLine("{0}: {1}", n, string.Join(" ", PrimeFactors(n).Select (x => x.ToString()).ToArray())); //AOJ??¨
    }
     
    public static IEnumerable<int> PrimeFactors(int n)
    {
        int i = 2;
        int tmp = n;
         
        while (i * i <= n)
        {
            if(tmp % i == 0){
                tmp /= i;
                yield return i;
            }else{
                i++;
            }
        }
		if(tmp != 1) yield return tmp;
    }
}

Measured memory_bytes: 20188
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}




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

int n,k;
cin >> n >> k;
string s;
cin >> s;

rep(i,n) {
    if(i == k-1) s[i] = (char)s[i]+32;
}

cout << s << endl;

return 0;
}

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


int main(){

    int square = 1;
    int num = 1;

    int N; std::cin >> N;

    while(++num * num <= N)square = num * num; 

    std::cout << square;

    system("pause");

    return 0;

}

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

vector < int64_t > d (int64_t x) {
	vector < int64_t > res;
	for (int64_t i = 1; i * i <= x; ++i) {
		if (x % i == 0) {
			res.push_back(i);
			if (i * i != x)
				res.push_back(x / i);
		}
	}
	int t = res.size();
	for (int i = 0; i < t; ++i)
		res.push_back(-res[i]);
	sort(res.begin(), res.end());
	return res;
}

int64_t f (int64_t b, int64_t q) {
	return 5 * (b * b * b * b) * q + 10 * (b * b * b) * (q * q) + 10 * (b * b) * (q * q * q) + 5 * b * (q * q * q * q) + (q * q * q * q * q);
}

signed main () {
	int64_t x;
	cin >> x;
	vector < int64_t > ds = d(x);
	bool found = 0;
	for (int64_t q: ds) {
		if (abs(q) <= 2000) {
			for (int64_t b = -2000; b <= 2000; ++b) {
				if (f(b, q) == x) {
					cout << b + q << ' ' << b << '\n';
					found = 1;
					break;
				}
			}
		}
		if (found)
			break;
	}
}


Measured memory_bytes: 3596
(defun main ()
  (let* ((n (read))
         (result-list (loop for i from 1 to 9 collect
                            (and (= (mod n i) 0)
                                 (<= (/ n i)  9)))))
    (if (find t result-list)
      (format t "~a~%" "Yes")
      (format t "~a~%" "No"))))
(main)

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

using namespace std;

int main()
{
    string s;
    int month;

    cin >> s;
    month = stoi(s.substr(5, 2));

    if (month < 5)
        cout << "Heisei" << endl;
    else
        cout << "TBD" << endl;
    
    return 0;
}

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

int main(){
	int n,s,r,bit;
	int sum;
	
	while(cin >> n >> s && n || s){
		r = 0;
		for(int i=0;i < (1<<10) ;i++){
			sum = bit = 0;
			for(int j=0;j<10;j++)
				if( i & (1<<j) )bit++;
			if(bit != n)continue;
			
			for(int j=0;j<10;j++){
				if( i & (1<<j) )sum+=j;
			}

			if( sum == s )r++;
		}
		cout << r << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <sstream>
#include <string>
using namespace std;

typedef long long ll;

int main()
{
	int n, sum = 0;
	cin >> n;

	sum += (n / 500) * 1000;
	n %= 500;
	sum += (n / 5) * 5;
	cout << sum << endl;
}

Measured memory_bytes: 256
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Collections;
import java.util.Scanner;
import java.util.TreeSet;

public class Main{
       
	public static void main(String[] args) {
		Scanner sdf = new Scanner(System.in);
		
                int t=1;
                while(t-->0){
                    int n=sdf.nextInt();
                    int k=0;
                    int []a=new int[n];
                    for(int i=0;i<n;i++){
                        a[i]=sdf.nextInt();
                        k=k+a[i];
                    }
                    int fl=(int)Math.floor((double)k/(double)n);
                    int sum1=0;
                    for(int i=0;i<n;i++){
                       
                        sum1=sum1+(int)Math.pow(a[i]-fl, 2);
                                
                    }
                    
                    int c=(int)Math.ceil((double)k/(double)n);
                    int sum2=0;
                    for(int i=0;i<n;i++){
                        
                        sum2=sum2+(int)Math.pow(a[i]-c, 2);
                    }
                    System.out.println(Math.min(sum1, sum2));
                }                
        }
   

}

Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

int main()
{
    cout.precision(18);

    long long N, M;

    cin >> N >> M;
    vector<vector<long long>> E(N, vector<long long>{});
    for(long long i = 0; i < M; i++){
        long long a, b;
        cin >> a >> b;
        a--;
        b--;
        E[a].push_back(b);
        E[b].push_back(a);
    }

    queue<long long> q;
    q.push(0);
    vector<long long> f(N, -1);
    f[0] = 0;
    while (q.size() > 0) {
        long long c = q.front();
        q.pop();

        for (auto x : E[c]) {
            if (f[x] == -1){
                q.push(x);
                f[x] = c;
            }
        }
    }

    cout << "Yes" << endl;
    for(long long i = 1; i < N; i++){
        cout << f[i] + 1 << endl;
    }
}

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

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

	int A, B;
	cin >> A >> B;

	if (B == 1) {
		cout << 0 << endl;
		return 0;
	}

	int t = 1;
	int ans = 0;
	while(t < B) {
		t += A - 1;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  string s;
  cin>>s;

  int n=s.size();
  if(s!=string(s.rbegin(),s.rend())) drop("No");
  string t=s.substr(0,n/2);
  if(t!=string(t.rbegin(),t.rend())) drop("No");

  drop("Yes");
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>

#define DEBUG printf("Passing [%s] in Line %d\n" , __FUNCTION__ , __LINE__) ;

const int MAX_N = 100 + 10 ;

int n , m , a[MAX_N << 1] ;

int main() {
	scanf("%d" , &n) ; m = n << 1 ;
	for (int i = 0 ; i < m ; ++i) scanf("%d" , &a[i]) ;

	///

	int res = 0 ;
	std::sort(a + 0 , a + m) ;
	for (int i = 0 ; i < m ; i += 2) res += a[i] ;

	printf("%d\n" , res) ;

	return 0 ;
}

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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#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 FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

/* disguised dp[i][mask], need to pay attention to the constraint */

const int inf = 1e9;
const int maxn = 55;
const int maxm = 20;
LL dp[maxn][1<<maxm];
int G[maxn][maxn], n,m, cover[maxn]; vector<PII> edge;

LL dfs(const int i, const int mask)
{
    if (i == n-1)
        return mask+1 == (1<<m);
    LL& ans = dp[i][mask];
    if (-1 == ans) {
        ans = 0;
        ans += dfs(i+1, mask|cover[i]);
        ans += dfs(i+1, mask);
    }
    return ans;
}

void dfs(const int u, const int v, set<PII>& p)
{
    if (u == v)
        return;
    int i = 1;
    for (; i < n+1; i++)
        if (G[u][i] == 1 && G[u][i]+G[i][v] == G[u][v])
            break;
    assert(i <= n);
    p.insert(PII(u,i));
    p.insert(PII(i,u));
    dfs(i,v,p);
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    while (cin >> n) {
        FOR(i,0,maxn) FOR(j,0,maxn)
            G[i][j] = i==j ? 0 : inf;
        edge.clear();
        FOR(i,0,n-1) {
            int u,v; cin >> u >> v;
            G[u][v] = G[v][u] = 1;
            edge.push_back(PII(u,v));
        }
        FOR(k,1,n+1) FOR(i,1,n+1) FOR(j,1,n+1)
            G[i][j] = min(G[i][j], G[i][k]+G[k][j]);
        memset(cover,0,sizeof(cover));
        cin >> m;
        FOR(i,0,m) {
            int u,v; cin >> u >> v;
            set<PII> path;
            dfs(u,v,path);
            FOR_ALL(p,path) {
                int j = 0;
                for (; j < n-1; j++)
                    if (edge[j] == *p)
                        break;
                cover[j] |= 1<<i;
            }
        }
        memset(dp,-1,sizeof(dp));
        cout << dfs(0,0) << endl;
    }
    return 0;
}


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

left = 1
right = N

for l, r in LR:
    left = max(left, l)
    right = min(right, r)

ans = right - left

print(ans + 1 if ans >= 0 else 0)


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

int main(void){
  int x, y;
  cin >> x >> y;
  if(!(x >= y)) swap(x, y);

  while(!(x == 0 || y == 0)){
    x = x % y;
    swap(x, y);
  }

  cout << max(x, y) << endl;

  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
int main(void)
{
	int a[9], n, b[10], i, k, an[9];
	
	for(i = 0; i < 9; i++){
		an[i] = 0;
	}
	
	for(i = 0; i < 9; i++){
		scanf("%d", &a[i]);
	}
	scanf("%d", &n);
	for(i = 0; i < n; i++){
		scanf("%d", &b[i]);
	}
	
	for(i = 0; i < n; i++){
		for(k = 0; k < 9; k++){
			if(b[i] == a[k]){
				an[k] = 1;
			}
		}
	}
	/*
	i = 0;
	while(i < 9){
		printf("%d %d %d\n", an[i], an[i + 1], an[i + 2]);
		i += 3;
	}
	*/
	if((an[0] == 1 && an[1] == 1 && an[2] == 1) ||
	   (an[3] == 1 && an[4] == 1 && an[5] == 1) ||
	   (an[6] == 1 && an[7] == 1 && an[8] == 1) ||
	   (an[0] == 1 && an[3] == 1 && an[6] == 1) ||
	   (an[1] == 1 && an[4] == 1 && an[7] == 1) ||
	   (an[2] == 1 && an[5] == 1 && an[8] == 1) ||
	   (an[0] == 1 && an[4] == 1 && an[8] == 1) ||
	   (an[2] == 1 && an[4] == 1 && an[6] == 1)){
		printf("Yes");
	}
	else{
		printf("No");
	}
	
	return 0;
}

Measured memory_bytes: 128
while True:
    s = raw_input().split()
    a = int(s[0])
    op = s[1]
    b = int(s[2])
    if op == '+':
        print a+b
    elif op == '-':
        print a-b
    elif op == '*':
        print a*b
    elif op == '/':
        print a/b
    elif op == '?':
        break

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 207;

vector <int> g[N];

int cl[N];

void dfs(int u) {
    for (auto v : g[u]) {
        if (cl[v] == -1) {
            cl[v] = cl[u] ^ 1;
            dfs(v);
        }
        if (cl[v] != (cl[u] ^ 1)) {
            cout << "-1\n";
            exit(0);
        }
    }
}

int d[N];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            char c;
            cin >> c;
            if (c == '1') g[i].push_back(j);
        }
    }
    fill(cl, cl + n, -1);
    for (int i = 0; i < n; ++i) {
        if (cl[i] == -1) dfs(i);
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        fill(d, d + N, (int)1e9);
        d[i] = 0;
        queue <int> q;
        q.push(i);
        while (!q.empty()) {
            int u = q.front();
            q.pop();
            for (auto v : g[u]) {
                if (d[v] > d[u] + 1) {
                    d[v] = d[u] + 1;
                    q.push(v);
                }
            }
        }
        for (int j = 0; j < n; ++j) ans = max(ans, d[j] + 1);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 512
#include<stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000
int main(){
  unsigned short *A, *B;

  int C[VMAX+1];
  int n, i, j;
  scanf("%d", &n);
  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  for ( i = 0; i <= VMAX; i++ ) C[i] = 0;
  for ( i = 0; i < n; i++ ){
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }
  for ( i = 1; i <= VMAX; i++ ) C[i] = C[i] + C[i - 1];for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 8460
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <ctime>

#define inf 0x3f3f3f3f
#define Inf 0x3FFFFFFFFFFFFFFFLL
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, n) for (int i = 1; i <= (n); ++i)
#define clr(x, a) memset(x, (a), sizeof x)
using namespace std;
typedef long long ll;
ll a[400400];
int main() {
  ll k; int n; scanf("%I64d %d", &k, &n);
  rep(i, n) scanf("%I64d", &a[i]);
  rep(i, n) a[i + n] = a[i] + k;
  ll ans = Inf;
  for (int i = 0; i < n; ++i) {
    ans = min(ans, a[i + n - 1] - a[i]);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int N;
  float v[55];
  int i,k;
  cin >> N;
  for(i=0;i<=N-1;i++)
    cin >> v[i];
  sort(v,v+N);
  float sum =0;
  for(i=1;i<=N-1;i++)
    v[0] /= 2;
  for(i=1;i<=N-1;i++)
    for(k=1;k<=N-i;k++)
      v[i] /= 2;
  for(i=0;i<=N-1;i++)
    sum += v[i];
  cout << sum << endl;
}

Measured memory_bytes: 256
# Python code to sort the tuples using second element 
# of sublist Function to sort using sorted() 
def Sort(sub_li): 

	# reverse = None (Sorts in Ascending order) 
	# key is set to sort using second element of 
	# sublist lambda has been used 
	return(sorted(sub_li, key = lambda x: x[1]))	 

n=int(input())
l=[]
for i in range(0,n):
    p=input().rstrip().split(' ')
    D=[]
    D.append(int(p[0]))
    D.append(int(p[1]))
    l.append(D)
l=Sort(l)
t=0;
G=0;
for i in range(0,len(l)):
    t=t+int(l[i][0])
    if t<=int(l[i][1]):
        continue;
    else:
        G=1;
        break;
if G==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 42836
#include<bits/stdc++.h>
#define N 55
#define ll long long
using namespace std;
ll f[N][N*N],ans=0;
int x,a,n;
int main(){
	f[0][0]=1,scanf("%d%d",&n,&a);
	for(int i=1;i<=n;++i){
		scanf("%d",&x);
		for(int j=i;j;--j)for(int k=2500;k>=x;--k)f[j][k]+=f[j-1][k-x];
	}
	for(int i=1;i<=n;++i)ans+=f[i][i*a];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1408
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s[0]=='M') cout << 6 << endl;
    else if(s[0]=='W') cout << 4 << endl;
    else if(s[0]=='F') cout << 2 << endl;
    else if(s[1]=='A') cout << 1 << endl;
    else if(s[1]=='H') cout << 3 << endl;
    else if(s[0]=='T') cout << 5 << endl;
    else cout << 7 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

struct point {
    double x, y, r;
    point(double xx, double yy, double rr) :x(xx), y(yy), r(rr) {};
};

int main() {
    double xs, ys, xt, yt;
    cin >> xs >> ys >> xt >> yt;
    int n;
    cin >> n;

    auto d = make_v(n+2, n+2, 0.0);
    vector<point> v;
    vector<double> ans(n+2, INF<double>);
    vector<int> used(n+2, 0);
    ans[0] = 0;

    v.emplace_back(xs, ys, 0.0);


    for (int i = 1; i <= n; ++i) {
        double x, y, r;
        scanf("%lf %lf %lf", &x, &y ,&r);
        v.emplace_back(x, y, r);
    }
    v.emplace_back(xt, yt, 0.0);

    for (int i = 0; i <= n+1; ++i) {
        for (int j = i+1; j <= n+1; ++j) {
            if(i == j) continue;
            d[i][j] = d[j][i] = max(0.0, hypot(fabs(v[i].x-v[j].x), fabs(v[i].y-v[j].y))-v[i].r-v[j].r);
        }
    }
    while(true){
        int x = -1;
        for (int u = 0; u < n+2; ++u) {
            if(!used[u] && (x == -1 || ans[u] < ans[x])) x = u;
        }
        if(x == -1) break;
        used[x] = true;
        for (int u = 0; u < n+2; ++u) {
            ans[u] = min(ans[u], ans[x] + d[x][u]);
        }
    }
     cout << setprecision(11) <<  ans[n+1] << "\n";

    return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 998244353;

int main() {
    Int n;
    cin >> n;
    vector<Int> h(n);
    for (Int i = 0; i < n; i++) cin >> h[i];
    for (Int i = n - 1; i > 0; i--) {
        if (h[i - 1] > h[i]) {
            h[i - 1]--;
        }
    }
    bool check = true;
    for (Int i = 0; i < n - 1; i++) {
        if (h[i] > h[i + 1]) check = false;
    }
    dump(check ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <set>
#define MAXX 111
#define ll long long
using namespace std;

// 01, 32
// 00, 22

string S[55];

int main() {
    int N,M;
    cin>>N>>M;
    for(int i=0;i<N;i++)
        cin>>S[i];
    
    bool ok=true;
    for(int i=0;i<N;i++)
        for(int j=0;j<M;j++) {
            if (S[i][j]=='.')
                continue;
            int num_n=0;
            if (i-1>=0 && S[i-1][j]=='#')
                num_n++;
            
            if (i+1<N && S[i+1][j]=='#')
                num_n++;
            
            if (j-1>=0 && S[i][j-1]=='#')
                num_n++;
            
            if (j+1<M && S[i][j+1]=='#')
                num_n++;
            
            if (num_n==0) {
                ok=false;
            }
        }
    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int main()
{
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	int dp[n]={0};
	dp[0]=0,dp[1]=abs(arr[1]-arr[0]);
	for(int i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
	}
	cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024