akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int gcd(int a, int b){
    while(b != 0){
        int t = a;
        a = b;
        b = t%b;
    }

    return a;
}

int main(void){
    int N, M; cin >> N >> M;
    string S, T; cin >> S >> T;
    
    vector<int> mdiv(N), ndiv(M);
    int n = N / gcd(N, M), m = M / gcd(N, M);
    for(int i=0; i<N; i++) mdiv[i] = 1 + (i * m);
    for(int i=0; i<M; i++) ndiv[i] = 1 + (i * n);

    

    int a = 0, b = 0;
    while(a < N && b < M){
        if(mdiv[a] < ndiv[b]) a++;
        else if(mdiv[a] > ndiv[b]) b++;
        else if(mdiv[a] == ndiv[b]){
            if(S[a] != T[b]){
                cout << -1 << endl;
                return 0;
            }
            a++;
        }
    }

    cout << (ll)N * M / gcd(N, M) << endl;

}

Measured memory_bytes: 1152
// https://atcoder.jp/contests/abc047/tasks/arc063_a
#include <bits/stdc++.h>
using namespace std;

int main() {
    string s;cin>>s;
    int ans=0;
    for(int i=0;i<s.size()-1;i++)
        if(s[i] != s[i+1]) ans++;
    cout<<ans<<"\n";
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define ALL(V) V.begin(), V.end()
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
using PQ = priority_queue<ll, vector<ll>, greater<ll>>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;

int main() {
    ll N;
    cin >> N;
    PQ q;
    for(ll i = 0; i < N; i++) {
        ll A;
        cin >> A;
        q.push(A);
    }
    while(q.size() > 1) {
        ll t = q.top();
        q.pop();
        PQ qq;
        while(q.size()) {
            ll tmp = q.top();
            q.pop();
            tmp %= t;
            if(tmp) qq.push(tmp);
        }
        qq.push(t);
        q = move(qq);
    }
    cout << q.top() << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> table(N);
  for(int i = 0; i < N; i++) { 
    cin >> table.at(i);
  }
  vector<int> &calc = table;
  int sum = 0;
  bool judge = true;
  while(judge == true){
    for(int i = 0; i < N; i++) {
	  if(calc.at(i) % 2 == 0) {
        calc.at(i) /= 2;
      }
      else {
        judge = false;
        break;
      }
    }
    if(judge == true) {
      sum++;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

  int n; cin >> n;
  vector<ll> na(n);
  rep(i, n) {
    int a; cin >> a;
    na[i] = a-(i+1);
  }
  sort(na.begin(), na.end());

  ll mid = na[n/2];
  ll ans = 0;
  rep(i, n) {
    ans += abs(na[i]-mid);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<set>
using namespace std;
int main(){
	multiset<long long int> que;
	long long int n,temp,sum,x,now;
	while(cin>>n,n){
		sum=0;
		while(n-->0){
			cin>>x;
			que.insert(x);
		}
		multiset<long long int>::iterator ite=que.begin();
		temp=*ite;
		ite++;
		now=1;
		while(ite!=que.end()){
			sum+=temp*(que.size()-now);
			temp=*ite;
			ite++;
			now++;
		}
		cout<<sum<<endl;
		que.clear();
	}
	return 0;
}

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

#define debug(x) cout << fixed << #x << " is " << x << endl;
#define ll long long

const int MAX = 200;
const int INF = 10000000;
int dp[MAX][MAX][MAX];

int dp_solve(int a, int b, int c)
{
	if(a == b && b == c)
		return 0;
	if(a > MAX-2 || b > MAX-2 || c > MAX-2)
		return INF;
	if(dp[a][b][c] != -1)
		return dp[a][b][c];
	int Min = INF;
	Min = min(Min, dp_solve(a+2, b, c));
	Min = min(Min, dp_solve(a, b+2, c));
	Min = min(Min, dp_solve(a, b, c+2));
	Min = min(Min, dp_solve(a+1, b+1, c));
	Min = min(Min, dp_solve(a+1, b, c+1));
	Min = min(Min, dp_solve(a, b+1, c+1));
	return dp[a][b][c] = Min + 1;
}

int main()
{
	int A, B, C;
	memset(dp, -1, sizeof(dp));
	scanf("%d %d %d", &A, &B, &C);
	printf("%d\n", dp_solve(A, B, C));
	return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef pair<int,int> pii;
const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int n,m;
    int64_t l;
    cin >> n >> m >> l;
    vector<int64_t> k(n),s(m);
    vector<int64_t> sum(m);
    rep(i,0,n){
        cin >> k[i];
        --k[i];
    }
    rep(i,0,m){
        cin >> s[i];
        sum[i]=s[i];
        if(i>0) sum[i]+=sum[i-1];
    }
    sort(k.begin(),k.end());

    auto calc_sum=[&sum](int l,int r){
        int64_t res=sum[r];
        if(l>0) res-=sum[l-1];
        return res;
    };

    vector<vector<int64_t>> memo(n,vector<int64_t>(n,inf64));
    vector<vector<bool>> done(n,vector<bool>(n));
    function<int64_t(int,int)> rec=[&](int p,int q){
        if(done[p][q]) return memo[p][q];
        done[p][q]=true;
        int next=max(p,q)+1;
        if(next==n-1) return memo[p][q]=calc_sum(k[p],k[n-1])/l+calc_sum(k[q],k[n-1])/l;
        int64_t res=inf64;
        if(p<next) res=min(res,rec(next,q)+calc_sum(k[p],k[next])/l);
        if(q<next) res=min(res,rec(p,next)+calc_sum(k[q],k[next])/l);
        return memo[p][q]=res;
    };
    cout << rec(0,0) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 36644
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=5005;


//统计不合法个数
//必要条件：子树大小为偶数（该点以上的边有可能不合法） 树dp（容斥） 合理嘛

vi g[maxn];
int son[maxn];
int facc[maxn];
int dp[maxn][maxn][2]; 
int f[maxn][2];
void Add(int &x,int y){x+=y;x-=x>=mod? mod:0;}
int MOD(int x){x-=x>=mod? mod:0;return x;}
int Minus(int x){x+=x<0? mod:0;return x;}

void dfs(int u,int fa)
{
    dp[u][1][0]=1; son[u]=1;
    for(auto v:g[u])
    {
        if(v==fa) continue;
        dfs(v,u);
        for(int j=1;j<=son[u];++j)
        {
            f[j][0]=dp[u][j][0], dp[u][j][0]=0;
            f[j][1]=dp[u][j][1], dp[u][j][1]=0;
        }
        for(int j=1;j<=son[u];++j)
            for(int k=1;k<=son[v];++k)
            {
                Add(dp[u][j+k][0],MOD(1ll*f[j][0]*dp[v][k][0]%mod+1ll*f[j][1]*dp[v][k][1]%mod));
				Add(dp[u][j+k][1],MOD(1ll*f[j][0]*dp[v][k][1]%mod+1ll*f[j][1]*dp[v][k][0]%mod));
				Add(dp[u][j][0],MOD(1ll*f[j][0]*facc[k-1]%mod*dp[v][k][1]%mod+1ll*f[j][1]*facc[k-1]%mod*dp[v][k][0]%mod));
				Add(dp[u][j][1],MOD(1ll*f[j][1]*facc[k-1]%mod*dp[v][k][1]%mod+1ll*f[j][0]*facc[k-1]%mod*dp[v][k][0]%mod));
            }
        son[u]+=son[v];
    }
}

int main(){
    int n; cin>>n;
    facc[1]=1;for(int i=3;i<=n;i+=2)facc[i]=1ll*facc[i-2]*i%mod;
    for(int i=1;i<=n-1;++i)
    {
        int x,y; cin>>x>>y;
        g[x].push_back(y); g[y].push_back(x);
    }
    dfs(1,0);
    int ans=0;
	for(int i=2;i<=n;i+=2){
		Add(ans,1ll*dp[1][i][0]*facc[i-1]%mod);
		ans=Minus(ans-1ll*dp[1][i][1]*facc[i-1]%mod);
	}
    print(ans);
    return 0;
}

Measured memory_bytes: 92804
#include<bits/stdc++.h>
using namespace std;
#define ll      long long int
#define pii     pair<ll,ll>
#define vi      vector<ll>
#define mp      make_pair
#define pb      push_back
#define F       first
#define S       second
#define pf(n)   printf("%lld\n",n)
#define sf(n)   scanf("%lld",&n)
#define fast    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x)  x.begin(),x.end()
#define ms(n,i) memset(n,i,sizeof n)
#define sz(x)   (ll)x.size()
#define pi      3.141592653589793238
#define hell    1000000007
#define hell2   1000000009
#define endl    '\n'
#define inf     1e18
#define N       100005

int main()
{
    ll n,w,i,j,k;
    cin>>n>>w;
    vector<pii> v(n);
    ll s=0;
    for(i=0;i<n;i++){
        cin>>v[i].F>>v[i].S;
        s+=v[i].S;
    }
    vi dp(s+1);
    for(i=0;i<=s;i++)dp[i]=inf;
    dp[0]=0;
    for(i=0;i<n;i++){
        for(j=s;j>=v[i].S;j--)
            dp[j]=min(dp[j],dp[j-v[i].S]+v[i].F);
    }
    ll ans=0;
    for(i=0;i<=s;i++){
        //cout<<dp[i]<<" ";
        if(dp[i]<=w)ans=i;
    }
    //cout<<endl;
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b := iScan(), iScan()
	ans := 0
	for i := a; i <= b; i++ {
		x := strconv.Itoa(i)
		if x[0] == x[4] && x[1] == x[3] {
			ans++
		}
	}
	fmt.Println(ans)
}


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

int count1(char* st1,char* st2,char* st3){
  	int num=0;
	for(int i=0;i<2;i++){
      if (*st1 == '#') num++;
      if (*st2 == '#') num++;
      if (*st3 == '#') num++;
      
      ++st1; ++st2; ++st3;
    }
	return num;
}

int count2(char* st1,char* st2,char* st3){
  	int num=0;
	for(int i=0;i<3;i++){
      if (*st1 == '#') num++;
      if (*st2 == '#') num++;
      if (*st3 == '#') num++;
      
      ++st1; ++st2; ++st3;
    }
	return num;
}



int main(){
  int H=0, W=0;
  cin >>H >>W;
  
  string map[H+2]={};
  
  for(int i=1;i<=H;i++){
  cin >>map[i];
  }
  
  
  for(int i=1;i<=H;i++){
    for(int j=0;j<=W;j++){
      int mine=0;
      if(map[i][j]=='.'){
      	if(j==0){
        	mine = count1(&map[i-1][j], &map[i][j], &map[i+1][j]);
        	map[i][j]='0'+mine;
      		}
      	if(j!=0) {
          mine = count2(&map[i-1][j-1], &map[i][j-1], &map[i+1][j-1]);
            map[i][j]='0'+ mine;
      		}
        }
        
    }  
  }
  for(int i=1;i<=H;i++){
  cout <<map[i] <<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<string.h>
#include<math.h>
#include<queue>
#include<cstring>
#include<new>
#include<cmath>
#include<sstream>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define sz size()
#define em empty()
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define sett(a,b) memset(a,b,sizeof(a))
#define copy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n==3||n==5||n==7)cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 256
(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
      (cons (subseq str 0 pos)
            (split x (subseq str (+ pos size))))
      (list str))))

(setq *n* (read))
(setq *ps* (mapcar #'parse-integer (split " " (read-line))))

(defun increasingp (l)
  (let ((delta (if
                (or
                  (and (< (car l) (cadr l)) (< (cadr l) (caddr l)))
                  (and (> (car l) (cadr l)) (> (cadr l) (caddr l)))
                ) 1 0)
        ))
       
    (if (equal (cadddr l) nil)
        delta
        (+ delta (increasingp (cdr l)))
  )))

(print (increasingp *ps*))

Measured memory_bytes: 4200
#include <iostream>

using namespace std;

int main()
{
	int n, h, w;
	cin >> n >> h >> w;
	int a, b;
	int count = 0;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		if (a >= h && b >= w)
			count++;
	}
	cout << count << endl;
	return 0;
}

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

int main(){
	vector<string>t={"maerd"s,"remaerd"s,"esare"s,"resare"s};
	string s;
	cin>>s;
	reverse(s.begin(),s.end());
	int i,j;
	for(i=0,j=0;i<t.size();++i){
		string s2=s.substr(j,t.at(i).size());
		if(s2==t.at(i)){
			j+=t.at(i).size();
			i=-1;
		}
	}
	if(j==s.size())cout<<"YES\n"s;
	else cout<<"NO\n"s;
}

Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <cstdio>
#include  <cstdlib>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <vector>
#include <string>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long lint;
#define SZ(x) ((int)(x).size())
int main()
{
	int a[3];
	int k;
	int max=-1;
	int m_num;
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
		if (max < a[i]) {
			max = a[i];
			m_num = i;
		}
	}
	cin >> k;
	int sum=0;
	for (int i = 0; i < 3; i++) {
		if (i != m_num) sum += a[i];
		else {
			sum += (a[i] * int(pow(2, k)));
		}
	}
	cout << sum << endl;
	
	
	
	return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int diff = Math.abs(a-b);
        if(diff % 2 == 0){
            System.out.println(Math.min(a,b) + diff/2);
        }else{
            System.out.println("IMPOSSIBLE");
        }
        sc.close();

    }

}


Measured memory_bytes: 25812
#include <iostream>
#include <vector>

int main()
{
    const std::string LOWER = "abcdefghijklmnopqrstuvwxyz";
    const std::string UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    char c;
    std::cin >> c;
    for (int index = 0; index < LOWER.length(); ++index)
    {
        if (c == LOWER[index])
        {
            std::cout << 'a';
        }
        else if (c == UPPER[index])
        {
            std::cout << 'A';
        }
    }
}


Measured memory_bytes: 3008
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)

int main() {
	int n; cin >> n;
	int a[3], b[3];
	cin >> a[0] >> a[1] >> a[2] >> b[0] >> b[1] >> b[2];

	vector<ll> dp(n + 1);
	iota(dp.begin(), dp.end(), 0);
	rep(i, 0, n + 1)
		rep(j, 0, 3) 
			if (i >= a[j]) dp[i] = max(dp[i], dp[i - a[j]] + b[j]);

	n = dp[n];
	dp.clear();
	dp.assign(n + 1, 0);
	iota(dp.begin(), dp.end(), 0);
	rep(i, 0, n + 1)
		rep(j, 0, 3)
		if (i >= b[j]) dp[i] = max(dp[i], dp[i - b[j]] + a[j]);
	cout << dp[n] << endl;
	return 0;
}

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

int main()
{
  char c;
  
  cin >> c;
  
  if('a'<= c && c<='z')
    cout << 'a' << endl;
  else
    cout << 'A'<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
const int M = 1e5+10;
int t[M], x[M], y[M];

int main() {
	int n;
	scanf("%d", &n);
	x[0] = 0, y[0] = 0, t[0] = 0;
	for(int i = 1; i <= n; ++ i) {
		scanf("%d%d%d", &t[i], &x[i], &y[i]);
	}
	bool flag = true;
	for(int i = 1; i <= n; ++ i) {
        int tt = t[i] - t[i-1];
		int dis = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]);
		// printf("%d %d\n", dis, t[i]);
		if(dis > tt) flag = false;
		else if((tt-dis)%2) flag = false;
	}
	if(flag) puts("Yes");
	else puts("No");
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
 string S;
  cin>>S;
  string ans="Good";
  for(int i=0;i<3;i++){
   if(S.at(i)==S.at(i+1)){
   ans="Bad"; break;
   }
  }cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
# include <iostream>
using namespace std;
int main(void)
{
	int n,a[300];
	scanf("%d",&n);
	for(int i = 1;i <= n;i++) scanf("%d",&a[i]);
	for(int i = 1;i <= n;i++)
	{
		printf("node %d: key = %d, ",i,a[i]);
		if(i/2 >= 1) printf("parent key = %d, ",a[i/2]);
		if(2*i <= n) printf("left key = %d, ",a[2*i]);
		if(2*i+1 <= n) printf("right key = %d, ",a[2*i+1]);
		printf("\n");
	}
	return 0;
} 


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


bool bingo(vector<vector<bool>> c) {
    for (int i = 0; i < 3; i++) {
        bool bingo = true;
        for (int j = 0; j < 3; j++) {
            if (c[i][j] == false) {
                bingo = false;
            }
        }
        if (bingo) {
            return true;
        }
    }

    for (int j = 0; j < 3; j++) {
        bool bingo = true;
        for (int i = 0; i < 3; i++) {
            if (c[i][j] == false) {
                bingo = false;
            }
        }
        if (bingo) {
            return true;
        }
    }
    if (c[0][0] and c[1][1] and c[2][2]) {
        return true;
    }
    if (c[0][2] and c[1][1] and c[2][0]) {
        return true;
    }
    return false;
}

int main() {
    
    vector<vector<int>> sheet;
    vector<vector<bool>> check;
    for (int i = 0; i < 3; i++) {
        vector<int> v;
        vector<bool> c;
        for (int j = 0; j < 3; j++) {
            int x;
            cin >> x;
            v.push_back(x);
            c.push_back(false);
        }
        sheet.push_back(v);
        check.push_back(c);
    }
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (check[j][k] == false and sheet[j][k] == x) {
                    check[j][k] = true;
                    if (bingo(check)) {
                        cout << "Yes" << endl;
                        return 0;
                    }
                    break;
                }
            }
        }
    }
    cout << "No" << endl;

    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, k, q, a, b, c;
vector<ii> e[N];
ll dist[N];

void dfs(int par, int x, ll sum) {
    dist[x] = sum;
    for (auto [t, w] : e[x]) {
        if (t == par) continue;
        dfs(x, t, sum + w);
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        cin >> a >> b >> c;
        e[a].push_back({b, c});
        e[b].push_back({a, c});
    }
    cin >> q >> k;
    dfs(-1, k, 0);

    for (int i = 0; i < q; ++i) {
        cin >> a >> b;
        cout << dist[a] + dist[b] << endl;
    }
    return 0;
}


Measured memory_bytes: 14544
#include <bits/stdc++.h>
#include <algorithm>  
#include <unordered_set>
#include <cmath>
#define ll long long

using namespace std;

int main() {

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


	string s, t, u;
	int a, b;

	cin >> s >> t;
	cin >> a >> b;
	cin >> u;


	if (u == s) {
		a--;
	}
	else if (u == t) {
		b--;
	}

	cout << a << " " << b << endl;


	

	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

int linear(int);

int s[10001], n;

int main(){
  int i, c = 0, q, t[501];

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d", &s[i]);

  scanf("%d", &q);
  for(i=0; i<q; i++) scanf("%d", &t[i]);

  for(i=0; i<q; i++) c += linear(t[i]);

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

int linear(int key){
  int i = 0;
  s[n] = key;
  while(s[i] != key)
    i++;
  if(i == n) return 0;
  return 1;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B,L;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//const ll MOD = 998244353;
typedef pair<ll,ll> P;

int main() {
    cin>>N;
    vec a(N),b(N);
    rep(i,N) cin>>a[i];
    priority_queue<P> pque;
    rep(i,N) {
        cin>>b[i];
        pque.emplace(b[i],i);
    }
    bool judge = false;
    ll ans = 0;
    while((!judge) && (!pque.empty())){
        P p = pque.top();
        pque.pop();
        if(p.fi > a[p.se]){
            A = p.fi;
            ll nei = (b[(p.se + N - 1) % N] + b[(p.se + 1) % N]);
            M = (a[p.se] >= nei) ? (A - a[p.se])/nei : A/nei;
            M = max(1LL,M);
            A -= M * nei;
            ans += M;
            b[p.se] = A;
            pque.emplace(A,p.se);
            if(A <= 0) judge = true;
        }
    }
    bool bad = false;
    rep(i,pque.size()){
        P p = pque.top();
        pque.pop();
        if(p.fi != a[p.se]) bad = true;
    }
    cout<<(bad ? -1 : ans)<<endl;
}


Measured memory_bytes: 9584
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

# 最短距離
# 素因数分解
N = I()

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

# c = sympy.divisors(N)
c = make_divisors(N)
lenc = len(c)
if (lenc % 2)==0:
    a = c[lenc // 2 - 1]
    b = c[lenc // 2]
else:
    a = c[lenc // 2]
    b = a

print(a + b -2)

#H,N = LI()
#AB = [LI() for _ in range(N)]
#A,B = zip(*AB)
#Ap = np.array(A)
#C = np.zeros(N + 1)

# if ans:
#     print('Yes')
# else:
#     print('No')

Measured memory_bytes: 27440
#include<iostream>
#include<algorithm>
#include<string.h>
#define int long long
using namespace std;
 
int32_t main()
{ int n;
cin >> n;
int arr[n];
for(int i=0; i<n; i++)
{
 
    cin >> arr[i];
}
sort(arr,arr+n);
int ans=0;
ans+=arr[n-1];
int remain=n-2;
int cnt=0;
int j=2;
for(int i=1; i<=remain; i++)
{ if(cnt==2)
{ cnt=0;
j++;
}
ans+=arr[n-j];
cnt++;
}
cout << ans << endl;
 
    }

Measured memory_bytes: 5124
url = "https://atcoder.jp/contests/abc045/tasks/abc045_b"

def main():
    S = {i: list(input()) for i in 'abc'}
    s = 'a'
    while S[s]:
        s = S[s].pop(0)
    print(s.upper())

if __name__ == '__main__':
    main()




Measured memory_bytes: 2940
#if __cplusplus > 199711L      /* C++11 */
#include <unordered_map>
#include <unordered_set>
#include <forward_list>
#include <array>
#endif                         /* C++11 */
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define IOS cin.tie(0);ios::sync_with_stdio(false)
#define M_P make_pair
#define P_B push_back
#define U_B upper_bound
#define L_B lower_bound
#define P_Q priority_queue
#define FIR first
#define SEC second
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZ(x) ((int)(x).size())
#define COUT(x) cout<<(x)<<endl
#define CIN(x) cin>>(x)
#define CIN2(x,y) cin>>(x)>>(y)
#define CIN3(x,y,z) cin>>(x)>>(y)>>(z)
#define CIN4(x,y,z,w) cin>>(x)>>(y)>>(z)>>(w)
#define SCAND(x) scanf("%d",&(x))
#define SCAND2(x,y) scanf("%d%d",&(x),&(y))
#define SCAND3(x,y,z) scanf("%d%d%d",&(x),&(y),&(z))
#define SCAND4(x,y,z,w) scanf("%d%d%d%d",&(x),&(y),&(z),&(w))
#define SCANLLD(x) scanf("%lld",&(x))
#define SCANLLD2(x,y) scanf("%lld%lld",&(x),&(y))
#define SCANLLD3(x,y,z) scanf("%lld%lld%lld",&(x),&(y),&(z))
#define SCANLLD4(x,y,z,w) scanf("%lld%lld%lld%lld",&(x),&(y),&(z),&(w))
#define PRINTD(x) printf("%d\n",(x))
#define PRINTLLD(x) printf("%lld\n",(x))
typedef long long int lli;
using namespace std;

int ctoi(char c)
{
  if( c >= '0' and c <= '9' )
    {
      return (int)(c-'0');
    }

  return -1;
}

int alphabet_pos(char c) 
{
  if( c >= 'a' and c <= 'z' )
    {
      return (int)(c-'a');
    }

  return -1;
}


int alphabet_pos_capital(char c)
{
  if( c >= 'A' and c <= 'Z' )
    {
      return (int)(c-'A');
    }

  return -1;
}


vector<string> split(string str, char ch)
{
  int first = 0;
  int last = str.find_first_of(ch);
  
  if(last == string::npos)
    {
      last = SIZ(str);
    }

  vector<string> result;

  while( first < SIZ(str) )
    {
      string Ssubstr(str, first, last - first);
      result.push_back(Ssubstr);
      first = last + 1;
      last = str.find_first_of(ch, first);

      if(last == string::npos)
	{
	  last = SIZ(str);
	}
    }
  
  return result;
}

/*--------------- the end of the template --------------------*/









int main()
{
  //IOS; /* making cin faster */
  int N;

  SCAND(N);
  
  
  int m = N;
  
  while( m % 2 != 0 or m % N != 0 )
    {
      ++ m;
      
    }

  PRINTD(m);
  
  

}


Measured memory_bytes: 256
package main

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

var (
	BufferSize = 100
)

func readLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func scanStr(sc *bufio.Scanner) string {
	if !sc.Scan() {
		panic(nil)
	}
	return sc.Text()
}

func scanInt(sc *bufio.Scanner) int {
	if !sc.Scan() {
		panic(nil)
	}
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, BufferSize)
	sc.Split(bufio.ScanWords)

	n := scanInt(sc)
	ans := 0

	if n%2 == 0 {
		ans = n/2 - 1
	} else {
		ans = n / 2
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
n = gets.to_i
a = []
n.times { a << gets.to_i }
score = 0
more = a.sort.reverse
less = a.sort
ans = []
i = 0
op_more = 0 # 0のとき左から
op_less = 0 # 0のとき左から
cnt = (n % 2 == 0 ? n : n - 1)
while i < cnt
  if i % 2 == 0
    if op_less == 0
      ans.unshift(less.shift)
    else
      ans.push(less.shift)
    end
    op_less = 1 - op_less
  else
    if op_more == 1
      ans.unshift(more.shift)
    else
      ans.push(more.shift)
    end
    op_more = 1 - op_more
  end
  i += 1
end
if n % 2 == 0
  p ans.each_cons(2).map { |(x, y)| (x - y).abs }.inject(:+)
else
  cands = [ans.dup, ans.dup]
  cands[0].push(more[0])
  cands[1].unshift(more[0])
  p cands.map { |cand| cand.each_cons(2).map { |(x, y)| (x - y).abs }.inject(:+) }.max
end


Measured memory_bytes: 9656
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

ll GCD(ll a, ll b){
	if(b==0) return a;
	else return GCD(b,a%b);
}

int main(){
	ll k; cin >> k;
	ll ans = 0;
	REP(i,1,k+1){
		REP(j,1,k+1){
			REP(l,1,k+1){
				ans += GCD(GCD(i,j),l);
			}
		}
	}
	cout << ans << endl;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    if(a == 1) a += 13;
    if(b == 1) b += 13;

    if(a > b){ cout << "Alice" << endl; }
    else if(b > a){ cout << "Bob" << endl; }
    else{ cout << "Draw" << endl; }

}


Measured memory_bytes: 256
//BISMILLAH
#include <bits/stdc++.h>
using namespace std;
int main(){
    
    cout << setprecision(20);
    cout << fixed;
    double x,y,d,rr;
    int n;
    int cnt = 0;
    cin >> n >> d;
    while(n--){
        cin >> x >> y;
        rr = sqrt((x*x) + (y*y));
        if(rr<=d) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) FOR(i, n, 0);

class UF {

  vector<int> par; // 親
  vector<int> rank; // 深さ

public:

  void init(int n) { // n個で初期化
    for(int i=0;i<n;i++) {
      par.push_back(i);
      rank.push_back(0);
    }
  }

  int find(int x) { // 木の中のxの深さを返す
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
  }

  void unite(int x, int y) { // xとyを統合する
    x = find(x);
    y = find(y);
    if (x == y) return;

    if(rank[x] < rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }

  bool same(int x, int y) { // xとyが等しいかどうか判定する
    return find(x) == find(y);
  }
};


signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, k, l; cin >> n >> k >> l;

  vector<pair<int,int>> a(k);
  vector<pair<int,int>> b(l);
  REP(i, k) cin >> a[i].first >> a[i].second;
  REP(i, l) cin >> b[i].first >> b[i].second;

  UF c, d;
  c.init(n);
  d.init(n);

  REP(i, k) c.unite(a[i].first-1, a[i].second-1);
  REP(i, l) d.unite(b[i].first-1, b[i].second-1);

  vector<pair<int, int>> e;
  map<pair<int, int>, int> f;
  REP(i, n) {
    e.pb(pair<int, int>(c.find(i), d.find(i)));
    f[e[i]]++;
  }

  REP(i, n) {
    cout << f[e[i]] << endl;
  }
}


Measured memory_bytes: 24672
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int age, cost;
    int ans = 0;
    cin >> age >> cost;
    if (age >= 6 && age <= 12) {
        cout << cost / 2 << endl;
    } else if (age < 6) {
        cout << 0 << endl;
    } else {
        cout << cost << endl;
    }
}


Measured memory_bytes: 764
import Data.Bool  (bool)
import Data.Maybe (fromJust)

import qualified Data.List as L

main :: IO ()
main = do
    n  <- read <$> getLine
    ts <- fmap read . words <$> getLine
    as <- fmap read . words <$> getLine
    answer $ solve n ts as

type Answer = Int
answer :: Answer -> IO ()
answer = print

modular = 10 ^ 9 + 7

solve :: Int -> [Int] -> [Int] -> Answer
solve n ts as
    | n == 1       = bool 0 1 $ ts == as
    | incompatible = 0
    | otherwise    = L.foldl ((.) (`mod` modular) . (*)) 1 zs
  where
    zs = reduce $ L.zipWith min ts as
    incompatible = fromJust $ do
        let k = L.maximum ts
        i <- L.elemIndex k ts
        return $ as !! i /= k

    reduce (x0 : xs@(x1 : x2 : _))
      | x0 < x1   =      reduce xs
      | x1 > x2   =      reduce xs
      | otherwise = x1 : reduce xs
    reduce _      = []


Measured memory_bytes: 110972
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(a): return "".join(list(map(str, a)))
 
a,b = rli()
if(a % 3 == 0 or b % 3 == 0 or (a+b)%3 == 0):
    print("Possible")
else:
    print("Impossible")

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

int main()
{
  string s, t;
  cin >> s >> t;

  vector<int> s_array(s.size());
  vector<int> t_array(t.size());

  for (int i = 0; i < s.size(); i++) {
    s_array[i] = s[i] - 'a';
  }

  for (int j = 0; j < t.size(); j++) {
    t_array[j] = t[j] - 'a';
  }

  sort(s_array.begin(), s_array.end());
  sort(t_array.begin(), t_array.end(), greater<int>());

  int small;
  s.size() < t.size() ? small = s.size() : small = t.size();
  // cout << small << endl;

  int yes = 0, equal = 0;
  for (int i = 0; i < small; i++) {
    if (s_array[i] < t_array[i]) {
      yes = 1;
      break;
    } else if (s_array[i] > t_array[i]) {
      break;
    } else {
      equal++;
    } // equalの時は辞書順で次のword
  }

  if (yes == 1 || (equal == small && (s.size() < t.size()))) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int n;
    cin >> n;
    int v[n];
    map<int, int> o, e;
    rep(i, n){
        cin >> v[i];
        if(i%2 == 0){
            if(!e.count(v[i])) e[v[i]] = 1;
            else e[v[i]]++;
        }
        if(i%2 == 1){
            if(!o.count(v[i])) o[v[i]] = 1;
            else o[v[i]]++;
        }
    }
    priority_queue<pii> eve, odd;
    for(auto &x: e){
        eve.push(pii(x.second, x.first));
    }
    eve.push(pii(0, 0));
    for(auto &x: o){
        odd.push(pii(x.second, x.first));
    }
    odd.push(pii(0, 0));
    pii a = eve.top(), b = odd.top();
    eve.pop(), odd.pop();
    if(a.second != b.second){
        cout << n-a.first-b.first << endl;
    }
    else{
        pii c = eve.top(), d = odd.top();
        cout << min(n-a.first-d.first, n-c.first-b.first) << endl;
    }
}

Measured memory_bytes: 6520
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()

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

vector<string> s;
string ans;


bool solve(ll i, ll a, ll b, ll c){
    if(a < 0 || b < 0 || c < 0){ return false; }
    if(i >= s.size()){ return true; }

    if(s.at(i) == "AB"){
        if(solve(i + 1, a - 1, min(b + 1, 2LL), c)){
            ans.push_back('B');
            return true;
        }else if(solve(i + 1, min(a + 1, 2LL), b - 1, c)){
            ans.push_back('A');
            return true;
        }
    }else if(s.at(i) == "BC"){
        if(solve(i + 1, a, min(b + 1, 2LL), c  -1)){
            ans.push_back('B');
            return true;
        }else if(solve(i + 1, a, b - 1, min(c + 1, 2LL))){
            ans.push_back('C');
            return true;
        }
    }else{
        assert(s.at(i) == "AC");
        if(solve(i + 1, min(a + 1, 2LL), b, c - 1)){
            ans.push_back('A');
            return true;
        }else if(solve(i + 1, a - 1, b, min(c + 1, 2LL))){
            ans.push_back('C');
            return true;
        }
    }

    return false;
}

int main(){
    ll n, a, b, c;
    cin >> n >> a >> b >> c;
    s.resize(n);
    REP(i, n){
        cin >> s.at(i);
    }
    a = min(a, 2LL);
    b = min(b, 2LL);
    c = min(c, 2LL);
    if(solve(0, a, b, c)){
        cout << YES << endl;
        for(ll i = n - 1; i >= 0; --i){
            cout << ans.at(i) << endl;
        }
    }else{
        cout << NO << endl;
    }
    return 0;
}


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

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
const dou pi=3.141592653589793;

int main(){
    string s;
    std::cin >> s;
    std::vector<int> a(26);
    rep(i,s.size()){
        a[s[i]-'a']++;
    }
    rep(i,26){
        if(a[i]==0){
            std::cout << char('a'+i) << std::endl;
            exit(0);
        }
    }
    std::cout << "None" << std::endl;
}


Measured memory_bytes: 512
import java.util.Deque;
import java.util.Scanner;
import java.util.ArrayDeque;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Deque<Integer> ad = new ArrayDeque<Integer>();
        int n=sc.nextInt();
        for(int i=1;i<=n;i++){
            if(i%2!=n%2)ad.offerLast(sc.nextInt());
            else{
                ad.offerFirst(sc.nextInt());
            }
        }
        for (Integer num : ad) {
            System.out.print(num+" ");
        }
    }
}

Measured memory_bytes: 96348
#include <bits/stdc++.h>
using namespace std;
#define long long ll
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> data(n);
  REP(i, n) { cin >> data[i]; }
  int ans = INT_MAX;
  FOR(i, 1, 101) {
    int sum = 0;
    REP(j, n) { sum += (data[j] - i) * (data[j] - i); }
    ans = min(ans, sum);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;

int main(){
    string s;
    int i, j;

    while( getline(cin, s) ){
        while(s.find("the") == s.npos && s.find("this") == s.npos && s.find("that") == s.npos){
            for(i = 0; s[i]; i++){
                if(s[i] >= 'a' && s[i] <= 'z')
                    s[i]++;
                if(s[i] == 'z' + 1){
                    s[i] = 'a';
                }
            }
        }
        cout << s << endl;
    }
}

Measured memory_bytes: 1176
#include<stdio.h>
#define N 1000000

int main() {
	int ipt;
	int root;
	int cnt = 0;
	int A[N];
	for (int i = 1; i <= N; i++) {
		A[i] = i;
	}
	for (int pos = 2; pos*pos <= N; pos++) {
		root = A[pos];
		if (!root)continue;
		for (int k = 2; k*root <= N; k++) {
			A[k*root] = 0;
		}
	}

	while(scanf("%d",&ipt)==1) {
		for (int i = 2; i <= ipt; i++) {
			if (A[i] != 0)cnt++;
		}
		printf("%d\n", cnt);
		cnt = 0;
	}

	return 0;
}


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

int main() {
  int n, x, s, ls = 0;
  cin >> n >> x;
  s = n + 1;
  vector<int> l(n);
  for(int i = 0; i < n; i++) {
    cin >> l.at(i);
    ls += l.at(i);
    if(ls > x && s == n + 1)
      s = i + 1;
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

int main() {
    lint mod = 1e+9 + 7;
    int n, m;
    cin >> n >> m;
    vector<int> s(n), t(m);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < m; i++) {
        cin >> t[i];
    }
    // dp[i][j]:右端がs[i-1],t[j-1]なる等しい部分列の数
    vector<vector<lint>> dp(n + 1, vector<lint>(m + 1, 0));
    // sum[i][j]:dp[0][0]~dp[i-1][j-1]の和
    vector<vector<lint>> sum(n + 1, vector<lint>(m + 1, 0));
    dp[0][0] = 1;
    lint ans = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] +
                        dp[i - 1][j - 1];
            sum[i][j] %= mod;
            if (s[i - 1] == t[j - 1]) {
                dp[i][j] = sum[i][j];
            } else {
                dp[i][j] = 0;
            }
            ans += dp[i][j];
            ans %= mod;
        }
    }
    // for (int i = 0; i < n + 1; i++) {
    //    for (int j = 0; j < m + 1; j++) {
    //        cout << dp[i][j] << " ";
    //    }
    //    cout << endl;
    //}
    if (ans < 0) {
        ans += mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 62976
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
ll n;
cin>>n;
ll arr[n+1];
ll fg=0;
for(ll i=0;i<n;i++){
    cin>>arr[i];
if(i%2==0){
    fg+=arr[i];
}
else{
    fg-=arr[i];
}
}
ll m[n+1];
//cout<<fg<<endl;
memset(m,0,sizeof m);
m[0]=fg;
for(ll i=0;i<n-1;i++){
    arr[i]-=m[i]/2;
    m[i+1]=arr[i]*2;
}
for(ll i=0;i<n;i++){
    cout<<m[i]<<" ";
}

}


Measured memory_bytes: 2816
/* AUTHOR: Naman */
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define IOS     ios_base::sync_with_stdio(0); cin.tie(NULL);
const ll N=2*1e6+1;


int main() {
	IOS
    ll t=1;
	//cin>>t;	
	
	for(ll _=1;_<=t;_++)
	{
	   //cout<<"Case #"<<_<<": ";
	    ll i,n;	
	    ll ct=0;
	    cin>>n;
	    
	    while(n--)
	    {
	        ll x,y;
	        cin>>x>>y;
	        if(x==y)ct++;
	        else ct=0;
	        if(ct>=3)
	        {
	            cout<<"Yes";
	            return 0;
	        }
	    }
	    
	    cout<<"No";
	    
	   
	   
	   


	   cout<<endl;
	   
	}
	
    
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long> VLL;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

int main(){
    int n;cin>>n;
    string s;cin>>s;
    int max=-1;
    map<char,int>cnt;
    rep(i,(int)s.size()){
        cnt[s[i]]++;
        map<char,bool>check;
        for(int j=i+1;j<(int)s.size();j++){
            if(cnt[s[j]])check[s[j]]=true;
        }
        if(max<(int)check.size())max=(int)check.size();
    }
    cout<<max<<endl;
}


Measured memory_bytes: 256
N, P = list(map(int, input().split()))

def factorize(n):
    fct = []  
    b, e = 2, 0  
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

re = 1
if N == 1:
    re = P
else:

    f_list = factorize(P)

    for k, n in f_list:
        if n // N > 0:
            re *= k ** (n //N)
        
print(re)

Measured memory_bytes: 3064