akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <bits/stdc++.h>

using namespace std;

typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;

typedef vector<lint> vl;
typedef pair<lint,lint> pll;


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

    lint n, k;
    cin>>n>>k;
    vi a(n+1);
    for (int i=1; i<=n; ++i) cin>>a[i];

    vi path;
    map<int, int> sp;
    int cur = 1;
    while(1){
        if (sp.count(cur)) break;
        path.push_back(cur);
        sp[cur] = path.size()-1;
        cur = a[cur];
    }

    lint T = path.size() - sp[cur];
    lint base = sp[cur];
    if (k+1 <= base) cout<<path[k];
    else cout<<path[base + (k-base)%T];


}


Measured memory_bytes: 13932
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()
	h := make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = ri()
	}

	ok := true
	prev := -1
	for _, now := range h {
		if prev > now {
			ok = false
			break
		} else if prev < now {
			now--
		}
		prev = now
	}

	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(void)
{
	char c[200];
	int a[3][3];
	int ans;
	while(scanf("%s", c) != EOF){
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				if(c[i * 3 + j] == 'o'){
					a[i][j] = 1;
				}else if(c[i * 3 + j] == 'x'){
					a[i][j] = 2;
				}else{
					a[i][j] = 0;
				}
			}
		}
		ans = 0;
		for(int i = 0; i < 3; i++){
			if(a[i][0] == a[i][1] && a[i][1] == a[i][2]){
				if(a[i][0]){
					ans = a[i][0];
				}
			}
			if(a[0][i] == a[1][i] && a[1][i] == a[2][i]){
				if(a[0][i]){
					ans = a[0][i];
				}
			}
		}
		if(a[0][0] == a[1][1] && a[1][1] == a[2][2]){
			if(a[0][0]){
				ans = a[0][0];
			}
		}
		if(a[0][2] == a[1][1] && a[1][1] == a[2][0]){
			if(a[0][2]){
				ans = a[0][2];
			}
		}
		if(ans == 1){
			printf("o\n");
		}else if(ans == 2){
			printf("x\n");
		}else{
			printf("d\n");
		}
	}
	return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, m;
string s;

int main(){
	cin >> s;
	for(int i=0;i<s.size();i++){
			if(s[i]=='A'&&s[i+1]=='C'){
				cout << "Yes" << endl;
				return 0;
			}
	}
	cout << "No" << endl;
	return 0;
}

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

int solve(int l, int r, int sq_sum, int sum, int n){
	int ans = 1e9;
	for(int mid = l; mid<=r; mid++){
		ans = min(ans, (n*mid*mid) + (sq_sum) - (2*mid*sum));
	}
	return ans;
}

int main(){
	int n, sq_sum = 0, sum = 0, min1 = 101, max1 = 0; cin>>n;
	vector<int> v(n);
	for(auto &i : v){
		cin>>i;
		sq_sum += i*i;
		sum += i;
		max1 = max(max1, i);
		min1 = min(min1, i);
		
	}
	cout<<solve(min1, max1, sq_sum, sum, n)<<endl;
	
}


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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int N, ans = 0;
	string S;
	
	cin >> N >> S;
	
	for(int i=1; i<N; i++){
		int cnt = 0;
		for(char c = 'a'; c<='z'; c++){
			bool left = false, right = false;
			for(int j=0; j<i; j++){
				if(S[j] == c)
					left = true;
			}
			for(int j=i; j<N; j++){
				if(S[j] == c)
					right = true;
			}
			if(left && right)
				cnt++;
		}
		ans = max(ans, cnt);
	}
	
	cout << ans;
	
	return 0;
}

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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

typedef pair<int,int> pii;
typedef long long int ll;

int n;
string s[2];
ll mod = 1e9+7;
ll cnt = 1;
vector<int> v;

int main(){
  cin >> n >> s[0] >> s[1];
  REP(i,s[0].size()){
    if(s[0][i] == s[1][i]){
      v.push_back(0);
    }else{
      v.push_back(1);
      i++;
    }
  }
  int prev = v[0];
  if(prev==0){
    cnt *= 3;
  }else{
    cnt *= 6;
  }
  FOR(i,1,v.size()){
    if(prev==0){
      if(v[i] == 0){
        cnt = (cnt*2) % mod;
      }else{
        cnt = (cnt*2) % mod;
      }
    }else{
      if(v[i] == 1){
        cnt = (cnt*3) % mod;
      }
    }
    prev = v[i];
  }
  cout << cnt <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <ctime>
#include <algorithm>
using namespace std;

int read() {
    int x = 0, f = 1; char c = getchar();
    while(!isdigit(c)){ if(c == '-') f = -1; c = getchar(); }
    while(isdigit(c)){ x = x * 10 + c - '0'; c = getchar(); }
    return x * f;
}

#define maxn 15
#define LL long long

int d;
LL ans;

int main() {
    d = read();
    
    if(d % 9) return puts("0"), 0;
    d /= 9;
    LL ini = 0, ten = 1;
    for(int i = 1; i <= 17; i++) {
        LL tmp = 1, D = d;
        ini = ini * 10 + 1;
        LL base = ini, lten = ten, rten = 1;
        for(int j = 0; j <= (i >> 1); j++) 
        {
            tmp *= 10 - abs(D % (rten * 10) / rten) - (!j ? 1 : 0);
            D -= base * (D % (rten * 10) / rten);
            base -= lten + rten;
            lten /= 10; rten *= 10;
        }
        ten *= 10;
        if(!D) ans += tmp;
    }
    printf("%lld\n", ans);
    
    return 0;
}

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

using namespace std;

#define int long long

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int l = 0, r = n - 1, ans = 0;
    while (l < r) {
        if (s[l] == 'W' && s[r] == 'R') {
            ++ans;
            swap(s[l], s[r]);
            ++l;
            --r;
        }
        else if (s[r] == 'W') {
            --r;
        }
        else if (s[l] == 'R') ++l;
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3768
N = int(input())
A = list(map(int, input().split()))
B = []
for a in A:
  B.append(a%4)

ans = 'No'
if B.count(0) >= B.count(1)+B.count(3):
  ans = 'Yes'
if B.count(2) == 0 and B.count(0) == B.count(1)+B.count(3)-1:
  ans = 'Yes'
print(ans)

Measured memory_bytes: 63000
#include <bits/stdc++.h>
using namespace std;
#define fi           first
#define se           second
#define ll           long long
#define pb           push_back
#define mp           make_pair
#define pll          pair<ll,ll>
#define pii          pair<int,int>
#define all(x)       (x).begin(),(x).end()
#define isWorking()  cout<<"Wroking"<<endl
#define FOR(i,x,y)   for(int i=x; i<y; i++)
#define SORT(x)      sort(x.begin(),x.end())
#define PRINT(ok)    cout<<(ok? "YES":"NO")<<endl
#define Fast_Input   ios_base :: sync_with_stdio(false), cin.tie(NULL);
typedef vector < int > VI;
const ll mod= 1e9+7,INF=1e18,mx= 5e6+5,mn=100;
int testCase=1,cas=0;

int main() {
    Fast_Input

    //cin>>testCase;
    while(testCase--){
        int n; cin>>n;
        string str; cin>>str;
        stack <char> st;
        deque <char> Ans;

        for(int i=0; i<n; i++){
            if(str[i]=='('){
                st.push('(');
                Ans.push_back('(');
                continue;
            }

            if(st.empty()){
                Ans.push_front('(');
                Ans.push_back(')');
                continue;
            }

            st.pop();
            Ans.push_back(')');
        }
        while(st.size()){
            Ans.push_back(')');
            st.pop();
        }

        while(Ans.size()){
            cout<<Ans.front();
            Ans.pop_front();
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
ll mod=1e9+7;
int main()
{
    ll s;
    cin>>s;
    vector<ll> dp(s+1,0);
    dp[0]=1;
    for(ll i=3;i<=s;i++)
    {
        for(ll j=3;j<=s;j++)
        {
            if(i-j>=0)
            {
                (dp[i]+=dp[i-j])%=mod;
            }
        }
    }
    cout<<dp[s]<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int mod=998244353;
int power[3005];
int dp[3003][3005];

signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    power[0]=1;
    for(int i=1;i<=3003;i++)
    {
        power[i]=(power[i-1]*2)%mod;
    }
    
    int n,s;
    cin>>n>>s;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];

    dp[0][0]=1;

    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=3001;j++)
        {
            if(j-a[i]>=0)
                dp[i][j]+=(dp[i-1][j-a[i]])%mod;
            dp[i][j]%=mod;
            dp[i][j]+=(dp[i-1][j]*2)%mod;
            dp[i][j]%=mod;
        }
    }


    cout<<dp[n][s];
} 



Measured memory_bytes: 74068
from collections import deque

H, W = map(int, input().split())
L = [str(input()) for _ in range(H)]
ans = 0
for h in range(H):
    for w in range(W):
        if L[h][w] == '#':
            continue
        else:
            flag = [[-1] * W for _ in range(H)]
            depth = [[0] * W for _ in range(H)]
            flag[h][w] = 0
            q = deque([(h, w)])
            while q:
                i, j = q.popleft()
                d = depth[i][j]
                if i != H - 1:
                    if L[i+1][j] == '.' and flag[i+1][j] < 0:
                        flag[i+1][j] = 0
                        depth[i+1][j] = d + 1
                        q.append((i+1, j))
                if i != 0:
                    if L[i-1][j] == '.' and flag[i-1][j] < 0:
                        flag[i-1][j] = 0
                        depth[i-1][j] = d + 1
                        q.append((i-1, j))
                if j != W - 1:
                    if L[i][j+1] == '.' and flag[i][j+1] < 0:
                        flag[i][j+1] = 0
                        depth[i][j+1] = d + 1
                        q.append((i, j+1))
                if j != 0:
                    if L[i][j-1] == '.' and flag[i][j-1] < 0:
                        flag[i][j-1] = 0
                        depth[i][j-1] = d + 1
                        q.append((i, j-1))
                ans = max(ans, d)
print(ans)


Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> X(N); rep(i, 0, N) {
		cin >> X[i];
	}
	vector<int> XX = X;
	sort(all(XX));
	int a = XX[N / 2 - 1];
	int b = XX[N / 2];
	rep(i, 0, N) {
		if (X[i] <= a) {
			cout << b << endl;
		}
		else if (X[i] >= b) {
			cout << a << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
int t[100010],x[100010],y[100010]; 
int n;
pair<int,pair<int,int> > a[100010];
int d(int a1,int a2,int a3,int a4){
	return abs(a3-a1)+abs(a4-a2);
}
void No(){
	cout<<"No";
	exit(0);
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>t[i]>>x[i]>>y[i];
		a[i]=mp(t[i],mp(x[i],y[i]));
	}
	sort(a,a+n);
	int de1=d(0,0,a[0].second.first,a[0].second.second);
	if(de1>a[0].first)	No();
	if(de1%2!=(a[0].first-0)%2)	No();
	for(int dept=1;dept<n;dept++){	
		int de=d(a[dept-1].second.first,a[dept-1].second.second,a[dept].second.first,a[dept].second.second);
		//cout<<de<<"\n";
		if(de>(a[dept].first-a[dept-1].first))	No();
		if(de%2!=(a[dept].first-a[dept-1].first)%2)	No();
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>

int main()
{
	char week[7][10]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int month,day;
	int numday[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
	int i;

	while((scanf("%d%d", &month, &day)) != EOF)
	{
		if (month == 0) break;
		for (i = 0; i < month -1; i++)
		{
			day += numday[i];
		}
		day = (day + 2)%7 ;
		printf("%s\n", week[day]);
	}
	return 0;
}

Measured memory_bytes: 2492
#include<iostream>
#include<vector>
#include<string>
#include<complex>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int n,m,out;
vi test,co;
int in[10][10]={0};
void f(int a){
  //rep(i,10){rep(j,10)cout<<" "<<in[i][j];cout<<endl;}cout<<endl;
  if(a==0){
    vi tes(n);
    rep(i,n)tes[i]=i;
    rep(i,8){
      rep(j,n)if(in[i][j]){
    swap(tes[j],tes[j+1]);
      }
    }
    //    rep(i,10){rep(j,10)cout<<" "<<in[i][j];cout<<endl;}cout<<endl;
    bool h=true;
    rep(i,n)if(tes[i]!=test[i])h=false;
    if(h){
      int ma=0;
      rep(i,8)rep(j,n)if(in[i][j])ma=max(ma,i);
      out=min(out,ma);
    }    
  }else{
    rep(i,n-1)if(co[i]){
      co[i]--;
      rep(j,8){
    if(in[j][i])continue;
    if(i&&in[j][i-1])continue;
    in[j][i]=true;
    f(a-1);
    in[j][i]=false;
      }
      co[i]++;
      break;
    }    
  }  
}
int main(){
  out=inf;
  cin>>n>>m;
  test=co=vi(n,0);
  rep(i,n)test[i]=i;
  rep(i,m){
    int a;cin>>a;a--;
    swap(test[a],test[a+1]);
    co[a]++;
  }
  f(m);
  cout<<out+1<<endl;
}

Measured memory_bytes: 1216
def chess(h,w):
    if (h+w) % 2 == 0:
        return '#'
    return '.'
    
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            print(chess(i,j),end = '')
        print()
    print()


Measured memory_bytes: 7008
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxx = 1e5 + 7;
const int Inf = 1 << 30;
const LL INF = 1LL << 60;
int x;
LL ans;

int main() {
	cin >> x;
	int dd = x / 500;
	ans += (LL)dd * 1000LL;
	x -= dd * 500;
	dd = x / 5;
	ans += (LL)dd * 5LL;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,a,b,c,d;
int main()
{
  scanf("%d",&n);
  a=n%10;n/=10;
  b=n%10;n/=10;
  c=n%10;n/=10;
  d=n%10;n/=10;
  if(a==b||c==b||c==d)cout<<"Bad";
  else cout<<"Good";
}

Measured memory_bytes: 256
//173 B-JudgeStatusSummary
#include <iostream>
#include <vector>;
using namespace std;
enum { AC = 0, WA, TLE, RE };
int main() {
	int caseNum = 0;
	cin >> caseNum;

	vector<string> judgeResult(caseNum);
	vector<int> judgeCnt(4);
	for (int i = 0; i < caseNum; i++)
	{
		cin >> judgeResult[i];
		
		if (judgeResult[i] == "AC") judgeCnt[AC]++;
		if (judgeResult[i] == "WA") judgeCnt[WA]++;
		if (judgeResult[i] == "TLE") judgeCnt[TLE]++;
		if (judgeResult[i] == "RE") judgeCnt[RE]++;
	}

	cout << "AC x " << judgeCnt[AC] << endl;
	cout << "WA x " << judgeCnt[WA] << endl;
	cout << "TLE x " << judgeCnt[TLE] << endl;
	cout << "RE x " << judgeCnt[RE] << endl;

	return 0;
}

Measured memory_bytes: 6396
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdlib>

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

using namespace std;

typedef long long ll;
const long long INF = 1e9;

int main()
{
  int n; cin >> n;
  vector<vector<int> > done(n, vector<int>(3));
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      //j -> A:0, B:1, C:2
      cin >> done[i][j];
    }
  }
  
  vector<vector<ll> > dp(n + 1, vector<ll>(3) );

  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      for (int k = 0; k < 3; k++)
      {
        if(j == k) continue;
        chmax(dp[i + 1][k], dp[i][j] + done[i][k]);
      }
    }
  }
  
  ll ans = 0;
  for(int j = 0; j < 3; j++) chmax(ans, dp[n][j]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
using namespace std;
#define INF 10000000000
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define rep(i, n) for(int (i)=1; (i)<=(n); (i)++)
typedef pair<int, int> P;
typedef long long ll;
int N, X;
int point[101000];
int diff[101000];
int ans = 0;

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

int main(){
    cin >> N >> X;
    REP(i, N){
        cin >> point[i];
        diff[i] = abs(point[i] - X);
    }

    if(N == 1){
        ans = diff[0];
    }else{
        int tmp = diff[0];
        if(tmp == 0) tmp = diff[1];
        REP(i, N){
            if(diff[i] == 0) continue;
            tmp = gcd(tmp, diff[i]);
        }
        ans = tmp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ull x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ld a, b, x;
    cin >> a >> b >> x;
    ld ans;
    dump(x/a, a*b/2.0);
    dump(atan2(2.0*(b-x/a/a), a)*180.0L/PI);
    dump(atan2(b, 2.0*x/a/b)*180.0L/PI);
    if(x/a > a*b/2.0){
        ans = atan2(2.0*(b-x/a/a), a);
    }else{
        ans = atan2(b, 2.0*x/a/b);
    }
    cout << ans*180.0L/PI << endl;
    return 0;
}

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define Cin(x) cin >> x
#define Cin2(x,y) cin >> x >> y
#define Cin3(x,y,z) cin >> x >> y >> z
#define Cin4(w,x,y,z) cin >> w >> x >> y >> z
#define Cout(x) cout << x << "\n"
#define Cout2(x,y) cout << x << y << "\n"
#define Cout3(x,y,z) cout << x << y << z << "\n"
#define Cout4(w,x,y,z) cout << w << x << y << z << "\n"
#define Kaigyou cout << "\n"
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define Size(n) (n).size()
#define All(v) (v).begin(), (v).end()
#define Pb(i) push_back(i)

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

    ll n,a[10001],ans=0; Cin(n);
    rep(i,n) Cin(a[i]);
    rep(i,n){
        if(a[i]%2==0){
            ans++;
            a[i] /= 2;
            i--;
        }
    }
    Cout(ans);
    return 0;
}

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

signed main(void)
{
	string s, ans;
	int k;
	bool like[10], flag;
	cin >> s >> k;

	int d[k];
	rep(i, 10) like[i] = true;
	rep(i, k)
	{
		cin >> d[i];
		like[d[i]] = false;
	}
	flag = true;
	rep(j, s.size())
	{
		rep(i, 10)
		{
			if (!(s.size() != 1 && j == 0 && i == 0))
			{
				if (like[i])
				{
					if (flag)
					{
						if (s[j] <= i + '0')
						{
							ans += i + '0';
							if (s[j] < i + '0')
							{
								flag = false;
							}
							break;
						}
					}
					else
					{
						ans += i + '0';
						break;
					}
				}
			}
		}
	}
	if (ans.size() != s.size())
	{
		ans = "";
		rep(j, s.size() + 1) rep(i, 10)
		{
			if (like[i])
			{
				if (!(j == 0 && i == 0))
				{
					ans += i + '0'; 
					break;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define N 200005
ll fact[N], inv[N], finv[N];
void make()
{
	fact[0] = 1;
	fact[1] = 1;
	inv[1] = 1;
	finv[1] = finv[0] = 1;
	for(int i = 2; i < N; ++i)
	{
		fact[i] = fact[i - 1] * i % MOD;
		inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
		finv[i] = finv[i -1] * inv[i] % MOD;
	}
}

ll C(int a, int b)
{
	if(a < b) return 0;
	return fact[a] * (finv[b] * finv[a - b] % MOD) % MOD;
}

ll exp(ll a, ll b)
{
	ll res = 1;
	while(b)
	{
		if(b & 1)
			res = res * a % MOD;
		b >>= 1;
		a = a * a % MOD;
	}
	return res;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	make();
	ll n, a, b, c;
	cin >> n >> a >> b >> c;

	ll ans = 0, pa = a * inv[a + b] % MOD, pb = b * inv[a + b] % MOD;
	for (int i = 0; i < n; ++i)
	{
		ans += C(n + i - 1, i) * exp(pa, i) % MOD * exp(pb, n) % MOD * (i + n) % MOD;
		ans += C(n + i - 1, i) * exp(pb, i) % MOD * exp(pa, n) % MOD * (i + n) % MOD;
		ans %= MOD; 
	}
	ans = ans * inv[100 -c] % MOD *100 % MOD;
	cout << ans; 
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
// ----------------------R00TDADA------------------------------
#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define bitcount __builtin_popcount //count no's of ones in a set bit
#define prq priority_queue
#define mp make_pair
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define int long long
#define M 1000000007

signed main()
{
    rootdada;
    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif
    int n, x, y;
    cin >> n >> x >> y;
    vector<int> ans(n + 1, 0);
    int mini;
    for (int i = 1; i <= n; i++)
    {
        for (int j = i + 1; j <= n; j++)
        {
            mini = min({abs(x - i) + 1 + abs(y - j),
                        abs(y - i) + 1 + abs(x - j),
                        j - i});

            ans[mini]++;
        }
    }

    for (int i = 1; i < n; i++)
        cout << ans[i] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int N;
    cin >> N;
    vector<int> a(N+2, 0);
    for(int i = 1; i < N+1; i++){
        cin >> a[i];
    }
    ll sum = 0;
    rep(i, N+1){
        int v = abs(a[i]-a[i+1]);
        sum += (ll)v;
    }
    for(int i = 1; i < N+1; i++){
        ll ans = sum;
        int minus = abs(a[i-1] - a[i]) + abs(a[i] - a[i+1]);
        int pulse = abs(a[i-1] - a[i+1]);
        ans -= minus;
        ans += pulse;
        cout << ans << endl;
    }
    return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    
    vector<int> b(n - 1);
    for (int i = 0; i < n - 1; i++)
        cin >> b[i];

    int ans = 0;
    ans += b[n - 2];
    for (int i = n - 2; i >= 0; i--){
        if (i == 0)
            ans += b[i];
        else
            ans += min(b[i], b[i - 1]);
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<iterator>
#include<iostream>
#include<cctype>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<list>
#include<stack>
#include<functional>
#include<utility>
#include<numeric>
#include<bitset>
#include<iterator>
#define INF (int)1e9
#define MOD 1000000007
#define tr(c, it) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz size
#define ll long long
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MEM(a, b) memset(a, (b), sizeof(a))
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define FOR(i,n) for(int (i)=0;(i)<(n);++(i))
#define PRE(i, m, n, in) for(int (i)=(m);(i)<(n);i+=in)
#define RFOR(i, n) for(int i=n ; i>=0 ; i--)
#define RPRE(i, j, k, in) for(int i=j ; i>=k ; i-=in)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
using namespace std;
typedef pair<int, int> II;
typedef vector <int> VI;
typedef vector<string> VS;
typedef vector <II> VII;
typedef vector <VI> VVI;
typedef vector <VII> VVII;
typedef map<int,int> MPII;
typedef set<int> SETI;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt","r",stdin);
    int N, X; cin >> N >> X; VI m(N); int res = N; int sum = 0;
    FOR(i, N) {
        cin >> m[i];
        sum += m[i];
    }
    sort(all(m));
    int t = X - sum; int i = 0;
    while(t > 0 && i < N) {
        //cout << t/m[i] << endl;
        res += t/m[i]; t = t - (t/m[i])*m[i];
        i++;
    }
    cout << res << endl;
    return 0;
}


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

int main(){
  int n,m;
  static int nails[2][5001][5001];
  scanf("%d %d",&n,&m);
  fill(nails[0][0],nails[0][0]+2*5001*5001,0);
  for(int i=0;i<m;i++){
    int a,b,x;
    scanf("%d %d %d",&a,&b,&x);
    nails[0][a-1][b-1]++;
    nails[0][a+x][b-1]--;
    nails[1][a-1][b]--;
    nails[1][a+x][b+x+1]++;
  }
  for(int i=1;i<=n;i++){
    for(int j=0;j<=i;j++){
      nails[0][i][j] += nails[0][i-1][j];
      if(j>=1) nails[1][i][j] += nails[1][i-1][j-1];
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<=i+1;j++){
      nails[0][i][j] += nails[0][i][j-1];
      nails[1][i][j] += nails[1][i][j-1];
    }
  }
  int ans = 0;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=i;j++){
      if(nails[0][i][j]+nails[1][i][j]>0) ans++;
    }
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 198108
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <memory.h>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>
using namespace std;

typedef pair<int,int> pi;
typedef pair<int,pi>  pii;

int n,m;

map<pi,vector<pi>> adj;

map<pi,int> dist;

int main(){
	scanf("%d%d",&n,&m);
	while(m--){
		int x,y,c;
		scanf("%d%d%d",&x,&y,&c);
		adj[pi(x,c)].push_back(pi(x,0));
		adj[pi(x,0)].push_back(pi(x,c));
		adj[pi(y,c)].push_back(pi(y,0));
		adj[pi(y,0)].push_back(pi(y,c));
		adj[pi(x,c)].push_back(pi(y,c));
		adj[pi(y,c)].push_back(pi(x,c));
	}
	priority_queue<pii,vector<pii>,greater<pii>> pq;
	dist[pi(0,0)]=0;
	pq.push(pii(0,pi(1,0)));
	while(!pq.empty()){
		pii now=pq.top();
		int dis=now.first;
		pi pos=now.second;
		pq.pop();
		for(auto v:adj[pos]){
			if(v.second==pos.second){
				if(dist.count(v)==0||dist[v]>dis){
					dist[v]=dis;
					pq.push(pii(dis,v));
				} 
			}
			else{
				if(dist.count(v)==0){
					dist[v]=dis+1;
					pq.push(pii(dis+1,v));
				}
			}
		}
	}
	int fare=dist[pi(n,0)];
	if(fare==0) printf("-1\n");
	else printf("%d\n",fare/2);
return 0;
}

Measured memory_bytes: 89780
#include <iostream>
#include <map>
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>
#include <cmath>
#include <string>
#define mp make_pair
#define pb push_back
 
using namespace std;
 
int main() 
{
	int n,a,b;
	scanf("%d %d %d", &n, &a, &b);
	if (a + b > n + 1) {
		printf("-1");
		return 0;
	}
	int k = b, d = 0;
	if (1ll*a*b >= n) {
		while (d < n) {
			for (int i = k; i>0; --i) {
				printf("%d ", i + d);
			}
			--a;
			d += k;
			if (a>0) { 
				k = (n-d)/a;
			}
		}
	} else{
		printf("-1");
	}
	return 0;
}

Measured memory_bytes: 2176
Module Main
  Sub Main
    Dim s = Console.ReadLine()
    Dim ss = s.Split(" "c)
    Dim d = CInt(ss(0))
    Dim n = CInt(ss(1))
    Dim i = 1
    Do
      	Dim x = i
      	Dim c = 0
      	Do While x Mod 100 = 0
        	x \= 100
        	c += 1
      	Loop
        If c = d Then
          n -= 1
          If n = 0 Then
            Console.WriteLine(i)
            Exit Do
          End If
        End If
		i += 1
    Loop
  End Sub
End Module


Measured memory_bytes: 24892
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
#include <math.h>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

string yorn(bool a){if(a) return"Yes" ; return "No" ;}
string YorN(bool a){if(a) return"YES" ; return "NO" ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	ll a,b,c ;
	cin >> a >> b >> c ;
	ll d = c-a-b ;
	if(d<=0){
		cout << yorn(0) << endl ;
		return 0 ;
	}
	cout << yorn(4*a*b<d*d) << endl ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=100;
const long INF=1e17;
int main(){
	int N;long A,B;cin>>N>>A>>B;
	long X[N];cin>>X[0];
	long sum=0;
	rep(i,1,N){
		cin>>X[i];
		sum+=min(A*(X[i]-X[i-1]),B);
	}cout<<sum<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    string S;
    cin >> S;
    //文字列の長さ
    int l;
    l = S.length();
    if(l==2){
        cout << S << endl;
    }else{
        cout << S[2] << S[1] << S[0] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
x, y = map(int,input().split())

group_1 = [1, 3, 5, 7, 8, 10, 12]
group_2 = [4, 6, 9, 11]
group_3 = [2]

groups = [group_1, group_2, group_3]

for group in groups:
    if x in group and y in group:
        print("Yes")
        break
    else:
        None
    if group == group_3:
        print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;

int main(){
    int N;cin>>N;
    ll D,A;cin>>D>>A;
    vector<P> X;
    for(int i=0;i<N;i++){
        ll x,h;cin>>x>>h;
        X.push_back((P){x,1+(h-1)/A});
    }
    sort(X.begin(),X.end());
    vec imos(N+2,0),S(N+2);imos[0]=S[0]=0;
    int l=0,r=0;
    ll ans=0;
    while(l<N){
        while(X[r].first<=X[l].first+2*D && r<N) r++;
        imos[l+1]-=X[l].second;
        imos[r+1]+=X[l].second;
        ans+=X[l].second;
        while(l<N){
            S[l+1]=S[l]+imos[l+1];
            if(X[l].second+S[l+1]>0)break;
            l++;
        }
        X[l].second+=S[l+1];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7020
using System;
class Program
    {
    	static void Main(string[] args)
    	{
    		// 整数の入力
    		long a = long.Parse(Console.ReadLine());
    		// 文字列の入力
    		string s = Console.ReadLine();
    		//出力
    		long[] count = new long[26];
            foreach (char c in s)
            {
                count[c - 'a'] ++ ;
            }
            long ans = 1;
            foreach (long i in count) ans = (ans * (i + 1)) % 1000000007;
            Console.WriteLine((ans - 1) % 1000000007);
        }
    }
    //mcs Main.cs
    //mono Main.exe

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

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

    for(int i=1; i<=n; i++){
        int a=i;
        if(a%3==0){
            cout<<" "<<i;
            continue;
        }
        while(1){
            if(a==0) break;
            if(a%10==3){
                cout<<" "<<i;
                break;
            }

            a/=10;
            if(a==0) continue;
        }
    }
    cout<<endl;

    return 0;
}



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

class union_find {
public:
    union_find(int n)
        : par_(n, -1)
    {}
    void init(int n) {
        par_.assign(n, -1);
    }

    int root(int x) {
        return par_[x] < 0 ? x : par_[x] = root(par_[x]);
    }

    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if(x == y) {
            return false;
        } else {
            if(par_[x] < par_[y]) { // size(x) > size(y)
                par_[x] += par_[y];
                par_[y] = x;
            } else {
                par_[y] += par_[x];
                par_[x] = y;
            }
            return true;
        }
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return -par_[root(x)];
    }

private:
    std::vector<int> par_;
};

int main() {
    int N, M;
    cin >> N >> M;
    union_find uf(N);
    vector<vector<int>> l(M+1);
    for(int i=0; i<N; ++i) {
        int K=0;
        cin >> K;
        for(int j=0; j<K; ++j) {
            int L;
            cin >> L;
            L--;
            l[L].push_back(i);
        }
    }
    for(int i=0; i<l.size(); ++i) {
        for(int j=1; j<l[i].size(); ++j) {
            uf.unite(l[i][j], l[i][j-1]);
        }
    }
    for(int i=0; i<N-1; ++i) {
        if(!uf.same(i, i+1)) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 4608
import numpy as np,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,W = LI()
wv = [LI() for _ in range(N)]
dp = np.zeros(W+1,dtype=int) #1_indexed
for i in range(N):
    w,v = wv[i]
    dp[w:] = np.fmax(dp[:-w]+v,dp[w:])
print(dp[-1])


Measured memory_bytes: 22440
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, vs, n, m) vector<vector<T>> vs(n, vector<T>(m))

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    Cin(string, s);
    
    int ans = 0;
    For(i, n){
        int a = 0;
        for(char c = 'a'; c <= 'z'; c ++){
            if(find(s.begin(), s.begin() + i, c) != s.begin() + i && find(s.begin() + i, s.end(), c) != s.end()) a ++;
        }
        ans = max(ans, a);
    }
    Cout(ans);
}


Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#define REP(i, n) for(i = 0; i < n; ++i)
#define FOR(i, a, b) for(i = a; i < b; ++i)

void yes_or_no(char boolean){
    if(boolean){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}

int main(){
    long int N;
    scanf("%ld", &N);
    int sqN = sqrt(N) + 1;
    int i;
    int digit = 11, min = 11;

    FOR(i, 1, sqN){
        if(N % i == 0){
            digit = log10(N / i) + 1;
            if(min > digit){
                min = digit;
            }
        }
    }

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

    return 0;
}

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

main()
{
  int K, X;
  cin >> K >> X;

  for(int i = max(-1000000, X - K + 1); i < min(1000001, X + K); i++) {
    cout << i << " ";
  }

  cout << endl;

  return 0;
}


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


int main(){
    int x;
    cin >> x;
    int count =0;
    for(int i=x;i<=100009;i++){
        for(int j=1;j<=i;j++){
            if(i%j==0)
            count++;
        }
        if(count == 2){
            cout << i << endl;
            return 0;
        }
        count = 0;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#define rep(i,n) for(int i = 0; i < n; i++)

using namespace std;

int main(){
	int n,k;
	cin >> n >> k;
	
	vector<int> a(n,0);
	rep(i, k){
		int d;
		cin >> d;
		rep(j, d){
			int treat;
			cin >> treat;
			a[treat-1] = 1;
		}
	}
	
	int ans = 0;
	rep(i, n){
		if(a[i] == 0) ans++;
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 3580
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func stringArrayToIntArray(stringArray []string) []int {
	intArray := make([]int, len(stringArray))
	for n := range stringArray {
		intArray[n], _ = strconv.Atoi(stringArray[n])
	}
	return intArray
}

func sumDigits(nums []int) int {
	var sum int
	for _, num := range nums {
		sum += num
	}
	return sum
}

func canDigitSumDevideOriginalNumber(digitSum int, originalNumber int) string {
	if originalNumber%digitSum == 0 {
		return "Yes"
	} else {
		return "No"
	}
}

func main() {
	var s string
	fmt.Scan(&s)

	originalNumber, _ := strconv.Atoi(s)
	digits := stringArrayToIntArray(strings.Split(s, ""))
	digitSum := sumDigits(digits)
	fmt.Println(canDigitSumDevideOriginalNumber(digitSum, originalNumber))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int d[5005],e[5005],n,x,w[1005],f[1005]; vector <int> a[1005];
void dfs(int x){
	for (int i=0;i<a[x].size();++i) dfs(a[x][i]);
	for (int i=1;i<=w[x];++i) d[i]=0; d[0]=1;
	for (int i=0,y;i<a[x].size();++i){
		y=w[a[x][i]]; f[x]+=f[a[x][i]];
		for (int i=y;i<=w[x];++i) e[i]=d[i-y];
		y=f[a[x][i]]-y;
		for (int i=y;i<=w[x];++i) e[i]|=d[i-y];
		for (int i=0;i<=w[x];++i) d[i]=e[i],e[i]=0;
	}
	int i; for (i=w[x];~i;--i) if (d[i]) break;
	if (i<0) {puts("IMPOSSIBLE"); exit(0);}
	f[x]+=w[x]-i;
}
int main(){
	scanf("%d",&n);
	for (int i=2;i<=n;++i)
		scanf("%d",&x),a[x].push_back(i);
	for (int i=1;i<=n;++i) scanf("%d",&w[i]);
	dfs(1); puts("POSSIBLE");
	return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        //long start = System.currentTimeMillis();
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0;i<n;++i) a[i] = sc.nextLong();
        sc.close();

        long ans = 0;
        long mod = (long) Math.pow(10,9)+7;

        long x = 0;
        for (int i = 0;i<n;++i)
        {
            ans += (a[i]%mod) * (x%mod);
            ans %= mod;
            x += (a[i]%mod);
        }

        System.out.println(ans);
//        long end = System.currentTimeMillis();
//        System.err.println((end-start)+"ms");
    }
}

Measured memory_bytes: 51420
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] p = new int[n+1];
		for (int i = 0; i < n; i++) {
			if (i == 0) {
				p[i] = in.nextInt();
				in.nextInt();
			} else if (i == n-1) {
				p[i] = in.nextInt();
				p[i+1] = in.nextInt();
			} else {
				p[i] = in.nextInt();
				in.nextInt();
			}
		}

		int[][] dp = new int[n+1][n+1];

		for (int l = 2; l <= n; l++) {
			for (int i = 1; i <= n - l + 1; i++) {
				int j = i + l - 1;
				dp[i][j] = Integer.MAX_VALUE;
				for (int k = i; k < j; k++) {
					dp[i][j] = Math.min(dp[i][k]+dp[k+1][j]+p[i-1]*p[k]*p[j],dp[i][j]);
				}
			}
		}

		System.out.println(dp[1][n]);

	}

}



Measured memory_bytes: 26596
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    ll a[n];
    rep(i,n)cin>>a[i];
    sort(a,a+n);
    if(n%2==0){
        ll ans=0;
        rep(i,n/2)ans-=a[i];
        rep(i,n/2)ans+=a[i+n/2];
        cout<<2*ans+a[n/2-1]-a[n/2]<<endl;
    }
    else {
        ll ans1=0;
        rep(i,n){
            if(i<n/2)ans1-=2*a[i];
            else ans1+=2*a[i];
        }
        ans1-=a[n/2]+a[n/2+1];
        ll ans2=0;
        rep(i,n){
            if(i<n/2+1)ans2-=2*a[i];
            else ans2+=2*a[i];
        }
        ans2+=a[n/2]+a[n/2-1];
        cout<<max(ans1,ans2)<<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

/* 前処理 O(n) */
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

/* 計算 O(1) */
long long COM(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  vector<vector<ll>> loc(n);
  rep(i, n + 1) {
    loc[a[i]].pb(i);
  }

  ll edge = 0;
  rep(i, n) {
    if (loc[i].size() == 2) {
      edge += loc[i][0];
      edge += (n - loc[i][1]);
    }
  }

  COMinit();
  repp(k, 1, n + 1) {
    ll ans = COM(n + 1, k);
    if (k - 1 <= edge)
      ans -= COM(edge, k - 1);
    if (ans < 0)
      ans += MOD;
    cout << ans << endl;
  }
}

Measured memory_bytes: 19456
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main(){
  lli N,M,A;
  cin>>N>>M;
  for(int i = 0; i<M; i++){
    cin>>A;
    N-=A;
  }
  N>=0?cout<<N:cout<<-1;
  return 0;
}

Measured memory_bytes: 3560
/* 
 * Project: AtCoder Beginners Contest 160 A - Coffee
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/04/06
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
string s;
 
void solve() {

    if (s[2] == s[3] && s[4] == s[5])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

}
 
int main() {
 
    cin >> s;
 
    solve();
 
}

Measured memory_bytes: 256
from collections import deque
def solve(s, t):
    par = {}
    par[s] = -1
    q = deque([s])
    while q:
        v = q.pop()
        for nxt_v in tree[v]:
            if nxt_v in par:
                continue
            else:
                q.append(nxt_v)
                par[nxt_v] = v
    res = []
    while True:
        if par[t] != -1:
            res.append(edge[min(t, par[t]), max(t, par[t])])
            t = par[t]
        else:
            return res
    
n = int(input())
info = [list(map(int, input().split())) for i in range(n - 1)]
m = int(input())
const = [list(map(int, input().split())) for i in range(m)]

tree = [[] for i in range(n)]
edge = {}
for i in range(n - 1):
    a, b = info[i]
    a -= 1
    b -= 1
    edge[min(a, b), max(a, b)] = i
    tree[a].append(b)
    tree[b].append(a)
    
bit_v = [0] * m
for i in range(m):
    s, t = const[i]
    s -= 1
    t -= 1
    bit_state = 0
    for mask in solve(s, t):
        bit_state |= (1 << mask)
    bit_v[i] = bit_state

ans = 0
for bit_state in range(1, 1 << m):
    bit_cnt = bin(bit_state).count("1")
    mask = 0
    for i in range(m):
        if bit_state & (1 << i):
            mask |= bit_v[i]
    if bit_cnt % 2 == 0:
        ans -= 2 ** (n - 1 - bin(mask).count("1"))
    else:
        ans += 2 ** (n - 1 - bin(mask).count("1"))
print(2 ** (n - 1) - ans)

Measured memory_bytes: 44540