akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = 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 (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

vector<int> used;
vector<int> d, c;
int now = 0;
void dfs(vector<vector<int>> &G, int n){
    if(used[n]) return;
    used[n] = 1;
    d[n] = c[now];
    now++;
    repe(i, G[n]) dfs(G, i);
}

int main(){
    int n;
    cin >> n;
    vector<vector<int> > G(n);
    vector<pair<int, int>> E(n-1);
    vector<pair<int, int>> num(n);
    c = vector<int>(n);
    rep(i, n) num[i] = make_pair(0, i);
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
        num[a].first++;
        num[b].first++;
        E[i] = make_pair(a, b);
    }
    sort(all(num));
    reverse(all(num));
    rep(i, n) cin >> c[i];
    sort(all(c));
    reverse(all(c));

    LL ans = 0;
    used = vector<int>(n, 0);
    d = vector<int>(n, 0);
    dfs(G, num[0].second);
    rep(i, n-1){
        ans += min(d[E[i].first], d[E[i].second]);
    }

    cout << ans << endl;
    rep(i, n) cout << d[i] << (i == n-1 ? "" : " ");
    cout << endl;

}

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

#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,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if (max(a, b) <= 8)cout << "Yay!" << endl;
	else cout << ":(" << endl;
}


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

int main(void){
  int N,M, C;
  int *B, *A;
  scanf("%d %d %d", &N, &M, &C);
  B = (int *)malloc(sizeof(int) * M);
  for(int i = 0; i < M; i++){
    scanf("%d", &B[i]);
  }
  A = (int *)malloc(sizeof(int) * M);
  int ans = 0;
  int cnt = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < M; j++){
      scanf("%d", &A[j]);
      ans += A[j] * B[j];
  	}
    ans += C;
    if(ans > 0){
      cnt++;
    }
    ans = 0;
  }
  printf("%d",cnt);
  free(A);
  free(B);
  return 0;
}

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

typedef long long ll;

const int N=1e4 + 5;
char arr[N];
vector <int> visit[28];
int k,len;

map<string,bool> mp;

string comp(int l,int len){
    string s="";
    for(int i=l;i<l+len;++i)
        s+=arr[i];
    return s;

}

vector<string> v;

int main(){
    scanf("%s",arr);
    scanf("%d",&k);
    for(len=0;arr[len];++len)
        visit[arr[len]-'a'].push_back(len);

    for(int c='a';c<='z' && k;++c){
        if(!visit[c-'a'].size())
            continue;
        int cnt=1;
        while(cnt && k){
            map<string,bool> mp;
            for(int x:visit[c-'a']){
                if(x+cnt<=len)
                    mp[comp(x,cnt)]=true;

            }
            ++cnt;
            if(!mp.size())
                break;
            --k;
            if(!k){

                for(pair<string,bool> i:mp)
                    v.push_back(i.first);
                printf("%s\n",v[0].c_str());
            }


        }


    }





}



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

using namespace std;

#define ll long long
#define pb push_back
#define F first
#define S second
#define rf(i,a,b) for(int (i) = (a); (i) <= (b); (i)++)
#define rb(i,b,a) for(int (i) = (b); (i) >= (a); (i)--)
#define watch(x) cout << (#x) << " = " << (x) << endl
#define test(t) int(testCnt) = 0; int(t); cin >> (t); while(t -- && ++testCnt)

const int INF = 2e9 + 7;
const int MAXA = 1e5 + 10;
const ll MOD = (ll) 1e9 + 7;
const ll INFLL = 9e18 + 7;

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

int n, ans, v[110];
ll W, w[110];
ii f[110][MAXA];
int sum;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
       //freopen("in.in", "r", stdin);
    #endif
    cin >> n >> W;
    rf(i, 1, n) {
        cin >> w[i] >> v[i];
        sum += v[i];
    }
    rf(i, 0, n) rf(j, 0, sum) f[i][j].F = 0,f[i][j].S = (ll)INF*3;
    f[0][0].F = 1;
    f[0][0].S = 0;
    rf(i, 1, n) {
        rf(j, 0, sum) {
            if(f[i - 1][j].F) {
                f[i][j].F = 1;
                ans = max(ans, j);
                f[i][j].S = min(f[i][j].S, f[i - 1][j].S);
            }
            if(j < v[i]) continue;
            if(f[i - 1][j - v[i]].F && f[i - 1][j - v[i]].S + w[i] <= W) {
                //cout << i << " " << j << endl;
                f[i][j].F = 1;
                ans = max(ans,j);
                f[i][j].S = min(f[i][j].S, f[i - 1][j - v[i]].S + w[i]);
            }
            //if(!f[i - 1][j - v[i]].F) f[i][j].F = 0;
        }
    }
    //cout << f[3][90].F <<endl;
    cout << ans;
    return 0;
}


Measured memory_bytes: 160128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

string convert(string str){
  string res = "";
  map<char, string>s;
  s[' '] = "101";
  s['\''] = "000000";
  s[','] = "000011";
  s['-'] = "10010001";
  s['.'] = "010001";
  s['?'] = "000001";
  s['A'] = "100101";
  s['B'] = "10011010";
  s['C'] = "0101";
  s['D'] = "0001";
  s['E'] = "110";
  s['F'] = "01001";
  s['G'] = "10011011";
  s['H'] = "010000";
  s['I'] = "0111";
  s['J'] = "10011000";
  s['K'] = "0110";
  s['L'] = "00100";
  s['M'] = "10011001";
  s['N'] = "10011110";
  s['O'] = "00101";
  s['P'] = "111";
  s['Q'] = "10011111";
  s['R'] = "1000";
  s['S'] = "00110";
  s['T'] = "00111";
  s['U'] = "10011100";
  s['V'] = "10011101";
  s['W'] = "000010";
  s['X'] = "10010010";
  s['Y'] = "10010011";
  s['Z'] = "10010000";

  rep(i, str.length()){
    res += s[str[i]];
  }

  while(res.size() % 5) res += "0";
 
  return res;
}

string reconvert(string str){
  string res = "";
  map<string, char>s;
  s["00000"] = 'A';
  s["00001"] = 'B';
  s["00010"] = 'C';
  s["00011"] = 'D';
  s["00100"] = 'E';
  s["00101"] = 'F';
  s["00110"] = 'G';
  s["00111"] = 'H';
  s["01000"] = 'I';
  s["01001"] = 'J';
  s["01010"] = 'K';
  s["01011"] = 'L';
  s["01100"] = 'M';
  s["01101"] = 'N';
  s["01110"] = 'O';
  s["01111"] = 'P';
  s["10000"] = 'Q';
  s["10001"] = 'R';
  s["10010"] = 'S';
  s["10011"] = 'T';
  s["10100"] = 'U';
  s["10101"] = 'V';
  s["10110"] = 'W';
  s["10111"] = 'X';
  s["11000"] = 'Y';
  s["11001"] = 'Z';
  s["11010"] = ' ';
  s["11011"] = '.';
  s["11100"] = ',';
  s["11101"] = '-';
  s["11110"] = '\'';
  s["11111"] = '?';

  for(int i = 0; i < str.length(); i += 5){
    string f; // = string(str[i] + str[i+1] + str[i+2] + str[i+3] + str[i+4]);
    f = str[i]; f += str[i+1]; f+= str[i+2]; f += str[i+3]; f += str[i+4];
    res += s[f];
  }
  return res;
}

int main(){
  string str;
  while(getline(cin, str)){
    str = convert(str);
    str = reconvert(str);
    cout << str << endl;
  }
  return 0;
}

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

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



Measured memory_bytes: 3076
import sys
input = sys.stdin.readline
import fractions
 
 
def main():
    N = int(input())
    A = list(map(int, input().split()))
 
    L_gcds = [0] * N
    L_gcd_tmp = L_gcds[0]
    for i in range(1, N):
        L_gcd_tmp = fractions.gcd(L_gcd_tmp, A[i-1])
        L_gcds[i] = L_gcd_tmp
 
    R_gcds = [0] * N
    R_gcd_tmp = R_gcds[0]
    for j in range(1, N):
        R_gcd_tmp = fractions.gcd(R_gcd_tmp, A[N-j])
        R_gcds[j] = R_gcd_tmp
    R_gcds.reverse()
 
    LR_gcds = [0] * N
    for k in range(0, N):
        LR_gcds[k] = fractions.gcd(L_gcds[k], R_gcds[k])
 
    print(max(LR_gcds))
 
main()

Measured memory_bytes: 16132
/*
AtCoderBeginnerContest167
Problem A - Registration /
Time Limit: 2 sec / Memory Limit: 1024 MB
Score :
100
points
*/

#include <iostream>

int main()
{
    std::string S;
    std::string T;
    std::cin >> S >> T;
    int L = S.length();
    //std::cout << "S: " << S << "; T: " << T << "\n";
    //std::cout << "length of S: " << L << "\n";
    for (int i=0; i<L; i++)
    {
        if (S[i] != T[i])
        {
            std::cout << "No\n";
            return 0;
        }
    }
    std::cout << "Yes\n";
}


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

using namespace std;

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int ans = k * 1900 + (n-k) *100;
  for (int i = 0; i < k; i++)
    ans <<= 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var set = new HashSet<Integer>();
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		var k = sc.nextInt();
		for(var i = 0; i < k; i++) {
			var d = sc.nextInt();
			for(var j = 0; j < d; j++) {
				var a = sc.nextInt();
				set.add(a);
			}
		}
		sc.close();

		System.out.println(n - set.size());
	}
}

Measured memory_bytes: 46192
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD 1000000007


void solve()
{
  int X,Y;
  cin>>X>>Y;

  int money = 0;
  if(X == 1)
  {
    money += 300000;
  }

  if(Y == 1)
  {
    money += 300000;
  }

  if(X == 2)
  {
    money += 200000;
  }

  if(Y == 2)
  {
    money += 200000;
  }

  if(X == 3)
  {
    money += 100000;
  }

  if(Y == 3)
  {
    money += 100000;
  }

  if((X==1)&&(Y==1))
  {
    money += 400000;
  }

  cout<<money<<endl;
}
 
int32_t main(int32_t argc, const char *argv[])
{
 
  solve();
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  string s; cin >> s;
  vector<int> cntE(n+1);
  rep(i, n) {
    cntE[i+1] = cntE[i];
    if(s[i]=='E') cntE[i+1]++;
  }
  int ans = inf;
  rep(i, n) {
    ans = min((i-cntE[i])+(cntE[n]-cntE[i+1]), ans);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 4716
import sys
R = lambda:map(int,raw_input().split())
s = raw_input()
ss = []
for i in xrange(len(s)):
    if (ord(s[i]) > ord('C')):
        ss.append(chr(ord(s[i])-3))
    else:
        ss.append(chr(ord(s[i])+23))
print "".join(ss)

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

int main()
{
  int n, m, origin = 0;
  cin >> n;
  vector<int> t(n);
  for(auto& i : t)
  {
    cin >> i;
    origin += i;
  }
  cin >> m;
  vector<pair<int, int>> px(m);
  for(int i = 0; i < m; ++i)
  {
    int tmp_p, tmp_x;
    cin >> tmp_p >> tmp_x;
    px[i] = make_pair(tmp_p, tmp_x);
  }
  
  for(int i = 0; i < m; ++i)
  {
    cout << origin + px[i].second - t[px[i].first - 1] << endl;
  }
}

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

using namespace std;

typedef long long ll;

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

	int a, b, c;
	cin >> a >> b >> c;

	int sm = a + b + c;
	if(sm >= 22){
		cout << "bust" << endl;
	}else{
		cout << "win" << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
const double r3=1.7320508075688772935274463415059;
vector<pair<double,double> >ans;
void dfs(double ax,double ay,double bx,double by,int p){
    if(p>=n){
        cout<<fixed<<setprecision(8)<<ax<<" "<<ay<<'\n';
        return;
    }
    double sx=(ax+ax+bx)/3.0;
    double sy=(ay+ay+by)/3.0;
    double tx=(ax+bx+bx)/3.0;
    double ty=(ay+by+by)/3.0;
    double vx=tx-sx;
    double vy=ty-sy;
    double ux=sx+0.5*vx-r3/2*vy;
    double uy=sy+r3/2*vx+0.5*vy;
    dfs(ax,ay,sx,sy,p+1);
    dfs(sx,sy,ux,uy,p+1);
    dfs(ux,uy,tx,ty,p+1);
    dfs(tx,ty,bx,by,p+1);
}
int main(){
    // freopen("Udebug.out","w",stdout);
    cin>>n;
    dfs(0,0,100,0,0);//表示p等级的没。
    cout<<fixed<<setprecision(8)<<100.0<<" "<<0.0<<'\n';
}
//线段只有三个方向。水平，右下斜，左下斜。
//还是！不能换点.
/*
对于线段(a,b),(c,d)
其斜率为(d-b)/(c-a)
中点为((a+c)/2,(b+d)/2)
有一点，与中点连线垂直该线。
(y-(b+d)/2)(d-b)==-(x-(a+c)/2)(c-a)
*/


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

using namespace std;

int main() {
  int n; cin >> n;
  vector< pair<int, int> > adj[n];
  
  for(int i = 0; i < n; i++) {
    int ix, nn; cin >> ix >> nn;
    for(int j = 0; j < nn; j++) {
      int v, c; cin >> v >> c;
      adj[ix].push_back(make_pair(c, v));
    }
  }

  int inf = 10000000;
  int ans[n];
  fill(ans, ans+n, inf);

  ans[0] = 0;
  int ix = 0, sd[n] = {1};
  while(true) {

    for(int i = 0; i < adj[ix].size(); i++) {
      int cost = ans[ix] + adj[ix][i].first;
      int k = adj[ix][i].second;

      if(cost < ans[k]) {
        ans[k] = cost;
        sd[k] = 0;
      }

    }

    sd[ix] = 1;
    ix = -1;
    for(int i = 0; i < n; i++) {
      if(sd[i] == 0 && (ix == -1 || ans[ix] > ans[i])) {
        ix = i;
      }
    }
    if(ix == -1) {
      break;
    }
  }

  for(int i = 0; i < n; i++) {
    cout << i << " " << ans[i] << endl;
  }
}

Measured memory_bytes: 3084
belong=list()
group=list()

def init(X):
  global belong
  global group
  belong=list(range(X))
  group=[[i] for i in range(X)]

def unite(x,y):
  if len(group[belong[x]])<len(group[belong[y]]):
    x,y=y,x
  if belong[x]==belong[y]:
    return True
  z=belong[y]
  for i in range(len(group[z])):
    belong[group[z][-1]]=belong[x]
    group[belong[x]].append(group[z][-1])
    del group[z][-1]
  return False

N,Q=map(int,input().split())
init(N)
f,u,v=0,0,0
for i in range(Q):
  f,u,v=map(int,input().split())
  if f:
    print((belong[u]==belong[v])+0)
  else:
    unite(u,v)

Measured memory_bytes: 96152
#include<iostream>
#include<cstdlib>
using namespace std;
int main() {
	long  int n;
	cin >> n;
	long int ans = 2000000000;
	long int s = 0;
	long int ar = 0;
	long int a[200000] = {};
	for (long  int i = 0; i < n; i++) {
		cin >> a[i];
		s += a[i];
	}
 
	for (long  int i = 0; i < n-1; i++) {
		ar += a[i];
		s -= a[i];
		if (abs(ar - s) < ans) {
			ans = abs(ar - s);
		}
	}
	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if ((a*b)%2==0) System.out.println("No");
		else System.out.println("Yes");
	}
}


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

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

    if(a[0] != 0){
        ll now = 0;
        ll ans1 = 0;
        now += a[0];
        for (int i = 1; i < n; i++){
            ll nex = now + a[i];
            if(now > 0){
                if(nex >= 0){
                    now = -1;
                    ans1 += nex + 1;
                } else {
                    now = nex;
                }
            } else {
                if(nex <= 0){
                    now = 1;
                    ans1 += 1 - nex;
                } else {
                    now = nex;
                }
            }
        }

        ll ans2;
        if(a[0] > 0){
            now = -1;
            ans2 = a[0] + 1;
        } else {
            now = 1;
            ans2 = 1 - a[0];
        }
        for (int i = 1; i < n; i++){
            ll nex = now + a[i];
            if(now > 0){
                if(nex >= 0){
                    now = -1;
                    ans2 += nex + 1;
                } else {
                    now = nex;
                }
            } else {
                if(nex <= 0){
                    now = 1;
                    ans2 += 1 - nex;
                } else {
                    now = nex;
                }
            }
        }

        cout << min(ans1, ans2) << endl;

    } else {
        ll now = 0;
        ll ans1 = 1;
        now = 1;
        for (int i = 1; i < n; i++){
            ll nex = now + a[i];
            if(now > 0){
                if(nex >= 0){
                    now = -1;
                    ans1 += nex + 1;
                } else {
                    now = nex;
                }
            } else {
                if(nex <= 0){
                    now = 1;
                    ans1 += 1 - nex;
                } else {
                    now = nex;
                }
            }
        }

        now = -1;
        ll ans2 = 1;
        for (int i = 1; i < n; i++){
            ll nex = now + a[i];
            if(now > 0){
                if(nex >= 0){
                    now = -1;
                    ans2 += nex + 1;
                } else {
                    now = nex;
                }
            } else {
                if(nex <= 0){
                    now = 1;
                    ans2 += 1 - nex;
                } else {
                    now = nex;
                }
            }
        }

        cout << min(ans1, ans2) << endl;
    }

    return 0;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

ll gcd(ll a, ll b)
{
    if (b==0) return a;
    return gcd(b, a%b);
}
ll lcm(ll a, ll b)
{
    return (a/gcd(a, b))*b;
}

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll e = lcm(c, d);

    ll ans = 0;
    ans += b/c;
    ans += b/d;
    ans -= b/e;
    ans -= (a-1)/c;
    ans -= (a-1)/d;
    ans += (a-1)/e;

    ans = (b-a+1)-ans;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define nl '\n'

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int , int> pi;

void solve()
{
	int a[5];
	for(int i=0; i<5; i++)
	{
		cin>>a[i];
		if(a[i] == 0)
		{
			cout<<i+1<<nl;
		}
	}
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	//cin>>t;
	t = 1;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  int t = (n + 1000 - 1) / 1000;
  cout << 1000 * t - n << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
using namespace std ;
int main(){
    string w;
    cin >> w;
    int n = w.size();
    vector<int> memo(26, 0);
    for(int i=0; i<n; i++){
        int t = static_cast<int>(w[i])-97;
        // cout << t << endl;
        memo[t] += 1;
    }
    int m = memo.size();
    int flag = 1;
    for(int k=0; k<m; k++){
        if(memo[k]%2 != 0){
            flag = 0;
        }
    }
    if(flag == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 4005;
char A[MAXN], B[MAXN];
int lft[MAXN], rgt[MAXN], id[MAXN], n;
bool vis[MAXN];

int main() {
	scanf("%s%s", A, B);
	if (strcmp(A, B) == 0) return puts("0"), 0;
	n = strlen(A);
	for (int i = 0; i < n; i++)
		A[i + n] = A[i], B[i + n] = B[i];
	int lst = 1e9, ans = 1e9;
	for (int i = n + n - 1; i >= 0; i--) {
		lst = B[i] == '1' ? 0 : lst + 1;
		if (i < n) rgt[i] = lst;
	}
	if (lst >= 1e9) return puts("-1"), 0;
	lst = 1e9;
	for (int i = 0; i < n + n; i++) {
		lst = B[i] == '1' ? 0 : lst + 1;
		if (i >= n) lft[i - n] = lst;
	}
	
	for (int i = 0; i < n; i++) id[i] = i;
	sort(id, id + n, [&](int x, int y) { return lft[x] > lft[y]; });
	for (int i = 0; i < n; i++) {
		memset(vis, 0, sizeof(vis));
		int mx = 0, cnt = 0;
		for (int j = 0; j < n; j++) {
			cnt += A[j] != B[j + n - i];
			vis[j] = A[j] != B[j + n - i] && lft[j] > i;
		}
		for (int j = 0; j < n; j++) {
			int d = id[j];
			if (!vis[d]) continue;
			if (lft[d] <= i) break;
			chkmin(ans, i + mx * 2 + (lft[d] - i) * 2 + cnt);
			chkmax(mx, rgt[d]);
		}
		chkmin(ans, i + mx * 2 + cnt);
	}
	
	sort(id, id + n, [&](int x, int y) { return rgt[x] > rgt[y]; });
	for (int i = 0; i < n; i++) {
		memset(vis, 0, sizeof(vis));
		int mx = 0, cnt = 0;
		for (int j = 0; j < n; j++) {
			cnt += A[j] != B[j + i];
			vis[j] = A[j] != B[j + i] && rgt[j] > i;
		}
		for (int j = 0; j < n; j++) {
			int d = id[j];
			if (!vis[d]) continue;
			if (rgt[d] <= i) break;
			chkmin(ans, i + mx * 2 + (rgt[d] - i) * 2 + cnt);
			chkmax(mx, lft[d]);
		}
		chkmin(ans, i + mx * 2 + cnt);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
s = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
a = list(map(int, s.split(", ")))
print(a[int(input()) - 1])

Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const int Max_n=1100;

int n,m,d;
struct Node{
    int x,y,d;
    Node(int xx,int yy,int dd):x(xx),y(yy),d(dd){}
};
char s[Max_n][Max_n];
bool vis[Max_n][Max_n];
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};

Node bfs(int x1,int y1,int k){
    memset(vis,0,sizeof(vis));
    queue<Node>que;
    que.push(Node(x1,y1,0));
    vis[x1][y1]=1;
    while(!que.empty()){
        Node node=que.front();que.pop();
        int x=node.x,y=node.y;
        if(k==s[x][y]-'0')return node;
        int d=node.d;
        for(int i=0;i<4;i++){
            int X=x+dx[i],Y=y+dy[i];
            if(!vis[X][Y]&&(s[X][Y]=='S'||s[X][Y]=='.'||(s[X][Y]>='1'&&s[X][Y]<='9'))){
                vis[X][Y]=1;
                que.push(Node(X,Y,d+1));
            }
        }
    }
}

int main()
{
    while(~scanf("%d%d%d",&n,&m,&d)){
        memset(s,0,sizeof(s));
        for(int i=1;i<=n;i++)scanf("%s",s[i]+1);
        int x,y;
        for(int i=1;i<=n;i++){
            for(int j=1;j<=m;j++)
            if(s[i][j]=='S'){x=i;y=j;}
        }
        int sum=0;
        for(int i=1;i<=d;i++){
            Node node=bfs(x,y,i);
            sum+=node.d;
            x=node.x,y=node.y;
        }
        printf("%d\n",sum);
    }
    return 0;
}




Measured memory_bytes: 5632
# coding: utf-8
# Your code here!


import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

#n = int(input())
n,m = [int(i) for i in readline().split()]

g = [[] for _ in range(n)]
for _ in range(m):
    s,t = [int(i)-1 for i in readline().split()]
    g[s].append(t)

L = [len(gi) for gi in g]

p = [0]*n
p[0] = 1
for i in range(n-1):
    c = p[i]/L[i]
    for v in g[i]:
        p[v] += c
#print(p)

inf = 1000000

dp0 = [0]*(n)
dp1 = [inf]*(n)

for i in range(n-2,-1,-1):
    res = 0
    m = 0
    for v in g[i]:
        res += dp0[v]
        if m<dp0[v]: m = dp0[v]
    dp0[i] = 1 + res/L[i]
    
    if L[i] >= 2:
        dp1[i] = 1 + (res-m)/(L[i]-1)
    
#print(dp0)
#print(dp1)

res = 0
for i in range(n):
    res = max(res,(dp0[i] - dp1[i])*p[i])

print(dp0[0]-res)












Measured memory_bytes: 52188
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int A[7] = {1,3,5,7,8,10,12};
    int B[4] = {4,6,9,11};
    int x[2];
    cin >> x[0] >> x[1];

    int cnt = 0;
    REP(i,2){
        REP(j,7){
            if(A[j] == x[i]) cnt ++;
        }
    }
    if(cnt == 2){
        cout << "Yes" << endl;
        return 0;
    }

    cnt = 0;
    REP(i,2){
        REP(j,4){
            if(B[j] == x[i]) cnt ++;
        }
    }
    if(cnt == 2){
        cout <<"Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
	string s;
       string ss[2];
	ll q, f=0,p=1,c=0;
	cin>>s>>q;
	while(q--){
		ll type;
		cin>>type;
		if(type==1){
			c++;
			swap(f,p);
		}
		else{
			ll x;
			char c;
			cin>>x>>c;
			if(x==1)
				ss[f].push_back(c);
			else
				ss[p].push_back(c);
		}
	}
	if(c%2)  reverse(s.begin(),s.end());

	reverse(ss[f].begin(),ss[f].end());

	cout<<ss[f]<<s<<ss[p]<<endl;
	return 0;
}


Measured memory_bytes: 1088
package main

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

func main() {
	var n [5]int
	fmt.Scanf("%d %d %d %d %d", &n[0], &n[1], &n[2], &n[3], &n[4])

	for i, j := range n {
		if j == 0 {
			fmt.Println(i + 1)
			return
		}
	}
}


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

using namespace std;

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)
const long long INF = 1LL << 60;

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

  ll n;
  cin >> n;

  vll a(n), b(n);
  rep(i, n) {
    cin >> a[i];
  }
  rep(i, n) {
    cin >> b[i];
  }

  sort(all(a));
  sort(all(b));

  bitset<64> ans = 0;

  rep(bt, 29) {
    ll mask = 1 << (bt + 1);
    mask--;

    vll p(n), q(n);
    rep(i, n) {
      p[i] = a[i] & mask;
      q[i] = b[i] & mask;
    }
    sort(all(p));
    sort(all(q));

    ll cnt = 0;
    for (auto x : p) {
      ll vl = (1 << bt) - x;
      ll vr = (1 << (bt + 1)) - x;
      ll l = distance(q.begin(), lower_bound(all(q), vl));
      ll r = distance(q.begin(), lower_bound(all(q), vr));
      cnt += r - l;

      vl += (1 << (bt + 1));
      vr = (1 << (bt + 2)) - x;
      l = distance(q.begin(), lower_bound(all(q), vl));
      r = distance(q.begin(), lower_bound(all(q), vr));
      cnt += r - l;
    }

    if (cnt & 0x01) {
      ans[bt] = 1;
    }
  }

  cout << ans.to_ullong() << endl;

  return 0;
}


Measured memory_bytes: 6572
K = int(input())

t = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(t[K - 1])

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

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "[";
    bool a = 1;
    for (auto e : v ) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "]";
    return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << " " << p.second << ")";
    return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::multiset Debug
template<typename T>
ostream& operator<<(ostream& os, const multiset<T>& st) {
    os << "{";
    bool a = 1;
    for (auto e : st) {
        os << (a ? "" : " ");
        os << e;
        a = 0;
    }
    os << "}";
    return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
    os << "{";
    bool a = 1;
    for (auto e : mp) {
        os << (a ? "" : " ");
        os << e.first << ":" << e.second;
        a = 0;
    }
    os << "}";
    return os;
}

// std::tuple Debug
template<int N, class Tuple>
void out(ostream& os, const Tuple& t){}
template<int N, class Tuple, class H, class ...Ts>
void out(ostream& os, const Tuple& t) {
    if (N) os << " ";
    os << get<N>(t);
    out<N+1,Tuple,Ts...>(os, t);
}
template<class ...Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
    os << "(";
    out<0,tuple<Ts...>,Ts...>(os, t);
    os << ")";
    return os;
}

// Debug
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl


struct edge { int to, cost; };
ostream& operator<<(ostream& os, const edge& e) {
    os << "(" << e.to << ", " << e.cost << ")";
    return os;
}

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

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

    sort(d.begin(), d.end());

    int ans = d[n/2] - d[n/2-1];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
S = input()

if S[0] == "A" :
    if S[2:-1].count("C") == 1 :
        a = list(S)
        a.remove("C")
        s = "".join(a[1:])
        if s.islower()==True:
            print("AC")
        else:
            print("WA")
    else:
        print("WA")
else:
    print("WA")


Measured memory_bytes: 2940
/*input
10 13 15
3
1
4
1
5
9
2
6
5
3
5
8
9
7
9


*/
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <string>
#include <set>
#include <stack>
#include <queue>
#include <iterator>
#include <limits>
#include <deque>
#include <algorithm>
#include <cmath>
#include <list>
#include <map>
#include <climits>
#define ff first
#define ss second
#define MAX 10005
#define endl "\n"
#define mp make_pair
#define pb push_back
#define int long long
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define vi vector<int>
#define mii map<int,int>
#define pii pair<int,int>
#define len(x) (x.size())
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) for(int i=0;i<a;i++)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define T int tc;cin>>tc;for(int t=1;t<=tc;t++)
#define set_arr(arr,i) memset(arr,i,sizeof(arr))
#define trace1(x)							cerr << #x << ": " << x << endl;
#define trace2(x, y)						cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)						cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       			cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    			cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) 			cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
using namespace std;

signed main(){
 	ios_base::sync_with_stdio(false);	
 	cin.tie(0);
	cout.tie(0);
	int n,k,q;
	cin>>n>>k>>q;
	vi a(n,k);
	vi diff(n+10,0);
	diff[0] = a[0];
	int x;
	while(q--){
		cin>>x;
		diff[0] -= 1;
		diff[x] += 1;
		diff[x+1] -= 1; 
	}
	a[0] = diff[0]+diff[1];
	f(i,1,n){
		a[i] = a[i-1] + diff[i+1];
	}

	rep(i,n){
		if(a[i]>0)cout<<"Yes\n";
		else cout<<"No\n";
	}
 	return 0;
}

Measured memory_bytes: 2176
def dfs(i, f):
    if i == n-1:
        return sum(list(map(int, f.split("+"))))
    return dfs(i+1, f+s[i+1])+\
           dfs(i+1, f+"+"+s[i+1])

s = input()
n = len(s)
print(dfs(0, s[0]))

Measured memory_bytes: 3316
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 2);
  for (int i = 0; i < m; i++) {
    int l, r;
    cin >> l >> r;
    a[l]++;
    a[r + 1]--;
  }
  for (int i = 1; i < (int) a.size(); i++) {
    a[i] += a[i - 1];
  }
  int ans = 0;
  for (int i = 0; i < (int) a.size(); i++) {
    if (a[i] == m) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<string>
#include<math.h>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
using namespace std;
const int INF=100000000;
int main(){
  int n;
  while(cin>>n,n!=-1){
    vector<int> a;
    if(n<4){
      cout<<n<<endl;
    }else{
      for(int i=0; ;i++){
	int amari=n%4;
	a.push_back(amari);
	n=n/4;
	if(n<4){
	  a.push_back(n);
	  break;
	}
      }
      for(int i=a.size()-1;i>=0;i--){
	cout<<a[i];
      }
      cout<<endl;
    }
  }
  return 0;
}
     

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

/+---test
3 2
---+/

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

  (N == M? "Yes": "No").writeln;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int main(){
	int A,B,C;
	cin >> A >> B >> C;
	int amari = A%B;
	int i = 0;
	int start = INT_MAX;
	while(i != start){
		start = 0;
		i += amari;
		i %= B;
		if(i == C){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <set>
#include <algorithm>

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

  std::set<int> set;
  for (int i=0; i<M; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);

    if (a != 1 && b != N) continue;

    int c=(a==1? b:a);
    if (set.count(c))
      return !printf("POSSIBLE\n");

    set.insert(c);
  }

  printf("IMPOSSIBLE\n");
  return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp);
void ipgraph(int m);
//void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
const ll INF=1e18L+5;
ll int dp[2090][3000];   
int main(){
ios_base::sync_with_stdio(0);
ll int t,n,i,j,k,m;
t=1;

// cin>>t;
int T;
Fo(T,1,t+1){
//  cout<<"Case #"<<T<<": ";
     cin>>n;
     int a[n][n];
     fo(i,n){
         fo(j,n){
             cin>>a[i][j];
         }
     }
     vector<int>dp(1<<n);
     dp[0]=1;
     for(int mask=0;mask<(1<<n)-1;mask++){
         int aa=__builtin_popcount(mask);
         for(int b=0;b<n;b++){
             if(a[aa][b]&&!(mask&(1<<b))){
                 int m=mask^(1<<b);
                 dp[m]=(dp[m]%mod+dp[mask]%mod)%mod;
             }
         }
     }
     cout<<dp[(1<<n)-1]%mod;
}
}


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

const int INF=123456789;

typedef pair<int,int> P;

char maze[101][101];
int H,W;

int d[101][101];

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

//sxsyからgxgyへの最短距離を求める

int bfs(int sy,int sx,int gy,int gx){
  if(maze[sy][sx]=='#' || maze[gy][gx]=='#') return 123456789;
  queue<P> que;
  for(int i=0;i<H;i++) {
    for(int j=0;j<W;j++){
       d[i][j]=INF;
     }
   }
  que.push(P(sy,sx));
  d[sy][sx]=0;

  while(que.size()){
    P p=que.front();que.pop();
    if(p.second==gx&&p.first==gy) break;

    for(int i=0;i<4;i++){
      int nx=p.second+dx[i], ny=p.first+dy[i];
      if(0<=nx&&nx<W&&0<=ny&&ny<H&&maze[ny][nx]!='#'&&d[ny][nx]==INF){
        que.push(P(ny,nx));
        d[ny][nx] = d[p.first][p.second]+1;
      }
    }
  }
  return d[gy][gx];
}

void solve(){

}

int main(){
  cin>>H>>W;
  int ans = H*W;
  for(int i=0;i<H;i++) for(int j=0;j<W;j++){
    cin>>maze[i][j];
    if(maze[i][j]=='#') ans--;
  }


int res = bfs(0,0,H-1,W-1);
ans = ans-res-1;

if(ans>=0&&ans<=2500) {
  cout<<ans<<endl;
}
else{
   cout<<-1<<endl;
 }
  //cout<<res<<endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
enum POSITION{ONLINE_BACK = -2, CLOCKWISE = -1, ON_SEGMENT = 0,
              COUNTER_CLOCKWISE = 1, ONLINE_FRONT = 2};
struct Point{
    double x;
    double y;
    Point(double x, double y) : x(x), y(y){}
    Point operator-(Point p){
        return Point(x - p.x, y - p.y);
    }
};
typedef Point Vector;
double get_cross(Vector v1, Vector v2){
    return v1.x * v2.y - v1.y * v2.x;
}
double get_dot(Vector v1, Vector v2){
    return v1.x * v2.x + v1.y * v2.y;
}
struct Segment{
    Point p1;
    Point p2;
    Segment(Point p1, Point p2) : p1(p1), p2(p2){}
};
POSITION get_position(Point p, Segment s){
    Vector base = s.p2 - s.p1;
    Vector obj  = p    - s.p1;
    double cross = get_cross(base, obj);
    if (cross >  1e-10) return CLOCKWISE;
    if (cross < -1e-10) return COUNTER_CLOCKWISE;
    if (get_dot(base, obj) < 0) return ONLINE_BACK;
    if (get_dot(base, base) < get_dot(obj, obj)) return ONLINE_FRONT;
    return ON_SEGMENT;
}
bool is_intersection(Segment s1, Segment s2){
    POSITION s2p1_s1 = get_position(s2.p1, s1);
    POSITION s2p2_s1 = get_position(s2.p2, s1);
    POSITION s1p1_s2 = get_position(s1.p1, s2);
    POSITION s1p2_s2 = get_position(s1.p2, s2);
    // if (s2p1_s1 == ON_SEGMENT || s2p2_s1 == ON_SEGMENT) return true;
    // if (s1p1_s2 == ON_SEGMENT || s1p2_s2 == ON_SEGMENT) return true;
    // if (s2p1_s1 == ONLINE_FRONT) {
    //     if (s2p2_s1 == ONLINE_BACK) return true;
    //     return false;
    // }
    // if (s2p1_s1 == ONLINE_BACK) {
    //     if (s2p2_s1 == ONLINE_FRONT) return true;
    //     return false;
    // }
    // if (s2p1_s1 != s2p2_s1 && s1p1_s2 != s1p2_s2) return true;
    // return false;
    if (s2p1_s1 * s2p2_s1 <= 0 && s1p1_s2 * s1p2_s2 <= 0) return true;
    return false;
}

int main(){
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int x_p0, y_p0, x_p1, y_p1, x_p2, y_p2, x_p3, y_p3;
        cin >> x_p0 >> y_p0 >> x_p1 >> y_p1;
        cin >> x_p2 >> y_p2 >> x_p3 >> y_p3;
        Point p0(x_p0, y_p0);
        Point p1(x_p1, y_p1);
        Point p2(x_p2, y_p2);
        Point p3(x_p3, y_p3);
        Segment s1(p0, p1);
        Segment s2(p2, p3);
        int ans = 0;
        if (is_intersection(s1, s2)) ans = 1;
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3116
#include "bits/stdc++.h"
using namespace std;

int main() {
	int X, A, B, C, D;
	char op1, op2, op3;
	cin >> X;
	D = X % 10;
	C = (X - D) / 10 % 10;
	B = (X - C * 10 - D) / 100 % 10;
	A = (X - B * 100 - C * 10 - D) / 1000;
	if (A + B + C + D == 7) {
		op1 = '+', op2 = '+', op3 = '+';
	}
	else if (A + B + C - D == 7) {
		op1 = '+', op2 = '+', op3 = '-';
	}
	else if (A + B - C + D == 7) {
		op1 = '+', op2 = '-', op3 = '+';
	}
	else if (A + B - C - D == 7) {
		op1 = '+', op2 = '-', op3 = '-';
	}
	else if (A - B + C + D == 7) {
		op1 = '-', op2 = '+', op3 = '+';
	}
	else if (A - B + C - D == 7) {
		op1 = '-', op2 = '+', op3 = '-';
	}
	else if (A - B - C + D == 7) {
		op1 = '-', op2 = '-', op3 = '+';
	}
	else if (A - B - C - D == 7) {
		op1 = '-', op2 = '-', op3 = '-';
	}
	cout << A << op1 << B << op2 << C << op3 << D << "=7";
}

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

int main() {
    lint x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    lint safe = x / d;
    if (safe >= k) {
        cout << x - k * d << endl;
    } else {
        lint now = x % d;
        k -= x / d;
        lint ans;
        if (k % 2 == 0) {
            ans = now;
        } else {
            ans = abs(now - d);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3588
#include <stdio.h>

int main()
{
	int i, N, K, A[200001];
	scanf("%d %d", &N, &K);
	for (i = 1; i <= K; i++) scanf("%d", &(A[i]));
	for (; i <= N; i++) {
		scanf("%d", &(A[i]));
		if (A[i] > A[i-K]) printf("Yes\n");
		else printf("No\n");
	}
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2440
import java.io.*
import java.util.*

fun solve(N: Int, M: Int){
    // Mの約数のうち、M/Nよりも小さいものが候補となる
    // M = d * m
    var ret = M/N
    while (M % ret != 0){
        ret--
    }
    println(ret)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val M = sc.next().toInt()
    solve(N, M)
}



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

int main(){
    int n;
    cin>>n;
    vector<int> v;
    for(int i=0;i<n;i++){
        int a; cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    double ans=v[0];
    for(int i=1;i<n;i++){
        ans=(ans+v[i])/2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256