akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 100010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int X,n,Q;

int R[maxn],c[maxn],l[maxn],r[maxn];

void Work(){
	read(Q);
	while(Q--){
		int t,a;
		read(t,a);
		int x=upper_bound(R+1,R+n+1,t)-R-1;
		int ans=a+c[x];
		ans=min(ans,r[x]);ans=max(ans,l[x]);
		if(x&1)ans+=t-R[x];else ans-=t-R[x];
		ans=min(ans,X);ans=max(ans,0);
		iout(ans);
	}
}

void Init(){
	read(X);
	read(n);
	REP(i,1,n)read(R[i]);
	l[0]=0;r[0]=X;c[0]=0;
	REP(i,1,n){
		int t;
		if(i&1)t=-1;else t=1;
		t*=(R[i]-R[i-1]);
		c[i]=c[i-1]+t;c[i]=min(c[i],X);c[i]=max(c[i],-X);
		l[i]=l[i-1]+t;l[i]=min(l[i],X);l[i]=max(l[i],0);
		r[i]=r[i-1]+t;r[i]=min(r[i],X);r[i]=max(r[i],0);
	}
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 2816
package main

import "fmt"

func main() {
	var n, m, q int
	fmt.Scan(&n, &m, &q)

	c := make([][]int, n)
	for i := 0; i < m; i++ {
		var l, r int
		fmt.Scan(&l, &r)
		if c[l-1] == nil {
			c[l-1] = make([]int, n)
		}
		c[l-1][r-1]++
	}

	s := make([][]int, n)
	for i := 0; i < n; i++ {
		s[i] = make([]int, n+1)
		s[i][0] = 0
		for j := 0; j < n; j++ {
			if c[i] == nil {
				continue
			}
			s[i][j+1] = s[i][j] + c[i][j]
		}
	}

	for i := 0; i < q; i++ {
		var l, r, x int
		fmt.Scan(&l, &r)
		for j := l - 1; j < r; j++ {
			x += s[j][r] - s[j][l-1]
		}
		fmt.Println(x)
	}
}

Measured memory_bytes: 6784
#include<iostream>
using namespace std;
int main() {
	int n;
	while (cin >> n&&n != 0) {
		int a[5],d[5];
		a[0] = n;
		bool b[3];
		fill(b, b + 3, false);
		b[n - 1] = true;
		for (int i = 1; i < 5; i++) {
			cin >> n;
			a[i] = n;
			b[n - 1] = true;
		}
		int c = 0;
		for (int i = 0; i < 3; i++ ) {
			if (b[i]) c++;
		}
		if (c == 1||c==3) {
			for (int i = 0; i < 5; i++) 
				d[i] = 3;
		}
		else {
			if (b[0] && b[1]) {
				for (int i = 0; i < 5; i++) {
					if (a[i] == 1) d[i] = 1;
					else d[i] = 2;
				}
			}
			else if (b[0] && b[2]) {
				for (int i = 0; i < 5; i++){
					if (a[i] == 1) d[i] = 2;
					else d[i] = 1;
				}
			}
			else if (b[2] && b[1]) {
				for (int i = 0; i < 5; i++) {
					if (a[i] == 2) d[i] = 1;
					else d[i] = 2;
				}
			}
		}
		for (int i = 0; i < 5; i++) {
			cout << d[i] << endl;
		}
	}
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
int main(){
  ll n;
  cin >> n;
  
  vector<string>vec;
  rep(a,4){
    rep(b,4){
      rep(c,4){
        rep(d,4){
          rep(e,4){
            rep(f,4){
              rep(g,4){
                rep(h,4){
                  rep(i,4){
                    string s = "";

                    if(a==0)s+="";
                    if(a==1)s+="3";
                    if(a==2)s+="5";
                    if(a==3)s+="7";

                    if(b==0)s+="";
                    if(b==1)s+="3";
                    if(b==2)s+="5";
                    if(b==3)s+="7";
                  
                    if(c==0)s+="";
                    if(c==1)s+="3";
                    if(c==2)s+="5";
                    if(c==3)s+="7";

                    if(d==0)s+="";
                    if(d==1)s+="3";
                    if(d==2)s+="5";
                    if(d==3)s+="7";

                    if(e==0)s+="";
                    if(e==1)s+="3";
                    if(e==2)s+="5";
                    if(e==3)s+="7";

                    if(f==0)s+="";
                    if(f==1)s+="3";
                    if(f==2)s+="5";
                    if(f==3)s+="7";
                  
                    if(g==0)s+="";
                    if(g==1)s+="3";
                    if(g==2)s+="5";
                    if(g==3)s+="7"; 
                    
                    if(h==0)s+="";
                    if(h==1)s+="3";
                    if(h==2)s+="5";
                    if(h==3)s+="7";
                    
                    if(i==0)s+="";
                    if(i==1)s+="3";
                    if(i==2)s+="5";
                    if(i==3)s+="7";
                    if(s=="")continue;
                    if(stoll(s)<=n) vec.push_back(s);
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  sort(vec.begin(),vec.end());
  vec.erase(unique(vec.begin(),vec.end()),vec.end());
  ll m = vec.size();
  ll ans = 0;
  rep(i,m){
    string t = vec[i];
      int three=0,five=0,seven=0;
      bool ok = false;
      rep(j,t.size()){
        if(t[j]=='3'&&three==0)three++;
        if(t[j]=='5'&&five==0)five++;
        if(t[j]=='7'&&seven==0)seven++;
        if(three+five+seven==3){
          ok = true;
          break;
        }
      }
      if(ok && stoll(t)<=n){
        ans++;  
        
      }
  }
  cout << ans << endl;
}

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

int main() {
  int n=4;
  char c[n];
  for(int i=0;i<n;i++){
    cin >> c[i];
  }
  std::string ans="No";
  if(c[0]==c[1]&&c[2]==c[3]&&c[0]!=c[2])ans="Yes";
  if(c[0]==c[2]&&c[1]==c[3]&&c[0]!=c[1])ans="Yes";
  if(c[0]==c[3]&&c[2]==c[1]&&c[0]!=c[2])ans="Yes";
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <cassert>
#include <tuple>
#include <cmath>
#include <chrono>

using namespace std;

using ll = long long;

int main() {
    int n;
    cin >> n;
    
    vector<int> x(n), y(n), h(n);
    
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> h[i];    
    }
    
    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100; j++) {
            int H = -1;
            int H_max = 2000000000;
            
            bool ok = true;
            
            for (int k = 0; k < n; k++) {
                int dx = abs(x[k] - j);
                int dy = abs(y[k] - i);
            
                if (h[k] != 0) {
                    if (H == -1) {
                        H = h[k] + dx + dy;
                    } else if(H != h[k] + dx + dy) {
                        ok = false;
                        break;
                    }
                } else {
                    H_max = min(H_max, dx + dy);
                }
            }
            
            ok = ok && (H <= H_max);
            
            if (ok) {
                cout << j << ' ' << i << ' ' << H << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		for (; solver.hasNext();) {
			solver.readBody(in.readLine());
		}
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public boolean hasNext() {
		// return cnt < N;
		return cnt < 1;
	}

	public void readBody(String str) {
		// System.out.println(str);
		int cntEAll = 0;
		for (int i = 0; i < N; i++) {
			if (str.charAt(i) == 'E')
				cntEAll++;
		}
		int ans = N;
		int cntE = 0;
		for (int i = 0; i < N; i++) {
			int turn = N;
			if (str.charAt(i) == 'E') {
				turn = (i - cntE) + (cntEAll - cntE - 1);
				cntE++;
			} else {
				turn = (i - cntE) + (cntEAll - cntE);
			}
			if (turn < ans)
				ans = turn;
		}
		System.out.println(ans);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 26580
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

int N,K;
int a[110];
int memo[100010][2];

bool dfs(int nokori,bool player) {
  if(memo[nokori][player] != -1){
    return memo[nokori][player];
  }
  bool ans = !player;
  if(nokori < a[0]){
    memo[nokori][player] = ans;
    return ans;
  }
  rep(i,N) {
    if(nokori - a[i] > -1) {
      bool tmp = dfs(nokori - a[i],!player);
      memo[nokori - a[i]][!player] = tmp;
      if(tmp == player) {
        ans = player;
      }
    }

  }
  memo[nokori][player] = ans;
  return ans;
}

int main() {
  cin >> N >> K;
  rep(i,K+1) {
    rep2(j,2){
      memo[i][j] = -1;
    }
  }
  rep(i,N){
    cin >> a[i];
  }

  bool ans = dfs(K,true);
  if(ans){
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
  return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <cmath>
#include<cstdio>
#include <cstring>
#include <algorithm>
#define ll long long int
using namespace std;

ll arr[100030];
ll x[100030],y[100030];
ll dp[3001][3001];
ll dis[3001][3001];
ll len1,len2;
char s1[3001],s2[3001];
string finalS;

int call(int i,int j)
{
    int ans = 0;
    if(s1[i] == '\0' or s2[j] == '\0')
        return 0;
    if(dis[i][j])
        return dp[i][j];
    else if(s1[i] == s2[j])
    {
        ans = 1 + call(i+1,j+1);
    }
    else
    {
        ans = max(call(i+1,j),call(i,j+1));
    }
    dis[i][j] = true;
    dp[i][j] = ans;
    return dp[i][j];
}
void Lcs(int i, int j)
{
    if(s1[i] == '\0' or s2[j] == '\0')
    {
        cout<<finalS;
        return ;
    }
    if(s1[i] == s2[j])
    {
        finalS += s1[i];
        Lcs(i+1,j+1);
    }
    else
    {
        if(dp[i+1][j] > dp[i][j+1])
            Lcs(i+1,j);
        else
            Lcs(i,j+1);
    }
}
int main()
{
    cin>>s1>>s2;
    len1 = strlen(s1);
    len2 = strlen(s2);
    int x = call(0,0);
    Lcs(0,0);
}


Measured memory_bytes: 141824
import copy
def warshall_floyd(d):
    cnt = 0
    d_first = copy.deepcopy(d)
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    for i in range(len(d)):
        for fir, rev in zip(d_first[i], d[i]):
            if (rev < fir) and fir != float('inf'):
                cnt += 1
    return cnt//2

if __name__ == '__main__':
    n,w = map(int,input().split()) #n:頂点数　w:辺の数

    d = [[float("inf")]*n for i in range(n)] 
    for i in range(w):
        x,y,z = map(int,input().split())
        d[x-1][y-1] = z
        d[y-1][x-1] = z
    for i in range(n):
        d[i][i] = 0 #自身のところに行くコストは０
    print(warshall_floyd(d))


Measured memory_bytes: 3956
import itertools
n, m=map(int,input().split())
count=0

switch_list_all=[None]*n
for i in range(n):
    switch_list=[0]*m
    switch_list_all[i]=switch_list

for i in range(m):
    lst=list(map(int,input().split()))
    for j in range(len(lst)-1):
        switch_list_all[lst[j+1]-1][i]+=1
        

p=list(map(int, input().split()))

a_list=list(itertools.product([0,1],repeat=n))


for i in range(len(a_list)):
    a=a_list[i]
    point=[0]*m
    c=0
    for z in range(m):
        point[z]+=p[z]
    for j in range(n):
        s_list=switch_list_all[j]
        if a[j]==1:
            for x in range(m):
                point[x]+=s_list[x]
    for y in range(m):
        if point[y]%2==0:
            c+=1
    if c==m:
        count+=1

print(count)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

signed main(){
   IOS;
   int n; cin >> n;
   string ans = "";
   while(n) {
      int x = n % 26;
      if(x == 0) {
         ans += 'z';
         n/=26;
         n--;
      }
      else {
         ans += char('a' + x - 1);
         n /= 26;
      }
   }  
   reverse(ans.begin(), ans.end());
   cout << ans << '\n';
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

int N, A;
int x[111];
ll coudp[111][111][5555];

int main() 
{
	
	
	cin >> N>>A;
	for (int i = 0; i < N; i++)
	{
		cin >> x[i];
	}
	coudp[0][0][0] = 1;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			for (int k = 0; k <= 5000; k++)
			{
				coudp[i + 1][j][k] += coudp[i][j][k];
				if (k >= x[i])
				{
					coudp[i + 1][j + 1][k] += coudp[i][j][k - x[i]];
				}
			}
		}
	}
	ll ans = 0;
	for (int j = 1; j <= N; j++)
	{
		ans += coudp[N][j][j * A];
	}
	cout << ans << endl;

	

	return 0;
	
}

Measured memory_bytes: 211200
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int k;
    cin >> k;
    string s;
    cin >> s;

    if (s.length() > k) {
        s = s.substr(0, k);
        s += "...";
    } 

    cout << s << '\n';


    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int n,m,c;
  cin>>n>>m>>c;
  int ans = 0;
  vector<int>b;
  for(int i=0;i<m;i++){
    int x;
    cin>>x;
    b.push_back(x);
  }
  for(int i=0;i<n;i++){
    int res = 0;
    for(int j=0;j<m;j++){
        int y;
        cin>>y;
        res+=y*b[j];
    }
    res+=c;
    if(res>0){
        ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main(){
	char a, b;
  	std::cin >> a >> b;
  	if(a < b)
      std::cout << '<';
  	else if(a > b)
      std::cout << '>';
  	else
      std::cout << '=';
  std::cout << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
 {
 int a, b, c;
 if(scanf("%d %d %d", &a,&b,&c) ==1);
  if(a+b >=2 && a+b <= 1000 && a+b >=c && c <=1000) {
    printf("Yes\n");
    }else{
     printf("No\n");
   }
 return 0;
 }
 

Measured memory_bytes: 128
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String x_k_d [] = s.split(" ", -1);
        long x = Long.parseLong(x_k_d[0]);
        long k = Long.parseLong(x_k_d[1]);
        long d = Long.parseLong(x_k_d[2]);
        
        //移動した後の位置pos、残り移動回数a
        long pos = x;
        long a = k;
        long b = 0;
        long c = 0;

        //出力は絶対値なのでposを正にして計算する
        if(x < 0){
            pos *= -1;
        }
        //0に近づけるように移動させる
        if(pos / d < k){
            a -= pos / d;
            pos = pos % d;
            
        }else{
            a = 0;
            pos -= d * k;
        }
        
        if(a == 0){
            System.out.println(pos);
        }else{
            b = pos;
            c = (pos - d) * -1;
            if(a % 2 == 0){
                System.out.println(b);
            }else if(a % 2 == 1){
                System.out.println(c);
            }
        }
    }
}

Measured memory_bytes: 35696
import java.util.ArrayList;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String ans = "Yes";

		ArrayList<int[]> list = new ArrayList<int[]>();

		for(int i = 0; i < n; i++){
			int[] dicee = new int[6];

			for(int j = 0; j < 6; j++){
				dicee[j] = sc.nextInt();
			}
			list.add(dicee);
		}

		int[] dice1 = new int[6];
		int[] dice2 = new int[6];


		for(int i = 0; i < n - 1; i++){
			for(int j = i + 1; j < n; j++){

				dice1 = list.get(j);
				dice2 = list.get(i);

				Dicee insDice = new Dicee(dice1,dice2);
				for(int k = 0; k < n; k++){
					if(("??????").equals(insDice.check())){
						ans = "No";
						break;
					}
				}
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

class Dicee{
	int[] dice1 = new int[6];
	int[] dice2 = new int[6];
	int temp = 0;

	public Dicee(int[] dice1, int[] dice2) {
		this.dice1 = dice1;
		this.dice2 = dice2;
	}

	public String check() {
		String check = "????????´";

		//?????????4?????????(???????????????????????????)
		for(int i = 0; i < 4; i++){
			//Ans???true?????£??????for???????????????
			if(Ans()){ check = "??????";}
			rollN('N');

			//??¨??????4?????????()
			for(int j = 0; j < 4; j++){
				if(Ans()){ check = "??????";}
				rollR('R');
			}
		}

		//?¨?????????§????????????
		for(int i = 0; i < 3; i++){
			if(Ans()){ check = "??????";}
			rollW('W');

			//?¨????4????????????
			for(int j = 0; j < 4; j++){
				if(Ans()){ check = "??????";}
				rollR('R');
			}
		}

		//?????????String??§??????
		return check;

	}

	//??¨??¨????????´???????????????true?????????
	//????????£???Arrays.equals??¨???????????????????????????
	boolean Ans(){
		if(dice1[0] == dice2[0] && dice1[1] == dice2[1] && dice1[2] == dice2[2] &&
				dice1[3] == dice2[3] && dice1[4] == dice2[4] && dice1[5] == dice2[5]){
			return true;

		}else{
			return false;
		}
	}

	//???????????????????????\????????????
	void rollN(char N){
		temp = dice1[0];
		dice1[0] = dice1[1];
		dice1[1] = dice1[5];
		dice1[5] = dice1[4];
		dice1[4] = temp;
	}

	void rollS(char S){
		temp = dice1[0];
		dice1[0] = dice1[4];
		dice1[4] = dice1[5];
		dice1[5] = dice1[1];
		dice1[1] = temp;
	}

	void rollE(char E){
		temp = dice1[0];
		dice1[0] = dice1[3];
		dice1[3] = dice1[5];
		dice1[5] = dice1[2];
		dice1[2] = temp;
	}

	void rollW(char W){
		temp = dice1[0];
		dice1[0] = dice1[2];
		dice1[2] = dice1[5];
		dice1[5] = dice1[3];
		dice1[3] = temp;
	}

	void rollL(char L){
		temp = dice1[2];
		dice1[2] = dice1[1];
		dice1[1] = dice1[3];
		dice1[3] = dice1[4];
		dice1[4] = temp;
	}

	void rollR(char R){
		temp = dice1[1];
		dice1[1] = dice1[2];
		dice1[2] = dice1[4];
		dice1[4] = dice1[3];
		dice1[3] = temp;
	}
}

Measured memory_bytes: 32796
//Palindromic Numbers

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end()
#define pb push_back
const int inf = 2147483647;

int main (){
    int a,b,ans=0;cin>>a>>b;
    rep(i,a,b+1){
        string s = to_string(i);
        if(s[0]==s[4]&&s[1]==s[3])ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var n = F();
		var x = 1L;
		for (int i = 0; i < n; i++) x = LCM(x, FL());
		Console.WriteLine(x);
	}
	long LCM(long a, long b) => (a / GCD(a, b)) * b;
	long GCD(long a, long b)
	{
		var n = (ulong)Math.Abs(a); var m = (ulong)Math.Abs(b);
		if (n == 0) return (long)m; if (m == 0) return (long)n;
		int zm = 0, zn = 0;
		while ((n & 1) == 0) { n >>= 1; zn++; }
		while ((m & 1) == 0) { m >>= 1; zm++; }
		while (m != n)
		{
			if (m > n) { m -= n; while ((m & 1) == 0) m >>= 1; }
			else { n -= m; while ((n & 1) == 0) n >>= 1; }
		}
		return (long)n << Math.Min(zm, zn);
	}
}


Measured memory_bytes: 13140
#include <stdio.h>
#define ANSWER_SUM 6

int main(void)
{
	int a, b;

	scanf("%d", &a);
	scanf("%d", &b);

	/* 選択肢の合計から誤答を引く */
	printf("%d", ANSWER_SUM - a - b);
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main()
{
	int data[51][105];
	int x=0,y=0,i,t, avg, sum[51];
         for(i=0;i<51;i++)
         sum[i]=0;
	while (1)
	{
		
		scanf("%d%d", &data[x][0],&data[x][1]);
		if (data[x][0] == 0 && data[x][1] == 0)break;
		for (y = 2; y <= data[x][0] + 1; y++)
			scanf("%d", &data[x][y]);
		x++;

	}
	
   for(i=0;i<x;i++)
   {avg=data[i][1]/data[i][0];
    for(t=2;t<=data[i][0]+1;t++)
      if(data[i][t]>=avg)sum[i]+=avg; else sum[i]+=data[i][t];
       printf("%d\n",sum[i]);
		}
 return 0;

}


Measured memory_bytes: 2020
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::io::*;
use std::str::FromStr;
 
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed reading char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed parsing")
}
 
use std::cmp::{min, max};
use std::num;
use std::collections::HashMap;
use std::collections::HashSet;

const MOD : u64 = 1_000_000_000 + 7;

fn main() {
    
    //let n = read::<usize>();
    //let m = read::<usize>();
    let s : Vec<char> = read::<String>().chars().collect();
    let t : Vec<char> = read::<String>().chars().collect();
    //let mut b : Vec<bool> = vec![false; 2*n];

    let mut ans = 0;
    for i in 0..3 {
        if s[i] == t[i] {ans += 1;}
    }
    
    println!("{}",ans);
}


Measured memory_bytes: 4352
// ref: https://qiita.com/tubo28/items/e6076e9040da57368845
use std::io::{stdin, Read};
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let _ = read::<String>();
    let s: Vec<char> = read::<String>().chars().collect();
    let _ = read::<String>();
    println!("A{}C", s[0]);
}

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

#define ll long long
#define pf push_front
#define np next_permutation
#define pp prev_permutation
#define fill(x,y) memset((x),y,sizeof(x))
#define rep(x,y,z) for(int x=y; x<z; x++)
#define rep1(x,y,z) for(int x=y; x>=z; x--)
#define all(x) (x).begin(),(x).end()

using namespace std;
int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    int p,ans=0;
    vector<long long>a(n+1),b(m+1);
    for(int i=1; i<=n; i++)
    {
        cin>>p;
        a[i]=a[i-1]+p;
    }
    for(int i=1; i<=m; i++)
    {
        cin>>p;
        b[i]=b[i-1]+p;
    }
    for(int i=0; i<=n; i++)
    {
        if(a[i]>k) break;
        while(a[i]+b[m]>k && m>0)
                  m--;
        ans=max(ans,i+m);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 6392
#include<bits/stdc++.h>
using namespace std;
int n , m , q , sumr[330000] , sumc[330000] , x , y , ans;
int ansr[330000] , ansc[330000];
long long maxr , maxc , totr , totc;
map< pair< int , int > , bool > mp;
int main()
{
	scanf("%d%d%d" , &n , &m , &q);
	for(int i = 1 ; i <= q ; i++ )
	{
		scanf("%d%d" , &x , &y);
		sumr[x]++;
		if(sumr[x] == maxr) ansr[++totr] = x;
		if(sumr[x] > maxr) maxr = sumr[x] , ansr[(totr = 1)] = x;
		sumc[y]++;
		if(sumc[y] == maxc) ansc[++totc] = y;
		if(sumc[y] > maxc) maxc = sumc[y] , ansc[(totc = 1)] = y;
		mp[make_pair(x , y)] = 1;
	}
	if(totr * totc > q) printf("%lld" , maxr + maxc);
	else
	{
		int flag = 1;
		for(int i = 1 ; i <= totr ; i++ )
		{
			for(int j = 1 ; j <= totc ; j++ )
			{
				if(!mp[make_pair(ansr[i] , ansc[j])])
				{
					flag = 0;
					break;
				}
			}
			if(!flag) break;
		}
		printf("%lld" , maxr + maxc - flag);
	}
    return 0;
}

Measured memory_bytes: 27224
#include<iostream>
#include<string>
using namespace std;
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	if (n % 2==1) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < s.length() / 2; i++) {
		if (s[i] == s[i + s.length() / 2])
			continue;
		else {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from itertools import*
from fractions import*
ac = lambda l: list(accumulate([0] + l, gcd))
n, *a = map(int, open(0).read().split())
print(max(gcd(s, t) for s, t in zip(ac(a), ac(a[::-1])[::-1][1:])))

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

int main(){
  int N;
  cin >> N;
  vector<int> v(N),p(N),q(N);
  for(int i=0;i<N;i++){
    cin >> p.at(i);
  }
  for(int i=0;i<N;i++){
    cin >> q.at(i);
  }
  for(int i=0;i<N;i++){
    v.at(i)=i+1;
  }
  int a,b;
  int n=1;
  do{
    if(v==p){
      a=n;
    }
    if(v==q){
      b=n;
    }
    n++;
  }while(next_permutation(v.begin(),v.end()));
  cout << abs(a-b) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int A, B, C, D;
    cin >> A >> B >> C;
    D = A * C;
    if (D < B)
    {
        cout << C;
    }
    else
    {
        cout << B / A;
    }
}

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

int main () {
    int K; cin >> K;
    queue<ll> que;
    for(ll i = 1; i <= 9; i++)
        que.push(i);
    int count = 0;
    while(true) {
        ll a = que.front();
        que.pop();
        //cout << a << endl;
        count++;
        if(count == K) {
            cout << a << endl;
            return 0;
        }
        if(a%10!=0 && a%10!=9) {
            que.push(10*a+a%10-1);
            que.push(10*a+a%10);
            que.push(10*a+a%10+1);
        } else if(a%10==0) {
            que.push(10*a);
            que.push(10*a+1);
        } else {
            que.push(10*a+8);
            que.push(10*a+9);
        }
    }
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define X first
#define Y second

using namespace std;

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

vector<string> words;
int x[15][15];

string dp[1 << 10][10];
const string INF = string(200, 'z');

int samecnt(const string &a, const string &b){
	rep(i, a.size()){
		bool ok = true;
		FOR(j, i, a.size()){
			if (j - i >= b.size() || a[j] != b[j - i]){
				ok = false;
				break;
			}
		}
		if (ok) return a.size() - i;
	}
	return 0;
}

int n;
string rec(int bits, int pos){
	if (bits + 1 == (1 << n)){
		return words[pos];
	}

	string &res = dp[bits][pos];
	if (res != INF) return res;

	rep(i, n){
		if (bits&(1 << i)) continue;
		string ret = words[pos];
		string ret2 = rec(bits | (1 << i), i);
		ret += ret2.substr(x[pos][i]);
		if (res.size() < ret.size()) continue;
		if (res.size() > ret.size()) res = ret;
		else res = min(res, ret);
	}

	return res;
}

int main(){
	//cout << INF << endl;
	while (cin >> n, n){
		words.clear();
		words.resize(n);
		rep(i, n) cin >> words[i];
		int e = 0;
		sort(ALL(words));
		words.erase(unique(ALL(words)), words.end());
		n = words.size();
		rep(i, n) rep(j, n){
			if (words[i] == string(200, 'z')) continue;
			if (i == j) continue;
			if (words[i].find(words[j]) != -1) words[j] = string(200, 'z'), ++e;
		}
		sort(ALL(words));
		n -= e;
		rep(i, n) rep(j, n){
			if (i == j) continue;
			//cout << words[i] << " " << words[j] << endl;
			//cout << samecnt(words[i], words[j]) << endl;
			x[i][j] = samecnt(words[i], words[j]);
		}
		rep(i, n) rep(j, 1 << n) dp[j][i] = INF;
		string ans = INF;
		rep(i, n){
			string ret = rec(1 << i, i);
			if (ans.size() > ret.size() || (ans.size() == ret.size() && ret < ans)){
				ans = ret;
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1752
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] d = new int[k];
		for(int i = 0 ; i < k ; i++) d[i] = sc.nextInt();
		for(int i = n ;;i++) {
			boolean ok = true;
			String temp = String.valueOf(i);
			for(int j = 0 ; j < temp.length() ; j++) {
				for(int l = 0 ; l < k ; l++) {
					if(Integer.valueOf(String.valueOf(temp.charAt(j))) == d[l]) ok = false;
				}
			}
			if(ok) {
				System.out.println(i);
				return;
			}
		}
	}
}


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

class route{
public:
  char c;
  int n;
};

int main(){
  int hp,hpmax;
  while(cin >> hp >> hpmax && hp && hpmax){
    int h,w,t,s,pp,a[100][100],p[100],dp[2][1<<12];
    string str[100];
    bool ans = true;
    vector<route> v;
    cin >> h >> w;
    for(int i=0;i<h;i++) cin >> str[i];
    cin >> t;
    for(int k=0;k<t;k++){
      int n;
      char c;
      cin >> c >> n;
      for(int i=0;i<h;i++){
	for(int j=0;j<w;j++) if(str[i][j] == c) a[i][j] = n;
      }
    }
    cin >> s;
    for(int i=0;i<s;i++){
      route r;
      cin >> r.c >> r.n;
      v.push_back(r);
    }
    cin >> pp;
    for(int i=0;i<pp;i++) cin >> p[i];

    int x = 0, y = 0;
    hp -= a[0][0];

    for(int i=0;i<(1<<12);i++) dp[0][i] = dp[1][i] = 0;
    dp[0][0] = hp;

    for(int i=0;i<s;i++){
      for(int j=0;j<v[i].n;j++){
	if(v[i].c == 'U') y--;
	else if(v[i].c == 'D') y++;
	else if(v[i].c == 'L') x--;
	else if(v[i].c == 'R') x++;
	for(int k=0;k<(1<<pp);k++){
	  if(dp[0][k] > 0){
	    for(int l=0;l<pp;l++){
	      if((k & (1<<l)) == 0){
		int kk = k | (1<<l);
		dp[1][kk] = max(dp[0][kk],min(hpmax,dp[0][k]+p[l]));
	      }
	    }
	  }
	}
        ans = false;
	for(int k=0;k<(1<<pp);k++){
	  if(dp[1][k] == 0) dp[1][k] = dp[0][k];
	  dp[0][k] = dp[1][k] - a[y][x];
	  dp[1][k] = 0;
	  if(dp[0][k] > 0) ans = true;
	}
	if(!ans) break;
      }
      if(!ans) break;
    }

    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int> l(n);
  rep(i,n) cin>>l[i];
  sort(begin(l),end(l));
  ll ans=0;
  //cout_vec(l);
  rep(i,n)FOR(j,i+1,n){//l[i]<=l[j]
    int a=l[i],b=l[j];
    int itr1=lower_bound(begin(l),end(l),b+a)-begin(l);
    int itr2=upper_bound(begin(l),end(l),b-a)-begin(l);
    ans+=itr1-itr2;
    if(itr2<=i && i<itr1) ans--;
    if(itr2<=j && j<itr1) ans--;
    //cout<<a<<' '<<b<<' '<<itr1<<' '<<itr2<<' '<<ans<<endl;
  }
  cout<<ans/3<<endl;
}

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

int main()
{
    int n, k, ar[1000], sum=0;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    sort(ar, ar+n);
    for(int i=0;i<k;i++)
    {
        sum+= ar[i];
    }
    cout<<sum;

}


Measured memory_bytes: 3608
#include <cstdio>

int main()
{
	int cnt = 0, N;
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) {
		int t;
		scanf("%d", &t);
		t = t & -t;
		while (t) ++cnt, t >>= 1;
		--cnt;
	}
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int a,b,c;
  cin>>a>>b>>c;
  map<int ,int>m;
  m.insert({a,1});
  m.insert({b,1});
  m.insert({c,1});
  
    
  if(m.size()==2)cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var x, n int
	fmt.Scan(&x, &n)

	l := make([]int, 100)

	var tmp int
	for i := 0; i < n; i++ {
		fmt.Scan(&tmp)
		l[tmp-1] = 1
	}

	high := x
	for {
		if l[high-1] == 0 {
			break
		}
		high++
		if high == 101 {
			break
		}
	}

	low := x
	for {
		if l[low-1] == 0 {
			break
		}
		low -= 1
		if low == 0 {
			break
		}
	}

	if high-x < x-low {
		fmt.Println(high)
	} else {
		fmt.Println(low)
	}
}


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

#define sc second
#define fr first

#define ll long long
#define pi pair<int,int>
#define ppi pair<pi,pi>
#define mp make_pair
using namespace std;


int main()
{

	ios::sync_with_stdio(0);
    cin.tie(0) , cout.tie(0);

	int a, b, t; cin >> a >> b >> t;
	int cnt = 0;
	int ans = 0;
	for (int i = 1; i < 10000; i++)
	{
		cnt = a * i;
		if (cnt <= t)
			ans+= b;
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll dh[2010][2010];
ll dw[2010][2010];

int main() {
	ll h,w;
	cin>>h>>w;
	vector<string> vs;
	rep(i,0,h){
		string s;
		cin>>s;
		vs.pb(s);
	}
	// w
	rep(y,0,h){
		ll c = 0;
		rep(x,0,w){
			if(vs[y][x]=='#'){
				c = 0;
			}
			else{
				c++;
				dw[y][x]=c;
			}
		}
		ll mx = 0;
		per(x,0,w){
			if(vs[y][x]=='#'){
				mx = 0;
			}
			else{
				mx = max(mx,dw[y][x]);
				dw[y][x]=mx;
			}			
		}
	}
	// h
	rep(x,0,w){
		ll c = 0;
		rep(y,0,h){
			if(vs[y][x]=='#'){
				c = 0;
			}
			else{
				c++;
				dh[y][x]=c;
			}
		}
		ll mx = 0;
		per(y,0,h){
			if(vs[y][x]=='#'){
				mx = 0;
			}
			else{
				mx = max(mx,dh[y][x]);
				dh[y][x]=mx;
			}			
		}
	}
	ll ans = 0;
	rep(y,0,h){
		rep(x,0,w){
			ans = max(ans,dw[y][x]+dh[y][x]-1);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 67328
#include<stdio.h> 
   #include<string.h>
        int main(void)
        {
    char a[101][12];
    int b;
    scanf("%d\n",&b);
    char last='\0';
    int out=0;
    for (int i=0;i<b;i++)
    {
    scanf("%s",a[i]);
    if(a[i][0]!=last&&last!='\0')out=1;
    for (int j=0;j<i;j++)
    {
    if(strcmp(a[i],a[j])==0) out=1;
    }
    for (int j=0;j<101;j++)
    {
    if(a[i][j]=='\0')
    {
    last=a[i][j-1];
    break;
    }
    }
    }
        if(out==1)printf("No");
        else printf("Yes");
        }

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
//#include<string>
//#include<set>
//#include<vector>
//#include<iomanip>
using namespace std;
int ind=0;
int down(int x,int d, int arr[],int len);
int up(int x,int d,int arr[],int len){
    for(int i=ind;i<len;i++){
        if(x+d<arr[i]){return x+d;}
        if(x+d==arr[i]){return down(x,d+1,arr,len);}
    }
    return x+d;
}
int down(int x,int d, int arr[],int len){
    for(int i=ind-1;i>=0;i--){
        if(x-d>arr[i]){return x-d;}
        if(x-d==arr[i]){return up(x,d,arr,len);}
    }
    return x-d;
}
int main(){

    int x,n,q=0;
    cin>>x>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
        if(arr[i]<x){ind++;}
        else if(arr[i]==x){q=1;}
    }
    sort(arr,arr+n);
    if(q==1){cout<<up(x,0,arr,n);}
    else if(q==0){cout<<x;}
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>

int main(void){

  long a,b,c;
  scanf("%ld %ld %ld", &a, &b, &c);

  long left;
  long right;

  right = c - a - b;
  if (right < 0) {
    printf("No\n");
    return 0;
  }
  right = right*right;

  left = 4*a;
  left *= b;

  if (right > left) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
import java.io.*;
// import java.math.*;
// import java.util.*;
// import java.util.Map.*;
// import java.util.stream.*;

public class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader reader =
            new BufferedReader (new InputStreamReader (System.in));
        int N = Integer.parseInt (reader.readLine());
        String S = reader.readLine();
        String alp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        System.out.println (
            trans (S, alp, alp.substring (N) + alp.substring (0, N)));
        return;
    }

    static String trans (String S, String f, String t) {
        for (int i = 0; i < S.length(); i++) {
            int idx = f.indexOf (S.charAt (i));
            S = S.substring (0, i) + t.charAt (idx) + S.substring (i + 1);
        }
        return S;
    }
}

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

int main() {
    long n, ans = 0;
    cin >> n;
    long temp = n;
    for(long i = 2; i * i <= n; i++) {
        long t = 0, x = 0, y = 1;
        while(temp % i == 0) {
            temp /= i;
            t++;
        }
        while(x + y <= t) {
            x += y;
            y++;
            ans++;
        }
    }
    if(temp != 1) ans++;
    cout << ans << endl;
}

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

int main()
{
    int N;
    int a[110];
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    sort(a, a + N, greater<int>());
    int Alice = 0;
    int Bob = 0;
    for (int i = 0; i < N; ++i){
        if (i % 2 == 0){
            Alice += a[i];
        } else {
            Bob += a[i];
        }
    }
    cout << Alice - Bob << endl;
    return 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    if (a == 1)
    {
        if (b == 1)
        {
            cout << "Draw";
            return 0;
        }
        cout << "Alice";
        return 0;
    }
    if (b == 1)
    {
        cout << "Bob";
        return 0;
    }
    if (a == b)
    {
        cout << "Draw";
        return 0;
    }

    cout << ((a > b) ? "Alice" : "Bob");
    return 0;
}

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

int main(){
    int n, d, cnt=0; cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++) cin >> x[i][j];
    }
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            int sum = 0;
            for(int k = 0; k < d; k++){
                sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            for(int k = 1; k < 160; k++){
                if(k*k == sum) cnt++;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


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

int N;
int C[501];
int S[501];
int F[501];

long long int get_time(int k) {
    long long int time = S[k] + C[k];
    for (int i = k; i < N-2; i++) {
        if (time <= S[i+1])
            time = S[i+1];

        if (((time - S[i+1]) % F[i+1]) != 0) {
            time += (F[i+1] - ((time - S[i+1]) % F[i+1]));
        }
        time += C[i+1];
    }
    return time;
}



int main(int argc, const char * argv[]) {
    cin >> N;
    int i;
    for (i = 0; i < N-1; i++) {
        cin >> C[i] >> S[i] >> F[i];
    }
    for (i = 0; i < N-1; i++) {
        cout << get_time(i) << endl;
    }
    cout << "0" << endl;
    return 0;
}




Measured memory_bytes: 256
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int firstInputNumber  = scan.nextInt();
        int secondInputNumber = scan.nextInt();
        int thirdInputNumber  = scan.nextInt();
        
        List<Integer> minList = new ArrayList<Integer>(Arrays.asList(firstInputNumber, secondInputNumber, thirdInputNumber));
        
        Collections.sort(minList);
        
        for(int listCount = 0; listCount < minList.size(); listCount++){
            if(listCount == minList.size()-1){
                System.out.println(minList.get(listCount));
                break;
            }
            System.out.print(minList.get(listCount) + " ");
        }
    }
}


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

#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)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int N;
	string A, B, C;
	cin >> N >> A >> B >> C;

	int ans = 0;
	rep(i, N){
		if(A[i] == B[i] && B[i] == C[i]) continue;

		if(A[i] == B[i] || B[i] == C[i] || A[i] == C[i]){
			ans++;
			continue;
		}

		ans += 2;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<tuple>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

struct edge{int to,cost;};

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

	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);

	if(a[0]==a[1] && a[1]==a[2]){
		if(a[0]%2==0)cout << "-1\n";
		else		cout << "0\n";
		return 0;
	}
	else{
		ll ans=0,tmp;
		while(true){
			if(a[0]%2 != 0 || a[1]%2 != 0 || a[2]%2 != 0){
				cout << ans << "\n";
				return 0;
			}
			a[2]-=a[0]; a[1]-=a[0]; a[0]=0;
			tmp=a[1]; a[0]=a[1]/2; a[1]=a[2]/2; a[2]=(tmp+a[2])/2;
			ans++;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)

















int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    auto ok = [&](ll m){
        ll cnt = 0;
        REP(i, n){
            if(a[i] > 0){
                ll b = m / a[i];
                if(m < 0 && m % a[i]) b--;
                cnt += min(i, (ll)(upper_bound(a.begin(), a.end(), b) - a.begin()));
            }
            else if(a[i] < 0){
                ll b = m / a[i];
                if(m < 0 && m % a[i]) b++;
                cnt += max(0LL, i - (ll)(lower_bound(a.begin(), a.end(), b) - a.begin()));
            }
            else{
                if(m >= 0) cnt += i;
            }
        }
        return cnt >= k;
    };
    ll l = -INF, r = INF;
    while(r - l > 1){
        ll c = (l + r) / 2;
        (ok(c)? r : l) = c;
    }
    cout << r << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

char get_op(int i){
    if(i==1){
        return '+';
    }else{
        return '-';
    }
}


int main()
{
    long long x,N,K;

    cin>>N>>K;

    x=N;

    long long a,b;

    a = N/K;
    b = a+1;

    x = min(x,min(abs(x-K*a),abs(x-K*b)));

    cout<<x<<endl;

    return 0;
}


Measured memory_bytes: 256