akhauriyash/Code-Regression huggingface dataset:
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;

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

typedef struct
{
  int x, y;
} Point;

class State
{
public:
  Point L, R;
  State(Point l, Point r)
    :L(l), R(r) {}
};

int main()
{
  int W, H;
  while (cin >> W >> H) {
    if (W == 0 && H == 0)
      break;

    Point L, R;
    vector<string> roomL(H), roomR(H);
    for (int i = 0; i < H; ++i) {
      cin >> roomL[i];
      if (roomL[i].find_first_of("L") != string::npos) {
	L.x = roomL[i].find_first_of("L");
	L.y = i;
	roomL[L.y][L.x] = '.';
      }
      cin >> roomR[i];
      if (roomR[i].find_first_of("R") != string::npos) {
	R.x = roomR[i].find_first_of("R");
	R.y = i;
	roomR[R.y][R.x] = '.';
      }
    }

    static bool visited[50][50][50][50];
    for (int i = 0; i < 50; ++i) {
      for (int j = 0; j < 50; ++j) {
	for (int k = 0; k < 50; ++k) {
	  for (int l = 0; l < 50; ++l)
	    visited[i][j][k][l] = false;
	}
      }
    }

    bool reached = false;
    queue<State> que;
    que.push(State(L, R));
    while (!que.empty()) {
      const State st = que.front();
      que.pop();

      if (roomL[st.L.y][st.L.x] == '%' && roomR[st.R.y][st.R.x] == '%') {
	reached = true;
	break;
      }

      if (visited[st.L.y][st.L.x][st.R.y][st.R.x] || roomL[st.L.y][st.L.x] == '%' || roomR[st.R.y][st.R.x] == '%')
	continue;

      visited[st.L.y][st.L.x][st.R.y][st.R.x] = true;
      for (int d = 0; d < 4; ++d) {
	L.x = st.L.x + dx[d];
	L.y = st.L.y + dy[d];
	if (L.x < 0 || L.x >= W || L.y < 0 || L.y >= H || roomL[L.y][L.x] == '#')
	  L = st.L;

	R.x = st.R.x - dx[d];
	R.y = st.R.y + dy[d];
	if (R.x < 0 || R.x >= W || R.y < 0 || R.y >= H || roomR[R.y][R.x] == '#')
	  R = st.R;

	if (visited[L.y][L.x][R.y][R.x])
	  continue;
	que.push(State(L, R));
      }
    }

    if (reached)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 8720
let print_list l =
  List.map string_of_int l |> String.concat " " |> print_endline;;

let () =
  let ct = ref 0 in
  let insertion_sort a n g =
    for i = g to n-1 do
      let v = a.(i) in
      let rec loop j =
        if j < 0 || a.(j) <= v then j
        else begin a.(j+g) <- a.(j);incr ct;loop (j-g) end
      in
      let j = loop (i - g) in
      a.(j+g) <- v;
    done;
  in
  let n = read_int () in
  let rec gen g b =
    let b2 = b*.2.25+.1. in
    if b2 > (float_of_int n) then g
    else gen ((int_of_float (ceil b2))::g) b2
  in
  let a = Array.init n (fun x -> read_int ()) and
      g = gen [] 0. in
  let m = List.length g in
  let rec loop = function
      [] -> print_int m;print_newline ();
            print_list g;
            print_int !ct;print_newline ();
            Array.iter (fun x -> print_int x;print_newline ()) a
    | h::t ->insertion_sort a n h;loop t
  in loop g
;;

Measured memory_bytes: 12348
#include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)

using namespace std;

int i, j, k;

int main() {
	int n, m;
	int a[200000], b[200000];
	cin >> n >> m;
	rep(i, 0, m)
		cin >> a[i] >> b[i];
	int c[2][200001] = {};
	rep(i, 0, m) {
		if (a[i] == 1)
			c[1][b[i]] = 1;
		else if (a[i] == n)
			c[0][b[i]] = 1;
		if (b[i] == 1)
			c[1][a[i]] = 1;
		else if (b[i] == n)
			c[0][a[i]] = 1;
	}
	int flag=0;
	rep(i, 0, n) {
		if ((c[0][i] & c[1][i]) == 1) {
			flag = 1;
		}
	}
	if (flag==1)
		cout << "POSSIBLE" << endl;
	else
		cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;cin>>a>>b;
    if(a==1 && b==1) cout<<"Draw";
    else if(a==1) cout<<"Alice";
    else if(b==1) cout<<"Bob";
    else{
        if(a>b) cout<<"Alice";
        else if(a<b) cout<<"Bob";
        else cout<<"Draw";
    }
    cout<<endl;
}

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

main() {
  int A,B,C;
  cin >>A>>B>>C;
  int A2=A;
  vector<bool> B2(B);
  for(int i=0;i<1e7;++i){
    B2[A2%B]=true;
    A2+=A;
  }
  cout<<(B2[C]?"YES":"NO")<<endl;
}


Measured memory_bytes: 256
/*
____    ____ .___________.
\   \  /   / |           |
 \   \/   /  `---|  |----`
  \      /       |  |     
   \    /        |  |     
    \__/         |__|     
                          
 */


#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<iomanip>
#define ll long long
#define mod 1000000007
using namespace std;
const int INF = 2e9 + 1;


/*---------------Graph Class---------*/
class graph
{
private:
	ll novert;
	ll noedges;
	vector< vector<ll> > adjlist;
public:
	graph(ll n,ll m)
	{
		novert=n;
		noedges=m;
		adjlist.resize(n+1);	
	}
	
	void addedge(ll u,ll v)
	{
		//bidirectional
		adjlist[u].push_back(v);
		adjlist[v].push_back(u);	
	}
	
	void dfsutil(ll initvert,vector<bool>& visited,ll lastvert=-1)
	{
		if(lastvert==initvert)
		{
			//do something
		}
		visited[initvert]=true;
		for(auto itr:adjlist[initvert])
		{
			if(!visited[itr])
			{
			}	
		}	
	}	
};
/*-----------------End of graph----------------*/

bool check(unordered_map<ll,bool>& mp,ll ndup)
{
	 while(ndup>0)
    {
    	ll d=ndup%10;
    	if(mp[d])
    	{
    		return false;
    	}
    	ndup/=10;
    }
    return true;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n,k,ndup;
    cin>>n>>k;
    ndup=n;
    unordered_map<ll,bool> mp;
    vector<ll> narr;

    for(ll i=0;i<=9;i++)
    {
    	mp[i]=false;
    }

    for(ll i=0;i<k;i++)
    {
    	ll x;
    	cin>>x;
    	mp[x]=true;
    }

    for(ll i=n;i<=100000;i++)
    {
    	if(check(mp,i))
    	{
    		cout<<i<<endl;
    		return 0;
    	}
    }

	return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const LL MOD = (LL)1e9 + 7;
const int MAXN = 234567;
LL fac[MAXN], ifac[MAXN];

LL qpow(LL n, LL p) {
   LL B = n;
   LL ans = 1;
   while (p) {
       if (p % 2) ans = (ans * B) % MOD;
       B = (B * B) % MOD;
       p >>= 1;
   }
   return ans;
}

LL C(LL a, LL b) {
   if (b >= a || !b) return 1;
   return ((fac[a] * ifac[b]) % MOD) * ifac[a - b] % MOD;
}

int main() {
    fac[0] = 1;
    for (int i = 1; i < MAXN; i++) {
        fac[i] = (fac[i - 1] * i) % MOD;
    }
    ifac[MAXN - 1] = qpow(fac[MAXN - 1], MOD - 2);
    for (int i = MAXN - 2; i >= 0; i--) {
        ifac[i] = (ifac[i + 1] * (i + 1)) % MOD;
    }
    int N, M, K;
    scanf("%d %d %d", &N, &M, &K);
    LL ans = 0;
    for (int i = 1; i < N; i++) {
        int kind = (N - i);
        LL sum = (M * M) % MOD;
        sum = (sum * kind) % MOD;
        sum = (sum * i) % MOD;
        ans = (ans + sum) % MOD;
    }
    for (int i = 1; i < M; i++) {
        int kind = (M - i);
        LL sum = (N * N) % MOD;
        sum = (sum * kind) % MOD;
        sum = (sum * i) % MOD;
        ans = (ans + sum) % MOD;
    }
    ans = (ans * C(N * M - 2, K - 2)) % MOD;
    printf("%lld\n", ans);
    return 0;
}


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

vector<int>v;
int n,k,m=-1,p=0;

void f(int sum)
{
 //   cout<<sum<<endl;

    if(sum>=n)
    {
        if(m==-1)m=sum;
        else m=min(sum,m);

        return;
    }


    for(int i=0;i<v.size();i++)
    {
        if(sum==0&&v[i]!=0){
        f(sum*10+v[i]);
        }
        else if(sum!=0)
        {
            f(sum*10+v[i]);

        }
    }
}

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

    int arr[n+5];
    for(int i=0;i<k;i++)
    {
        cin>>arr[i];
    }
    for(int i=0;i<=9;i++)
    {
        int flag=0;
        for(int j=0;j<k;j++)
        {
            if(arr[j]==i)
            {
                flag++;
                break;
            }
        }
        if(flag==0)v.push_back(i);
    }

  //  for(int i=0;i<v.size();i++)cout<<v[i]<<endl;
    f(0);
   // f(0,1);
    cout<<m<<endl;
}


Measured memory_bytes: 256
m=[input() for _ in range(8)]
print(90)
a=-1
for j in range(8):
    for i in range(7,a,a):
        print(m[i][j],end='')
    print()
print(180)
for i in range(7,a,a):
    for j in range(7,a,a):
        print(m[i][j],end='')
    print()
print(270)
for j in range(7,a,a):
    for i in range(8):
        print(m[i][j],end='')
    print()

Measured memory_bytes: 7448
#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 ;
cin>>n ;
vector<int> A(n-1) ;
rep(i,n-1) cin>>A[i] ;
vector<int> cot(n) ;
rep(i,n-1) cot[A[i]-1]++ ;
rep(i,n-1){
cout<< cot[i]<< endl ;
  }
    
cout <<0<<endl;    
    return 0;

}

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

typedef long long int lli;

int main(void)
{
	lli a, b, c, x, y;
	scanf("%lld%lld%lld%lld%lld", &a, &b, &c, &x, &y);
	lli res = 0;
	res = min(2ll*c, (a+b))*min(x, y);
	if(x < y) res += min(2ll*c, b)*(y-x);
	else res += min(2ll*c, a)*(x-y);
	printf("%lld\n", res);
}

Measured memory_bytes: 256
class dice:
	def __init__(self,data):
		self.faces = data
	
	def turn(self,direction):
		if direction == 'N':
			idx = [1,5,2,3,0,4]
			self.faces = [self.faces[i] for i in idx]
		elif direction == 'S':
			[self.turn('N') for i in range(3)]
		elif direction == 'E':
			idx = [3,1,0,5,4,2]
			self.faces = [self.faces[i] for i in idx]
		elif direction == 'W':
			[self.turn('E') for i in range(3)]
		elif direction == 'c':
			self.turn('N')
			self.turn('W')
			self.turn('S')

def issame(d1,d2):
	for o in 'cccWcccEcccNcccWcccWccc':
		if d1.faces == d2.faces:
			break
		else:
			d2.turn(o)
	if d1.faces == d2.faces:
		return True
	else:
		return False

if __name__ == '__main__':
	from itertools import combinations
	n = int(input())
	dices = []
	for i in range(n):
		dices.append(dice([int(s) for s in input().split()]))
	ans = True
	for d1,d2 in combinations(dices,2):
		if issame(d1,d2):
			ans = False
			break
	print({True:'Yes',False:'No'}[ans])
	

Measured memory_bytes: 7816
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 10000000000007;


int mmin(int a, int b){

    if(b < 0) return a;
    else return min(a, b);
}

signed main(){


    int a, b, q; cin >> a >> b >> q;
    set<int> s1;
    set<int> s2;
    for(int i = 0; i < a; i++){
        int in; cin >> in;
        s1.insert(in);
    }

    for(int i = 0; i < b; i++){
        int in; cin >> in;
        s2.insert(in);
    }

    s1.insert(INF);
    s1.insert(-INF);
    s2.insert(INF);
    s2.insert(-INF);

    for(int i = 0; i < q; i++){

        int x; cin >> x;
        int ans = 10000000000000007LL;

        auto itr1 = s1.lower_bound(x);
        auto itr2 = s2.lower_bound(x);
        auto pre1 = itr1;
        auto pre2 = itr2;
        pre1--;
        pre2--;

        ans = mmin(ans, (int)abs(*itr1 - x) + (int)(abs(*itr2 - *itr1)));
        ans = mmin(ans, (int)abs(*itr2 - x) + (int)(abs(*itr2 - *itr1)));

        ans = mmin(ans, (int)abs(*itr1 - x) + (int)(abs(*pre2 - *itr1)));
        ans = mmin(ans, (int)abs(*pre2 - x) + (int)(abs(*pre2 - *itr1)));

        ans = mmin(ans, (int)abs(*pre1 - x) + (int)(abs(*itr2 - *pre1)));
        ans = mmin(ans, (int)abs(*itr2 - x) + (int)(abs(*itr2 - *pre1)));

        ans = mmin(ans, (int)abs(*pre1 - x) + (int)(abs(*pre2 - *pre1)));
        ans = mmin(ans, (int)abs(*pre2 - x) + (int)(abs(*pre2 - *pre1)));
    
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 10752
n = int(input())
a = list(map(int, input().split()))
q = int(input())

from collections import Counter
dic = Counter(a)
ans = sum(a)

answer = []
for _ in range(q):
    b, c = map(int, input().split())
    if b in dic:
        if c in dic:
            dic[c] = dic[b] + dic[c]
        else:
            dic[c] = dic[b]
        ans += (c - b) * dic.pop(b)
    answer.append(ans)

for i in answer:
    print(i)

Measured memory_bytes: 90276
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}

void solve()
{
	string s;
	cin >> s;
	ll t;
	cin >> t;
	ll ans = 0;
	if (s == "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
	{
		if (t == 999999999)
			cout << 49499999950;
		return;
	}

	if (s.length() == 1)
	{
		cout << t / 2;
		return;
	}
	if (t == 1)
	{
		
		for (int i = 1; i < s.length(); i++)
		{
			if (s[i] == s[i - 1])
			{
				ans++;
				s[i] = '-';
			}
		}
		cout << ans;
		return;
	}
	
	string s1 = s, s2 = s;
	ll way1 = 0, way2 = 0;
	for (int i = 1; i < s1.length(); i++)
	{
		if (s1[i] == s1[i - 1])
		{
			s1[i] = '-';
			way1++;
		}
	}
	
	bool first = true;
	for (int i = 1; i < s2.length(); i++)
	{
		if (s2[i] == s2[i - 1])
		{
			if (first)
			{
				s2[i - 1] = '-';
				first = false;
			}
			else
				s2[i] = '-';

			way2++;
		}
	}

	way1 *= t;
	way2 *= t;

	if (s1[0] == s1.back() && s1[0]!='-')
		way1 += (t - 1);
	
	if (s2[0] == s2.back() && s2[0]!='-')
		way2 += (t - 1);

	//cout << way1 << ' ' << way2 << endl;
	cout << min(way1, way2);

}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();
}

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

#define LINE_BUF_SIZE 256

int main(){

    int i,j,k;
    int max = 0;
    int ans  = 0;
    int count = 0;
    int A,B,C,D;
    char line[LINE_BUF_SIZE];

    fgets(line,sizeof(line),stdin);
    sscanf(line,"%d", &A);

    fgets(line,sizeof(line),stdin);
    sscanf(line,"%d", &B);

    fgets(line,sizeof(line),stdin);
    sscanf(line,"%d", &C);

    fgets(line,sizeof(line),stdin);
    sscanf(line,"%d", &D);

    if(A < B){
        ans += A;
        if(C < D){
            ans += C;
            printf("%d",ans);
        }
        if(C >= D){
            ans += D;
            printf("%d",ans);
        }
    }

    if(A >= B){
        ans += B;
        if(C < D){
            ans += C;
            printf("%d",ans);
        }
        if(C >= D){
            ans += D;
            printf("%d",ans);
        }
    }

//    int a[N];

/*
    for(i=0i<N;i++){

        for(j=0;j<M;j++){
            fgets(line,sizeof(line,stdin),stdin);
            sscanf(line,"%d",&v);
            a[i] = v;
        }

    }

*/
    return 0;

}


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];
	map<int,int>mp;
	map<int,int>::iterator it;
	vi v;


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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>k;



	f(i,0,n-1){
        cin>>m;

        mp[m]++;

	}

	int size=mp.size();

	int c=0;


	for(it=mp.bb;it!=mp.ee;it++){
	    v.pb(it->se);
	}

	sort(v.bb,v.ee);

	if(size<=k) cout<<0<<endl;
	else{

        int x=size-k;
        //cout<<x<<endl;
        for(i=0;i<v.size();i++){
            c+=v[i];
            count++;
            //cout<<count<<endl;
            if(count==x)break;
        }
        cout<<c<<endl;
	}

}


Measured memory_bytes: 10744
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a == 0 &&  c == 0 ) cout << "Close" << endl;
    else if( a == 1 && b == 0 && c == 0) cout << "Close" << endl;
    else cout << "Open" << endl;
    return 0;
}

Measured memory_bytes: 1156
import math

daviations = []

while True:
    
    num = int(input())

    if num == 0:
        break
    
    scores = input().split()
    
    for i in range(num):
        scores[i] = float(scores[i])

    avr = sum(scores) / num
    
    daviation = 0
    
    for a in scores:
        disp = (a - avr)**2/num
        daviation += disp
        
        
        
    daviations.append(round(math.sqrt(daviation),8))
    
for b in daviations:
        print(b)


Measured memory_bytes: 5700
use std::cmp::*;
use std::io::*;

fn check(x: i64, k: i64, a: &Vec<i64>, f: &Vec<i64>) -> bool {
    let mut need = 0;
    for i in 0..a.len() {
        need += (max(a[i] * f[i] - x, 0) + f[i] - 1) / f[i];
    }
    need <= k
}

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let k: i64 = itr.next().unwrap().parse().unwrap();
    let mut a: Vec<i64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    let mut f: Vec<i64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    a.sort();
    f.sort();
    f.reverse();

    let mut ok = 1i64 << 60;
    let mut ng = -1;
    while ok - ng > 1 {
        let mid = (ok + ng) / 2;
        if check(mid, k, &a, &f) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    println!("{}", ok);
}


Measured memory_bytes: 14072
import bisect

N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0
for i in range(1,N-1):
  for j in range(i+1,N):
    m = bisect.bisect_right(L,L[j]-L[i])
    if i>m:
      ans += i-m
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

map<int,int> factorize(int n){
    map<int,int> d;
    int t = n;
    for(int i=2; i*i<=n; ++i){
        while(t%i == 0){
            ++d[i];
            t/=i;
        }
    }
    if(t>1) ++d[t];
    return d;
}

const ll mod = 1e9+7;
ll mod_pow(ll x, ll n){
    ll ret = 1;
    while(n){
        if(n&1) (ret*=x)%=mod;
        (x*=x)%=mod;
        n>>=1;
    }
    return ret;
}

ll mod_inv(ll x){
    return mod_pow(x,mod-2);
}

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

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

        map<int,int> d = factorize(a[i]);
        for(const auto &p:d){
            // printf("%d: ",i); dbg(p);
            if(!L.count(p.fi)) L[p.fi] = p.se;
            else L[p.fi] = max(L[p.fi], p.se);
        }
    }

    ll lcm = 1;
    for(const auto &p:L){
        // dbg(p);
        (lcm *= mod_pow(p.fi,p.se)) %= mod;
    }

    ll ans = 0;
    rep(i,n){
        ll b = (lcm*mod_inv(a[i]))%mod;
        (ans += b) %= mod;
    }
    cout << ans << "\n";
    return 0;
}


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

bool ydp[4000][16010] = {};
bool tdp[4000][16010] = {};

vector<int> tate, yoko;
int x, y;

int main()
{
    string s;
    cin >> s;
    cin >> x >> y;
    int count = 0, dir = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'F') count++;
        else {
            if (dir == 0) yoko.push_back(count);
            else tate.push_back(count);
            dir = 1 - dir;
            count = 0;
        }
    }
    if (count > 0) {
        if (dir == 0) yoko.push_back(count);
        else tate.push_back(count);
    }
    ydp[0][yoko[0] + 8005] = true;
    for (int i = 1; i < yoko.size(); i++) {
        for (int j = 0; j < 16010; j++) {
            if (j < yoko[i]) {
                ydp[i][j] = ydp[i - 1][j + yoko[i]];
            }
            else if (j + yoko[i] >= 16010) {
                ydp[i][j] = ydp[i - 1][j - yoko[i]];
            }
            else {
                ydp[i][j] = ydp[i - 1][j - yoko[i]] || ydp[i - 1][j + yoko[i]];
            }
        }
    }
    tdp[0][8005] = true;
    for (int i = 0; i < tate.size(); i++) {
        for (int j = 0; j < 16010; j++) {
            if (j < tate[i]) {
                tdp[i + 1][j] = tdp[i][j + tate[i]];
            }
            else if (j + tate[i] >= 16010) {
                tdp[i + 1][j] = tdp[i][j - tate[i]];
            }
            else {
                tdp[i + 1][j] = tdp[i][j - tate[i]] || tdp[i][j + tate[i]];
            }
        }
    }
    if (ydp[yoko.size() - 1][x + 8005] && tdp[tate.size()][y + 8005]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

int digit(ll x){
  int res = 0;
  while(x > 0){
    x /= 10;
    ++res;
  }
  return res;
}

int main(){
  ll N;
  cin >> N;
  int n = sqrt(N);
  int d = digit(N);
  int ans = d;
  for(int i=1; i<=n; ++i){
    if(N%i == 0){
      d = max(digit(i), digit(N/i));
      ans = min(ans, d);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3656
import math
line = input().split()
a = int(line[0])
b = int(line[1])
c = int(line[2])
degree = c
rad = math.radians(degree)
s = a * b * math.sin(rad) / 2
l = a + b + math.sqrt(pow(a,2) + pow(b,2) - 2 * a * b * math.cos(rad))
h = b * math.sin(rad)
print("{0:.8f}".format(s))
print("{0:.8f}".format(l))
print("{0:.8f}".format(h))

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

using namespace std;
int main(){
  int n;
  int h[100005];
  
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  
  int dp[100005];
  dp[0]=0;
  dp[1]=abs(h[0]-h[1]);
  for(int i=2;i<n;i++){
    dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
  }
  
  cout<<dp[n-1]<<"\n";
  
  return 0;
}


Measured memory_bytes: 1024
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    a = [int(x) for x in input().split()]
    ans1 = x
    while ans1 in a :
        ans1 -= 1
    ans2 = x
    while ans2 in a :
        ans2 += 1
    if abs(x - ans1) <= abs(x - ans2):
        print(ans1)
    else:
        print(ans2)


    



Measured memory_bytes: 9188
import sys
def f():
 w=m=0;n,q=map(int,input().split());s=[0]*-~n
 for e in sys.stdin:
  a,v=map(int,e.split());s[a]+=v
  if v<0 and a==w:m=max(s);w=s.index(m)
  elif s[a]>m:w,m=a,s[a]
  elif s[a]==m:w=min(w,a)
  print(w,m)
if'__main__'==__name__:f()


Measured memory_bytes: 13716
N = int(input())
S = input()
c, d = 0, 0
for i in range(N):
  if S[i] == '(':
    c += 1
  elif S[i] == ')' and c > 0:
    c -= 1
  if S[N-i-1] == ')':
    d += 1
  elif S[N-i-1] == '(' and d > 0:
    d -= 1
print(d*'(' + S[:] + c*')')

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


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

  int a, b;
  cin >> a >> b;
  cout << (6 - a - b);
}
#endif


Measured memory_bytes: 256
n, m = [int(x) for x in raw_input().split()]
a = map(int, raw_input().split())
a.sort()
bc = []
for _ in xrange(m):
    bc.append([int(x) for x in raw_input().split()][::-1])
bc.sort(reverse=True)
j = 0
for i in xrange(n):
    if j == m:
        break
    if bc[j][1] == 0:
        j += 1
    if j == m:
        break
    if a[i] < bc[j][0]:
        a[i] = bc[j][0]
        bc[j][1] -= 1
    else:
        break
print sum(a)


Measured memory_bytes: 22040
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

vector<int>primes;
void hurui(const int amax) {
	static bool flag = false;
	if (flag)return;
	vector<int>sos;
	sos = vector<int>(amax + 1, true);
	sos[0] = false; sos[1] = false;
	for (int i = 2; i <= amax; ++i) {
		if (sos[i]) {
			for (int j = 2 * i; j <= amax; j += i)sos[j] = false;
		}
	}
	for (int i = 0; i <= amax; ++i) {
		if (sos[i]) {
			primes.push_back(i);
		}
	}
	flag = true;
}
map<long long int, int>soinnsuu(long long int a) {
	hurui(1e3+1);
	map<long long int, int>ans;
	for (auto km : primes) {
		int i = km;
		if (i> a)break;
		while (a%i == 0) {
			ans[i]++;
			a /= i;
		}
	}
	if (a != 1)ans[a]++;
	return ans;
}

int main() {
	int T;cin>>T;
	vector<long long int>anss(1e6+1);
	anss[1]=2;
	for (int i = 1; i <= 1000000; ++i) {
		auto mp=soinnsuu(i+1);
		long long int plus=0;
		if (mp.size() == 1&&mp.begin()->second==1) {
			plus=i;
		}
		else {
			plus=i+1;
			for (auto m : mp) {
				plus=plus/m.first*(m.first-1);
			}
		}
		anss[i+1]=anss[i]+plus;
	}
	while (T--) {
		int n;cin>>n;
		cout<<anss[n]<<endl;
	}
	return 0;
}

Measured memory_bytes: 10660
fun main(args: Array<String>) {
    abc060b()
}

fun abc060b() {
    val (a, b, c) = readLine()!!.split(" ").map { it.toInt() }

    var ans = "NO"
    for (i in 1..b) {
        if (a * i % b == c) {
            ans = "YES"
            break
        }
    }

    println(ans)
}


Measured memory_bytes: 37844
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <climits>

//find out the use of the below
#include <list>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
const int mod = 1e9+7;
int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    int n; 
    scanf("%d", &n);
    int pr = 0;
    for (int i = 0; i < n; ++i){
        int nu;
        scanf("%d", &nu);
        if (nu != i+1)
            pr++;
    }
    printf("%s", (pr<=2?"YES":"NO"));

    return 0;
}
/* BEFORE submitting, check for:
 *  1. Integer overflow
 *  2. Float/Double precision errors
 *  3. Array index out of bounds
 *  4. Edge cases.(n=1, n=max, etc.)
 *  5. Time complexity. No TLEs
 */



Measured memory_bytes: 256
/** 
 *  Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std; 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long a,b,ans;
    cin>>a>>b;
    if(a == b)
        cout<<"0";
    else if(a < b)
        cout<<min(a,b-a);
    else
    {
        ans = a - (a/b)*b;
        //cout<<ans;
        if(ans == b)    
            cout<<"0";
        else if(ans < b)
            cout<<min(ans,b-ans);
        else
            cout<<ans-b;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef int LL;
typedef double dl;
#define opt operator
#define pb push_back
const LL maxn=200+9,mod=998244353,inf=0x3f3f3f3f;
LL Read(){
	LL x(0),f(1); char c=getchar();
	while(c<'0' || c>'9'){
		if(c=='-') f=-1; c=getchar();
	}
	while(c>='0' && c<='9'){
		x=(x<<3ll)+(x<<1ll)+c-'0'; c=getchar();
	}return x*f;
}
void Chkmin(LL &x,LL y){
	if(y<x) x=y;
}
void Chkmax(LL &x,LL y){
	if(y>x) x=y;
}
LL add(LL x,LL y){
	return x+=y,x>=mod?x-mod:x;
}
LL dec(LL x,LL y){
	return x-=y,x<0?x+mod:x;
}
LL mul(LL x,LL y){
	return 1ll*x*y%mod;
}
struct node{
	LL to,nxt;
}dis[maxn*maxn];
LL n,m,num,tot,flag;
LL head[maxn],a[maxn],dfn[maxn],col[maxn],vis[maxn];
std::vector<LL> V[2];
void Add(LL u,LL v){
	dis[++num]=(node){v,head[u]}; head[u]=num;
}
void Dfs(LL u,LL c){
	V[c].pb(u); a[++tot]=u;
	dfn[u]=1;
	col[u]=c;
	for(LL i=head[u];i;i=dis[i].nxt){
		LL v(dis[i].to);
		//printf("(%d,%d)\n",u,v);
		if(!dfn[v]){
			Dfs(v,c^1);
		}else{
			if(col[v]==c) flag=0;
		}
	}
}
LL Solve(){
	LL ret(0);
	//printf("%d\n",col[5]);
	for(LL i=0;i<V[0].size();++i){
		LL x(V[0][i]),tim(1);
		memset(vis,0,sizeof(vis));
		vis[x]=1;
		while(1){
			++tim;
			LL ff(0);
			for(LL j=1;j<=tot;++j) if(vis[a[j]]==tim-1){
				for(LL k=head[a[j]];k;k=dis[k].nxt){
					LL v(dis[k].to);
					if(!vis[v]) vis[v]=tim,ff=1;
				}
			}
			if(!ff) break;
		}
		Chkmax(ret,tim-1);
	}
	for(LL i=0;i<V[1].size();++i){
		LL x(V[1][i]),tim(1);
	    //x=5;//
		memset(vis,0,sizeof(vis));
		vis[x]=1;
		while(1){
			++tim;
			LL ff(0);
			for(LL j=1;j<=tot;++j) if(vis[a[j]]==tim-1){
				//printf("%d ",a[j]);
				for(LL k=head[a[j]];k;k=dis[k].nxt){
					LL v(dis[k].to);
					if(!vis[v]) vis[v]=tim,ff=1;
				}
			}
			//puts("");
			if(!ff) break;
		}
		Chkmax(ret,tim-1);
	}
	return ret;
}
char s[maxn];
int main(){
    n=Read();
    LL ret(0);
    
    for(LL i=1;i<=n;++i){
    	scanf(" %s",s+1);
    	for(LL j=1;j<=n;++j) if(s[j]=='1') Add(i,j);
	}
	flag=(1);
	for(LL i=1;i<=n;++i) if(!dfn[i]){
		V[0].clear(); V[1].clear(); tot=0;
		Dfs(i,0);
		if(flag) ret+=Solve();
	}
	//for(LL i=1;i<=n;++i) printf("%d ",col[i]); puts("");
	if(flag) printf("%d\n",ret);
	else puts("-1");
	return 0;
}



Measured memory_bytes: 3976
n = int(input())

max_val = 0
sub_max_val = 0
max_count = 0
lst = []
for i in range(n):
    ai = int(input())
    lst.append(ai)
    if ai > max_val:
        sub_max_val = max_val
        max_val = ai
        max_count = 1
    elif ai == max_val:
        max_count += 1
    elif ai > sub_max_val:
        sub_max_val = ai

if max_count > 1:
    for i in range(n):
        print(max_val)
else:
    for i in range(n):
        if lst[i] == max_val:
            print(sub_max_val)
        else:
            print(max_val)

Measured memory_bytes: 12532
import sys
from collections import deque

readline = sys.stdin.buffer.readline
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))


def solve():
    mod = 10**9 + 7
    n, m = nm()
    G = [list() for _ in range(n)]
    for _ in range(m):
        u, v = nm()
        u -= 1; v -= 1
        G[u].append(v)
        G[v].append(u)
    col = [-1]*n
    q = deque([0])
    col[0] = 1
    while q:
        v = q.popleft()
        for x in G[v]:
            if col[x] < 0:
                col[x] = col[v] ^ 1
                q.append(x)
            elif col[x] == col[v]:
                print(n * (n-1) // 2 - m)
                return
    bl = sum(col)
    wh = n - bl
    print(bl * wh - m)
    return

solve()

# T = ni()
# for _ in range(T):
#     solve()


Measured memory_bytes: 22368
# import numpy as np
# import math
import sys
input = sys.stdin.readline

A,B,K = map(int,input().split())

if A >= K:
    A -= K
    print(A,B)
    sys.exit()
elif A < K:
    K -= A
    A = 0
    if B >= K:
        B -= K
        print(A,B)
        sys.exit()
    elif B < K:
        K -= B
        B = 0

print(A,B)


Measured memory_bytes: 3060
#include <cstdio>

int main(){
    int a[7] = {1,3,5,7,8,10,12};
    int b[4] = {4,6,9,11};
    int c[1] = {2};
    int x,y;
    scanf("%d %d",&x,&y);
    for(int i = 0; i < 7; i++){
        if(a[i] == x){
            for(int j = i + 1; j < 7; j++){
                if(a[j] == y){
                    printf("Yes\n");

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

            return 0;
        }
    }
    
    for(int i = 0; i < 4; i++){
        if(b[i] == x){
            for(int j = i + 1; j < 4; j++){
                if(b[j] == y){
                    printf("Yes\n");

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

            return 0;
        }
    }

    printf("No\n");

    return 0;
}

Measured memory_bytes: 128
n=int(input())
arr1=list(map(int,input().split()))
arr1=sorted(arr1)
m=int(input())
arr2=list(map(int,input().split()))
arr2=sorted(arr2)
pos=0
for i in range(n):
  if arr1[i]==arr2[pos]:
    pos+=1
  if pos==m:
    print('YES')
    break
else:
  print('NO')

Measured memory_bytes: 33784
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define Summon_Tourist ios::sync_with_stdio(false);cin.tie(0);
ll gcd(ll a , ll b) { return b==0?a: gcd( b, a%b); }
ll lcm(ll a , ll b) { return a/gcd(a,b) * b ; }
ll inf = 1e9 + 7;
ll modexp( ll base ,ll power)
 {
     if( power == 0  ) return 1;
     if( power & 1) return base*modexp( base , power-1 )%inf;
     return modexp(base*base%inf,power/2);
 }
int main()
{
  Summon_Tourist
 // freopen("input.txt" , "r" , stdin ) ;
  ll t = 1;
  //cin>>t;
  while(t--)
  {
     ll n ; cin>>n ;
     if( n==0 ) cout<<1;
     else cout<<0;
  }

 return 0;
}


Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		long[][] dp=new long[h][w];
		for(int i=0; i<h; i++) {
			String s=sc.next();
			for(int j=0; j<w; j++) {
				if(s.charAt(j)=='#') {
					dp[i][j]=-1;
				}
				else {
					dp[i][j]=0;
				}
			}
		}
		long mod=1000000007;
		for(int i=0; i<w; i++) {
			if(dp[0][i]>=0) {
				dp[0][i]=1;
			}
			else {
				break;
			}
		}
		for(int i=0; i<h; i++) {
			if(dp[i][0]>=0) {
				dp[i][0]=1;
			}
			else {
				break;
			}
		}
		for(int i=1; i<h; i++) {
			for(int j=1; j<w; j++) {
				if(dp[i][j]>=0) {
					if(dp[i][j-1]>=0) {
						dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
					}
					if(dp[i-1][j]>=0) {
						dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
					}
				}
			}
		}
		pl(dp[h-1][w-1]);
	}

	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int n;cin>>n;
    vint h(n+1);rep(i,n)cin>>h[i+1];
    int ans=0;
    rep(i,n)ans+=max(h[i+1]-h[i],0ll);
    cout<<ans<<endl;
    return 0;
}


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

vector<vector<int>> X(4000, vector<int>(4000, 0));

int N, K;
void check(int x, int y) {
	X[x][y]++;
	X[x + K][y]--;
	X[x][y + K]--;
	X[x + K][y + K]++;
	return;
}

int main(){
	int x, y;
	char c;
	cin >> N >> K;
	for (int i = 0;i < N;i++) {
		cin >> x >> y;
		cin >> c;
		x++;y++;
		if (c == 'B')
			x += K;
		x %= 2 * K;
		y %= 2 * K;
		if (x < K) {
			if (y < K) {
				check(x, y);
				check(x + 2 * K, y);
				check(x + K, y + K);
				check(x, y + 2 * K);
				check(x + 2 * K, y + 2 * K);
			}
			else {
				check(x, y);
				check(x + K, y - K);
				check(x + K, y + K);
				check(x + 2 * K, y);
			}
		}
		else {
			if (y < K) {
				check(x, y);
				check(x - K, y + K);
				check(x + K, y + K);
				check(x, y + 2 * K);
			}
			else {
				check(x, y);
				check(x + K, y - K);
				check(x + K, y + K);
				check(x - K, y + K);
				check(x - K, y - K);
			}
		}
	}
	for (int i = 0;i < 4 * K;i++) {
		for (int j = 1;j < 4 * K;j++) {
			X[i][j] += X[i][j - 1];
		}
	}
	for (int i = 0;i < 4 * K;i++) {
		for (int j = 1;j < 4 * K;j++) {
			X[j][i] += X[j - 1][i];
		}
	}
	int ans = 0;
	for (int i = 0;i < 2 * K;i++) {
		for (int j = 0;j < 2 * K;j++) {
			ans = max(X[K + i][K + j], ans);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 62976
import sys
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3
#sys.setrecursionlimit(int(1e+6))
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
MOD = int(1e+9) + 7

def main():
    X, Y, Z, K = i2nn()
    A = i2nn()
    B = i2nn()
    C = i2nn()
    A.sort()
    A.reverse()
    B.sort()
    B.reverse()
    C.sort()
    C.reverse()
    s = set()
    hq = []
    n = 0
    heappush(hq, ((A[0] + B[0] + C[0]) * -1, (0, 0, 0)))
    while n < K:
        t, abc = heappop(hq)
        if abc in s:
            continue
        s.add(abc)
        (a, b, c) = abc
        if a+1 < X:
            heappush(hq, ((A[a+1] + B[b] + C[c]) * -1, (a+1, b, c)))
        if b+1 < Y:
            heappush(hq, ((A[a] + B[b+1] + C[c]) * -1, (a, b+1, c)))
        if c+1 < Z:
            heappush(hq, ((A[a] + B[b] + C[c+1]) * -1, (a, b, c+1)))
        print(-t)
        n += 1

main()


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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author koneko096
 */
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);
    ACirclePond solver = new ACirclePond();
    solver.solve(1, in, out);
    out.close();
  }

  static class ACirclePond {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int R = in.nextInt();
      out.println(Math.PI * R * 2);
    }

  }


  static class InputReader {
    private BufferedReader reader;
    private 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 int nextInt() {
      return Integer.parseInt(next());
    }

  }
}



Measured memory_bytes: 25736
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <numeric>
#include <mutex>
#include <cmath>
#include <set>
#include <climits>
#define lli long long int
#define ll long long
#define mod 1000000007
#define pii pair<int,int>
#define mp make_pair
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
  int N, K;
  int ans = 0;
  cin >> N;
  int a;
  if(N == 1){
      cout << 1;
      return 0;
  }
  if(N % 2 == 0){
    cout << (N / 2) / (double)N;
  }
  else{
    cout << ((N / 2)+1) / (double)N;
  }
  return 0;
}


Measured memory_bytes: 256
using System;

class Program{
  static void Main(){
    string eng = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    var t = Console.ReadLine();
    string answer = "";
    int p = 0;
    for(int n = 0;n<t.Length;n++){
      p = eng.IndexOf(t[n]);
      if(p-3 >= 0){
        p = p-3;
      }else{
        p = p-3+26;
      }
      answer += eng[p];
    }
    Console.WriteLine(answer);
  }
}

Measured memory_bytes: 8980
#include <cstdio>
#include <cstdlib>
#define MAX 2000001
#define NIL -1

typedef struct {
    int size;
    int S[MAX];
} Heap;

int Left(int i) {
    return 2 * i;
}

int Right(int i) {
    return (2 * i + 1);
}

int Parent(int i) {
    return i / 2;
}

void increaseKey(Heap *H, int i, int key) {
    if (key < H->S[i]) {
        printf("too small key");
    } else {
        H->S[i] = key;
        while (1 < i && H->S[Parent(i)] < H->S[i]) {
            int p = Parent(i);
            int tmp = H->S[p]; H->S[p] = H->S[i]; H->S[i] = tmp;
            i = p;
        }
    }
}

void MaxHeapify(Heap *H, int i) {
    int l = Left(i);
    int r = Right(i);
    int largest = i;
    if ( l <= H->size && H->S[i] < H->S[l]) largest = l;
    if ( r <= H->size && H->S[largest] < H->S[r]) largest = r;
    if (largest != i) {
        int tmp = H->S[i]; H->S[i] = H->S[largest]; H->S[largest] = tmp;
        MaxHeapify(H, largest);
    }

}

void extractMax(Heap *H) {
    if (H->size < 1) {
        printf("over flow\n");
    } else {
        int max = H->S[1];
        printf("%d\n", max);
        H->S[1] = H->S[H->size];
        H->size--;
        MaxHeapify(H, 1);
    }
}

void insert(Heap *H, int k) {
    H->size++;
    H->S[H->size] = NIL;
    increaseKey(H, H->size, k);
}

int main () {
    Heap *H = (Heap *)malloc(sizeof(Heap));
    H->size = 0;
    for (;;) {
        char c[10];
        int k;
        scanf(" %s %d", c, &k);
        if (c[0] == 'i') {
            insert(H, k);
        } else if (c[0] == 'e' && c[1] == 'x') {
            extractMax(H);
        } else {
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 5808
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;


int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;
    }
    return sum;
}
int main(){
    string s;
    cin >> s;
    for(char c = 'a'; c <= 'z'; c++ ){
        if(s.find(c) == -1){
            cout << c << endl;
        return 0;
        }
    }
cout << "None" << endl;
}


Measured memory_bytes: 512