akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
set<int>se[500];
int n,m,ans;
struct data{
	int t,a,b;
}dt[100100];
bool live[500];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i){
		scanf("%d%d",&dt[i].a,&dt[i].b);
		dt[i].t=i;
	}
	for(int i=1;i<=n;++i){
		se[i].insert(i);
		live[i]=1;
		for(int j=m;j>=1;--j){
			int t1=se[i].count(dt[j].a),t2=se[i].count(dt[j].b);
			if(t1&&t2){
				live[i]=0;
				break;
				se[i].erase(se[i].find(dt[j].a));
				se[i].erase(se[i].find(dt[j].b));
			}
			else if(t1) se[i].insert(dt[j].b);
			else if(t2) se[i].insert(dt[j].a);
		}
	}
	for(int i=1;i<=n;++i){
		for(int j=i+1;j<=n;++j){
			if(!live[i]||!live[j])continue;
			bool flag=1;
			for(set<int>::iterator it=se[i].begin();it!=se[i].end();++it){
				int x=*it;
				if(se[j].count(x)){
					flag=0;
					break;
				}
			}
			ans+=flag;
//			if(flag)cout<<'\n'<<i<<' '<<j<<endl;
		}
	}
	cout<<ans;
}

Measured memory_bytes: 2048
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <bitset>
//#include <boost/math/common_factor_rt.hpp>

#define ll long long
#define max 100000
using namespace std;
ll l = 1000000007;
ll h[100050] = {};

int main()
{
	ll n, k;
	ll min = l;
	ll ans = 0;
	cin >> n >> k;

	for (int i = 0; i < n; i++)
	{
		cin >> h[i];
	}

	sort(h, h + n);
	
	for (int i = 0; i < n - (k - 1); i++)
	{
		ll num = 0;
		num = h[i + (k - 1)] - h[i];

		if (num < min) {
			ans = num;
			min = num;
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 1024
s_input_sort = sorted(list(str(input())))
t_input_sort = sorted(list(str(input())), reverse=True)

s_str = "".join(s_input_sort)
t_str = "".join(t_input_sort)

if s_str == t_str:
    print("No")
else:    
    if t_str < s_str:
        print("No")
    else:
        print("Yes")

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

using namespace std;

int main(){
 int n,k;
  cin>>n>>k;
  set<int> st;
  for(int i=0;i<k;i++){
    int x;
    cin>>x;
    st.insert(x);
  }
  for(int i=n;;i++){
    int temp=i,flag=1;;
    while(temp){
      int l=temp%10;
      temp=temp/10;
      if(st.count(l))
        flag=0;
    }
    if(flag){
     cout<<i;
      break;
    }
  }
}

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

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

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

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

bool sosuu(int x){
	bool b = 1;
	if(x == 1) b = 0;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) {
			b = 0;
			break;
		}
	}
	return b;
}

int n, m;
bool can[9][9] = {0};

int main(){
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		can[a][b] = 1;
		can[b][a] = 1;
	}
	
	queue<P> q;
	q.push(make_pair(1, 1));
	int ans = 0;
	while(q.size()){
		P now = q.front();
		q.pop();
		if(now.second == (1 << n) - 1) ans++;
		for(int i = 1; i < n; i++){
			if(can[now.first][i+1] && !((now.second >> i) & 1)){
				q.push(make_pair(i+1, now.second + (1 << i)));
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 384
(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  const arr = lines.shift().split(' ').map(Number);
  buildMaxHeap(arr, n);
  console.log(arr.reduce((s, e) => s += ` ${e}`, ''));
})();

function buildMaxHeap(arr, n) {
  const maxHeapify = (i) => {
    let left, right, largest;
    left = 2 * i + 1;
    right = 2 * i + 2;
    largest = left < n && arr[left] > arr[i] ? left : i;
    if (right < n && arr[right] > arr[largest]) largest = right;
    if (largest != i) {
      arr[largest] = [arr[i], arr[i] = arr[largest]][0];
      maxHeapify(largest);
    }
  };

  for (let i = Math.floor(n / 2); i > -1; i--) maxHeapify(i);
}



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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	int n; cin >> n;
	priority_queue<ll> q;
	for (int i=0; i<n; i++) {
		ll a; cin >> a;
		q.push(a);
	}
	ll ret = 0;
	ret += q.top();
	q.pop();
	int cnt=0;
	for (int i=2; i<n; i++) {
		ret += q.top();
		//cout << ret << endl;
		cnt++;
		if (cnt==2) {
			q.pop();
			cnt=0;
		}
	}
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 5364
#include<iostream>
using namespace std;
int main(){
  char n[4];
  cin >> n;
  if(n[0] == n[1] && n[1] == n[2]){
    cout << "Yes" << endl;
  }else if(n[1] == n[2] && n[2] == n[3]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 using namespace std;
 typedef long long ll;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;

 int main() {
   ll N, K;
   cin >> N >> K;

   cout << min(N % K, K - N % K) << endl;
 }


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin>>n;
  vvll edge(n);
  REP(i,n-1){
    ll a,b;
    cin>>a>>b;

    a--;
    b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }

  queue<pll> que;
  vll visited(n);
  que.push(pll(0,0));
  visited[0]=-1;

  while(!que.empty()){
    pll p=que.front();
    que.pop();
    ll v=p.FI;
    ll dist=p.SE;
    for(auto e:edge[v]){
      if(visited[e])
        continue;

      visited[e]=dist+1;
      que.push(pll(e,dist+1));
    }
  }

  ll st=0;
  ll d=-1;
  REP(i,n){
    if(d<visited[i]){
      st=i;
      d=visited[i];
    }
  }

  visited=vll(n);
  que.push(pll(st,0));
  visited[st]=-1;
  while(!que.empty()){
    pll p=que.front();
    que.pop();
    ll v=p.FI;
    ll dist=p.SE;
    for(auto e:edge[v]){
      if(visited[e])
        continue;

      visited[e]=dist+1;
      que.push(pll(e,dist+1));
    }
  }

  d=-1;
  REP(i,n){
    if(d<visited[i]){
      st=i;
      d=visited[i];
    }
  }

  if(d%3==1)
    cout<<"Second"<<endl;
  else
    cout<<"First"<<endl;



}



Measured memory_bytes: 20416
N=int(input())
S=input()
count=0
count=S.count('R')*S.count('G')*S.count('B')
for i in range(N-2):
    for j in range(1,(N+i+1)//2-i):

        if(S[i]+S[i+j]+S[i+2*j] in ['RGB','RBG','GRB','GBR','BGR','BRG']):

            count=count-1
print(count)


Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N, vector<long long> d){
	ll res = 0;
	rep(i, N) {
		rep(j, N) {
			if (i >= j) continue;
			res += d[i]*d[j];
		}
	}
	cout << res << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> d(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&d[i]);
	}
	solve(N, d);
	return 0;
}



Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
using namespace std;

int main(){

  int n; cin >> n;
  vector<int> A(n); for (int i=0; i<n; i++) cin >> A[i];
  cout <<  A[0];
  for (int i=1; i<n; i++) cout << " " << A[i];
  cout << endl;

  for (int i=1; i<n; i++){
    int v=A[i];
    int j=i-1;
    while (j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=v;
    cout << A[0];
    for (int k=1; k<n; k++) cout << " " << A[k];
    cout << endl;
  }

  return 0;
}



Measured memory_bytes: 3084
N = int(input())

A, B = 0, 0

for i in range(N):
    x, y = map(int, input().split())
    if i == 0:
        A = x
        B = y
        continue
    tmpa = (A - 1) // x + 1
    tmpb = (B - 1) // y + 1
    tmp = max(1, tmpa, tmpb)
    x *= tmp
    y *= tmp
    A = x
    B = y

print(A + B)

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

int main() {
  
  	int a,b,c,d,e,k ;
  	cin >> a >> b >> c >> d >> e >> k;
  
  	if( e-a > k )
      cout << ":(" << endl;
  	else
      cout << "Yay!" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char card[2][208];
	int n, h, f, len, i, j;
	int curr, next;

	for (;;) {
		for (i = 0; i < 2; i++)
			for (j = 0; j < 208; j++)
				card[i][j] = '\0';
		scanf("%s", &card[0][0]);
		if (card[0][0] == '-') break;
		scanf("%d", &n);
		for (len = 0; card[0][len] != '\0'; len++) ;
		curr = 0;
		while (n--) {
			scanf("%d", &h);
			next = (curr + 1) % 2;
			for (i = 0; i < h; i++) {
				card[next][len - h + i] = card[curr][i];
			}
			for (i = 0; i < len - h; i++) {
				card[next][i] =  card[curr][h + i];
			}
			curr = (curr + 1) % 2;
		}
		printf("%s\n", &card[next][0]);
	}
	return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (a > b) a = b; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s; cin >> s;

  int month = stoi(s.substr(5, 2));
  if (month <= 4) cout << "Heisei" << endl;
  else cout << "TBD" << endl;

  return (0);
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = K; i < N; i++) {
        if (A[i] > A[i - K]) {
            cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }
}


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

using namespace std;

int main()
{
    int V, d;
    
    while (scanf("%d %d", &V, &d) == 2){
        vector<int> a(V);
        
        a[0] = 2;
        for (int i = 1; i < V; i++){
            if (i == 1) a[i] = 3;
            else a[i] = (a[i - 1] + a[i - 2]) % 1001;
        }
        
        sort(a.begin(), a.end());
        
        int ct = 1;
        for (int i = 1; i < V; i++) if (a[i] - a[i - 1] >= d) ct++;
        
        printf("%d\n", ct);
    }
    
    return (0);
}

Measured memory_bytes: 1204
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <math.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
int n;
char s[105],t[105];
bool o=false;
int main(void){
    cin>>s>>t;
    n=strlen(s);
    for(int i=0;i<n;i++){
        bool k=true;
        for(int j=0;j<n;j++){
            if(s[j]!=t[(i+j)%n])k=false;
        }
        if(k)o=true;
    }
    if(o)cout<<"Yes\n";
    else cout<<"No\n";
}


Measured memory_bytes: 256
#include<stdio.h>

#define QQ_MAX 9

int main(){

        int height = 0, weight = 0;
        int ans=0;


        for(height = 1; height <= QQ_MAX; height++)
        {
                for(weight=1;weight <= QQ_MAX; weight++)
                {
                        ans = weight * height;
                        printf("%dx%d=%d\n", height, weight, ans);
                }
        }
    return 0;
}

Measured memory_bytes: 524
S = input()
count = [0,0]

for i in range(len(S)):
    if i%2 == 0:
        if S[i] == '1':
            count[0] +=1
        else:
            count[1] +=1
    else:
        if S[i] == '0':
            count[0] +=1
        else:
            count[1] +=1

print(min(count))

Measured memory_bytes: 3188
#import numpy as np
words = lambda t : list(map(t, input().split()))



h,w = words(int)
wq = [0] * w

grid = []
for i in range(h):
    grid.append(list(input()))

ans = 0
for i in range(h):
    j = 0
    while j < w:
        #print(i,j, grid[i][j])
        if grid[i][j] == '#':
            wq[j] = 0
            j+=1
            continue
        k = 0
        while j+k < w:
            if grid[i][j+k] == '.':
                k += 1
            else:
                break
        #print(i,j,k)
        if k + h > ans:
            for x in range(j,j+k):
                vplus = 0
                if not wq[x] == 0:
                    vplus = wq[x]
                else:
                    for vi in range(i-1,-1,-1):
                        if grid[vi][x] == '#':
                            break
                        else:
                            vplus += 1
                    for vi in range(i+1,h):
                        if grid[vi][x] == '#':
                            break
                        else:
                            vplus += 1
                ans = max(ans, vplus+k)
                wq[x] = vplus
        j += k
print(ans)


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

using ll = long long;

int main() {
    int w, h;
    cin >> w >> h;
    while (w != 0) {
        vector<vector<int>> r(h + 1, vector<int>(w, 1)), c(h , vector<int>(w + 1, 1));
        rep(i, h - 1) {
            rep(j, w - 1) cin >> c[i][j + 1];
            rep(j, w) cin >> r[i + 1][j];
        }
        rep(j, w - 1) cin >> c[h - 1][j + 1];
        vector<vector<int>> d(h + 2, vector<int>(w + 2, 0));
        rep(i, h + 2) {
            d[i][0] = -1;
            d[i][w + 1] = -1;
        }
        rep(i, w + 2) {
            d[0][i] = -1;
            d[h + 1][i] = -1;
        }
        queue<vector<int>> q;
        q.push({1, 1, 1});
        d[1][1] = 1;
        while (!q.empty()) {
            auto p = q.front();
            //cout << "p={" << p[0] << "," << p[1] << "," << p[2] << "\n";
            int x = p[0], y = p[1], z = p[2];
            q.pop();
            if (r[x - 1][y - 1] == 0 && d[x - 1][y] == 0) {
                d[x - 1][y] = z + 1;
                q.push({x - 1, y, z + 1});
            }
            if (r[x][y - 1] == 0 && d[x + 1][y] == 0) {
                d[x + 1][y] = z + 1;
                q.push({x + 1, y, z + 1});
            }
            if (c[x - 1][y - 1] == 0 && d[x][y - 1] == 0) {
                d[x][y - 1] = z + 1;
                q.push({x, y - 1, z + 1});
            }
            if (c[x - 1][y] == 0 && d[x][y + 1] == 0) {
                d[x][y + 1] = z + 1;
                q.push({x, y + 1, z + 1});
            }
        }
        cout << d[h][w] << "\n";
        cin >> w >> h;
    }
}


Measured memory_bytes: 3184
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define sc3(a,b,c)  cin>>a>>b>>c
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"Yes"<<endl
#define prN         cout<<"No"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first 
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	sc(n);
	cout<<prec(10)<<((ld)n*n*n/27);
	
	
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	} 		
}

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

using namespace std;
using i64 = std::int_fast64_t;

const int MOD = 1000000007;

template <typename T>
ostream &operator<<(ostream &os, const std::vector<T> &vec) {
  for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
  return os;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W, K;
  cin >> H >> W >> K;

  vector<vector<i64>> dp(H + 1, vector<i64>(W + 1, 0));
  dp[0][0] = 1;
  for (int h = 0; h < H; h++) {
    for (int w = 0; w < W; w++) {
      for (int bit = 0; bit < (1 << (W - 1)); bit++) {
        auto check = [bit, W]() -> bool {
          for (int b = 0; b < W - 2; b++) {
            if ((bit >> b) & 1 && (bit >> (b + 1)) & 1) return false;
          }
          return true;
        };

        if (!check()) continue;

        int nw = w;
        if ((bit >> w) & 1) {
          nw++;
        } else if (w > 0 && (bit >> (w - 1)) & 1) {
          nw--;
        }

        dp[h + 1][nw] = (dp[h + 1][nw] + dp[h][w]) % MOD;
      }
    }
  }

  cout << dp[H][K - 1] << '\n';
  return 0;
}


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

int main()
{
	int S;
	int h, m, s;
	
	cin >> S;
	
	s = S%60;
	m = S/60;
	h = m/60;
	m = m%60;
	
	cout << h << ':' << m << ':' << s << endl;
	
	return 0;

}

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

int main(){
  int n, a,b, A,B;

  while( cin >> n && n ){
    A=B=0;
    while( n-- ){
      cin >> a >> b;
      if( a>b )
	A += a+b;
      else if( a<b )
	B += a+b;
      else{
	A += a;
	B += b;
      }
    }
    cout << A << " " << B << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstring>
#include <map>
#include <algorithm>
#define INF 100000
using namespace std;
int T,N;
int t[101];
typedef pair<int,int> P;
P p[201];
int dp[201][31];
int d[101];

int main(void){
	while(1){
		scanf("%d",&T);
		if(T==0)break;
		for(int i=0;i<T;i++){
			scanf("%d",&t[i]);
		}
		for(int i=0;i<=100;i++)d[i]=23;
		scanf("%d",&N);
		for(int i=0;i<N;i++){
			scanf("%d %d",&p[i].first,&p[i].second);
			p[i].first--;
			d[p[i].first]=min(d[p[i].first],p[i].second);
		}
		for(int i=0;i<=100;i++){
			for(int j=0;j<=T;j++){
				dp[i][j]=INF;
			}
		}
		dp[0][0]=0;
		int res=INF;
		for(int i=0;i<100;i++){
			for(int j=0;j<T;j++){
				if(dp[i][j]!=INF){
					if(d[i]>=t[j]){
						dp[i+1][(j+1)%T]=min(dp[i+1][(j+1)%T],dp[i][j]);
						if(i+1==100)res=min(res,dp[i+1][(j+1)%T]);
					}
					dp[i+1][1]=min(dp[i+1][1],dp[i][j]+1);
					if(i+1==100)res=min(res,dp[i+1][1]);
				}
			}
		}
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 1044
//#include <iomanip>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <cmath>
#define mod 1000000009
int main() {
	int a, b, c, x, y;
	std::cin >> a >> b >> c >> x >> y;
	int res = a * x + b * y;
	res = std::min(res, c * 2 * std::max(x, y));
	if (x < y) {
		res = std::min(res, c * 2 * x + (y - x) * b);
	} else {
		res = std::min(res, c * 2 * y + (x - y) * a);
	}
	std::cout << res << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long L, R; cin >> L >> R;
    long long MOD = 2019;
    long long seg_cnt = 0;
    vector<long long> mod_cnt(2019);
    for (long long l = 0; l <= R; l += 2019) {
        long long r = l + 2018;
        if (L <= l && r <= R) {
            seg_cnt++;
        } else if (min(R, r) - max(L, l) >= 0) {
            for (long long j = l; j <= r; j++) {
                if (L <= j && j <= R) {
                    mod_cnt[j % MOD]++;
                }
            }
        }
    }
    for (int i = 0; i < 2019; i++) {
        mod_cnt[i] += seg_cnt;
    }
    long long ans = 2020;
    for (long long i = 0; i < 2019; i++) {
        for (long long j = i+1; j < 2019; j++) {
            if (mod_cnt[i] > 1) ans = min(i*i%MOD, ans);
            if (mod_cnt[i] && mod_cnt[j]) ans = min(i*j%MOD, ans);
        }
    }
    cout << ans << endl;
}


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

// boost
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using vld = vector<ld>;
using vvld = vector<vld>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
// #define mod (998244353ll)

const long long INF = 1LL << 60;

vll pl;

bool is_prime(const unsigned n) {
  if (n % 2 == 0 || n % 3 == 0) {
    if (n == 2 || n == 3) {
      return true;
    }
    return false;
  }
  if (n == 1) {
    return false;
  }

  for (unsigned i = 5; i * i <= n; i += 6) {
    if (n % i == 0 || n % (i + 2) == 0) {
      return false;
    }
  }

  return true;
}

// prime factorization (素因数分解)
// key: value of prime factor
// value: number of prime factor
vll prime_factorization(ll n) {
  vll prime_factors;
  for (ll i : pl) {
    if (i * i > n)
      break;

    while (n % i == 0) {
      prime_factors.push_back(i);
      n /= i;
    }
  }
  if (n != 1)
    prime_factors.push_back(n);
  return prime_factors;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll n;
  cin >> n;
  vll a(n);
  rep(i, n) cin >> a[i];

  set<ll> primes;

  REP(i, 1e6 + 10) {
    if (is_prime(i)) {
      pl.push_back(i);
    }
  }

  bool is_pairwise = true;

  rep(i, n) {
    auto pf = prime_factorization(a[i]);
    for (auto& p : pf) {
      auto it = primes.lower_bound(p);
      if (it != primes.end() && *it == p) {
        is_pairwise = false;
      }
    }
    for (auto& p : pf) {
      primes.insert(p);
    }
  }

  ll all_gcd = a[0];
  rep(i, n) {
    all_gcd = gcd(all_gcd, a[i]);
  }

  if (is_pairwise) {
    cout << "pairwise coprime" << endl;
  } else if (all_gcd == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
  return 0;
}


Measured memory_bytes: 15156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;
ll N;
vector<string> A;
vector<ll> B, C;
vector<vector<string>> D;
vector<vector<int>> paths;
vector<ll> adjcent;

vector<ll> dp;

void solve() {
    A.resize(N);
    B.resize(N);
    C.resize(N);
    D.resize(N);
    paths.resize(N);
    adjcent.resize(N);
    for(int i = 0; i < N; i++) {
        paths[i].resize(N);
        adjcent[i] = (1LL << N) - 1;
        for(int j = 0; j < N; j++) {
            paths[i][j] = 0;
        }
        cin >> A[i] >> B[i] >> C[i];
        D[i].resize(C[i]);
        for(int j = 0; j < C[i]; j++) {
            cin >> D[i][j];
        }
    }
    for(int i = 0; i < N; i++) {
        adjcent[i] ^= (1LL << i);
        for(int j = 0; j < N; j++) {
            for(int k = 0; k < C[i]; k++) {
                if(D[i][k] == A[j]) {
                    paths[i][j] = 1;
                    adjcent[i] ^= (1LL << j);
                }
            }
        }
        //cerr << i << " " << bitset<20>(adjcent[i]) << endl;
    }
    ll Main = (N + 1) / 2;
    ll Rest = N - Main;
    dp.resize((1 << Rest), -1e18);
    for(ll bits = 0; bits < (1LL << Rest); bits++) {
        dp[bits] = -1e18;
        bool ok = false;
        ll Bsum = 0;
        ll checker = (1LL << N) - 1;
        for(int i = 0; i < Rest; i++) {
            if(!(bits & (1 << i))) continue;
            Bsum += B[i+Main];
            checker &= adjcent[i+Main] | (1LL << (i+Main));
        }
        ok = ((checker >> Main) & bits) == bits;
        if(ok) chmax(dp[bits], Bsum);
        for(int i = 0; i < Rest; i++) {
            if(bits & (1 << i)) chmax(dp[bits], dp[bits ^ (1 << i)]);
        }
        //cerr << bits << " " << checker << " " << dp[bits] << endl;
    }
    ll ans = 0;
    for(ll bits = 0; bits < (1 << Main); bits++) {
        if(!(bits & 1LL)) continue;
        ll Bsum = 0;
        ll to = (1LL << N) - 1;
        for(int i = 0; i < Main; i++) {
            if(!(bits & (1LL << i))) continue;
            Bsum += B[i];
            //cerr << bits << " " << i << " " << adjcent[i] << " " << to << endl;
            to &= (adjcent[i] | (1LL << i));
            //cerr << bits << " " << i << " " << adjcent[i] << " " << to << endl;
        }
        //cerr << bits << " " << bitset<20>(to) << endl;
        if((to & ((1 << Main) - 1) & bits) != bits) Bsum = -1e18;
        chmax(ans, Bsum + dp[(to >> Main)]);
    }
    cout << ans << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> N) {
        if(N == 0) break;
        solve();
    }
    return 0;
}


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

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

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

int main(){
    long long a, b;
    cin >> a >> b;

    long long g = gcd(a, b);

    vector<long long> div = divisor(g);
    long long n = (long long) div.size();
    vector<bool> flag(n, true);
    

    for(long long i = 1; i < n; i++){
        if(flag[i] == false) continue;
        for(long long j = i+1; j < n; j++){
            if(div[j] % div[i] == 0) flag[j] = false;
        }
    }

    long long cnt = 0;
    for(long long i = 0; i < n; i++){
        if(flag[i] == true) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3600
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);

	public static void main(String[] args) {
			int N=sc.nextInt();
			ArrayList<Integer> cc = new ArrayList<>(N);
			for(int i=0;i<N;i++) {
				
				cc.add(sc.nextInt());
			}
			int ans=0;
			for(int i=0;i<N;i++) {
				int v=cc.get(i);
				
				if(cc.get(v-1)-1==i) {
					ans++;
				}
				
				
			}p(ans/2);
			
			
	}
	

	
	//N==S
	//E==W
//83 S 
	//69E
	//78N
	//87W
	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


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

// Begin {{{
using namespace std;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<>>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
inline i64 sigma(i64 n) { return n * (1 + n) >> 1; }
inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; }
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
#ifndef DEBUG
#define dump(...)
#endif

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

inline void outs() { cout << "\n"; }
template <class Head, class... Tail>
inline void outs(Head&& head, Tail&&... tail) {
  cout << head << (sizeof...(tail) ? " " : "");
  outs(forward<Tail>(tail)...);
}

template <class T>
inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e == &vec.back()]; }

template <class T>
inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); }

inline void outl() { cout << "\n"; }
template <class Head, class... Tail>
inline void outl(Head&& head, Tail&&... tail) {
  cout << head << (sizeof...(tail) ? "\n" : "");
  outl(forward<Tail>(tail)...);
}

template <class T>
inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

inline void outn() {}
template <class Head, class... Tail>
inline void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
  return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
  return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}
// }}} End

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

  var(int, N);

  vector<i64> upcum(N + 10), downcum(N + 10);
  vector<i64> a(N + 10);
  reps(i, 1, N) {
    input(a[i]);
  }

  reps(i, 1, N) {
    upcum[i] = upcum[i-1] + a[i];
    dump(upcum[i]);
  }

  repr(i, N, 1) {
    downcum[i] = downcum[i+1] + a[i];
    dump(downcum[i]);
  }

  i64 minv = LINF;
  reps(i, 1, N - 1) {
    chmin(minv, abs(upcum[i] - downcum[i+1]));
  }

  outl(minv);

  return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n =sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		int x[][] = new int [n+1][n+1];
		int c[][] = new int [n+1][n+1];
		int d[][] = new int [n+1][n+1];
		for (int i=0;i<m;i++) 
			x[sc.nextInt()][sc.nextInt()]++;
		
		for (int i=1;i<=n;i++) {
			for (int j=1;j<=n;j++) {
				c[i][j] = c[i][j-1]+x[i][j];
			}
		}
		
		for (int i=1;i<=n;i++) {
			for (int j=1;j<=n;j++) 
				d[i][j] = d[i-1][j]+c[i][j];
		}
		
		for (int i=0;i<k;i++) {
			int p = sc.nextInt();
			int q = sc.nextInt();
			System.out.println(d[q][q] - d[p-1][q] - d[q][p-1] + d[p-1][p-1]);
		}

	}
}


Measured memory_bytes: 161096
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

L, R = MAP()

if abs(L-R)+1 >= 2019:
	print(0)
	exit()

a = list(range(L, R+1))
ans = 2019

for x, y in combinations(a, 2):
	ans = min(ans, (x*y)%2019)

print(ans)


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

int main() {
  int N, K;
  cin >> N >> K;
  
  int A = 1;  
  for (int i = 0; i < N; i++){
    if (A * 2 < A + K){
     A *= 2;
    } else {
     A += K; 
    }
  }
    
  cout << A << endl;
  
}


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

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

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (long long)1e18 + 1;

class UnionFind {
public:
    struct Node {
        long long parent;
        long long rank;
        Node() = default;
        Node(const long long& _parent,
             const long long& _rank) :
            parent(_parent),
            rank(_rank) { }
    };

    std::vector<Node> node;

    UnionFind(const long long& num_node) :
        node(num_node) {
        for(long long i = 0; i < num_node; i++) {
            node[i].parent = i;
        }
    }

    long long getRoot(const long long& x) {
        return (node[x].parent == x) ?
            x : node[x].parent = getRoot(node[x].parent);
    }

    void unite(const long long& x,
               const long long& y) {
        auto rx = getRoot(x);
        auto ry = getRoot(y);
        if(rx != ry) {
            if(node[rx].rank < node[ry].rank) {
                node[rx].parent = ry;
            }
            else {
                node[ry].parent = rx;
                if(node[rx].rank == node[ry].rank) {
                    node[rx].rank++;
                }
            }
        }
    }

    bool checkSameRoot(const long long& x,
                       const long long& y) {
        return getRoot(x) == getRoot(y);
    }
};

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

    int N, K, L;
    std::cin >> N >> K >> L;

    UnionFind road(N), tr(N);
    REP(i, K) {
        int p, q;
        std::cin >> p >> q;
        road.unite(p - 1, q - 1);
    }
    REP(i, L) {
        int r, s;
        std::cin >> r >> s;
        tr.unite(r - 1, s - 1);
    }

    map<pair<int, int>, int> map;
    REP(i, N) {
        auto p = make_pair(road.getRoot(i), tr.getRoot(i));
        auto itr = map.find(p);
        if(itr != map.end()) {
            itr->second++;
        }
        else {
            map.insert(make_pair(p, 1));
        }
    }

    REP(i, N) {
        std::cout << map[make_pair(road.getRoot(i), tr.getRoot(i))] << " ";
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 18048
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpi = vector<pi>;
using vvpi = vector<vpi>;
const ull MOD = 998244353;
#ifdef LOCAL
#include "../../pp.hpp"
#define debug pp::debug
#else
#define debug(args...)
#endif

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

    int n; cin >> n;
    vi h(n+1);
    for (int i = 0; i < n; ++i) cin >> h[i+1];
    vi dp(n+1, 0);
    dp[2] = abs(h[2] - h[1]);
    for (int i = 3; i <= n; ++i) {
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[n] << '\n';
}


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

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;
 
public:
  u64 a;
 
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

	using mint=modint<MOD>;

    cin>>s;
	vector<vector<mint>> dp(Size(s)+100,vector<mint>(5));
	//dp[i][j]:= (j=1:未満で確定してる) (j=0:いいえ)


	/* 
	rep(i,Size(s)+50){
		rep(j,4){
			dp[i][j]=0;
		}
	}
	*/

	dp[0][0]=1;
	rrep(i,1,Size(s)+1){
		if(s[i-1]=='0'){
			//a+b==0
			dp[i][0]+=dp[i-1][0];
			dp[i][1]+=dp[i-1][1];

			//a+b=1
			dp[i][1]+=dp[i-1][1]*2;
		}
		else{
			//a+b==0
			dp[i][1]+=dp[i-1][1]+dp[i-1][0];

			//a+b=1
			dp[i][0]+=dp[i-1][0]*2;
			dp[i][1]+=dp[i-1][1]*2;
		}
	}
	Cout((dp[Size(s)][0]+dp[Size(s)][1]).value());
    return 0;
}


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

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> a(N);
  long long ac = 1;
  int two = 0;
  bool flag = true;
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    ac = ac*a/2/gcd(ac,a/2);
    int c = 0;
    while(a%2 == 0){
      a /= 2;
      c += 1;
    }
    if(i == 0) two = c;
    else if(two != c) flag = false;
  }
  if(flag) cout << (M/ac)/2+(M/ac)%2 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 3724
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader s = new FastReader();
        int n = s.nextInt();
        int k = s.nextInt();
        int [] arr = new int[n];
        for(int i=0;i<n;i++){
            arr[i]=s.nextInt();
        }
        int sum=0;
        Arrays.sort(arr);
        for(int i=0;i<k;i++){
            sum+=arr[i];
        }
        System.out.println(sum);
    }

    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

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

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

    if(x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
const int INF = 1e9+7;
const int LIMN = 102;
const int LIMP = 1002;
 
vector<vector<int>> pd;
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int N, W;
    cin >> N >> W;
    pd.resize(N+1);
    for(int i=0; i<=N; i++){
        pd[i] = vector<int>((i+1)*LIMP, INF);
    }
    
    pd[0][0] = 0;
    for(int i=0, v, w; i<N; i++){
        
        cin >> w >> v;
        
        for(int j=0; j<pd[i].size(); j++){
            pd[i+1][j+v] = min(pd[i+1][j+v], pd[i][j]+w);
            pd[i+1][j] = min(pd[i+1][j], pd[i][j]);
        }
    }
    
    for(int i=pd[N].size()-1; i>=0; i--){
        
        if(pd[N][i]<=W){
            cout << i;
            break;
        }
    }
    
	return 0;
}

Measured memory_bytes: 20608
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  if(n >= 64) cout << 64 << endl;
  else if (32 <= n && n < 64) cout << 32 << endl;
  else if (16 <= n && n < 32) cout << 16 << endl;
  else if (8 <= n && n < 16) cout << 8 << endl;
  else if (4 <= n && n < 8) cout << 4 << endl;
  else if (2 <= n && n < 4) cout << 2 << endl;
  else  cout << 1 << endl;
}

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

int main() {
  vector<int> vec(3);
  
  for(int i =0; i<3;i++){
    cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  cout << vec.at(0) <<" "<<vec.at(1) <<" "<< vec.at(2) <<endl;

}



Measured memory_bytes: 3148
#include<iostream>
#include<cmath>
using namespace std;
int main(void)
{
    string s;
    int m=754;
    cin>>s;
    for (int i=0;i<=s.length()-3;++i)
    {
        int x=abs((s[i]-'0')*100+(s[i+1]-'0')*10+s[i+2]-'0'-753);
        m=m<x? m:x;
    }
    cout<<m;
    return 0;
}


Measured memory_bytes: 256