akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<algorithm>
#include<vector>
#include<stack>

using namespace std;

int main(){
    int H,W;
    cin>>H>>W;
    string S[22];

    for(int i=0;i<H;i++){
        cin>>S[i+1];
        S[i+1]="#"+S[i+1]+"#";
    }
    S[0]="";
    S[H]="";
    for(int i=0;i<W+10;i++){
        S[0]+="#";
        S[H+1]+="#";
    }

    int ans=0;
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            if(S[i][j]=='.'){
                int a[30][30];
                for(int k=0;k<30;k++){
                    for(int l=0;l<30;l++){
                        a[k][l]=-1;
                    }
                }
                a[i][j]=0;
                int c=0;
                stack<int> sx,sy;
                sx.push(j);
                sy.push(i);
                while(!sx.empty()){
                    int nx=sx.top();
                    int ny=sy.top();
                    sx.pop();
                    sy.pop();
                    int dx[4]={0,0,1,-1};
                    int dy[4]={1,-1,0,0};
                    for(int k=0;k<4;k++){
                        int tx=nx+dx[k];
                        int ty=ny+dy[k];
                        //cout<<ty<<","<<tx<<","<<S[ty][tx]<<endl;
                        if(S[ty][tx]=='.'){
                            if(a[ty][tx]==-1||a[ny][nx]+1<a[ty][tx]){
                                a[ty][tx]=a[ny][nx]+1;
                                sx.push(tx);
                                sy.push(ty);
                            }
                        }
                    }
                }
                for(int k=0;k<30;k++){
                    for(int l=0;l<30;l++){
                        if(a[k][l]!=-1){
                            c=max(c,a[k][l]);
                        }
                    }
                }
                //cout<<i<<","<<j<<","<<c<<endl;
                ans=max(ans,c);
            }
        }
    }
    cout<<ans<<endl;
}


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

const int N = 15, M = 1000, INF = 0x3f3f3f3f;
int n, m;
int du[N];
int dis[N][N];
int dp[1 << 16];
vector<int> v;

inline int nextInt(void) {
	int res;
	scanf("%d", &res);
	return res;
}

inline void addEdge(int x, int y, int w) {
	dis[x][y] = dis[y][x] = min(dis[x][y], w);
	du[x]++;
	du[y]++;
}

inline int getBits(int x) {
	int res = 0;
	for (int i = 0; i < x; i++)
		res |= (1 << i);
	return res;
}

inline void Floyd(void) {
	for (int k = 0; k < n; k++)
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
}

inline int bitAt(int bits, int pos) {
	return (bits >> pos) & 1;
}

inline int chgBits(int bits, int x, int y) {
	bits &= ~((1 << x) | (1 << y));
	return bits;
}

inline int DP(int bits) {
	if (~dp[bits])
		return dp[bits];
	if (!bits)
		return dp[bits] = 0;
	dp[bits] = INF;
	for (int i = 0; i < v.size(); i++)
		for (int j = i; j < v.size(); j++)
			if (i != j && bitAt(bits, i) && bitAt(bits, j))
				dp[bits] = min(dp[bits], DP(chgBits(bits, i, j)) + dis[v[i]][v[j]]);
	return dp[bits];
}

signed main(void) {
	n = nextInt();
	m = nextInt();
	int ans = 0;
	memset(dis, 0x3f, sizeof(dis));
	memset(du, 0, sizeof(du));
	memset(dp, -1, sizeof(dp));
	for (int i = 0; i < m; i++) {
		int x = nextInt();
		int y = nextInt();
		int w = nextInt();
		addEdge(x, y, w);
		ans += w;
	}
	Floyd();
	for (int i = 0; i < n; i++)
		if (du[i] & 1)
			v.push_back(i);
	printf("%d\n", ans + DP(getBits(v.size())));
	return 0;
}

Measured memory_bytes: 1472
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    def select(n,k):
        return math.factorial(n)//(math.factorial(k)*math.factorial(n-k))
    n = I()
    dic = collections.defaultdict(int)
    for _ in range(n):
        s = S()
        if s[0] in {"M","A","R","C","H"}:
            dic[s[0]] += 1

    vlst = [i for i in dic.values() if i!=0]
    ans = 0
    lenth = len(vlst)

    for i in range(lenth):
        for j in range(i+1,lenth):
            for k in range(j+1,lenth):
                ans += select(vlst[i],1)*select(vlst[j],1)*select(vlst[k],1)
    print(ans)
main()            


Measured memory_bytes: 80856
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <regex>
#include <climits>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define forin(i, a) for(auto i: (a))
#define p(...) printf(__VA_ARGS__); cout << endl;
#define in(...) __VA_ARGS__; input__(__VA_ARGS__);
#define input(...) in(__VA_ARGS__)
#define out(...) output__(__VA_ARGS__);
#define output(...) out(__VA_ARGS__)
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](auto const &a, auto const &b){ return c ;}
#define key(t, x, compare) [](const t &a, const t &b){ return a x compare b x ;}
#define unless(a) if(!(a))

using namespace std;

using pii = pair<int, int>;

template <class... T>
void input__(T &...a) {
  for(auto v: {&a...}) {
    cin >> *v;
  }
}

void output__(){
  cout << endl;
}

template <class Head, class... T>
void output__(Head const &v, T const &...a) {
  if(sizeof...(a) == 0) {
    cout << v;
  } else {
    cout << v << " ";
  }
  output__(a...);
}

int main(){
  int in(a, b);
  if (b >= a) {
    out(a);
  } else {
    out(a - 1);
  }
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }

const int maxn = 1e6 + 11;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    string s; cin >> s;
    int n = (int)s.size();

    for (int i = 0; i < n; i++) {
        if (s[i] == '?') s[i] = 'D';
    }

    out(s);
    
    
    return 0;
}


Measured memory_bytes: 4164
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[0].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(tmp[0], 10);
	var b = parseInt(tmp[1], 10);
	var c = parseInt(tmp[2], 10);
	var d = parseInt(tmp[3], 10);
	//出力
	if( (Math.abs(a-c)<=d) || ( (Math.abs(a-b) <= d)&&(Math.abs(b-c)<=d) ) )
	  console.log('Yes');
	else
	  console.log('No');
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
#include <bits/stdc++.h>
using namespace std;
void run_case(){
    string s;
    cin>>s;
    int c = 0;
    int ans = 0;
    for(int i = 0; i< 3; i++){
        if(s[i] == 'R'){
            c++;
        }else{
            c = 0;
        }
        ans = max(c, ans);
    }
    cout<<ans<<"\n";
}
int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    if (fopen("input.in", "r")) 
        freopen("input.in", "r", stdin), freopen("output.out", "w", stdout);
    int t;
    t = 1;
    while(t--){
        run_case();
    }
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
long long a,b;
void yakusuu (int i,int j){
	int I=i;
	int J=j;
	while(i>=0){
	     while(i<j){
		       j=j-i;
	      }
	     while(j<i){
		       i=i-j;
	     }
         if(i==j){
		    cout<<i<<" " ;
		    break;
	     }
	 }
	     cout<<I/i*J<<endl;
}
int main(){
	while(cin>>a>>b){
	    yakusuu(a,b);
    }
	 
}



Measured memory_bytes: 3076
def solve(i, m):
    if m == 0:
        return True
    if n <= i or sum(A) < m:
        return False
    res = (solve(i+1, m) or solve(i+1, m-A[i]))
    return res

n = input()
A = map(int, raw_input().split())
q = input()
M = map(int, raw_input().split())

for m in M:
    if solve(0, m):
        print "yes"
    else:
        print "no"

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

int n_query = 0;

int ask(int y1, int x1, int y2, int x2)
{
	++n_query;
	printf("? %d %d %d %d\n", y1, x1, y2 - 1, x2 - 1);
	fflush(stdout);
	int a;
	scanf("%d", &a);
	return a;
}

int score(int q)
{
	if (q > 2500) return 0;
	if (q >= 930) return max((int)(1e-8 + 125 - 3.2 * sqrt(q - 920)), 40);
	if (q >= 880) return (int)(1e-8 + 288 - 22 * sqrt(q - 870));
	return min(2860 - 3 * q, 300);
}

int H, W, N, K;
int C[50][50];

void solve(int y1, int x1, int y2, int x2, int cnt)
{
	if (y2 - y1 == 1 && x2 - x1 == 1) {
		C[y1][x1] = cnt;
		return;
	}
	if (cnt == 0) return;
	if ((y2 - y1) * (x2 - x1) == cnt) {
		for (int i = y1; i < y2; ++i) {
			for (int j = x1; j < x2; ++j) {
				C[i][j] = 1;
			}
		}
		return;
	}

	if (x2 - x1 == 1) {
		int ym = (y2 + y1) / 2;
		int a = ask(y1, x1, ym, x2);
		solve(y1, x1, ym, x2, a);
		solve(ym, x1, y2, x2, cnt - a);
	} else {
		int xm = (x2 + x1) / 2;
		int a = ask(y1, x1, y2, xm);
		solve(y1, x1, y2, xm, a);
		solve(y1, xm, y2, x2, cnt - a);
	}
}

int main()
{
	scanf("%d%d%d%d", &H, &W, &N, &K);
	solve(0, 0, H, W, N);

	int ret = 0;
	int pw = 1;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			ret += C[i][j] * pw;
			ret %= K;
			pw = pw * 2 % K;
		}
	}
	int aa = ask(0, 0, 20, 20);
	while (score(n_query) > aa) ++n_query;

	printf("! %d\n", ret);
	return 0;
}


Measured memory_bytes: 720
n=list(map(int,input().split()))[0]

dp=[[0]*3 for _ in range(n+1)]
for i in range(1,n+1):
    a,b,c=list(map(int,input().split()))
    dp[i][0]=max(dp[i-1][1]+a,dp[i-1][2]+a)
    dp[i][1]=max(dp[i-1][0]+b,dp[i-1][2]+b)
    dp[i][2]=max(dp[i-1][1]+c,dp[i-1][0]+c)
print(max(dp[-1]))

Measured memory_bytes: 28828
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
vector<vector<pl>> G;
void Dij(ll v,vl &dist){
    dist[v]=0;
    priority_queue<pl,vector<pl>,greater<pl>> que;
    que.emplace(0,v);
    while(que.size()){
        ll d=que.top().fi,v=que.top().se;
        que.pop();
        for(auto nv:G[v]){
            if(dist[nv.fi]>dist[v]+nv.se){
                dist[nv.fi]=dist[v]+nv.se;
                que.emplace(dist[nv.fi],nv.fi);
            }
        }
    }
}
int main(){
    ll N;cin>>N;
    vl dist(N,INF);
    G=vector<vector<pl>>(N,vector<pl>());
    rep(i,N-1){
        ll a,b,c;cin>>a>>b>>c;
        a--,b--;
        G[a].push_back({b,c});
        G[b].push_back({a,c});
    }
    ll Q,K;cin>>Q>>K;
    K--;
    Dij(K,dist);
    rep(i,Q){
        ll x,y;cin>>x>>y;
        x--,y--;
        cout<<dist[x]+dist[y]<<endl;
    }
    return 0;
}

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

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acosl(-1)
#define ld long double
#define prime (1000000000 + 7)
#define INF 1000000000

using namespace std;


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

    string s;
    cin >> s;
    cout << string(s.size(), 'x') << endl;

   
    return 0;
}


/*
    r   o   #   r   o   u   n   d
-1  0   0   0   1   2   0   0   0 
*/
// 1 = 3
// 2 = 3
// 3 = -1
// 4 = 0
// 5 = 1

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

#define pb push_back
#define mp make_pair

#define fi first
#define se second

typedef long long ll;

using namespace std;

char ans[100005];

char s[100005];

int n;

bool ok(int x) {
    int l = (x - 1 + n) % n;
    int r = (x + 1) % n;

    if (ans[x] == 0) {
        if (s[x] == 'o') {
            return ans[l] == ans[r];
        }

        return ans[l] != ans[r];
    }
    else {
        if (s[x] == 'x') {
            return ans[l] == ans[r];
        }

        return ans[l] != ans[r];
    }
}

void solve() {
    scanf("%d", &n);
    scanf("%s", s);

    for (ans[0] = 0; ans[0] < 2; ++ans[0]) {
        for (ans[1] = 0; ans[1] < 2; ++ans[1]) {
            for (int i = 1; i + 1 < n; ++i) {
                if (ans[i] == 0) {
                    if (s[i] == 'o') {
                        ans[i + 1] = ans[i - 1];
                    }
                    else {
                        ans[i + 1] = (ans[i - 1] ^ 1);
                    }
                }
                else {
                    if (s[i] == 'x') {
                        ans[i + 1] = ans[i - 1];
                    }
                    else {
                        ans[i + 1] = (ans[i - 1] ^ 1);
                    }
                }
            }

            if (ok(0) && ok(n - 1)) {
                for (int i = 0; i < n; ++i) {
                    printf(ans[i] ? "W" : "S");
                }

                return;
            }
        }
    }

    printf("-1\n");
}

int main() {
    #ifdef BThero
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // BThero

    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

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


void solve(long long A, long long P){
    cout << (A * 3 + P) / 2 << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
int main(){
    long long A;
    scanf("%lld",&A);
    long long P;
    scanf("%lld",&P);
    solve(A, P);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool is(int n){
    if(n>=1&&n<=9)return true;
    return false;
}
int main(){
    int n,m;
    cin>>n;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define FOR(i,a,b) for(long long int i=a;i<b;i++)
#define sz(s) (long long int)(s).size()
#define pb push_back
#define mp make_pair
const ll inf = 1000000000;
const ll MOD = 1000000007;

int main(void){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
    cout.tie(NULL);
    register ll i,j,k,x,y,m,n,t,q,temp,sum=0,count=0,f=1;
    string s, z;    
    cin>>s>>z;
    n = s.length(), m = z.length();
    ll dp[n+1][m+1];
    for(i=0;i<=n;i++){
    	for(j=0;j<=m;j++){
    		if(i == 0 || j == 0)dp[i][j] = 0;
    		else if(s[i-1] == z[j-1])dp[i][j] = 1 + dp[i-1][j-1];
    		else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    	}
    }
    // for(i=0;i<=n;i++){
    // 	for(j=0;j<=m;j++){
    // 		cout<<dp[i][j]<<" ";
    // 	}
    // 	cout<<"\n";
    // }
    i = n, j = m;
    vector<char> ans;
    while(i != 0 && j != 0){    
    	// cout<<i<<" "<<j<<"\n";
    	if(s[i-1] == z[j-1]){
    		ans.pb(z[j-1]);	
    		i--;
    		j--;    	
    	}
    	else if(dp[i-1][j] > dp[i][j-1])i--;
    	else j--;    	
    }
    for(i=ans.size()-1;i>=0;i--){
    	cout<<ans[i];
    }
    // cout<<dp[n][m];
}    
	

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

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

int main(){
  string S;
  cin>>S;
  bool A[3]={false,false,true};
  map<char,int>m;
  if(S[0]=='A')
    A[0]=true;
  for(int i=2;i<S.size()-1;i++){
    m[S[i]]++;
    if(S[i]=='C')
      S[i]='c';
  }
  if(m['C']==1)
    A[1]=true;
  for(int i=1;i<S.size();i++){
    if(isupper(S[i]))
      A[2]=false;
  }
  if(A[0]&&A[1]&&A[2])
    cout<<"AC"<<endl;
  else
    cout<<"WA"<<endl;


  return 0;
}


Measured memory_bytes: 256
import heapq


def dijkstra(adj, start):
    # adj: [[to, cost] * vertices], 0th index must be empty
    prev = [0] * len(adj)
    dist = [float('inf')] * len(adj)
    dist[start] = 0
    q = []
    heapq.heappush(q, [0, start])
    while q:
        min_dist, v_from = heapq.heappop(q)
        if min_dist > dist[v_from]:
            continue
        v_tos = adj[v_from]
        for v_to in v_tos:
            if min_dist + v_to[1] < dist[v_to[0]]:
                dist[v_to[0]] = min_dist + v_to[1]
                prev[v_to[0]] = v_from
                heapq.heappush(q, [dist[v_to[0]], v_to[0]])
    return dist, prev


N, M = map(int, input().split())
adj = [[] for _ in range(2 * N + 1)]
flg = 1
see = [0] * (N + 1)
for _ in range(M):
    A, B = map(int, input().split())
    adj[A].append([B, 1])
    adj[A].append([B + N, 1])

ans_best = []
len_ans = N+1
for start in range(1, N+1):
    if flg == 0:
        if see[start] == 0:
            continue
    ans = []
    dist, prev = dijkstra(adj, start)
    if dist[start + N] < 10 ** 10:
        k = start + N
        while k != start:
            k = prev[k]
            ans.append(k)
        if len(ans) < len_ans:
            ans_best = ans
            len_ans = len(ans)
            if flg:
                for a in ans:
                    see[a] = 1
                flg = 0

if len_ans == N+1:
    print(-1)
else:
    print(len_ans)
    for a in ans_best:
        print(a)


Measured memory_bytes: 77020
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int main (void) {
	int i, j, n, max, buy, tmp;
	scanf("%d", &n);
	scanf("%d", &buy);
	max = INT_MIN;
	for (i = 1; i < n; i++) {
		scanf("%d", &tmp);
		if (max < tmp - buy) {
			max = tmp - buy;
		}
		if (buy > tmp) {
			buy = tmp;
		}
	}
	printf("%d\n", max);
	return 0;
}


Measured memory_bytes: 1992
// 素因数分解

#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>;

    vector<vector<int>> f;
    vector<vector<ll>> dp;
    vector<int> t(3);

int main(){
    int N,K;
    cin>>N>>K;
    // R,S,P;
    rep(i,3)cin>>t[i];
    string s;
    cin>>s;
    int n=s.size();
    f.resize(K);
    rep(i,n){
        int k=i%K;
        if(s[i]=='s') f[k].push_back(0);
        else if(s[i]=='p') f[k].push_back(1);
        else f[k].push_back(2);
    }
    ll ans=0;
    rep(i,K){
        int n=f[i].size();
        int p=1;
        ans+=t[f[i][0]];
        for(int j=1;j<n;j++){
            if(f[i][j-1]==f[i][j]){
                if(p==0){
                    ans+=t[f[i][j]];
                    p=1;
                }
                else p=0;
            }
            else{
                p=1;
                ans+=t[f[i][j]];
            }
        }
        
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8128
import java.util.*;
 
class Main {
    static Scanner sc;
    static int n, m;
    public static void main(String[] args) {
        sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();

        UnionFindTree uft = new UnionFindTree(n);
        for (int i = 0; i < m; i++) {
            int x, y;
            x = sc.nextInt() - 1;
            y = sc.nextInt() - 1;
            uft.unite(x, y);
        }

        int ans = 0;
        for (int i = 0; i < n; i++) {
            ans = Math.max(uft.getGroupSize(i), ans);
        }
        System.out.println(ans);
    }
}

class UnionFindTree {
    int size;
    int groupNum;
    int[] parents;
    int[] heights;
    int[] groupSizes;
    
    UnionFindTree(int size) {
        parents = new int[size];
        heights = new int[size];
        groupSizes = new int[size];
        for (int i = 0; i < size; i++) {
            parents[i] = i;
            heights[i] = 0;
            groupSizes[i] = 1;
        }
        groupNum = size;
    }

    public void unite(int x, int y) {
        int x_root = findRoot(x);
        int y_root = findRoot(y);

        if (x_root == y_root) {
            return;
        }

        if (heights[x_root] > heights[y_root]) {
            parents[y_root] = x_root;
            groupSizes[x_root] += groupSizes[y_root];
        } else if (heights[x_root] < heights[y_root]) {
            parents[x_root] = y_root;
            groupSizes[y_root] += groupSizes[x_root];
        } else {
            parents[y_root] = x_root;
            heights[x_root]++;
            groupSizes[x_root] += groupSizes[y_root];
        }
        groupNum--;
    }

    public Boolean is_equiv(int x, int y) {
        return findRoot(x) == findRoot(y);
    }

    public int getGroupSize(int x) {
        int root = findRoot(x);
        return groupSizes[root];
    }

    int findRoot(int x) {
        ArrayList<Integer> paths = new ArrayList<Integer>();
        int crt = x;
        while (parents[crt] != crt) {
            paths.add(crt);
            crt = parents[crt];
        }
        for (Integer v: paths) {
            parents[v] = crt;
        }
        heights[crt] = 1;
        return crt;
    }
}

Measured memory_bytes: 52752
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n, k, c; cin >> n >> k >> c;
	c++;
	string s; cin >> s;

	vector<bool> ss(n);
	FOR_LT(i, 0, n) {
		if (s[i] == 'o') {
			ss[i] = true;
		}
	}

	vector<int> bs(n + 2 * c);
	FOR_DW(i, n - 1, 0) {
		if (ss[i]) bs[i + c] = bs[i + c + c] + 1;
		else bs[i + c] = bs[i + c + 1];
	}

	vector<int> fs(n + 2 * c);
	FOR_LT(i, 0, n) {
		if (ss[i]) fs[i + c] = fs[i] + 1;
		else fs[i + c] = fs[i + c - 1];
	}

	FOR_LT(i, 0, n) {
		if (!ss[i]) {
			continue;
		}
		if (fs[i + c - 1] + bs[i + c + 1] != k - 1) {
			continue;
		}
		cout << i + 1 << endl;
	}
	return 0;
}

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

int main(){
    ll n,a,b; cin >> n >> a >> b;
    vector<ll> x(n);
    rep(i,n) cin >> x.at(i);
    ll ans = 0;
    for(int i=1;i<n;i++){
        ans += min(a*(x.at(i)-x.at(i-1)) , b);
    }
    cout << ans << endl;
}

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

using namespace std;

#define ll long long int
#define inf 1e16

const int N=300005;
ll lt[N],rt[N];
ll a[N];


int main() {
   int n;
   cin>>n;
   for(int i=1;i<=n;i++) cin>>a[i];
   memset(lt,0,sizeof(lt));
   memset(rt,0,sizeof(rt));
   for(int i=1;i<=n;i++) lt[i]=lt[i-1]+a[i];
   for(int i=n;i>=1;i--) rt[i]=rt[i+1]+a[i];

   ll ans=inf;
   for(int i=1;i<n;i++) {
     ans=min(ans,abs(lt[i]-rt[i+1]));
   }
   cout<<ans<<endl;

   return 0;
}


Measured memory_bytes: 6784
import sys
N,Y = map(int,input().split())

for A in range(N+1):
  for B in range(N-A+1):
    C=N-A-B
    if (10000*A+5000*B+1000*C==Y):
      print(A,B,C)        
      sys.exit()
print(-1,-1,-1)

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

using namespace std;

typedef long long ll;

const int LGN = 60;
const int Z = 1e9+7;

void addm(int &a, int b) {
    a = a + b >= Z ? a + b - Z : a + b;
}

int main() {
    ios::sync_with_stdio(false);

    ll l, r;
    cin >> l >> r;

    int dp[LGN+1][2][2][2];
    fill(&dp[0][0][0][0], &dp[LGN+1][0][0][0], 0);
    fill(&dp[0][0][0][0], &dp[1][0][0][0], 1);
    for (int i = 1; i <= LGN; i++) {
        bool bl = l >> (i - 1) & 1, br = r >> (i - 1) & 1;
        for (int fl = 0; fl <= 1; fl++) {
            for (int fr = 0; fr <= 1; fr++) {
                for (int sb = 0; sb <= 1; sb++) {
                    if (!(bl && fl)) {
                        addm(dp[i][fl][fr][sb], dp[i-1][fl][br?0:fr][sb]);
                    }
                    if (!sb && !(bl && fl) && !(!br && fr)) {
                        addm(dp[i][fl][fr][sb], dp[i-1][fl][fr][sb]);
                    }
                    if (!(!br && fr)) {
                        addm(dp[i][fl][fr][sb], dp[i-1][!bl?0:fl][fr][0]);
                    }
                }
            }
        }
    }

    cout << dp[LGN][1][1][1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 250

int main(void)
{
	int i, H, id;
	int A[MAX+1];
	
	scanf("%d",&H);
	for(i=1; i<=H; i++) {
		scanf("%d",&A[i]);
	}
	
	for(i=1; i<=H; i++) {
		printf("node %d: key = %d, ", i, A[i]);
		if(i!=1) printf("parent key = %d, ", A[i/2]);
		id = 2*i;
		if(id <= H) printf("left key = %d, ", A[id]);
		id++;
		if(id <= H) printf("right key = %d, ", A[id]);
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N, K;
  cin >> N >> K;
  long ans = 0;
  rep (i, N) {
    long h;
    cin >> h;
    if (h >= K) ans++;
  }
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  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() {
    int n, k; cin >> n >> k;
    map<int, int> m;
    REP(i, n) {
        int tmp;
        cin >> tmp;
        if (m.find(tmp) == m.end()) {
            m[tmp] = 1;
        } else {
            m[tmp]++;
        }
    }
    vector<int> v;
    for (auto p:m) {v.push_back(p.second);}
    sort(ALL(v), greater<int>());
    int res = 0;
    while (v.size() > k) {
        res += v[v.size()-1];
        v.pop_back();
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 10748
#include <stdio.h>

void doit(int n){
	if(n>0){
		int m;
		int i;
		int b;
		int bt;
		int up=0;
		int dw=0;
		scanf("%d",&m);
		scanf("%d",&bt);
		for(i=1;i<m;i++){
			scanf("%d",&b);
			if(b>bt){
				if(up<(b-bt)){
					up=b-bt;
				}
			}
			else if(b<bt){
				if(dw<(bt-b)){
					dw=bt-b;
				}
			}
			bt=b;
		}
		printf("%d %d\n",up,dw);
		doit(n-1);
	}
}

int main(void) {
	int n;
	scanf("%d",&n);
	doit(n);
	return 0;
}

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

int main() {
  int N;
  string S;
  bool Check = true;
  cin >> N;
  
  for (int i = 0; i < N; i++){
    cin >> S;
      if(S == "Y"){
        Check = false;
        break;
      }
	}
	if (Check == false){
      cout << "Four" << endl;
    }else{
      cout << "Three" << endl;
    }
}      

Measured memory_bytes: 3628
#include <unistd.h>
#include <stdlib.h>

void writing(int ans)
{
    char c;
    if (ans < 10)
    {
        c = ans + '0';
        write(1, &c, 1);
    }
    else
    {
        writing(ans / 10);
        writing(ans % 10);
    }
}

int get_num(char *s)
{
    int num;
    int i;
    
    i = -1;
    while (s[++i] != 10)
    {
        if (s[i] != 32)
        {
            num = 0;
            while ('0' <= s[i] && s[i] <= '9')
            {
                num = num * 10 + s[i++] - '0';
                    
            }
            return (num);
        }
    }  
}

void get_nums(int *array, char *s, int count)
{
    int num;
    int i;
    
    i = -1;
    while (s[++i])
    {
        if (s[i] != 10 && s[i] != 32)
        {
            num = 0;
            while ('0' <= s[i] && s[i] <= '9')
            {
                num = num * 10 + s[i++] - '0';
                if (!s[i])
                {
                    array[count] = num;
                    return ;                    
                }
            }
            array[count++] = num;
            i--;
        }
    }  
}

void get_num_plus(int *tab, char *tmp, int pass_flag, int count)
{
    int i;
    
    i = -1;
    while (count < pass_flag)
    {
        while (tmp[++i] != 10)
            ;
        count++;
    }
    get_nums(tab, &tmp[++i], 0);
}

void get_ans(int n, char *tmp)
{
    int i;
    int j;
    int tab[n];
    int count;
    
    get_num_plus(tab, tmp, 1, 0);
    count = 0;
    j = 0;
    i = -1;
    while (++i < n)
    {
        count++;
        if (tab[j] == 2)
        {
            writing(count);
            return ;
        }
        j = tab[j] - 1;
    }
    write(1, "-1", 2);
}

char *create_array(char *s, char *new_arr, char *t, int size)
{
    int i;
    int j;
    
    i = -1;
    while (s[++i])
        new_arr[i] = s[i];
    free(s);
    j = 0;
    while (j < size)
        new_arr[i++] = t[j++];   
    new_arr[i] = 0;
    return (new_arr);
}

char *get_data(char *s)
{
    int size;
    int sum_size;
    char t[10000000];
    char *new_arr;
    
    sum_size = 0;
    while ((size = read(0, t, 10000000)))
    {
        if (size == -1)
            return (NULL);
        sum_size += size;
        if (!(new_arr = (char*)malloc(sum_size + 1)))
            return (NULL);
        s = create_array(s, new_arr, t, size);
    }
    return (s);
}

int main(void){
    int num;
    char *s;
    
    s = malloc(1);
    s = get_data(s);
    num = get_num(s);
    get_ans(num, s);
    free(s);
    return (0);
}


Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

int cnt = 0;

void merge(vector<int>& S, int left, int mid, int right)
{
    int n_1 = mid - left;
    int n_2 = right - mid;

    vector<int> L = vector<int>(n_1 + 1);
    vector<int> R = vector<int>(n_2 + 1);

    copy(S.begin() + left, S.begin() + mid, L.begin());
    L[n_1] = INT_MAX;
    copy(S.begin() + mid, S.begin() + right, R.begin());
    R[n_2] = INT_MAX;

    int i, j, k;
    for (i = 0, j = 0, k = left; k < right; k++){
        if (L[i] < R[j]) S[k] = L[i++];
        else S[k] = R[j++];
    }

    cnt += right - left;
}

void merge_sort(vector<int>& S, int left, int right)
{
    if (left + 1 < right){
        int mid = (left + right) / 2;

        merge_sort(S, left, mid);
        merge_sort(S, mid, right);
        merge(S, left, mid, right);
    }
}

int main()
{
    int n;
    vector<int> S;

    cin >> n;
    S = vector<int>(n);
    for (int i = 0; i < n; i++) cin >> S[i];

    merge_sort(S, 0, n);

    bool first = true;
    for (int num : S){
        if (first)  first = false;
        else printf(" ");

        printf("%d", num);
    }
    cout << endl;

    cout << cnt << endl;

    return 0;
}




Measured memory_bytes: 6772
import math
A,B,H,M=map(int,input().split())

dA=(60*H+M)/2
dB=6*M
rad=dA-dB

C=math.radians(rad)

c=(A**2+B**2-2*A*B*math.cos(C))**0.5
print(format(c,'.10f'))


Measured memory_bytes: 9508
read n k

for i in `seq "$k"`
do
	read
	read -a "a${i}s"
done

result=(`seq "$n"`)

for i in `seq "$k"`
do
	temp=a${i}s[@]

	# ${result[@]} \= ${!temp}
	for j in "${!temp}"
	do
		for k in "${!result[@]}"
		do
			if [[ "${result[k]}" = "$j" ]]; then
				unset result[k]
			fi
		done
	done
done

echo "${#result[@]}"

Measured memory_bytes: 4632
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdlib>
using namespace std;

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

	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; ++i) cin >> h[i];

	vector<int> dp(n);
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; ++i) {
		dp[i] = min(dp[i-2] + abs(h[i] - h[i-2]), dp[i-1] + abs(h[i] - h[i-1]));
	}
	cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
bool MM(int j);
int main()
{

    string s;
    cin >> s;
    int i = stoi(s);

    bool a = MM(i/100);
    bool b = MM(i%100);
    if(a){
        if(b){
            cout << "NA\n";
        }
        else{
            cout << "YYMM\n";
        }
    }
    else{
        if(b){
            cout << "MMYY\n";
        }
        else{
            cout << "AMBIGUOUS\n";
        }
    }


    return 0;

}
bool MM(int j)
{
    if(j<=0||j>=13){
        return true;
    }
    return false;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

// 最後に注文する料理は注文する料理の中で最も所要時間が長いものにするのが最適

int N, T, A[3000], B[3000];
pair<int, int> a[3000];

int dp[3001][3001];
int solve(int n, int t){
    if(n == N) return 0;
    if(t >= T) return 0;
    if(dp[n][t] != -1) return dp[n][t];
    return dp[n][t] = max(solve(n+1, t), solve(n+1, t+a[n].first) + a[n].second);
}

signed main(){
    cin >> N >> T;
    rep(i, N){
        cin >> A[i] >> B[i];
        a[i] ={ A[i], B[i] };
    }
    sort(a, a+N);
    memset(dp, -1, sizeof(dp));
    cout << solve(0, 0) << endl;
}

Measured memory_bytes: 35712
fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(" ").map(String::toInt)
    val grid = Array(h) { readLine()!! }

    for (y in 0 until h) {
        for (x in 0 until w) {
            val left = x - 1
            val right = x + 1
            val up = y - 1
            val down = y + 1

            if (grid[y][x] != '#') {
                continue
            }

            if (0 <= left && grid[y][left] == '#') {
                continue
            }
            if (right < w && grid[y][right] == '#') {
                continue
            }

            if (0 <= up && grid[up][x] == '#') {
                continue
            }

            if (down < h && grid[down][x] == '#') {
                continue
            }

            println("No")
            return
        }
    }
    println("Yes")

}

Measured memory_bytes: 37860
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int n;
  std::cin >> n;

  std::vector<int> p(n);
  for (int i = 0; i < n; ++i)
    std::cin >> p[i];

  // Main
  int res = 0;
  for (int i = 0; i < n - 2; ++i) {
    if (p[i] < p[i + 1] and p[i + 1] < p[i + 2]) {
      res++;
      continue;
    }
    if (p[i] > p[i + 1] and p[i + 1] > p[i + 2]) {
      res++;
      continue;
    }
  }

  // Output
  std::cout << res << std::endl;

  return 0;
}


Measured memory_bytes: 256
import math
t = 1
for tc in range(t):
    n = int(input())
    arr =  []
    for i in range(n):
        lst = list(map(int, input().split()))
        # print(n1,n2)
        arr.append(lst)
        # print(arr)
    # print(arr)
    ans = False
    for i in range(n-2):
        if arr[i][0] == arr[i][1] and arr[i+1][0] == arr[i+1][1] and arr[i+2][0] == arr[i+2][1] :
            ans = True
            break
    if ans == True:
        print("Yes")
    else:
        print("No")
        

    
    


Measured memory_bytes: 9068
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int n = in.nextInt();
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < n; i++) {
            int x = in.nextInt();
            min = Math.min(min, x);
            max = Math.max(max, x);
        }

        out.println(max - min);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }

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

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 21204
#include<stdio.h>

int main(void)
{
  int a,b;

  while( scanf("%d", &a)!=EOF){
    scanf("%d", &b);

    if(a+b<10)
      printf("1\n");
    else if(a+b<100)
      printf("2\n");
    else if(a+b<1000)
      printf("3\n");
    else if(a+b<10000)
      printf("4\n");
    else if(a+b<100000)
      printf("5\n");
    else if(a+b<1000000)
      printf("6\n");
    else
      printf("7\n");
  }
  return 0;
}
   

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

const ll INF = 1LL<<60;

int main() {
    string s;
    cin >> s;
    int L = s.size();

    int ans = 1;
    for(int i = L - 2; i > 0; i--) {
        if((i + 1) % 2 != 0) continue;
        int half = (i + 1) / 2;
        if(s.substr(0, half) == s.substr(half, half)) ans = max(ans, i + 1);
    }

    cout << ans << endl;

    return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(string N){
    if (N[0] == '7' || N[1] == '7' || N[2] =='7') cout << YES << endl;
    else cout << NO << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    string N;
    cin >> N;
    solve(N);
    return 0;
}

Measured memory_bytes: 3632
N,T=map(int,input().split())
C=1000
X=0
for i in range(N) :
  A,B=map(int,input().split())
  if A<=C and B<=T :
    C=A 
    X=B 
if X==0 :
  print("TLE")
else :
  print(C)
  

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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;



int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,m;
	cin >> n >>m;
	vector<deque<int>> a(n,deque<int>(m));
	rep(i,n) rep(j,m){ cin >>a[i][j]; a[i][j]--;}
	set<int> st;
	
	int ans = n;
	while(1){
		VI ct(m+2,0);
		rep(j,n){
			ct[a[j][0]]++;
		}
		int cm=0,ci=-1;
		rep(j,m) if(cm < ct[j]){ cm=ct[j], ci=j;}
		if(cm<1) break;
		ans = min(ans,  cm );
		st.insert(ci);
		//printf("%d:%d ",ci,cm);
		rep(j,n){
			if(sz(a[j]) && a[j][0] == ci)  a[j].pop_front();
			while(sz(a[j]) && st.count(a[j][0]))   a[j].pop_front();
			if(sz(a[j]) < 1) goto ggggg;
		}
		
		//puts("");rep(i,n){ rep(j,sz(a[i])) printf("%d ", a[i][j]);puts("");}
		//puts("");
	}
	ggggg:;
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 768
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
nm=list(map(int, input().split()))
a=list(map(int, input().split()))
n=nm[0]
m=nm[1]
b=0
c=a[0]
dnum=0
while c%2==0:
    dnum+=1
    c=c//2
for i in range(len(a)):
    c=a[i]
    dnum1=0
    while c%2==0:
        dnum1+=1
        c=c//2
    #print(dnum)
    if dnum1!=dnum:
        b=1
        break

#print(a)
if b==1:
    print(0)
else:
    for i in range(len(a)):
        a[i]=a[i]//2
    #print(a)
    amc=lcm_list(a)
    #print(amc)
    # version3.5にてgcdがfractionsからmathに移動した
    print(int((m+amc)/(2*amc)))



Measured memory_bytes: 16348
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#define NUM 10010
using namespace std;

int main(void){
    int a_end = 0;
    int b_end = 0;
    int ab_end = 0;
    int sum = 0;

    int N;
    scanf("%d", &N);

    vector<string> S(N);
    for(int i = 0; i < N; i++){
        cin >> S[i];
    }

    for(int i = 0; i < N; i++){
        if(S[i][0] == 'B'){
            if(S[i][S[i].size()-1] == 'A'){
                ab_end++;
            }else{
                b_end++;
            }
        }else{
            if(S[i][S[i].size()-1] == 'A'){
                a_end++;
            }else{

            }
        }
        for(int j = 0; j < S[i].size() - 1; j++){
            if (S[i][j] == 'A' && S[i][j + 1] == 'B'){
                sum++;
            }
        }
    }

    int x = ab_end;
    int y = a_end;
    int z = b_end;

   if(x == 0){
      if(y == 0 || z == 0){
        sum = sum;
      }else{
          sum = sum + min(y , z);
      }
      
   }
   
   else{
    if(y == 0 || z == 0){
        if (y == 0 && z == 0){
        sum = sum + x - 1;
        }
        else{
        sum = sum + x; 
        }
    }
    else{
    sum = sum + x + 1 + min(y - 1, z - 1); 
    }
   }
    printf("%d\n", sum);
}



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

int min(int x, int y)
{
  if (x <= y)
    return x;
  else
    return y;
}

int gt(const void *p, const void *q)
{
  if (*(long long*)q < *(long long*)p)
    return -1;
  else if (*(long long*)q == *(long long*)p)
    return 0;
  else
    return 1;
}

int main(void)
{
  int i, j, x, y, z, k;
  static long long as[1000], bs[1000], cs[1000], abs[1000000], abcs[3000000];

  scanf("%d %d %d %d\n", &x, &y, &z, &k);
  for(i = 0; i < x; i++)
    scanf("%lld ", &as[i]);
  for(i = 0; i < y; i++)
    scanf("%lld ", &bs[i]);
  for(i = 0; i < z; i++)
    scanf("%lld ", &cs[i]);

  for(i = 0; i < x; i++)
    for(j = 0; j < y; j++)
      abs[i + x * j] = as[i] + bs[j];

  qsort(abs, x * y, sizeof(long long), gt);

  for(i = 0; i < min(k, x * y); i++)
    for(j = 0; j < z; j++)
      abcs[z * i + j] = abs[i] + cs[j];

  qsort(abcs, min(k, x * y) * z, sizeof(long long), gt);

  for(i = 0; i < k; i++)
    printf("%lld\n", abcs[i]);

  return 0;
}


Measured memory_bytes: 54900
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int main(){
    int a[] = {1,3,1,2,1,2,1,1,2,1,2,1};
    int x, y;
    cin >> x >> y;
    x--; y--;
    string ans = "No";
    if(a[x] == a[y]) ans = "Yes";
    cout << ans << endl;
    return 0;
}


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

int main() {
  int A1, A2, A3;
  
  cin >> A1 >> A2 >> A3;
  if (A1 + A2 + A3 >= 22) cout << "bust" << endl;
  else if (A1 + A2 + A3 <= 21) cout << "win" << endl;
}

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

int main() {
    cin.tie(NULL);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    vector<bool> v(26,false);//97
    for(char i:s){
        v[int(i-'a')]=true;
    }
    for(int i=0;i<26;i++){
        if(!v[i]){
            cout<<char(97+i);
            break;
        }
        else if(i==25){
            cout<<"None";
        }
    }
    return 0;
}

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

int main(){
  int N;  //餅の枚数
  cin >> N;
  
  vector <int> d(N,0); //餅iの直径
  for (int i=0; i<N; i++){
    cin >> d.at(i);
  }

  int maisu = 0;
  int Maxd;    // 最大の直径
  int Maxpos;  // その位置

  for (int i=0; i<N; i++){
    Maxd = 0;
    Maxpos = 0;
    for (int j=0; j<N; j++){
      if (d.at(j) > Maxd){
        Maxd = d.at(j);
        Maxpos = j;
      }
    }
    if (Maxd > 0){
      maisu += 1;
    }
    for (int j=0; j<N; j++){
      if(d.at(j) == Maxd){
        d.at(j) = 0;
      }
    }
  }

  cout << maisu << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int cmp( const void *p, const void *q ) {
    return *(int*)p - *(int*)q;
}
int main(void) {
	int l[3];
	int n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++) {
		scanf("%d %d %d",&l[0],&l[1],&l[2]);
		qsort(l,3,sizeof(int),cmp);
		if(!(l[0]*l[0]+l[1]*l[1]-l[2]*l[2])) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 584