akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int xcomp(vector<int>& a, vector<int>& b) {
	return a[0] < b[0];
}

int ycomp(vector<int>& a, vector<int>& b) {
	return a[1] < b[1];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)
#define YSORT(c) sort((c).begin(),(c).end(),ycomp)

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

int henkan(int a) {
	if (a == 10000) {
		return 199;
	}
	else {
		return (a + 10000) / 100;
	}
}

int henkan2(int a) {
	if (a == 10000) {
		return 1999;
	}
	else {
		return (a + 10000) / 10;
	}
}
LL mod = 1000000007;
int main() {

	int n;
	cin >> n;

	if (n <= 40000) {
		vector<vector<int>> v(n, vector<int>(2));
		REP(i, n) {
			cin >> v[i][0] >> v[i][1];

		}
		int min = 1000000000;
		REP(i, n) {
			FOR(j, i+1, n) {
				int r = (v[i][0] - v[j][0])*(v[i][0] - v[j][0]) + (v[i][1] - v[j][1])*(v[i][1] - v[j][1]);
				if (r < min) { min = r; }
			}
		}
		cout << min << endl;
	}
	else {

		vector<vector<vector<vector<int>>>> v(200, vector<vector<vector<int>>>(200, vector<vector<int>>(0)));
		REP(i, n) {
			int a, b;
			cin >> a >> b;
			v[henkan(a)][henkan(b)].push_back({ a,b });
		}
		int min = 100000;

		REP(i, 199) {

			REP(j, 199) {
				vector<vector<int>> vv(0);

				vv.insert(vv.end(), v[i][j].begin(), v[i][j].end());
				vv.insert(vv.end(), v[i][j+1].begin(), v[i][j + 1].end());
				vv.insert(vv.end(), v[i + 1][j].begin(), v[i + 1][j].end());
				vv.insert(vv.end(), v[i + 1][j + 1].begin(), v[i + 1][j + 1].end());

				REP(ii, vv.size()) {
					FOR(jj, ii + 1, vv.size()) {
						int r = (vv[ii][0] - vv[jj][0])*(vv[ii][0] - vv[jj][0]) + (vv[ii][1] - vv[jj][1])*(vv[ii][1] - vv[jj][1]);
						if (r < min) { min = r; }
					}
				}
			}
		}
		cout << min << endl;
	}
}

Measured memory_bytes: 35864
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

struct MyStruct {
	int num, honsu;
};

bool comp(const MyStruct& s, const MyStruct& t) {
	if (s.honsu != t.honsu)
		return s.honsu < t.honsu; // 昇順
	return s.num > t.num;
}

int B[20];

int main() {
	int N, M, C;
	cin >> N >> M >> C;

	REP(i, M) {
		cin >> B[i];
	}
	
	int tmp;
	int sum = 0;
	int ans = 0;
	REP(i, N) {
		sum = 0;
		REP(j, M) {
			cin >> tmp;
			sum += B[j] * tmp;
		}
		if (sum + C > 0) {
			ans++;
		}
	}

	ANS(ans);
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;


int main(){
    int d, n;
    cin >> d >> n;
    int ans;
    if (n == 100){
        ans = pow(100, d) * 101;
    }else{
        ans = pow(100, d) * n;
    }
    cout << ans << "\n";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;

  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		// 全体人数
		int N = sc.nextInt();
		// お菓子の種類
		int K = sc.nextInt();

		// お菓子持ってる人数配列
		int[] snackMenbers = new int[K];
		// お菓子持ってる人リスト
		List<int[]> snackMenberList = new ArrayList<int[]>();

		// i = お菓子カウンター
		for (int i = 0; i < K; i++) {

			snackMenbers[i] = sc.nextInt();
			int[] menberArray = new int[snackMenbers[i]];

			for (int j = 0; j < snackMenbers[i]; j++) {

				menberArray[j] = sc.nextInt();
			}

			snackMenberList.add(menberArray);
		}

		// 全すぬけ
		int[] all = new int[N];

		// お菓子の種類分回す
		for (int k = 0; k < K; k++) {

			// お菓子持ってる人分回す
			for (int l = 0; l < snackMenberList.get(k).length; l++) {

				all[snackMenberList.get(k)[l] - 1] = all[snackMenberList.get(k)[l] - 1] + 1;
			}
		}

		int ans = 0;

		for (int n = 0; n < all.length; n++) {

			if (all[n] == 0) {
				ans++;
			}
		}

		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 37640
#include<bits/stdc++.h>
using namespace std;
auto ____ = [] () {ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); };
typedef int_fast64_t LL;
const int_fast32_t MAXN = 3e5+7;
int_fast32_t n,A[MAXN],height[MAXN],F[MAXN];
int main(){
    ____();
    cin >> n;
    for(int i = 1; i <= n; i++){
        int tp;
        cin >> tp;
        A[tp]++;
    }
    for(int i = 1; i <= n; i++) height[A[i]]++;
    LL LS = 0, R = n - height[0];
    for(int h = 1; h <= n; h++){
        F[h] = LS/h+R;
        R -= height[h];
        LS += height[h] * h;
    }
    int h = n;
    for(int i = 1; i <= n; i++){
        while(h>0&&F[h]<i) h--;
        cout << h << endl;
    }
    return 0;
}

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

signed main(void)
{
	int m, d, cnt;
	int d_1, d_10;
	cin >> m >> d;
	cnt = 0;
	for(int i = 1; i <= m; i++)
	{
		for(int j = 20; j <= d; j++)
		{
			d_10 = j / 10;
			d_1 = j % 10;
			if (d_1 >= 2 && d_10 >= 2 && d_1 * d_10 == i)
				cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+7;
int w[N],v[N],dp[N];
main()
{
    int n,W;
    scanf("%lld%lld",&n,&W);
    for(int i=0;i<n;i++)
        scanf("%lld%lld",&w[i],&v[i]);
    for(int i=0;i<n;i++){
        for(int j=W-w[i];j>=0;j--)
            dp[j+w[i]]=max(dp[j+w[i]],dp[j]+v[i]);
    }
    int ans=0;
    for(int i=0;i<=W+1;i++)
        ans=max(ans,dp[i]);
    printf("%lld\n",ans);
}


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

int main() {
	char a, b;
	cin >> a ;
	switch (a) {
	    case'A':
			b = 'T';
			break;
		case'T':
			b = 'A';
			break;
		case'G':
			b = 'C';
			break;
		case'C':
			b = 'G';
			break;
	}
	
	cout << b;
	return 0;
}

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

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

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin >> k;
    string now = "1";
    for (int x = 1; x < k; ++x) {
        if (count(all(now), '9') == now.size()) {
            int z = now.size();
            now.clear();
            now.resize(z + 1, '0');
            now[0] = '1';
        } else {
            for (int i = now.size() - 1; i >= 0; --i) {
                if (i == 0 || (now[i] != '9' && abs(now[i] + 1 - now[i - 1]) <= 1)) {
                    ++now[i];
                    for (int j = i + 1; j < now.size(); ++j) {
                        now[j] = now[j - 1];
                        if (now[j] != '0') --now[j];
                    }
                    break;
                }
            }
        }
    }
    cout << now;
}


Measured memory_bytes: 256
type Vector=[Int]

product :: (Int,Int)->Int
product (x,y) = x*y

vproduct :: Vector->Vector->Int
vproduct a b = sum $ zipWith (*) a b

toVector :: [String] -> Vector
toVector = map (read :: String->Int)

myDivide :: Int->([a],[a])->([a],[a])
myDivide 0 (x,y) = (x,y)
myDivide n (x,y) = myDivide (n-1) (x++[head y],tail y)

mproduct :: Vector->[Vector]->Vector
mproduct v = map $ vproduct v

dim :: String->Int
dim=(read::String->Int).head.words.head.lines

prepare :: String->([Vector],Vector)
prepare xs = (\(x,y)->(map (toVector.words) x,toVector y)) $ myDivide (dim xs) ([],tail.lines $ xs)

calc :: ([Vector],Vector)->Vector
calc (a,b) = mproduct b a

printv :: Vector->IO ()
printv = mapM_ print

main=getContents >>= printv.calc.prepare

Measured memory_bytes: 7516
#include <stdio.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
typedef long long lint;
const int mod=1000000007;
int k,n=-1,cnt=13;
char c[15];
lint fact[2000010],inv[2000010];
int main(){
	while(1){
		*c=getchar_unlocked();
		if(*c=='\n')break;
		k*=10;
		k+=*c-'0';
	}
	while(getchar_unlocked()!=-1)n++;
	fact[0]=1;
	for(int i=1;i<=n+k;i++)fact[i]=fact[i-1]*i%mod;
	inv[n+k]=1;
	lint now=fact[n+k];
	int b=mod-2;
	while(b){
		if(b&1){
			inv[n+k]*=now;
			inv[n+k]%=mod;
		}
		b>>=1;
		now*=now;
		now%=mod;
	}
	for(int i=n+k-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
	lint ans=1;now=1;
	for(int i=1;i<=k;i++){
		now*=25;
		now%=mod;
		ans+=fact[n+k]*inv[n+k-i]%mod*inv[i]%mod*now;
		ans%=mod;
	}
	*(c+14)='\n';
	while(ans){
		*(c+cnt)=ans%10+'0';
		ans/=10;
		cnt--;
	}
	fwrite(c+cnt+1,1,14-cnt,stdout);
	return 0;
}

Measured memory_bytes: 32720
a, b, c = map(int,input().split())

if a%2!=0 or b%2!=0 or c%2!=0:
    print(0)
    exit()

if a==b==c:
    print(-1)
    exit()

times=0
while a%2==0 and b%2==0 and c%2==0:
    times+=1
    a_=a//2
    b_=b//2
    c_=c//2
    a=b_+c_
    b=a_+c_
    c=a_+b_

print(times)

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int w = 0, e = 0;
  int ans[n];
  rep(i,n)ans[i] = 0;
  rep(i,n){
    ans[i] = w;
    if(s[i]=='W')w++;
  }
  rep(i,n){
    ans[n-1-i] += e;
    if(s[n-1-i]=='E')e++;
  }
  int minans = INF;
  rep(i,n)if(minans > ans[i]) minans = ans[i];
  cout << minans << endl;
  return 0;
}

Measured memory_bytes: 4932
from math import *

def cin(): # To take limited number of inputs
    return map(int,input().split())

def cins(): # To take space sepreated strings
    return input.split()

def cino(test=False): # To take individual int input (test = False)
    if not test:
        return int(input())
    else: # To take string input (test = True)
        return input()

def cina(): # array input
  return list(map(int,input().split()))

def ssplit(): # multiple string input
    return list(input().split())

def printlist(l): # To print space seperated array
    for i in l:
        print(i,end=" ")

def main():
    n = cino()
    l = []
    for i in range(n):
        a,b = cin()
        l.append([a,b])
    check = True
    for i in range(n-2):
        if l[i][0] == l[i][1] and l[i+1][0] == l[i+1][1] and l[i+2][0] == l[i+2][1]:
            print("Yes")
            check = False
            break
    if check:
        print("No")
        

if __name__ == '__main__':
    main()

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

using namespace std;

int main()
{
    int N; cin >> N;
    vector<long long> A(N), B(N), C(N);

    for(int i=0; i<N; ++i) cin >> A[i];
    for(int i=0; i<N; ++i) cin >> B[i];
    for(int i=0; i<N; ++i) cin >> C[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    long long ans = 0;
    for(int i=0; i<N; ++i)
    {
        auto itr = lower_bound(A.begin(), A.end(), B[i]);
        auto itr2 = upper_bound(C.begin(), C.end(), B[i]);
        
        ans += (itr - A.begin()) * (C.end() - itr2);
    }

    cout << ans << endl;
}

Measured memory_bytes: 5640
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set> 
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>
using namespace std;
#define assem99 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define ld long double
#define ii pair<int, int>
#define vii vector<ii>
#define f(i,a,b) for(int i=a; i<b; i++)
#define F first
#define S second
#define sz(a) (int)(a).size()
#define ReadFile freopen("input.txt","r",stdin)
#define WriteFile freopen("output.txt","w",stdout)
int x[] = { 0, -1, 0, 1, -1, 1, -1, 1 };
int y[] = { -1, 0, 1, 0, 1, -1, -1, 1 };
const int MOD = 998244353, N = 2e5 + 5;
const double pi = acos(-1);

ll dp[105][N]; // items, value

int main()
{
	assem99;

	pair<ll, ll> arr[105]; // w, v
	ll w, n; cin >> n >> w;
	f(i, 0, n) cin >> arr[i].F >> arr[i].S; // weight, value
	f(i, 0, 105) dp[0][i] = 0, dp[i][0] = 0;
	f(i, 1, n + 1) // items
	{
		f(j, 1, w + 1) // weight
		{
			if (j - arr[i - 1].F < 0) dp[i][j] = dp[i - 1][j];
			else dp[i][j] = max(dp[i - 1][j - arr[i - 1].F] + arr[i - 1].S, dp[i - 1][j]);
		}
	}
	cout << dp[n][w];

	return 0;
}


/*
5 4
1 8
2 4
3 0
2 5
2 3
*/

Measured memory_bytes: 162560
#include <stdio.h>

int main()
{
	int w,n,a,b;
	int ans[30],temp;

	scanf("%d%d",&w,&n);
	for(int i = 0; i < w; i++){
		ans[i] = i+1;
	}

	for(int i = 0; i < n; i++){
		scanf("%d,%d",&a,&b);
		temp = ans[a-1];
		ans[a-1] = ans[b-1];
		ans[b-1] = temp;
	}

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

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, M, a[200000], l, r, res;

int main() {
	cin >> N >> M;
	for (int i = 0; i < N + N; ++i) {
		cin >> a[i];
	}
	sort(a, a + N + N);
	l = -1;
	r = N + N;
	while (l + 1 != r) {
		int m = (l + r) / 2;
		bool f = true;
		for (int i = 0; i + m < N + N; ++i) {
			if (a[m + i] + a[N + N - 1 - i] < M) {
				l = m;
				f = false;
				break;
			}
		}
		if (f) {
			r = m;
		}
	}
	r += (r & 1);
	for (int i = 0; i < r; ++i) {
		res = max(res, a[i] + a[r - 1 - i]);
	}
	for (int i = 0; i + r < N + N; ++i) {
		res = max(res, a[r + i] + a[N + N - i - 1] - M);
	}
	cout << res << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int sum=0;
        sum = 1000*(n/500);
        n%=500;
        sum+=(5*(n/5));
        System.out.println(sum);
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define int int64_t
#define double long double
#define rep(i, N) for(int i=0; i<N; i++)
#define repr(i, N) for(int i=N-1; i>=0; --i)
#define all(v) v.begin(),v.end() 
using namespace std;
//using pr = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<int>;
using vvec = vector<vec>;

//プロトタイプ宣言
//int myfunc(int, vvec);

//グローバル変数
//int N, M;
//vvec data(N, vec(M));

//関数：
int gauss(int n) {
	int ans = 0;
	for(int i=1; i<=n; i++) ans += i;
	return ans;
}

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

	string S; cin >> S;
	int lg = S.size();
	lg++;

	vec d(lg);
	d[0] = 1; d[lg-1] = 1;
	int ans = 0;
	int cmp = 0;
	for(int i=1; i<lg-1; i++) {
		if(S[i] != S[i-1]) {
			d[i] = 1;
			if(S[i-1] == '<') {
				cmp = d[i-1];
				ans += gauss(d[i-1]);
			}
			else {
				ans += gauss(d[i-1]);
				ans -= min(d[i-1], cmp);
			}
		}
		else {
			d[i] = d[i-1] + 1;
		}
	}

	ans += gauss(d[lg-2]);
	if(S[lg-2] == '>') ans -= min(d[lg-2], cmp);

	cout << ans << endl;
	return 0;
}
//std::string str;
//str = std::to_string(int i);
//bitset<3> s(N);
//int ans = (char)grid - '0';

Measured memory_bytes: 4892
n,k=map(int,input().split())
arr=list(map(int,input().split()))
dp=[False]*(2*k+1)
for i in range(k):
  for val in arr:
    if dp[i]==False:
      dp[i+val]=True
if dp[k]==True:
  print('First')
else:
  print('Second')

Measured memory_bytes: 69204
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n,m;cin >> n >>m;
    vvl g(n);rep(i,m){
        ll a,b;cin >> a >> b;a--;b--;
        g[a].pb(b);g[b].pb(a);
    }
    ll q;cin >> q;
    vl col(q);
    vvl dp(n,vl(11,-1));
    rep(i,q){
        ll v,d,c;cin >> v >> d >> c;v--;
        dp[v][d]=i;col[i]=c;
    }
    for(int i=10;i>0;i--){
        rep(j,n){
            chmax(dp[j][i-1],dp[j][i]);
            for(auto p:g[j]){
                chmax(dp[p][i-1],dp[j][i]);
            }
        }
    }
    rep(i,n){
        if(dp[i][0]==-1)cout << 0 <<endl;
        else cout << col[dp[i][0]] <<endl;
    }
}

Measured memory_bytes: 21948
using System;

public class Program
{
  static private readonly int MAX = 100;
  static private readonly int INFINITY = (1<<21);
  static private readonly int WHITE = 0;
  static private readonly int GRAY = 1;
  static private readonly int BLACK = 2;

  static private int n = -1;
  static private int[,] M = new int[MAX, MAX];

  private static void dijkstra()
  {
    int minv;
    int[] d = new int[n];
    int[] color = new int[n];

 //   Console.Write("n={0}, d.length={1}, color.length={2}\n", n, d.Length, color.Length);

    for(int i=0; i<n; i++)
    {
      d[i] = INFINITY;
      color[i] = WHITE;
    }

    d[0] = 0;
    color[0] = GRAY;
    while(true)
    {
      minv = INFINITY;
      int u = -1;
      for(int i=0; i<n; i++)
      {
        if(minv > d[i] && color[i] != BLACK)
	{
	  u = i;
	  minv = d[i];
	}
      }

      if(u == -1) { break; }
      color[u] = BLACK;
      for(int v=0; v<n; v++)
      {
	if(color[v] != BLACK && M[u,v] != INFINITY)
	{
	  if(d[v] > d[u] + M[u,v])
	  {
	    d[v] = d[u] + M[u,v];
	    color[v] = GRAY;
	  }
	}
      }
    }

    for(int i=0; i<n; i++)
    {
      Console.Write("{0} {1}\n", i, (d[i] == INFINITY ? -1 : d[i]));
    }
  }

  public static void Main()
  {
    n = int.Parse(Console.ReadLine());
    M = new int[n, n];

    for(int i=0; i<n; i++)
    {
      for(int j=0; j<n; j++)
      {
	M[i,j] = INFINITY;
      }
    }

    int k, c, u, v;
    for(int i=0; i<n; i++)
    {
      int s=0;
      string [] str = Console.ReadLine().Split(' ');
      u = int.Parse(str[s++]);
      k = int.Parse(str[s++]);
//      Console.Write("{0}, {1}\n", u, k);
      for(int j=0; j<k; j++)
      {
	v = int.Parse(str[s++]);
	c = int.Parse(str[s++]);
	M[u,v] = c;
//	Console.Write("{0}, {1}\n", v, c);
      }
    }

    dijkstra();
  }
}

Measured memory_bytes: 9300
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int a,b; cin >> a >> b;
    for (int v = 1; v <= 10000; v++)
    {
        int v1 = v*0.08;
        int v2 = v*0.10;
        if (v1 == a && v2 == b) {
            cout << v << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
// #define DEBUGGING
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()

template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = int64_t;
using ull = uint64_t;
using PLL = pair<ll, ll>;

template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return max(low, min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { t = clamp(t, low, high); }

namespace init__ {

struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

}

#ifdef DEBUGGING
// #include "../debug/debug.cpp"
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

template <typename T>
T make_v(T init) { return init; }

template <typename T, typename... Tail>
auto make_v(T init, size_t s, Tail... tail) {
#define rec make_v(init, tail...)
    return V<decltype(rec)>(s, rec);
#undef rec
}

const ll mod = 998244353;
const size_t dp_size = 300 * 300 + 10;

ll dp1[dp_size] = { 1 };
ll dp2[dp_size] = { 1 };

ll pow__(ll n, ll k) { return k ? (k & 1 ? n : 1) * pow__(n * n % mod, k / 2) % mod : 1; }
/*
ll inv(ll n) { return pow__(n, mod - 2); }
*/

int main() {
    ll N;
    cin >> N;
    ll sum = 0;
    for(ll loops = 0; loops < N; loops++) {
        ll e;
        cin >> e;
        sum += e;
        for(ll i = dp_size - 1; 0 <= i; i--) {
            (dp1[i] *= 2) %= mod;
            if(0 <= i - e) {
                (dp1[i] += dp1[i - e]) %= mod;
                (dp2[i] += dp2[i - e]) %= mod;
            }
        }
    }
    ll total = pow__(3, N);
    ll sum_dec = 0;
    for(ll i = (sum + 1) / 2; i <= sum; i++) {
        ll add_v = dp1[i] * 3 % mod;
        if(sum % 2 == 0 && i == sum / 2) {
            ll dec_v = dp2[sum / 2] * 3 % mod;
            (add_v += mod - dec_v) %= mod;
        }
        (sum_dec += add_v % mod) %= mod;
    }
    DEBUG(dp1[sum/2]);
    DEBUG(dp2[sum/2]);
    DEBUG(sum, sum_dec, total);
    cout << (total - sum_dec + mod) % mod << endl;
    return 0;
}


Measured memory_bytes: 1664
module ABC120

  ! <module> to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: ABC120_B
  private :: isMultiple

  ! variables for this <module>
  integer(kind=INT8), public  :: A, B, K

  ! contained <subroutine>s and <function>s are below
  contains

  pure function isMultiple (target, divisor) result (stat)

    ! arguments for this <function>
    integer(kind=INT8), intent(in) :: target, divisor

    ! return value of this <function>
    logical :: stat

    stat = mod (target, divisor) .eq. 0_INT8
    return

  end function isMultiple

  pure function ABC120_B (A, B, K) result (divisor)

    ! arguments for this <function>
    integer(kind=INT8), intent(in) :: A, B, K

    ! return value of this <function>
    integer(kind=INT8) :: divisor

    ! variables for this <function>
    integer(kind=INT8) :: itr_dvsr, dvsr_max, counter
  
    ! STEP.01
    ! initialize the variables
    dvsr_max = min (A, B)
    counter  = 0_INT8

    ! STEP.02
    ! search the target divisor
    do itr_dvsr = dvsr_max, 1_INT8, -1_INT8

      if ( isMultiple (target=A, divisor=itr_dvsr) .and. isMultiple (target=B, divisor=itr_dvsr) ) counter = counter + 1_INT8

      if (counter .eq. K) then
        divisor = itr_dvsr
        return
      end if

    end do

  end function ABC120_B

end module ABC120


program main

  ! <module> to import
  use, non_intrinsic :: ABC120
  
  ! STEP.01
  ! read out the data
  read *, A, B, K
  
  ! STEP.02
  ! output the result
  write (unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') ABC120_B (A, B, K)

end program main

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

struct you{
    int ma;
    set<P> st;
};

int main() {
    string s; cin >> s;
    int a = s[0] - 'A';
    int b = s[1] - 'A';
    int c = s[2] - 'A';
    int d = s[3] - 'A';
    if (a==b&&c==d&&a!=c){
        cout << "Yes" << endl;
        return 0;
    }
    if (a==c&&b==d&&a!=b){
        cout << "Yes" << endl;
        return 0;
    }
    if (a==d&&b==c&&a!=b){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
const int N=104; 
int a[N];
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	int n,x;
	cin>>n>>x;
	int id=n;
	for(int i=1;i<=n;i++)
	{ 
	    int p; cin>>p; 
	    a[i]=a[i-1]+p; 
	    //cout<<a[i]<<":";
	    if(a[i]>x){ id=i-1; break; } 
	    //cout<<id<<"(";
	} 
	cout<<id+1;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  int x,y;
  cin >> x >>y;
  int s=min(x,y),r=max(x,y);
  int d;
  for(int i=0;i<20;i++){
  
  int b=r%s;
  r=s;
  s=b;
  if(b==0){break;}  
  }  
  cout <<r <<endl;
  
}
 


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

int main(){
    int N; cin >> N;
    vector<int> d(N);
    rep(i, N) {
        cin >> d.at(i);
    }
    sort(d.begin(), d.end());
    int ans = 1;
    rep(i, N-1) {
        if (d.at(i) < d.at(i+1)) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

# n = int(input())
# a, b
# s = input()


N, K = map(int, input().split())
h = list(map(int, input().split()))

ans = 0
for e in h:
    if e >= K:
        ans += 1
print(ans)


Measured memory_bytes: 11900
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define SZ(x) ((ll)(x).size())
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int n,k;
string s;
int main(){
    cin >> n >> s >> k;
    char c = s[k-1];
    REP(i,n){
        if(s[i]!=c){
            s[i]='*';
        }
    }
    put(s);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int N, X, ans, loc; cin >> N >> X;
    loc = 0;
    ans = 1;
    for (int i = 0; i < N; i++)
    {
        int L; cin >> L;
        loc += L;
        if (loc <= X) ans++;
        else break;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;

struct Res {
	char type;
	int x, y, z;
};

vector <Res> res;
const int ONE = 20;
const int A = 0, B = 1;
const int AB = 2;

const int N = 2e5 + 7;
int arr[N];

void query(char c, int x, int y, int z) {
	res.pb({c, x, y, z});
	if (c == '+') {
		arr[z] = arr[x] + arr[y];
	} else {
		arr[z] = (bool) (arr[x] < arr[y]);
	}
}

void set_ONE() {
	query('+', A, B, 100);
	query('<', 101, 100, ONE);
}

int check_both(int bit1, int bit2) {
	int st = 32278;
	query('+', bit1, bit2, st);
	query('<', ONE, st, st);
	return st;
}

void print() {
	cout << "ARRAY\n";
	for (int i = 0; i < 20; ++i) {
		cout << arr[i] << " ";
	}
	cout << endl;
	cout << "===========\n";
}

void clear(int pos) {
	int st = 100000;
	query('<', st, st + 1, pos);
}

void assign(int from, int to) {
	query('+', from, 1e5, to);
}

int get_deg2(int one, int deg) {
	int pos = 1007;
	clear(pos);
	query('+', pos, one, pos);
	for (int i = 0; i < deg - 1; ++i) {
		query('+', pos, pos, pos);
	}
	return pos;
}

// one = 1 --> return val; one = 0 --> return 0;
int get_val(int one, int val) {
	//cout << "GET: " << arr[one] << " " << arr[val] << endl;
	int need = 1009, need2 = need + 1; 
	clear(need), clear(need2);
	for (int i = 30; i >= 0; --i) {
		assign(need, need2);
		int deg2 = get_deg2(one, i);
		//cout << arr[one] << " " << i << " " << arr[deg2] << endl;
		query('+', need2, deg2, need2);
		
		int nxt_one = 1010;
		query('<', need2, val, nxt_one);
		nxt_one = check_both(nxt_one, one);
		//cout << i << " " << arr[one] << " " << arr[nxt_one] << endl;
		deg2 = get_deg2(nxt_one, i);
		//cout << i << " " << arr[deg2] << endl;
		query('+', need, deg2, need);
	}
	//cout << arr[one] << " " << arr[val] << " " << arr[need] << endl;
	//query('+', need, one, need);
	return need;
}

void get_total() {
	int val = B;
	int need = 1337, need2 = need + 1; 
	clear(need), clear(need2);
	for (int i = 30; i >= 0; --i) {
		assign(need, need2);
		int deg2 = get_deg2(ONE, i);
		query('+', need2, deg2, need2);
		
		int nxt_one = 1488;
		query('<', need2, val, nxt_one);
		deg2 = get_deg2(nxt_one, i);
		query('+', need, deg2, need);

		int AA = get_val(nxt_one, A);
		//cout << arr[nxt_one] << " " << arr[AA] << endl;
		int degA = get_deg2(AA, i);
		query('+', AB, degA, AB);
	}
	//query('+', AB, A, AB);
}

int main(){
#ifdef LOCAL
	freopen("E_input.txt", "r", stdin);
	//freopen("E_output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	arr[0] = 1007;
	arr[1] = 1008;

	set_ONE();
	query('+', A, ONE, A);
	query('+', B, ONE, B);

	get_total();

	cout << res.size() << endl;
	for (auto t : res) {
		cout << t.type << " " << t.x << " " << t.y << " " << t.z << endl;
	}

}


Measured memory_bytes: 4268
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int M = 5;
const int INF = 1e9;

int N, ans = INF;

int count(vector< vector<int> > &v){
  int ret = 0, j;
  REP(i, M){
    for(j = (int)v[i].size() - 1; j >= 0 && v[i][j] == -1; --j) ;
    ret = max(ret, j);
  }
  return ret + 1;
}

bool check(int x, int s, vector< vector<int> > &v, vector< vector<int> > &t){
  REP(i, M) REP(j, N) if(t[i][j] && v[i][j + x + s] != -1) return false;
  return true;
}

void dfs(int n, int x, vector< vector<int> > &v, vector< vector<int> > &t){
  if(n >= 10) if(x + N < ans) ans = x + N;
  if(x + N >= ans) return ;
  FOR(_, 1, N + 1){
    if(!check(x, _, v, t)) continue;
    REP(i, M) REP(j, N) if(t[i][j]) v[i][j + x + _] = n;
    dfs(n + 1, x + _, v, t);
    REP(i, M) REP(j, N) if(t[i][j]) v[i][j + x + _] = -1;
  }
}

int main() {
  while(cin >>N && N){
    ans = INF;
    vector< vector<int> > t(M, vector<int>(N)), v(M, vector<int>(N * 12, -1));
    REP(i, M){
      REP(j, N){
        char c; cin >>c;
        t[i][j] = (c == 'X' ? 1 : 0);
        if(t[i][j]) v[i][j] = 0;
      }
    }
    dfs(1, 0, v, t);
    cout <<ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define ld long double
#define F first
#define S second
#define pb push_back
#define pii pair <int, int>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define reunique(x) (x).resize(std::unique(all(x)) - (x).begin())
#define roflan ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
using namespace std;

signed main(){
  roflan;
  int n;
  cin >> n;
  vector <int> a(n), dp(n, 1e18);
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  dp[0] = 0;
  dp[1] = abs(a[1] - a[0]);
  for (int i = 2; i < n; i++){
    dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
  }
  cout << dp[n - 1];
  return 14 / 88;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#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>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    vll b;
    rep(i, n) {
        ll sm = 0;
        for (int j = i; j < n; ++j) {
            sm += a[j];
            b.pb(sm);
        } 
    }
    int m = sz(b);
    ll ans = 0;
    for (int i = 40; i >= 0; --i) {
        ll now = ans + (1LL<<i);
        int cnt = 0;
        rep(j, m) if ((now & b[j]) == now) cnt++;
        if (cnt >= k) ans += (1LL<<i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6512
n= int(input())
h_list = [i for i in map(int , input().split())]

cnt = 0
#左から1以上の数を未定って0があったらそこまでの数を-1してカウントを1増やす
def mizu(h_list):
    hidari = 0
    migi = len(h_list)
    tmp = []
    for index,elem in enumerate(h_list):
        if elem == 0:
            continue
        if elem >0:
            hidari = index
            break
    for index,elem in enumerate(h_list[hidari:]):
        if elem >0:
            continue
        elif elem == 0:
            migi = hidari + index
            break
    for index,elem in enumerate(h_list):
        if index >= hidari and index <= migi-1:
            elem = elem-1
        tmp.append(elem)
    return tmp

while (not(all(elem == 0 for elem in h_list))) :
    h_list = mizu(h_list)
    #print(h_list)
    cnt += 1
print(cnt)


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

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

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

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int w = in.nextInt();
			int h = in.nextInt();
			int x = in.nextInt();
			int y = in.nextInt();
			double area = (double) w * (double) h / 2;
			int ans = 0;
			if (x * 2 == w && y * 2 == h) {
				ans = 1;
			}
			out.println(area + " " + ans);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

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

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

		public char nextChar() {
			return next().charAt(0);
		}

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

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

	}
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll m, k;
    cin >> m >> k;
    if (k == 0) {
        rep(i, (1 << m)) cout << i << " " << i << (i == (1 << m - 1) ? "\n" : " ");
    } else {
        deque<int> que;
        que.push_back(k);
        int xor_sum = 0;

        rep(i, (1 << m)) {
            if (i == k) continue;
            xor_sum ^= i;
            que.push_front(i);
            que.push_back(i);
        }
        if (xor_sum == k) {
            que.push_back(k);

            rep(i, que.size()) {
                cout << que[i] << (i == que.size() - 1 ? "\n" : " ");
            }
        } else {
            cout << -1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 2944
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: usize,
        b: [usize; n],
    };

    let mut a = b.clone();

    let mut c = 0;
    let mut flag = false;
    loop {
        for i in 0..a.len(){
            if a[i] % 2 == 0{
                a[i] = a[i] / 2;
            } else {
                flag = true;
                break;
            }
        }
        if flag {
            break;
        }
            c += 1;
    }


    println!("{}", c);
}


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

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

  int ans =0;
  for(int i=1; i <= n; i++){
    string s = to_string(i);
    if(s.size() % 2 == 1){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
 

int main(){
    int n,k; cin >> n >> k;
    int h[n];
    int ans=0;
    rep(i,n){
        cin >> h[i];
        if(h[i]>=k) ans++;
    }
    cout << ans << endl;
return 0;
}


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

int main(){

	int time;
	int s, m, h;

	cin >> time;
	h = time / 3600;
	m = time % 3600 / 60;
	s = time % 3600 % 60;

	cout << h << ":" << m << ":" << s << endl;

	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    vector<int> nums;
    int now = 1;
    int cnt = 0;
    rep(i,n) {
      if (s[i]-'0' == now) cnt++;
      else {
        nums.push_back(cnt);
        now ^= 1;
        cnt = 1;
      } 
    }
    nums.push_back(cnt);
    if (nums.size()%2 == 0) nums.push_back(0);
    int l = 0, r = 0;
    int tmp = 0;
    int ans = 0;
    for (int i = 0; i < nums.size(); i += 2) {
      int nextleft = i, nextright = min(i+k*2+1, (int)nums.size());
      while (l < nextleft) {
        tmp -= nums[l];
        l++;
      }
      while (r < nextright) {
        tmp += nums[r];
        r++;
      }
      ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3944
#include <stdio.h>

int main(void)
{
    int n,m,i,j;
    
    scanf("%d %d",&n,&m);
    
    int a[100][100]={{0}},b[100]={0},c[100]={0};
    
    for(i=0;i<n;i++) {
        for(j=0;j<m;j++) {
            scanf("%d", &a[i][j]);
        }
    }
    
    for(i=0;i<m;i++)
        scanf("%d",&b[i]);

    for(i=0;i<n;i++) {
        for(j=0;j<m;j++) {
            c[i] += a[i][j]*b[j];
        }
        printf("%d\n", c[i]);
    }
    
    return 0;
}  

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

//input
ll k;
vector<ll>a;

int main(){
    //input
    cin >> k;
    a.resize(k);
    rep(i,k)cin>>a[k-1-i];

    vector<ll>l(k+1),r(k+1);
    l[0]=2;r[0]=2;
    for(int i=1;i<=k;i++){
        ll x = (l[i-1]+a[i-1]-1)/a[i-1]*a[i-1];
        ll y = r[i-1]/a[i-1]*a[i-1];
        if(x>y){
            cout << -1 << endl;
            return 0;
        }
        l[i]=(l[i-1]+a[i-1]-1)/a[i-1]*a[i-1];
        r[i]=r[i-1]/a[i-1]*a[i-1]+a[i-1]-1;
    }
    cout << l[k] << ' ' << r[k] << endl;

    return 0;
}


Measured memory_bytes: 5564
#include<iostream>
#include<numeric>
#include<math.h>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
using ll = long long int;

int n;
ll sum = 0;
vector<ll> a, ret;

int main(void) {
	cin >> n;
	for (int i = 0; i < n; i++) {
		ll ai;
		cin >> ai;
		a.push_back(ai);
		sum += ai;
	}

	ll tmp = a.back();
	for (int i = 0; i < n - 1; i++) {
		if (i % 2 == 0)
			tmp -= a[i];
		else
			tmp += a[i];
	}
	ret.push_back(tmp);
	for (int i = 0; i < n - 1; i++) {
		tmp = a[n - i - 2] - ret[i] / 2;
		ret.push_back(tmp * 2);
	}
	for (int i = n - 1; i > 0; i--)
		cout << ret[i] << " ";
	cout << ret.front() << endl;
	return 0;
}


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

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n)  FOR(i,0,(n))
typedef pair<int,int> P;


class CGridRepainting2 {
public:
	void solve(std::istream& in, std::ostream& out) {
    int h,w;
    in >> h >> w;
    vector<vector<char>> s(h, vector<char>(w));
    REP(i,h)REP(j,w){
      in >> s[i][j];
    }
    vector<P> action = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};
    REP(i,h) REP(j,w){
      if(s[i][j] == '#') {
        bool f = false;
        for (P p : action) {
          if (i + p.first >= 0 && i + p.first < h && j + p.second >= 0 && j + p.second < w) {
            f |= s[i + p.first][j + p.second] == '#';
          }
        }
        if (!f) {
          out << "No" << endl;
          return;
        }
      }
    }
    out << "Yes" << endl;
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	CGridRepainting2 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
int main(void){
    // Your code here!
    int n;
    scanf("%d",&n);
    int w[n],i,j,k;
    int sa=10000;
    int o1=0,o2=0;
    for(i=0;i<n;i++){
        scanf("%d",&w[i]);
    }
    
    for(i=1;i<n;i++){
        for(j=0;j<n;j++){
            if(i>=j) o1 += w[j];
            else o2 += w[j];
        }
        k = o1-o2;
        if(k<0) k = k*(-1);
        if(sa > k) sa = k;
        o1 = 0; o2 = 0;
    }
    
    printf("%d\n",sa);
    
    return 0;
}


Measured memory_bytes: 128