akhauriyash/Code-Regression huggingface dataset:
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
    return list(map(int,input().split()))
def m():
    return map(int,input().split())
def onem():
    return int(input())
def s(x):
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x):
    return " ".join(map(str,x))

a,b = m()

print(100,100)
aa = [["." for i in range(100)] for j in range(100)]
c = 0
for i in range(50):
    for j in range(100):
        aa[i][j] = "#"
a -= 1
b -= 1
k = 0
for i in range(100):
    if i <= 48:
        if k == 1:
            k = 0
            continue
        if a != 0:
            for j in range(100):
                if a == 0:
                    break
                if i//2 % 2 == 0:
                    if j % 2 == 0:
                        aa[i][j] = "."
                        a -= 1
                        k = 1
                else:
                    if j % 2 == 1:
                        aa[i][j] = "."
                        a -= 1
                        k = 1
    elif i >= 51:
        if k == 1:
            k = 0
            continue
        if b == 0:
            break
        else:
            for j in range(100):
                if b == 0:
                    break
                if i//2 % 2 == 0:
                    if j % 2 == 0:
                        aa[i][j] = "#"
                        b -= 1
                        k = 1
                else:
                    if j % 2 == 1:
                        aa[i][j] = "#"
                        b -= 1
                        k = 1
    else:
        k = 0

for i in range(100):
    print("".join(aa[i]))

Measured memory_bytes: 3444
# coding:utf-8


def main():
    N, A, B, C, D = map(int, input().split())
    A -= 1
    B -= 1
    C -= 1
    D -= 1
    iwa = "#"
    S = input()
    ans = True
    canexchange = False

    for i in [A, B, C, D]:
        if S[i] == iwa:
            exit()

    exchagable_list = []
    for i in range(N-2):
        temps = S[i:i+3]
        if temps == "...":
            exchagable_list.append(i)

    if len(exchagable_list) > 0:
        for i in exchagable_list:
            if i+1 >= B and i+1 <= min(C, D):
                canexchange = True

    # print(canexchange)
    for i in range(N-1):
        if S[i] == iwa and S[i+1] == iwa:
            if C < B and (C < i and i+1 < B):
                pass
            elif not (i+1 < A or i > max(C, D)):
                ans = False

    if ans:
        if C < D:
            ans = True
        elif C > D and canexchange:
            ans = True
        elif C > D and not canexchange:
            if S[D-1] == iwa or S[D+1] == iwa:
                ans = False
            else:
                ans = True

    if ans:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 40048
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <deque>
#include <string>
#include <list>
#include <algorithm>
#include <cmath>
#include <fstream>
#include <map>
#include <set>
#include <sstream>
#include <ctime>
using namespace std;
typedef signed long long int lli;
#define FOR(i, p, n) for(int i(p); i < n; i++)
#define ALL(a) (a.begin()),(a.end())
#define sqrt(x) sqrt(1.0*(x))
#define pow(x,n) pow(1.0*(x),n)
#define UN(x) (x).resize(unique(ALL((x))) - (x).begin());
#define mp make_pair
const lli INF = 10e8;
map< char, int > mt;
void chet(int k){
	for (auto it : mt){
		int t = it.second;
		while (k && t>= 4){
			k--; t -= 4;
		}
		mt[it.first] = t;
	}
}
void dv(int k){
	for (auto it : mt){
		int t = it.second;
		while (k && t>= 2){
			k--;
			t -= 2;
		}
		mt[it.first] = t;
	}
}
bool solve()
{

	int n, m;
	cin >> n >> m;
	for (int i(0); i < n; i++){
		for (int j(0); j < m; j++){
			char t; cin >> t;
			mt[t]++;
		}
	}
	if ((n & 1) == 0 && (m & 1) == 0){
		for (auto it : mt){
			if (it.second % 4 != 0){
				cout << "No";
				return 1;
			}
		}
		cout << "Yes";
		return 1;
	}
	if (( n & 1)  && ( m & 1) ){
		chet((n-1)*(m-1)/4);
		dv((n+m-2)/2);
		int sum(0);
		for (auto it : mt){
			sum += it.second;
		}
		if (sum == 1) cout << "Yes"; else cout <<  "No";
		return 1;
	}
	if (( n & 1) == 1 && (m & 1) == 0){
		chet( ((n - 1)*m)/4);
		dv((m)/2);
		for (auto it : mt){
			if (it.second != 0){
				cout << "No";
				return 1;
			}
		}
		cout << "Yes";
		return 1;
	}
	if ((n & 1) == 0 && (m & 1) == 1){
		chet((n*(m - 1)) / 4);
		dv(n / 2);
		for (auto it : mt){
			if (it.second != 0){
				cout << "No";
				return 1;
			}
		}
		cout << "Yes";
	}
	return 1;
}
int main()
{
	solve();
//	while (solve());
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
	int key, id;
} data;

void merge_sort(data x[], int n)
{
	static data y[100001] = {};
	if (n <= 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p].key < x[q].key)? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N, A[100001], B[100001];
	data d[2][100001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%d", &(A[i]));
		d[0][i-1].key = A[i];
		d[0][i-1].id = i;
	}
	for (i = 1; i <= N; i++) {
		scanf("%d", &(B[i]));
		d[1][i-1].key = B[i];
		d[1][i-1].id = i;
	}
	merge_sort(d[0], N);
	merge_sort(d[1], N);
	
	for (i = 0; i < N; i++) if (d[0][i].key > d[1][i].key) break;
	if (i < N) {
		printf("No\n");
		fflush(stdout);
		return 0;
	}
	for (i = 0; i < N - 1; i++) if (d[0][i+1].key <= d[1][i].key) break;
	if (i < N - 1) {
		printf("Yes\n");
		fflush(stdout);
		return 0;
	}
	
	int j, P[100001], flag[100001] = {};
	for (i = 0; i < N; i++) P[d[0][i].id] = d[1][i].id;
	for (i = 1, j = 1, flag[1] = 1; flag[P[i]] == 0; i = P[i], j++) flag[P[i]] = 1; 
	if (j == N) printf("No\n");
	else printf("Yes\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 5500
#include <iostream>
using namespace std;
char d[10050]= {'\0'};
int e[10050]= {0};
int main()
{
    int i,c=0;
    int n,q,a,b;
    cin>>n>>q;
#define N n
#define Q q
    char d[N+1]= {'\0'};
    int e[N+1]= {0};
    cin>>d;
    cin.get();
    for(i=1; i<N+1; i++)
    {
        if((d[i]=='C'&&d[i-1]=='A'))
        {
            c++;
        }
        e[i]=c;
    }
    for(i=0; i<q; i++)
    {
        cin>>a>>b;
        cout<<e[b-1]-e[a-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1280
n, a, b, c = map(int, input().split())
stage = []

for _ in range(n):
    s = input()
    stage.append(s)


var = [a, b, c]

if var.count(0) == 3:
    print('No')
    exit()


d = {"A": 0, "B": 1, "C": 2}
dd = {0: "A", 1: "B", 2: "C"}

ans = []

for i in range(n):
    p = d[stage[i][0]]
    q = d[stage[i][1]]
    r = 3 - p - q
    if var[p] == 0 and var[q] == 0:
        print('No')
        exit()
    elif var[p] == 1 and var[q] == 1 and var[r] == 0:
        if i != n-1:
            pp = d[stage[i+1][0]]
            qq = d[stage[i+1][1]]
            if p not in [pp, qq]:
                var[q] += 1
                var[p] -= 1
                ans.append(dd[q])
            else:
                var[p] += 1
                var[q] -= 1
                ans.append(dd[p])
        else:
            ans.append(dd[p])
    else:
        if var[p] < var[q]:
            var[p] += 1
            var[q] -= 1
            ans.append(dd[p])
        else:
            var[q] += 1
            var[p] -= 1
            ans.append(dd[q])

print('Yes')
for x in ans:
    print(x)


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

int main() {
  int n;
  cin >> n;
  vii a(n, vi(n - 1));
  rep (i, n) {
    rep (j, n - 1) {
      cin >> a[i][j];
      a[i][j]--;
    }
    a[i].push_back(i);
  }

  vi idx(n);
  set<pii> st;
  rep (i, n) {
    int u = i, v = a[i][0];
    if (a[v][0] == u) {
      st.insert(pii(min(u, v), max(u, v)));
    }
  }

  int ans = 0;
  int fin = 0;
  while (fin < n) {
    if (st.size() == 0) {
      cout << -1 << endl;
      return 0;
    }
    //DEBUG_VEC(idx);
    ans++;
    set<pii> st2;
    for (auto itr = st.begin(); itr != st.end(); itr++) {
      pii uv = *itr;
      int u = uv.first, v = uv.second;
      idx[u]++;
      idx[v]++;
      if (idx[u] == n - 1) {
        fin++;
      }
      if (idx[v] == n - 1) {
        fin++;
      }
      
      int au = a[u][idx[u]], av = a[v][idx[v]];
      if (a[au][idx[au]] == u) {
        if (u != au) {
          st2.insert(pii(u, au));
        }
      }
      if (a[av][idx[av]] == v) {
        if (v != av) {
          st2.insert(pii(v, av));
        }
      }
    }
    swap(st, st2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 8192
#include<stdio.h>
int main(void){
    int W,H,x,y,r;
    scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
    int a = W-x-r;
    int b = H-y-r;
    int c = 0+x-r;
    int d = 0+y-r;
    if(a >= 0&&b >= 0&&c >= 0&&d >= 0){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 584
from scipy.misc import comb
mod = 1000000007

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

for i in range(1, K+1):
    blue = K - i
    red = N - K - (i - 1)
    if blue < 0 or red < 0:
        print(0)
    else:
        print(((comb(red+i, i, exact=True) % mod) * (comb(blue+i-1, i-1, exact=True) % mod)) % mod)

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

int main(){
//srandom((unsigned long)time(NULL));

//x K
// K  x
long long n,k;
cin>>n>>k;
if(n%k==0){
    cout<<0<<endl;
    return 0;
}
if(n<(double)k/2){
    cout<<n<<endl;
}
if((double)k/2<=n && n<k){
    cout<<k-n<<endl;
}
if(n>=k){
    long long mn=n%k;
    mn=min(mn,k-mn);
    
    cout<<mn<<endl;
}


return 0;
}

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

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

using namespace std;

int main(void) {
	int N; cin >> N;
	vector<int> X(N);
	double ave = 0;
	int ans = 1e10;

	rep(i, N) {
		cin >> X[i];
		ave += X[i];
	}
	ave /= (double)N;

	for (int i = 1; i <= 100; i++) {
		int sum = 0;
		rep(j, N)sum += pow(X[j] - i, 2);
		ans = min(ans, sum);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int cnt = 0, H[10000], W[10000];
	int i, j, k;
	
	do{
		scanf("%d %d", &H[cnt], &W[cnt]);
		cnt++;
	} while(H[cnt-1] != 0 && W[cnt-1] != 0);
	
	for(i = 0; i < cnt-1; i++) {
		for(j = 0; j < H[i]; j++){
			for(k = 0; k < W[i]; k++) {
				if((j+k)%2 ==0) {
					printf("#");
				} else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}

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

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

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
        return len(self.roots())
 
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

N, M = map(int, input().split())

uf = UnionFind(N)

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.union(a, b)

ans = 0
for r in uf.roots():
    ans = max(ans, uf.size(r))
print(ans)    

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

#define ll long long

using namespace std;

int n, k;
int MOD = 1000000007;
vector<int> d[100000+3];
int p[100000+3];

ll sol = 1;
int main() {
    cin >> n >> k;
    for (int i = 1; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        d[v].push_back(u);
        d[u].push_back(v);
    }
    queue<int> nodes;
    nodes.push(1);
    sol = k;
    while (!nodes.empty()) {
        int x = nodes.front();
        nodes.pop();
        int left;
        if (p[x] == 0)
            left = k - 1;
        else
            left = k - 2;
        for (auto s : d[x]) {
            if (p[s] || s == 1)
                continue;
            p[s] = x;
            sol = (sol * left) % MOD;
            left--;
            nodes.push(s);
        }
    }
    cout << sol;
    return 0;
}


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

using namespace std;

int main(){
   string s; cin>>s;
   int n = (int)s.size(), m = 0;
   vector<int> a(n, 0);
   for (int i=n-1; i>=0; --i){
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'T' || s[i] == 'G'){
        a[i] = 1;
        for (int j = i-1; j>=0; --j){
            if (s[j] == 'A' || s[j] == 'C' || s[j] == 'T' || s[j] == 'G') a[i]++;
            else break;
        }
    }
    m = max(m, a[i]);
   }
   cout<<m;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int k;
char s[105];
int main()
{
	scanf("%d%s",&k,s);
	if(strlen(s)<=k) printf("%s",s);
	else {
		for(int i=0;i<k;++i) putchar(s[i]);
		printf("...");
	}
	return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=200005;
char s[N];
int q[N];
ll ans;
void solve(){
	int cnt=0;
	Rep(i,*q,1)if(q[i]==2)cnt++; else ans+=cnt;
	*q=0;
}
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	For(i,1,n-1)if(s[i]=='A')q[++*q]=1; else {
		if(s[i]=='B'&&s[i+1]=='C'){q[++*q]=2; i++;}
		else {solve();}
	}
	solve();
	cout<<ans<<endl;
}

Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

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

    vector <int> p(M);
    vector <string> S(100001);
    vector <bool> S_bool(100001);
    vector <bool> AC(100001);
    vector <int> WA(100001);
    rep(i,0,M){
        cin>>p[i];
        cin>>S[i];
        if(S[i]=="AC")S_bool[i]=true;
        else S_bool[i]=false;
        AC[i]=false;
    }

    int ans_AC=0 ,ans_WA=0;
    rep(i,0,M){
        if(!AC[p[i]]){
            if(S_bool[i]){
                ans_AC++;
                AC[p[i]]=true;
            }
            else{
                WA[p[i]]++;
            }
        }
    }

    rep(i,0,N){
        if(AC[i+1]){
            ans_WA += WA[i+1];
        }
    }

    cout<<ans_AC<<" "<<ans_WA;

    return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

#define INF 1000000001
#define LINF 1000000000000000001

using namespace std;

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

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

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

int n, a[2001], z, w;

int main(){
	cin >> n >> z >> w;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	int c[2] = {0};
	c[0] = abs(a[n-1] - w);
	if(n > 1) c[1] = abs(a[n-2] - a[n-1]);
	cout << max(c[0],c[1]) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    ll x; cin >> x;
    ll r = 0;
    ll tmp = 0;
    ll res;
    while (true) {
        if ((-r <= x && x <= r)) {
            res = tmp;
            break;
        }
        tmp++;
        r += tmp;
    }
    cout << res << endl;
    return 0;
}

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

int main()
{
  int s;
  map<int, int> mp;
  cin >> s;
  int ans = 0;
  while (1) {
    mp[s]++;
    ans++;
    if(mp[s] == 2) break;
    if(s % 2){
      s = 3 * s + 1;
    }
    else  {
      s /= 2;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
vector< vector<long long int> >v;
vector<long long int>vis;
long long int dist[100002];
long long dfs(long long int i)
{
	
	if(dist[i]!=-1)
	return dist[i];
	for(long long int j=0;j<v[i].size();j++)
	{
		//cout<<v[i][j]<<" ";
		dist[i]=max(dfs(v[i][j])+1,dist[i]);
	}
	if(v[i].size()==0)
	dist[i]=0;
	return dist[i];
}
int main()
{
	ios_base::sync_with_stdio;
	cin.tie(NULL);
	cout.tie(NULL);
	long long int i,j,k,l,m,n,max1=0,ans=0;
	cin>>n>>m;
	v.resize(n+1);
	vis.resize(n+1);
	memset(dist,-1,sizeof(dist));
	vector<long long int >indeg(n+1);
	for(i=0;i<m;i++)
	{
		cin>>j>>k;
		v[j].push_back(k);
		indeg[k]++;
	}
	for(i=1;i<n+1;i++)
	{
		if(indeg[i]==0)
		{
			max1=dfs(i);
			if(ans<max1)
			{
				ans=max1;
			}
		}
	}
//	cout<<endl;
/*	for(i=1;i<n+1;i++)
	{
		cout<<dist[i]<<" ";
			//if(dist[i]>max1)
			//max1=dist[i];
	}*/
	cout<<ans;
	return 0;
}

Measured memory_bytes: 11136
let () = Scanf.scanf "%d\n" @@ fun n ->
  Printf.printf "%d\n" @@ 
  if n mod 2 = 1
  then 0
  else
    List.fold_right (fun d -> ( + ) @@ n / d)
    [ 10; 50; 250; 1250; 6250; 31250; 156250; 781250; 3906250; 19531250;
      97656250; 488281250; 2441406250; 12207031250; 61035156250;
      305175781250; 1525878906250; 7629394531250; 38146972656250;
      190734863281250; 953674316406250; 4768371582031250; 23841857910156250;
      119209289550781250; 596046447753906250; 2980232238769531250 ] 0


Measured memory_bytes: 384
import sys
sys.setrecursionlimit(500000) #これがないと再帰の回数オーバーでエラー出る。

N,M = map(int,input().split())

A = [[] for _ in range(N)]
for i in range(M):
  a,b,c = map(int,input().split())
  a -=1; b-=1
  A[a].append(b)
  A[b].append(a)
#print(A)

reach = [-1 for _ in range(N)] #-1が未到達、1が到達
def dfs(v):
  if reach[v] != -1:
    return
  else:
    reach[v] = 1
  for u in A[v]:
    dfs(u)
    
test = 0    
for i in range(N):
  if reach[i] == -1:
    dfs(i)
    test += 1
print(test)

Measured memory_bytes: 104760
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define inf 10000000
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
int main(){
IOS;
int n,i;
cin>>n;
int a[n+1],dp[n];
dp[n-1]=0;
dp[n]=inf;
for(i=0;i<n;i++){
    cin>>a[i];
}
a[n]=inf;
for(i=n-2;i>=0;i--){
    dp[i]=min(dp[i+1]+abs(a[i]-a[i+1]),dp[i+2]+abs(a[i]-a[i+2]));
}
cout<<dp[0]<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)

const ll MOD = (ll)1e9 + 7;
const ll HIGHINF = (ll)1e18;

const ll MAXN = 200005;

// fac: n!のmod
// finv: 1/n!のmod
// inv: 1/nのmod
vll fac(MAXN), finv(MAXN), inv(MAXN);

void COMinit() {
  fac.at(0) = fac.at(1) = 1;
  finv.at(0) = finv.at(1) = 1;
  inv.at(1) = 1;
  rep(i, 2, MAXN) {
    fac.at(i) = fac.at(i-1) * i % MOD;
    inv.at(i) = MOD - inv.at(MOD%i) * (MOD / i) % MOD;
    finv.at(i) = finv.at(i-1) * inv.at(i) % MOD;
  }
}

ll COM(ll n, ll k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac.at(n) * (finv.at(k) * finv.at(n-k) % MOD) % MOD;
}

int main() {
  ll n, a, b, c; cin >> n >> a >> b >> c;
  COMinit();
  vll powa(2*n+5), powb(2*n+5), powab(MAXN);
  powa.at(0)=1; powb.at(0)=1; powab.at(0)=1;
  rep(i, 1, 2*n+5) {
    powa.at(i) = powa.at(i-1) * a % MOD;
    powb.at(i) = powb.at(i-1) * b % MOD;
  }
  powab.at(0)=1;
  rep(i, 1, MAXN) powab.at(i) = powab.at(i-1) * inv.at(a+b) % MOD;
  ll P = 0;
  rep(m, n, 2*n) {
    //  分子の計算
    ll tmp = COM(m-1, n-1);
    tmp = tmp * (powa.at(n)*powb.at(m-n)%MOD + powa.at(m-n)*powb.at(n)%MOD) % MOD;
    tmp = tmp * powab.at(m+1) % MOD;
    tmp = tmp * m % MOD;
    P = (P + tmp) % MOD;
  }
  P *= 100;
  cout << P % MOD << endl;
  return 0;
}


Measured memory_bytes: 9600
#include <stdio.h>

int main(void){
	int N;
	int i;
	int A,B;
	char S[101];
	scanf("%d",&N);
	scanf("%s",S);

	if(N%2==1) {printf("No\n"); return 0;}

	A=0; B=0;
	for(i=0; i< N/2; i++){
		A += S[i];
	}

	for(i=N/2; i<N; i++){
		B += S[i];
	}

	if(A==B)printf("Yes\n");
	else printf("No\n");

	return 0;
}

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

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

    vector<long long> A(N);
    long long allSum = 0;
    for (int i = 0; i < A.size(); ++i) {
        cin >> A[i];
        allSum += A[i];
    }

    long long pSum = 0, ans = allSum;

    for (int i = 0; i < N; ++i) {
        pSum += A[i];
        ans = min(ans, abs(pSum - (allSum - pSum)));
    }

    cout << ans << endl;
    return 0;
}

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

int main() {
  
  int N;
  cin >> N;
  int j=0;
  int K;
  int KKK=1000000;
  
    while (j<N){
     j++;
     int A;
     cin >> A;
     int T=0;
      
       while (T<30){
         
         if (A%2==1){
          K=T;
          break;
          }
         else{
          T++;
          A/=2;  
          }
         
       }
      
     if (K<=KKK)
      KKK=K;
      
    }
  
  cout << KKK << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>

using namespace std;

int n,pos;
vector<int>pre,in,post;

void rec(int l,int r){
    if(l >= r) return;
    int root = pre[pos++];
    int m = distance(in.begin(),find(in.begin(),in.end(),root));
    rec(l,m);
    rec(m + 1,r);
    post.push_back(root);
}

void solve(){
    pos = 0;
    rec(0,pre.size());
    for(int i = 0;i < n;++i){
        if(i) cout << " ";
        cout << post[i];
    }
    cout << endl;
}


int main(){
    int k;
    cin >> n;
    
    for(int i = 0;i < n;++i){
        cin >> k;
        pre.push_back(k);
    }
    
    for(int i = 0;i < n;++i){
        cin >> k;
        in.push_back(k);
    }
    
    solve();
    return 0;
}



Measured memory_bytes: 3172
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	auto result = A;
	if (A == B)
	{
		result = C;
	}
	else if (A == C)
	{
		result = B;
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
 PROGRAM-ID. TEST108.

 DATA DIVISION.
 WORKING-STORAGE SECTION.

 01 K     PIC 9(3).
 01 SHO   PIC 9(3).
 01 AMARI PIC 9(1).
 01 ANS   PIC ZZZ9.

 PROCEDURE DIVISION.
 
  ACCEPT K.
 
  DIVIDE K  BY 2 GIVING SHO REMAINDER AMARI.
  COMPUTE ANS = SHO * (SHO + AMARI).

  DISPLAY ANS.

 STOP RUN.

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

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

  ll d = 0;
  rep(i, n) { d += a[i]; }

  if (d >= h) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 640
num_array = gets.chomp.to_i
array_to_sort = gets.chomp.split(" ").to_a.map(&:to_i)

flag = 1
count = 0

0.upto (num_array - 1) do |i|
  (num_array - 1).downto(i + 1) do  | j|
    if array_to_sort[j] < array_to_sort[j-1]
      array_to_sort[j], array_to_sort[j-1] =  array_to_sort[j-1], array_to_sort[j]
      count += 1
    end
  end
end

if num_array == 1
  p array_to_sort[0]
else
  array_to_sort.each_with_index do |num, index|
    print num
    break if index == (num_array - 1)
    print (" ")
  end
  print ("\n")
end

p count

Measured memory_bytes: 8716
#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>;

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

int H, W;
void search(int h, int w, vector<vector<int>> &c, vector<vector<bool>> &reached) {
    reached.at(h).at(w) = true;

    for (int direction = 0; direction < 8; ++direction) {
        int nh = h + dx[direction];
        int nw = w + dy[direction];
        if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
        if (c.at(nh).at(nw) == 0) continue;
        if (reached.at(nh).at(nw) == true) continue;
        search(nh, nw, c, reached);
    }
}

int main() {
    while (true) {
        int ans = 0;
        cin >> W >> H;
        if (H == 0 && W == 0) return 0;
        vector<vector<int>> c(H, vector<int>(W));
        vector<vector<bool>> reached(H, vector<bool>(W));
        rep(i,H) rep(j,W) cin >> c.at(i).at(j);

        rep(i,H) rep(j,W) {
            if (c.at(i).at(j) == 1 && reached.at(i).at(j) == false) {
                ++ans;
                search(i, j, c, reached);
            }
        }
        cout << ans << endl;
    }
}




Measured memory_bytes: 3232
#include <iostream>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <vector>
#include <cmath>
#include <cstdint>
#include <string>

using namespace std;

char grade(int m, int f, int r) {
  if (m < 0 || f < 0) {
    return 'F';
  }
  int total = m + f;
  if (80 <= total) {
    return 'A';
  }
  if (65 <= total) {
    return 'B';
  }
  if (50 <= total) {
    return 'C';
  }
  if (30 <= total) {
    if (50 <= r) {
      return 'C';
    }
    return 'D';
  }
  return 'F';
}

int main() {
  while (true) {
    int m, f, r;
    cin >> m >> f >> r;
    if (m < 0 && f < 0 && r < 0) {
      break;
    }
    cout << grade(m, f, r) << endl;
  }
}

Measured memory_bytes: 3064
from sys import stdin
import numpy as np
# import math
# import random
# import fractions
# import sys
# sys.setrecursionlimit(100000)
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]

W, H, x, y = [int(x) for x in stdin.readline().rstrip().split()]
S = W*H/2
frag = 0
if W==2*x and H==2*y:
  frag=1

print(S,frag)

Measured memory_bytes: 20780
#define M_PI 3.14159265358979323846

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

#include <bits/stdc++.h>

#define TASK ""
#define sqr(x) ((x)*(x))
typedef int ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
const ll INFLL = numeric_limits<int>::max();
const ll INFINT = numeric_limits<int>::max();
const ld EPS = 1e-7;
const ll MOD = 1000000000;
const ll MAXN = 223456;

void run()
{
    ll n, l;
    cin >> n >> l;
    vector<ll> mas(n);
    for (int i = 0; i < n; i++)
    {
        cin >> mas[i];
    }
    for (int i = 0; i < n - 1; i++)
    {
        if (mas[i] + mas[i + 1] >= l)
        {
            cout << "Possible" << "\n";
            for (int j = 0; j < i; j++)
            {
                cout << j + 1 << "\n";
            }
            for (int j = n - 1; j > i; j--)
            {
                cout << j << "\n";
            }
            return;
        }
    }
    cout << "Impossible";
}

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

#ifdef LOCAL
//#define STRESS
#ifdef STRESS
    freopen("input.txt", "w", stdout);
    ll N = 10;
    cout << N << endl;
    for (int i = 0; i < N; i++)
        cout << rand() % 30 << " " << rand() % 30 << endl;
    return 0;

#endif
    if (strcmp(TASK, "-") != 0)
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
#else
    if (strcmp(TASK, "")   != 0)
    {
        freopen(TASK".in", "r", stdin)  ;
        freopen(TASK".out", "w", stdout)  ;
    }
#endif
    run();

    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i = 0; i < n; i++){
        cin >> vec[i];
    }
    
    bool flag = 1;
    int sw = 0;
    for(int i = 0; flag; i++){
        flag = 0;
        for(int j = n - 1; j >= i + 1; j--){
            if(vec[j] < vec[j - 1]){
                swap(vec[j], vec[j - 1]);
                flag = 1;
                sw++;
            }
        }
    }
    
    for(int i = 0; i < n; i++){
        if(i) cout << " ";
        cout << vec[i];
    }
    cout << endl;
    cout << sw << endl;
}


Measured memory_bytes: 3088
#include <iostream>

using namespace std;

int main(void)
{
    int x,y;
    
    cin >> x >> y;
    
    if((y-2*x)%2 == 0 && y-2*x>=0 && (4*x-y)%2==0 && 4*x-y>=0) cout << "Yes";
    else cout << "No";
    
    return 0;
}

Measured memory_bytes: 3644
def main():
    n = int(input())
    al = list(map(int, input().split()))
    maxval = max(abs(max(al)), abs(min(al)))
    cost = []
    if len(list(set(al))) == 1 :
        print("0")
    else :
        k = -1
        for i in range(-100,100) :
            k += 1
            cost.append(0)
            for j in range(n) :
                cost[k] = cost[k] + (al[j] - i) ** 2
                #print(cost[i])
        print(min(cost))



if __name__ == '__main__':
    main()


Measured memory_bytes: 9160
#include<bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
static const ull MOD = 1e9 + 7;

int n;
char s[100005];
ull dp[100005][13];

int main()
{
    scanf("%s", s);
    n = strlen(s);
    //cout << "n:" << n << endl;
    dp[0][0] = 1;
    for(int i = 0; i < n; ++i) {

        /*
        for(int j = 0; j < 13; ++j) {
            for(int i = 0; i < n+1; ++i) {
                cout << dp[i][j] << " ";
            }
            cout << endl;
        }
        cout << endl;
        */

        int c;
        if(s[i] =='?') c = -1;
        else c = s[i] - '0';

        for(int j = 0; j < 10; ++j) {
            if(c != -1 && c != j) continue;
            for(int ki = 0; ki < 13; ++ki) {
                dp[i+1][(ki*10 + j)%13] += dp[i][ki];
            }
        }
        for(int j = 0; j < 13; ++j) dp[i+1][j] %= MOD;
    }

    cout << dp[n][5] << endl;
}


Measured memory_bytes: 10496
#include <stdio.h>

int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	
	if(a<b){
	printf("a < b\n");
	}
	else if(a>b){
		printf("a > b\n");
	}
	else{
		printf("a == b\n");
	}
	
	return 0;
}


Measured memory_bytes: 2048
import scala.io.StdIn.readLine

object Main extends App {
  val MOD = 1000000007
  val n = readLine.toInt
  val a = readLine.split(" ").map(_.toLong)

  val s = a.sum
  var cur = 0.toLong
  val t = for(i <- 0 until n - 1) yield {
    cur += a(i)
    cur
  }

  val ans = t.map(x => math.abs(x * 2 - s)).min

  println(ans)
}

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

int main()
{
    ll n;
    cin >> n;
    vector<ll> K(n + 1);

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n / i; j++)
        {
            K[i * j]++;
        }
    }

    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans += K[i] * i;
    }

    cout << ans << endl;
}

Measured memory_bytes: 81328
#include <stdio.h>
int main(void)
{
	int a,b,S,i;
	while(scanf("%d %d",&a,&b) != EOF)
	{
		S = a + b;
		for(i = 0;S != 0;i++){
					S /= 10;
				      }
		printf("%d\n",i);
	}

	return 0;
}

Measured memory_bytes: 600
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    ll n,h,w;
    cin>>n>>h>>w;
    vector<ll> a(w*n+1,0);
    for(int i=0;i<n;i++){
        ll x;
        cin>>x;
        if(i&1){
            a[i*w-x]++;
            a[i*w-x+w]--;
        }
        else{
            a[i*w+x]++;
            a[i*w+x+w]--;
        }
    }
    for(int i=1;i<=w*n;i++){a[i]+=a[i-1];}
    ll count=-1;
    for(auto &i:a){if(i==0){count++;}}
    cout<<count*h<<endl;
    
    return 0;
}



Measured memory_bytes: 3196
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>

const int MAX_N=1000000;

typedef long long ll;

using namespace std;

ll n,dat[2*MAX_N-1];

void init(int n_){
	n=1;
	while(n<n_)n*=2;
	for(int i=0;i<2*n-1;i++)dat[i]=0;
}

void update(int k,ll a){
	k+=n-1;
	dat[k]=a;
	
	while(k>0){
		k=(k-1)/2;
		dat[k]=max(dat[2*k+1],dat[2*k+2]);
	}
}

ll query(int a,int b,int k,int l,int r){
	if(r<=a || b<=l)return 0;
	if(a<=l && r<=b)return dat[k];
	else {
		ll vl=query(a,b,k*2+1,l,(l+r)/2);
		ll vr=query(a,b,k*2+2,(l+r)/2,r);
		return max(vl,vr);
	}
}

int main(void){
	
	ll in,n_,ans=0;
	cin >> n_;
	
	init(n_);
	
	for(int i=0;i<n_;i++){
		cin >> in;
		update(in,in+query(1,in+1,0,0,n));
		ans=max(ans,dat[in+n-1]);
	}
	cout << n_*(n_+1)/2-ans << endl;
	
	return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#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--)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    int N; cin >> N;
    vector<ll> A(N+1), s(N+1);
    rep(i, 1, N+1) cin >> A[i];
    s[0] = 0;
    rep(i, 1, N+1) s[i] = s[i-1] + A[i];
    //rep(i, 0, N+1) cout << s[i];
    ll sum = s[N];
    ll ans = 1e18;
    rep(i, 1, N+1){
        //cout << llabs(sum - 2 * s[i]);
        ans = min(ans, llabs(sum - 2 * s[i]));
    }
    cout << ans << endl;

}

Measured memory_bytes: 3328
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
 
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
 
 
int main()
{
    int n;
    long long int m;
    scanf("%d %lld",&n,&m);
    long long int min=1000000007;
    for(int i=1;i<=sqrt(m);i++)
    {
        if(m%i==0)
        {
            if(i>=n&&i<min)min=i;
            if(m/i>=n&&m/i<min)min=m/i;
        }
    }
    printf("%lld\n",m/min);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int x;
  cin >> x;

  if (x >= 1800)
    cout << 1 << endl;
  else if (x >= 1600)
    cout << 2 << endl;
  else if (x >= 1400)
    cout << 3 << endl;
  else if (x >= 1200)
    cout << 4 << endl;
  else if (x >= 1000)
    cout << 5 << endl;
  else if (x >= 800)
    cout << 6 << endl;
  else if (x >= 600)
    cout << 7 << endl;
  else if (x >= 400)
    cout << 8 << endl;
}


Measured memory_bytes: 3648
import sys
from collections import deque

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def bfs(edges, n_nodes):
    visited = [None] * n_nodes
    visited[0] = "B"
    visited[-1] = "W"

    q = deque([0, n_nodes - 1])

    while q:
        i = q.popleft()

        for j in edges[i]:
            if visited[j] is None:
                visited[j] = visited[i]
                q.append(j)

    return visited


def main():
    N = int(input())
    edges = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        edges[a].append(b)
        edges[b].append(a)

    visited = bfs(edges, N)
    if visited.count("B") > visited.count("W"):
        print("Fennec")
    else:
        print("Snuke")


if __name__ == "__main__":
    main()


Measured memory_bytes: 22268
N,K=map(int,input().split())
wa=0
for i in range(N+1-K):
    n=i+K
    min=(n)*(0+n-1)/2
    max=(n)*(N-n+1+N)/2

    wa=max-min+wa+1


wa=wa+1
wa=wa%(10**9+7)
print(int(wa))


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
#define db(x) cout << #x << " = " << (x) << "\n";
using ll = long long;
using ld = long double;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll n, w;
    cin >> n >> w;
    ll vl_lmt = 1'000 * 102;
    vector<long long> dp(vl_lmt, INT_MAX);
    dp[0] = 0;
    ll wi, vi;
    for (int i = 1; i <= n; i++)
    {
        cin >> wi >> vi;
        for (int j = vl_lmt - vi - 1; j >= 0; j--)
        {
            if (wi + dp[j] <= w && dp[j + vi] > dp[j] + wi)
            {
                dp[j + vi] = dp[j] + wi;
            }
        }
    }
    for (int j = vl_lmt -1; j >= 1; j--)
    {
        if (dp[j] != INT_MAX)
        {
            cout << j;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
n, m = map(int, input().split())
nl = []
ml = []
for _ in range(n):
    nl.append(input())
for _ in range(m):
    ml.append(input())
for i in range(n-m+1):
    for j in range(n-m+1):
        flag = True
        for k in range(0, m):
            for l in range(0, m):
                if nl[i+k][j+l] != ml[k][l]:
                    flag = False
                    break
            if not flag:
                break
        if flag:
            break
    if flag:
        break
print(['No', 'Yes'][flag])



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

int main() {
  int A, B, C, D;
  
  cin >> A >> B >> C >> D;

  if ( (A+B)>(C+D)) {
    cout << "Left" << endl;
  }
  else if ( (A+B)==(C+D)) {
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }
    
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <vector>
#include <iostream>
#include <string>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <ctime>
#include <queue>
#include <deque>
#include <math.h>
#include <cmath>
#include <stack>
#include <algorithm>
#include <list>
#include <array>
#include <valarray>
#include <unordered_map>
#include <cassert>
#include <random>
#include <cstring>

using namespace std;

typedef long long li;

#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define all(a) a.begin(), a.end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

double eps = 1e-5;
const int INF = 1e9 + 7;

const int N = 9e3 + 7;

bool d[N][2 * N];
bool used[N][2 * N];

vector<int> dx, dy;

bool calcX(int i, int x) {
	if (i < 0)
		return false;

	if (used[i][x])
		return d[i][x];

	if (i < 1)
		return false;

	used[i][x] = true;

	if (i == 1)
		d[i][x] = calcX(i - 1, x - dx[i - 1]);
	else
		d[i][x] = calcX(i - 1, x - dx[i - 1]) || calcX(i - 1, x + dx[i - 1]);

	return d[i][x];
}

bool calcY(int i, int y) {
	if (i < 0)
		return false;

	if (used[i][y])
		return d[i][y];

	if (i < 1)
		return false;

	used[i][y] = true;

	d[i][y] = calcY(i - 1, y - dy[i - 1]) || calcY(i - 1, y + dy[i - 1]);

	return d[i][y];
}

int main() {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif

	string s;
	cin >> s;

	int tx, ty;
	cin >> tx >> ty;

	int cur = 0, fl = 1;
	for (auto c : s) {
		if (c == 'F') {
			cur++;
		}
		else {
			if (fl)
				dx.push_back(cur);
			else
				dy.push_back(cur);

			fl ^= 1;
			cur = 0;
		}
	}

	if (cur) {
		if (fl)
			dx.push_back(cur);
		else
			dy.push_back(cur);
	}

	/*for (auto it : dx)
		cout << it << ' ';
	cout << endl;
	for (auto it : dy)
		cout << it << ' ';*/

	d[0][N] = true;
	used[0][N] = true;
	bool x = calcX(dx.size(), tx + N);

	memset(d, false, sizeof(d));
	memset(used, false, sizeof(used));

	d[0][N] = true;
	used[0][N] = true;
	bool y = calcY(dy.size(), ty + N);

	if (x && y)
		cout << "Yes";
	else
		cout << "No";
	cout << endl;
}


Measured memory_bytes: 317816
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int An[] = new int[N];
		for(int i = 0;i < N;i++){//値取得
			An[i] = sc.nextInt();
		}

		System.out.println(solve(N,An));

	}
	
	private static int solve(int N,int[] An){
       		ArrayList<Integer> an = new ArrayList<>();
		for(int a : An){
		an.add(a);
		}
		//Sorting
     		Collections.sort(an);

		//a & b Max 
		int amax = 0 ,bmax = 0;
		for(int i = 0;i < N;i++){
			if(i % 2 == 0){
			amax += an.get(i);
			}else{
			bmax += an.get(i); 
			}
		}
		
		return Math.abs(amax - bmax);
	
	}
}


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

int main()
{

        int A = 0;
        int B = 0;
        int C = 0;
        int D = 0;

        cin >> A;
        cin >> B;

        cin >> C;
        cin >> D;

        int total = 0;

        if (A > B) {
                total = B;
        }
        else {
                total = A;
        }
        if (C > D) {
                total += D;
        }
        else {
                total += C;
        }
        cout << total << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
ll hi[2000005];
ll lo[2000005];
int main(){
   ll n,k;
   ll mod=1e9+7;
   cin>>n>>k;
   for(ll i=1;i<=n+1;i++)lo[i]=lo[i-1]+i,hi[i]=hi[i-1]+(n-i+2);
  // for(ll i=1;i<=n+1;i++)cout<<lo[i]<<" "<<hi[i]<<endl;
   
   
   ll ans=0;
   for(ll i=k;i<=n+1;i++){
   	  ll s=(hi[i]-lo[i]+1ll);
   	  ans=(ans+s)%mod;
   }
   cout<<ans;

   
   
   
  
}


Measured memory_bytes: 6696
#pragma GCC optimize("Ofast")
#include<stdio.h>
int main(void)
{
    int n = 0;
    char c=getchar_unlocked();
    while(c<='9'&&c>='0') {n=(n<<1)+(n<<3)+c-'0'; c=getchar_unlocked();}
    int a = 0, b = 0, e = 0, d = 0;
    while(--n)
    {
        switch(getchar_unlocked())
        {
          case 'A': ++a;break;
          case 'W': ++b;break;
          case 'R': ++d;break;
          default: ++e;getchar_unlocked();
        }
        getchar_unlocked();
        getchar_unlocked();
    }
        switch(getchar_unlocked())
        {
          case 'A': ++a;break;
          case 'W': ++b;break;
          case 'R': ++d;break;
          default: ++e;
        }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d", a, b, e, d);
    return 0;
}


Measured memory_bytes: 1604