akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h> 
using namespace std; 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL); 
#define endl "\n"
#define ll long long int
#define ull unsigned long long int
#define mode 1000000007
//=================================================================================
int mod(int x)
{
	if(x>=0)
		return x;
	else
		return -1*x;
}


//=================================================================================
int main() 
{
	fastio
	

	//int t=1; 
	//cin>>t; 
	ull ans=0;
	 
		int n,k;
		cin>>n>>k;
		int arr[n+1],dp[n+5];
		memset(dp,0,sizeof(dp));
		memset(arr,0,sizeof(arr));
		dp[1]=0;

		for(int i=1;i<=n;i++)
		{
			cin>>arr[i];
			//cout<<arr[i]<<" ";
			
		}
		dp[2]=mod(arr[2]-arr[1]);
		for(int i=3;i<=n;i++)
		{
			int min=INT_MAX;
			for(int j=1;j<=k && i-j > 0 ;j++)
			{
				int temp=dp[i-j]+mod(arr[i] - arr[i-j]);
				if( temp < min)
				{
					min=temp;dp[i]=min;
				}

				
			}
		}
	
		ans=dp[n];
		cout<<ans<<endl;
	//cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
	return 0; 
} 



Measured memory_bytes: 4388
#include <stdio.h>

int main() {
  int a, b, d[5], o = 0;
  scanf("%d %d", &a, &b);
  for(int i = a; i <= b; i++) {
    int t = i;
    for(int j = 0; j < 5; j++) {
      d[j] = t % 10;
      t /= 10;
    }
    if(d[0] == d[4] && d[1] == d[3])
      o++;
  }
  printf("%d\n", o);
}

Measured memory_bytes: 128
#include <iostream>
#include <set>
#define FOR(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main(){
    int n; cin>>n;
    set<int> s;
    FOR(i,0,n){
        int now; cin>>now;
        if(s.find(now)==s.end()){
            s.insert(now);
        }else{
            s.erase(now);
        }
    }
    cout<<s.size()<<endl;
}

Measured memory_bytes: 4864
package main
 
import "fmt"
 
func main(){
  var ballNum, color, variation int
  fmt.Scan(&ballNum, &color)
  for i := 1; i <= ballNum; i++{
    if i == 1{
      variation = color
    } else {
      variation *= (color-1)
    }
  }
  fmt.Printf("%d", variation)
}

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

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

  vector<int> ansList;
  int num4 = 0, num7 = 0;

  while(true){
    int ans = num4 * 4 + num7 * 7;
    if(ans>=1 && ans<=100){
    ansList.push_back(ans);
    }
    if(ans+7>100){
      num4++;
      num7 = 0;
      if(num4*4+num7*7>100){
        break;
      }
    }else{
      num7++;
    }
  }

  bool flag = false;
  for(auto val : ansList){
    if(val==N){
      flag = true;
    }
  }

  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <utility>
#include <cmath>
#include <string>
#include <bitset>
#include <queue>
#include <cstdio>
#include <cstring>
#include <deque>
#include <unordered_map>
#include <climits>
#include <map>
#include <iomanip>
#include <set>
#include <unordered_set>
#include <ctime>
#include <cstdint>

#define ci(t) cin>>t
#define co(t) cout<<t
#define LL long long
#define fa(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>b;--i)
#define setp pair<pair<int,int>,int>
#define setl pair<int,int>
#define M_PI 3.14159265358979323846

using namespace std;

LL gcd(LL a, LL b) { return a % b ? gcd(b, a % b) : b; }
LL lcm(LL a, LL b) { return (a * b) / gcd(a, b); }
pair <int, int> vu[4] = { {0,1}, {0,-1} , {1,0},{-1,0} }; // EWSN

const int max_v = 1e5 + 7;
const int INF = 1e9 + 7;

struct cmp
{
	bool operator()(setl a, setl b)
	{
		return a.second > b.second;
	}
};

vector <int> adj[max_v];
int dfsn[max_v];
bool visit[max_v];
priority_queue <setl, vector<setl>, cmp> pq;
int v, e;
int pre[max_v];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ci(v >> e);
	fa(i, 0, e)
	{
		int x, y;
		ci(x >> y);
		adj[x - 1].push_back(y - 1);
		adj[y - 1].push_back(x - 1);
	}

	fill(dfsn, dfsn + max_v, INF);
	dfsn[0] = 0;
	pq.push({ 0,0 });
	while (!pq.empty())
	{
		int cur;
		do
		{
			cur = pq.top().first;
			pq.pop();
		} while (!pq.empty() && visit[cur]);

		if (visit[cur]) break;
		visit[cur] = true;

		for (auto x : adj[cur])
		{
			if (dfsn[x] > dfsn[cur] + 1)
			{
				dfsn[x] = dfsn[cur] + 1;
				pre[x] = cur;
				pq.push({ x,dfsn[x] });
			}
		}
	}

	bool ck = true;
	fa(i, 1, v)
	{
		if (dfsn[i] == INF) ck = false;
	}
	if (ck)
	{
		co("Yes\n");
		fa(i, 1, v)
		{
			co(pre[i]+1 << "\n");
		}
	}
	else co("No");

	return 0;

}


Measured memory_bytes: 11148
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>

#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)

using namespace std;


int main() {
	long long N;
	cin >> N;
	int i, j;
	long long x=N, y=N;
	long long n = (int)sqrt(N);
	rep(i, 2, n+1) {
		if (N % i == 0) {
			if (x + y > i + N / i) {
				x = i;
				y = N / i;
			}
		}

	}
	if (x == N && y == N) {
		y = 1;
	}
	cout << x + y - 2;
	return 0;

	
}

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

void solve(vector<vector<bool>>& board, int k, int num, bool color, int offset) {
	static const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1};
	static const int dx[] = {0, 1, 1, 1, 0, -1, -1, -1};

	rep(time, num - 1) {
		rep(i, k)rep(j, 2 * k) {
			int y = i + offset, x = j;
			if (board[y][x] != color) continue;

			bool flag = true;
			rep(t, 8) {
				int ny = y + dy[t], nx = x + dx[t];
				if (not (0 <= ny and ny < 2 * k and 0 <= nx and nx < 2 * k)) continue;
				if (board[ny][nx] != color) flag = false;
			}
			if (flag) {
				board[y][x] = not color;
				goto LAST;
			}
		}
LAST:;
	}
}

int main(int argc, char const *argv[])
{
	int a, b; cin >> a >> b;
	const int k = 50;
	vector<vector<bool>> board(2 * k, vector<bool>(2 * k));
	rep(i, k)rep(j, 2 * k) board[i][j] = 0;
	rep(i, k)rep(j, 2 * k) board[i + k][j] = 1;
	solve(board, k, a, 0, 0);
	solve(board, k, b, 1, k);
	printf("%d %d\n", k * 2, k * 2);
	rep(i, k * 2){
		rep(j, k * 2) printf("%c", (board[i][j]) ? '.' : '#');
		printf("\n");
	}
	return 0;
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b,c;cin >> a >> b >> c;
    cout << a * b /2 << endl;
}

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

using namespace std;

const int N = 1e5 + 10 ;

int noNum ;
int vizPar [ N ] ;
int vizImpar [ N ] ;

int main(){

//    freopen("file.in","r",stdin);
//    freopen("file.out","w",stdout);


    scanf("%d",&noNum);

    for ( int i = 1 ; i <= noNum ; i++ ){
        int crVal ;

        scanf("%d",&crVal);

        if ( i % 2 ){
            vizImpar [ crVal ] ++ ;
        }else{
            vizPar [ crVal ] ++ ;
        }
    }


    int noMaxPar1=0 , noMaxPar2=0;
    int noMaxImpar1=0 , noMaxImpar2=0 ;

    for ( int i = 1 ; i < N ; i++ ){

        if ( vizImpar [ i ] > vizImpar [ noMaxImpar1 ] ){
            noMaxImpar2 = noMaxImpar1 ;
            noMaxImpar1 = i ;
        }else if ( vizImpar [ i ] > vizImpar [ noMaxImpar2 ] ){
            noMaxImpar2 = i ;
        }

        if ( vizPar [ i ] > vizPar [ noMaxPar1 ] ){
            noMaxPar1 = noMaxPar2 ;
            noMaxPar1 = i ;
        }else if ( vizPar [ i ] >vizPar [ noMaxPar2 ]){
            noMaxPar2 = i ;
        }
    }

    int valParToReplace1 = noNum/2 - vizPar [ noMaxPar1 ];
    int valParToReplace2 = noNum/2 - vizPar [ noMaxPar2 ];
    int valImparToReplace1 = noNum/2 - vizImpar[ noMaxImpar1 ];
    int valImparToReplace2 = noNum/2 - vizImpar [ noMaxImpar2 ];

    if ( noMaxPar1 != noMaxImpar1 ){
        printf("%d", valParToReplace1 + valImparToReplace1 );
    }else{
        printf("%d" , min( valParToReplace1 + valImparToReplace2 , valParToReplace2 + valImparToReplace1) );
//        if ( valParToReplace1 + valImparToReplace2 < valParToReplace2 + valImparToReplace1 ){
//            printf("%d",);
//        }

    }


    return 0;
}


Measured memory_bytes: 1024
N, M = map(int, input().split())
H = list(map(int, input().split()))
m = [True] * N

for _ in range(M):
  A, B = map(int, input().split())
  
  if H[A - 1] > H[B - 1]:
    m[B - 1] = False
  elif H[B - 1] > H[A - 1]:
    m[A - 1] = False
  else:
    m[A - 1] = False
    m[B - 1] = False
  
ans = m.count(True)

print(ans)

Measured memory_bytes: 20108
#include<iostream>
#include<algorithm>
using namespace std;
int turn[4][10] = { { 1, 28, 2, 29, 3, 30, 15, 16, 19 ,21 }, { 7, 22, 8, 23, 9, 24, 13, 18 ,10,12}, { 1, 24, 4, 27, 7, 30, 21, 10, 16, 18 }, { 3, 22, 6, 25, 9, 28, 12, 19, 13, 15 } };
bool check(int cube[]){
	for (int i = 1; i < 10; i++)if (cube[1] != cube[i])return false;
	for (int i = 10; i < 13; i++)if (cube[10] != cube[i])return false;
	for (int i = 13; i < 16; i++)if (cube[13] != cube[i])return false;
	for (int i = 16; i < 19; i++)if (cube[16] != cube[i])return false;
	for (int i = 19; i < 22; i++)if (cube[19] != cube[i])return false;
	for (int i = 22; i < 31; i++)if (cube[22] != cube[i])return false;
	return true;

}
int ans = 100;
void search(int cube[], int cnt){
	if (check(cube)){
		ans = min(ans, cnt);
		return;
	}
	if (cnt >= 8)return;
	for (int i = 0; i < 4; i++){
		for (int i2 = 0; i2 < 9; i2+=2){
			swap(cube[turn[i][i2]], cube[turn[i][i2+1]]);
		}

		search(cube, cnt + 1);
		for (int i2 = 0; i2 < 9; i2 += 2){
			swap(cube[turn[i][i2]], cube[turn[i][i2 + 1]]);
		}
	}
	return;
}

int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		ans = 100;
		int cube[31];
		for (int i = 1; i <= 30; i++){
			cin >> cube[i];
		}
		search(cube, 0);
		cout << ans << endl;
	}
}

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

using namespace std;

#define N 3000000
#define LL long long

const LL mod=1000000007;
LL n,ans,a[10],b[10],fac[N],ifac[N];

void upd(LL &x,LL y){x=(x+y%mod+mod)%mod;}

LL inv(LL x){
	return x==1?1:(mod-mod/x)*inv(mod%x)%mod;
}

LL C(LL x,LL y){
	return x<y?0:fac[x]*ifac[y]%mod*ifac[x-y]%mod;
}

LL F(LL x,LL y){
	return x<0||y<0?0:C(x+y,x);
}

LL solve(LL x,LL y,LL xx,LL yy){
	LL ret=0;
	for (LL i=a[3];i<=a[4];++i){
		upd(ret,-(i+b[3]-1)*F(i-x,b[3]-1-y)%mod*F(xx-i,yy-b[3]));
		upd(ret,(i+b[4])*F(i-x,b[4]-y)%mod*F(xx-i,yy-(b[4]+1)));
	}
	for (LL i=b[3];i<=b[4];++i){
		upd(ret,-(a[3]+i-1)*F(a[3]-1-x,i-y)%mod*F(xx-a[3],yy-i));
		upd(ret,(a[4]+i)*F(a[4]-x,i-y)%mod*F(xx-(a[4]+1),yy-i));
	}
	return ret;
}

int main(){
	n=2200000;
	fac[0]=1; for (LL i=1;i<=n;++i) fac[i]=fac[i-1]*i%mod;
	ifac[n]=inv(fac[n]); for (LL i=n-1;~i;--i) ifac[i]=ifac[i+1]*(i+1)%mod;
	for (LL i=1;i<=6;++i) scanf("%lld",a+i);
	for (LL i=1;i<=6;++i) scanf("%lld",b+i);
	--a[1]; --b[1]; ++a[6]; ++b[6];
	for (LL i1=1;i1<=2;++i1)
		for (LL i2=1;i2<=2;++i2)
			for (LL j1=5;j1<=6;++j1)
				for (LL j2=5;j2<=6;++j2)
					upd(ans,(i1==i2?1:-1)*(j1==j2?1:-1)*solve(a[i1],b[i2],a[j1],b[j2]));
	printf("%lld\n",ans);
	
	return 0;
}
			

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;

using namespace std;

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

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

	vector<int>g1(n);

	int k = a[0];
	g1[0] = a[0];

	for (int i = 1; i < n; i++) {
		g1[i] = gcd(k, a[i]);
		k = gcd(k, a[i]);
	}

	reverse(a.begin(), a.end());

	vector<int>g2(n);

	int kl = a[0];
	g2[0] = kl;

	for (int i = 1; i < n; i++) {
		g2[i] = gcd(kl, a[i]);
		kl = gcd(kl, a[i]);
	}

	reverse(g2.begin(), g2.end());

	vector<int>ans(n);
	for (int i = 1; i < n - 1; i++) {
		ans[i] = gcd(g1[i - 1], g2[i + 1]);
	}
	ans[0] = g2[1];
	ans[n - 1] = g1[n - 2];

	sort(ans.begin(), ans.end());
	reverse(ans.begin(), ans.end());
	cout << ans[0] << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <iostream>
#include <string>
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int S;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  cin>>N;
  S = 0;
  for (int i = 0; i < N; ++i) {
  cin>>A[i];
}
  for (int i = 0; i < N; ++i) {
  cin>>B[i];
}
  for (int i = 0; i < N-1; ++i) {
  cin>>C[i];
}
  for(int i=0;i<N;i++){
  int a;
    a=0;
  a = A[i];
  S += B[a-1];
    if(A[i]+1 == A[i+1]){
      S += C[a-1];
    }
  }
 cout<<S<<endl;
}

Measured memory_bytes: 640
n = int(input())
l = list(map(int, input().split()))

ans = 0
for i in range(n):
    for g in range(i+1, n):
        for m in range(g+1, n):
            a = l[i]
            b = l[g]
            c = l[m]
            if a != b and b != c and c != a:
                if a+b > c and b+c > a and c+a > b:
                    ans += 1
print(ans)

Measured memory_bytes: 9196
#include <cstdio>
#include <complex>
#include <vector>
using namespace std;
typedef complex<double> P;
const double PI=3.141592653589793238462643383279;

bool inC(P p, P c, double r){return abs(p-c)<r+1e-9;}

P getE(P p){return p/abs(p);}

double sq(double x){ return  x*x;}

int main(){
    int n,i,j,k,ans,cnt;
    double x, y;
    while(scanf("%d",&n)){
        if(n==0) break;
        ans=0;
        vector<P> ps(n);
        for(i=0; i<n; i++){
            scanf("%lf%lf",&x,&y);
            ps[i] = P(x,y);
        }
        for(i=0;i<n;i++)
            for(j=i+1;j<n;j++)if(abs(ps[i]-ps[j])<2){
                double d=sqrt(1-sq(abs(ps[j]-ps[i])*0.5));
                P c1=0.5*(ps[i]+ps[j])+getE(getE(ps[j]-ps[i]))*polar(d,PI/2);
                P c2=0.5*(ps[i]+ps[j])+getE(getE(ps[j]-ps[i]))*polar(d,-PI/2);
                cnt=0;
                for(k=0;k<n;k++)if(inC(ps[k],c1,1.0))cnt++;
                if(cnt>ans)ans=cnt;
                cnt=0;
                for(k=0;k<n;k++)if(inC(ps[k],c2,1.0))cnt++;
                if(cnt>ans)ans=cnt;
            }
        if(ans==0) ans++;
        printf("%d\n",ans);
    }
    return 0;
}

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

	#define int ll

	typedef long long ll;

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

	typedef vector<int> vi;
	typedef vector<ll> vll;
	typedef vector<pii> vpii;
	typedef vector<pll> vpll;

	#define FOR(i, a, b) for (int i=a; i<(b); i++)
	#define F0R(i, a) for (int i=0; i<(a); i++)
	#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
	#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

	#define ALL(s) (s).begin(),(s).end()
	#define ALLn(s,n) s,s+n
	#define F first
	#define S second
	#define pb push_back
	#define tc(t) int t; cin >> t; while(t--)
	#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
	#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
	#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

	const ll MOD = 1e9 + 7;
	const ll MAXN = 1e6 + 7;
	const ll INF = LONG_LONG_MAX;


	void solve() {
		ll n,k;
		cin >> n >> k;
		ll a[n];
		F0R(i,n) cin >> a[i];
		sort(ALLn(a,n));
		ll sum = 0;
		F0R(i,k) sum += a[i];
		cout << sum;
	}

	int32_t main() {_
		
	#ifndef ONLINE_JUDGE
		freopen("in", "r", stdin);
		freopen("out", "w", stdout);
	#endif
		// tc(t)
			solve();
		cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
	}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
ll mo;


ll dp[305];
ll X[305][305];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K>>mo;
	
	dp[0]=1;
	while(K--) {
		ZERO(X);
		FOR(i,N+1) X[i][i]=dp[i];
		FOR(i,N+1) {
			for(j=i;j<=N;j++) {
				if(j-i-1>=0) (X[j][j-i-1]+=X[j][j-i])%=mo;
				(X[j+1][j-i]+=(j-i+1)*X[j][j-i])%=mo;
			}
		}
		FOR(i,N+1) dp[i]=X[i][0];
	}
	cout<<dp[N]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define dbg() cerr <<
#define name(x) (#x) << ": " << (x) << ' ' <<

using namespace std;

int MAX = (int)1e5;
int MAGIC = 1 << 9;

int Par(int node) {
  return (node - 1) / 2;
}

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

  int n; cin >> n;
  vector<pair<int, int>> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i].second >> v[i].first;
  }

  vector<vector<int>> dp(MAGIC, vector<int>(MAX + 1));
  for (int i = 0; i <= MAX; ++i) {
    dp[0][i] = v[0].first <= i ? v[0].second : 0;
  }

  for (int i = 1; i < min(MAGIC, n); ++i) {
    int p = Par(i);
    for (int j = 0; j <= MAX; ++j) {
      dp[i][j] = dp[p][j];
      if (v[i].first <= j) {
        dp[i][j] = max(dp[i][j], dp[p][j - v[i].first] + v[i].second);
      }
    }
  }

  int q; cin >> q;
  while (q--) {
    int node, val; cin >> node >> val; --node;

    vector<int> nodes;
    while (node >= MAGIC) {
      nodes.emplace_back(node);
      node = Par(node);
    }

    int ans = 0;
    for (int mask = 0; mask < (1 << (int)nodes.size()); ++mask) {
      int V = 0, W = 0;
      for (int bit = 0; (1 << bit) <= mask; ++bit) {
        if ((mask & (1 << bit)) != 0) {
          W += v[nodes[bit]].first;
          V += v[nodes[bit]].second; 
        }
      }

      if (W > val) continue;
      ans = max(ans, dp[node][val - W] + V);
    }

    cout << ans << '\n';
  }
}


Measured memory_bytes: 206452
import numpy as np
import math

# K = int(input())
# N, K = map(int, input().split())
# A = list(map(int, input().split()))
# S = input() # String
# DP = np.zeros((N, Y), dtype=int)

sN = input()
N = int(sN)
arN = list(map(int, sN))

def match(p):
    arP = list(map(int, str(p)))
    return arP[0] == arP[1] and arP[1] == arP[2]

if N <= 111:
    print(111)
    exit(0)

while not match(N):
    N = N + 1
    # print(N)
    

print(N)


Measured memory_bytes: 12504
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int i = 0;

		while(k*i <= b) {
			if(k * i >= a && k * i <= b) {
				System.out.println("OK");
				return;
			}
			i++;
		}
		System.out.println("NG");
	}

}


Measured memory_bytes: 35816
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

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

int r, D, x;

int main() {

	scanf("%d%d%d", &r, &D, &x);

	rep(i, 10) {
		x = r * x - D;
		printf("%d\n", x);
	}

	return 0;
}


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

using namespace std;

int n,a[100005],x;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    sort (a+1,a+n+1);
    cout << a[n] << ' ';
    if (a[n]%2==0) x=a[n]/2;
    else x=a[n]/2+1;
    for (int i = 1; i < n; i++)
        if (a[i]<=x&&a[i+1]>=x)
        {
            if (abs(x-a[i])<=abs(x-a[i+1])) cout << a[i];
            else cout << a[i+1];
            return 0;
        }
}

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

int main() {
  int N; cin >> N;
  int max_A = 0;
  vector<int> B(N - 1);
  for (int i = 0; i < N - 1; i++) {
    cin >> B.at(i);
  }
  
  for (int i = 0; i < N - 2; i++) {
    max_A += min(B.at(i), B.at(i + 1));
  }
  
  max_A += B.at(0) + B.at(N - 2);
  
  cout << max_A << endl;
}
  
  
  

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(){

  int a,b;

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

  if((a + b) % 2 == 1) printf("IMPOSSIBLE\n");

  else printf("%d\n", (a + b)/2);
  
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    cout << max(max(2*a-1, 2*b-1), a+b) << endl;
}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#define rep(i,s,n) for (int i=s;i<n;++i)
#define drep(i,s,n) for (int i=n;i>=s;--i)
#define all(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define print(x) cout<<(x)<<endl
using namespace std;
typedef long long ll;

int gcd(int a,int b)
{if (a%b == 0) return(b);
 else          return(gcd(b,a%b));}
int lcm(int a,int b)
{return a*b/gcd(a,b);}
void printv(vector<auto> v) {cout<<'[';rep(i,0,v.size()){cout<<v[i]<<',';}cout<<']'<<endl;}
void printvv(vector<vector<auto>> vv)
{
  cout<<'['<<endl;
  rep(q,0,vv.size()){cout<<'[';rep(p,0,vv.at(q).size())cout<<vv.at(q).at(p)<<',';cout <<']'<<endl;}
  cout<<']'<<endl;
}
void solve(); int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}
int step_x[] = {-1,0,0,1};
int step_y[] = {0,-1,1,0};
//------------------------------------------------------------
ll k,ans=0;

void solve() {
  cin>>k;

  rep(i,1,k+1)
  {
    rep(j,i,k+1)
    {
      if(j==i)
      {
        // 全部同じ
        ans += i;

        // 二つ同じ
        rep(l,j+1,k+1) ans+=gcd(i, gcd(j,l))*3;
      }
      else
      {
        // 二つ同じ
        ans+=gcd(i, j)*3;

        // 全部違う
        rep(l,j+1,k+1) ans+=gcd(i, gcd(j,l))*6;
      }
    }
  }

  print(ans);

  return;
}


Measured memory_bytes: 3652
#include <algorithm>
#include <cmath>
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll  = long long;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N;
    string S;
    cin >> N >> S;

    for(char c : S){
        cout << (char)(((c - 'A' + N) % 26) + 'A');
    }
    cout << endl;
}

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

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String line = null;
        while ((line = reader.readLine()) != null && !line.isEmpty()) {
            double target = Double.parseDouble(line);
            int n = 2;
            while (true) {
                double v = Math.sqrt(98 * n - 98);
                if (v >= target) {
                    break;
                }
                n++;
            }
            out.println(n);
        }
    }
}

Measured memory_bytes: 9728
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999;
	
	public class Cake
	{
		public int Index{get;set;}
		public int Count{get;set;}
	}
	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var k = p[0];
		var t = p[1];
		var a = Input().ToInt();
		var cakes = new HeapQueue<Cake>(t, (b,c) => b.Count - c.Count);
		for(int i = 0; i < t; i++)
		{
			cakes.Push(new Cake(){Index = i, Count = a[i]});
		}
		int r = 0;
		int lastCake = -1;
		for(int i = 0; i < k; i++)
		{
			var cake = cakes.Pop();
			if(cake.Index == lastCake && cakes.Count > 0)
			{
				var cake2 = cakes.Pop();
				cake2.Count--;
				if(cake2.Count > 0)
				{
					cakes.Push(cake2);
				}
				cakes.Push(cake);
				lastCake = cake2.Index;
				
			}
			else if(cake.Index == lastCake && cakes.Count == 0)
			{
				r++;
				cake.Count--;
				if(cake.Count > 0)
				{
					cakes.Push(cake);
				}
				lastCake = cake.Index;
				
			}
			else
			{
				cake.Count--;
				if(cake.Count > 0)
				{
					cakes.Push(cake);
				}
				lastCake = cake.Index;
			}
		}
		Console.WriteLine(r);
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}

class HeapQueue<T> 
{
	private List<T> _buffer;
	private Comparison<T> _comparer;
	
	public HeapQueue()
	{
		_buffer = new List<T>();
	}
	
	public HeapQueue(int capacity, Comparison<T> comparer = null)
	{
		_buffer = new List<T>(capacity);

		_comparer = comparer;
	}
	
	public void Push(T el)
	{
		List<T> array = _buffer;
		int n = array.Count;
		array.Add(el);
		
		while (n != 0)
		{
			int i = (n - 1) / 2;
			if (Compare(array[n], array[i]) > 0)
			{
				T tmp = array[n]; array[n] = array[i]; array[i] = tmp;
			}
			n = i;
		}
	}
	
	public T Pop()
	{
		T el = _buffer[0];
		
		List<T> array = _buffer;
		
		int n = array.Count - 1;
		array[0] = array[n];
		array.RemoveAt(n);

		for (int i = 0, j; (j = 2 * i + 1) < n; )
		{
			if ((j != n - 1) && (Compare(array[j], array[j + 1]) < 0))
				j++;
			if (Compare(array[i], array[j]) < 0)
			{
				T tmp = array[j]; array[j] = array[i]; array[i] = tmp;
			}
			i = j;
		}
		return el;
	}
	
	public T Peep()
	{
		if(_buffer.Count <= 0)
			return default(T);

		return _buffer[0];
	}
	private int Compare(T left, T right)
	{
		return _comparer(left, right);
	}
	
	public int Count
	{
		get{ return _buffer.Count; }
	}
	
}

Measured memory_bytes: 11220
#include <iostream>
#include <memory>
#define MAX_N 8
#define MAX_M 28
using namespace std;

int N,M;
bool g[MAX_N][MAX_N] = {false};
int dp[1 << MAX_N][MAX_N];//dpテーブル

//すでに訪れた頂点をＳ、現在位置がvとする
int rec(int S ,int v){
    if(S ==(1 << N) - 1){
        return 1;//全ての頂点を訪問した。
    }
    int res = 0;
    for(int u = 0; u < N; u++){
        if(!(S >> u & 1) && g[v][u] == true){//まだuには訪問していない　かつ、その辺は存在するか
            //次にuに移動する
            res += rec(S | 1 << u, u);
        }
    }
    return res;
}

int main(){
    cin >> N >> M;
    int f,t;
    for(int i = 0; i < M; i++){ 
        cin >> f >> t;
        g[f-1][t-1] = true;
        g[t-1][f-1] = true;
    }
    //bitDPで計算する
    cout << rec(1,0) << endl;//頂点1からスタートする。
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

char a[101],b[101];

int main(){
	scanf("%s %s",a,b);
	if(strlen(a) > strlen(b)) printf("GREATER");
	else if(strlen(a) < strlen(b)) printf("LESS");
	else{
		for(int i = 0; i < strlen(a); i++){
			if(a[i] > b[i]){
				printf("GREATER");
				break;
			}
			if(a[i] < b[i]){
				printf("LESS");
				break;
			}
			if(i+1 == strlen(a)) printf("EQUAL");
		}
	}
}

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

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

    long long res = 0;
    for(int i=1; i<=n; i++){
        if (i%3 == 0 and i%5 == 0) continue;
        if(i%3 == 0) continue;
        if (i%5 == 0) continue;

        res += i;
    }
    cout << res << endl;
}


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

int main(void){
	double a,b,c,d,e,f;
	double x,y;
	cout << fixed;
	cout.precision(3);
	while(cin >> a >>b >> c >> d >> e >>f){
		y=(c*d-a*f)/(b*d-a*e); if(y==0) y=0;
		x=(c*e-b*f)/(a*e-b*d); if(x==0) x=0.0;
		cout << x << " " << y << endl;
	}
	return 0;
}

Measured memory_bytes: 1284
N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]
if N == 1:
  print(1)
  exit()
d = []
for i in range(N):
  for j in range(N):
    if i == j:
      continue
    X = xy[i][0] - xy[j][0]
    Y = xy[i][1] - xy[j][1]
    d.append([X,Y])
d.sort()
#print(d)
cnt = 1
tmp = 1
std = d[0]
for i in range(1,len(d)):
  if d[i] == std:
    tmp += 1
  else:
    tmp = 1
  std = d[i]
  cnt = max(cnt,tmp)
print(N - cnt)

Measured memory_bytes: 3444
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

int solve(int x)
{
  return x == 0 ? 1 : 0;
}

int main()
{
  int x;
  std::cin >> x;

  std::cout << std::setprecision(20);
  std::cout << solve(x) << std::endl;
}


Measured memory_bytes: 3632
N = int(input())
A = list(map(int, input().split()))

a_max = max(A)
a_min = min(A)

cnt_dict = {}
for i in range(a_min-1, a_max+2):
    cnt_dict[i] = 0
for i in range(len(A)):
    cnt_dict[A[i]-1] += 1
    cnt_dict[A[i]] += 1
    cnt_dict[A[i]+1] += 1

print(max(cnt_dict.items(), key = lambda x: x[1])[1])


Measured memory_bytes: 98124
#include <iostream>
using namespace std;
int main() {
	string N;
	cin >> N;
	for (int i = 0; i < 3; i++) {
		if (N.at(i) == '7') {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}


Measured memory_bytes: 3628
import java.security.KeyStore.TrustedCertificateEntry

object Main {

  import java.util.Scanner

  def main(args: Array[String]): Unit = {
    val scanner = new Scanner(System.in)
    val s = scanner.next
    var n = s.toInt
    var sum = 0

    while(n != 0){
      sum += n
      n -= 1
    }

    println(sum)
  }
}

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

int main(){
	int C,N,K,x;
	C = 0;
	cin >> N >> K;
	
	for(int i = 0; N > i;i++){
		cin >> x;
		int A,B;
		A = x;
		B = x - K;
		if(B<0)
			B = (-1)*B;
		if(A>B)
			C = C+2*B;
		else
			C = C+2*A;
	}
	
	cout << C <<endl;
}



Measured memory_bytes: 256
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip>
#include<map>
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll t;
    while (cin >> t)
    {
        if(t>=1000000000000000000)
        {
            cout<<"3760\n";
            continue;
        }
        ll k=100,i;
        for(i=0;i<=3760;i++)
        {
            k=k+k*0.01;
            if(k>=t)break;
        }
        //cout<<k;
        cout<<i+1<<'\n';
    }
}

Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main()
{
	//79502884197169399375105820974944
  int r;
   cin>>r;
   long double pi=3.1415926535897932384626433832;
long  double ans = 2*r*pi;
cout<<ans<<setprecision(6);

  return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n=s.size();
    bool flag=true;
    if(s.at(n-1)=='1') flag=false;
    if(s.at(0)=='0') flag=false;
    for(int i=0; i<n/2; i++){
        if(s.at(i)!=s.at(n-2-i)){
            flag = false;
        }
    }
    if(!flag){
        cout << -1 << endl;
        return 0;
    }

    //そうでないとき
    //i個の連結成分の有無はS.at(i-1)が持ってる

    
    if(n%2==0){
        int m=n/2;
        if(s.at(m-1)=='1'){
            cout << m << " " << n+1-m << endl;
            int before=m;
            for(int i=m-1;i>=1;i--){
                if(s.at(i-1)=='1'){
                    cout << before <<  " " << i << endl;
                    cout << n+1-before << " " << n+1-i << endl;
                    before = i;
                }
                else{
                    cout << before << " " << i << endl;
                    cout << n+1-before << " " << n+1-i <<endl;
                }
            }
        }
        if(s.at(m-1)=='0'){
            cout << m << " " << n << endl; //あとは奇数と同じ処理
            n--;
            int k=(n+1)/2;
            int before = k;
            for(int i=k-1;i>=1;i--){
                if(s.at(i-1)=='1'){
                    cout << before <<  " " << i << endl;
                    cout << n+1-before << " " << n+1-i << endl;
                    before = i;
                }
                else{
                    cout << before << " " << i << endl;
                    cout << n+1-before << " " << n+1-i <<endl;
                }
            }
        return 0;
        }
    }
    if(n%2==1){
//        cout << "a" << endl;
        int m=(n+1)/2;
        int before = m;
        for(int i=m-1;i>=1;i--){
            if(s.at(i-1)=='1'){
                cout << before <<  " " << i << endl;
                cout << n+1-before << " " << n+1-i << endl;
                before = i;
            }
            else{
                cout << before << " " << i << endl;
                cout << n+1-before << " " << n+1-i <<endl;
            }
        }
    }
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner();
		String s = sc.next();
		int max = Integer.MAX_VALUE;
		for(int i = 0; i < s.length() - 2; i++) {
			int n = Integer.parseInt(s.substring(i, i+3));
			if(Math.abs(753 - n) < max)
				max = Math.abs(753 - n);
		}
		System.out.println(max);
	}
}

class Scanner {
	private static final int SPACE = (int)' ';
	private static final int LINE_END_0 = 13;
	private static final int LINE_END_1 = 10;
	private static final int BEFORE = -1;
	private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public String next(){
		StringBuilder sb = new StringBuilder();
		
		int length = BEFORE;
		readLoop: while(true) {
			try {
				int value = br.read();
				switch(value) {
				case LINE_END_1:
					if(length == BEFORE)
						break;
					
					if((int)sb.charAt(length) == LINE_END_0)
						sb.deleteCharAt(length);
				case SPACE:
					break readLoop;
				}
				sb.append((char)value);
				length++;

			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return sb.toString();
	}
	
	public String[] nextArray(int length) {
		String[] array = new String[length];
		for(int i = 0; i < length; i++)
			array[i] = next();
		return array;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	
	public double[] nextDoubleArray(int length) {
		double[] array = new double[length];
		for(int i = 0; i < length; i++)
			array[i] = nextDouble();
		return array;
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public int[] nextIntArray(int length) {
		int[] array = new int[length];
		for(int i = 0; i < length; i++)
			array[i] = nextInt();
		return array;
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
	
	public long[] nextLongArray(int length) {
		long[] array = new long[length];
		for(int i = 0; i < length; i++)
			array[i] = nextLong();
		return array;
	}
	
	public boolean ready() {
		try {
			return br.ready();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define ull unsigned long long
#define mod 1000000007
using namespace std;

int bfs(int s, int d, int* a, int n) {
  bool visited[n+1];
  memset(visited,false,sizeof(visited));
  visited[s] = true;
  queue<int> q;
  q.push(s);
  int ops = 0;
  bool found = false;
  while(!q.empty()) {
    int node = q.front();q.pop();
    // cout<<"node: "<<node<<endl;
    if(node==d) {
      found=true;
      break;
    }
    if(!visited[a[node]]) {
      visited[a[node]] = true;
      q.push(a[node]);ops++;
    }
  }
  if(found)
    return ops;
  return -1;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin>>n;
  int a[n+1];
  a[0] = 0;
  for(int i=1;i<=n;i++) cin>>a[i];
  cout<<bfs(1,2,a,n);
  cout<<"\n";
  return 0;
}

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

int main(){
  string S;
  cin>>S;
  if((S.at(0)==S.at(1)&&S.at(2)==S.at(3)&&S.at(0)!=S.at(2))||(S.at(0)==S.at(2)&&S.at(1)==S.at(3)&&S.at(0)!=S.at(1))||(S.at(0)==S.at(3)&&S.at(1)==S.at(2)&&S.at(0)!=S.at(1))){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
    


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuffer str = new StringBuffer(sc.next());
		String S = str.reverse().toString();
		sc.close();
		System.out.println(solve(S));
	}
	
	public static String solve(String S) {
		int index = 0;
		while(index+5<S.length()) {
			if(S.substring(index,index+5).equals("esare")) {
				index += 5;
			}else if(S.substring(index,index+5).equals("maerd")) {
				index += 5;
			}else if(S.substring(index,index+6).equals("resare")) {
				index += 6;
			}else if(S.substring(index,index+7).equals("remaerd")) {
				index += 7;
			}else {
				return "NO";
			}
		}
		return "YES";
	}
}


Measured memory_bytes: 30968
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner s= new Scanner(System.in);
		int l = s.nextInt();
		int r = s.nextInt();
		int d=s.nextInt();
		
		int count = multiples(l,r,d);
		System.out.println(count);

	}

	private static int multiples(int l, int r, int d) {
		
		int count = 0;
		
		for(int i=l;i<=r;i++) {
			if(i % d == 0 ) {
				count++;
			}
		}
		return count;
	}

}


Measured memory_bytes: 35620
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main(){
	int n; cin >> n;
	if(n % 2 == 0){
		cout << n << endl;
	}else{
		cout << n * 2 << endl;
	}
	return 0;
}

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

int main() {
  long n,ac=0,wa=0,tle=0,re=0;
  cin >> n;
  for(long i=0;i<n;i++) {
    string s;
    cin >> s;
    if(s=="AC") ac++;
    if(s=="WA") wa++;
    if(s=="TLE") tle++;
    if(s=="RE") re++;
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int gcd(int a, int b){
  return b?gcd(b,a%b):a;
}
int main(){
  int n,m,a;
  scanf("%d%d",&n,&m);
  while(--n){
    scanf("%d",&a);
    m=gcd(m,a);
  }
  printf("%d\n",m);
}

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

int main() {
  int n,k;
  cin >> n >> k;
  long long min = 1000000000;
  vector<long long>data(n);
  for(int i = 0;i < n;i++){
    cin >> data.at(i);
  }
  sort(data.begin(),data.end());
  for(int i = 0;i < n-k+1;i++){
    if(data.at(i+k-1)-data.at(i) < min){
      min = data.at(i+k-1)-data.at(i);
    }
  }
  cout << min << endl;
}


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

vector<pair<int, int> > G[100001];
int color[100001];

void dfs(int k, int step, int prev) {
    if (step % 2 == 0) {
        color[k] = 1;
    }
    for (int i=0; i<G[k].size(); ++i) {
        if (G[k][i].first != prev) {
            dfs(G[k][i].first, step+G[k][i].second, k);
        }
    }
}

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

    int N;
    cin >> N;
    
    int u, v, w;
    for (int i=0; i<N-1; ++i) {
        cin >> u >> v >> w;
        G[u].push_back(make_pair(v, w));
        G[v].push_back(make_pair(u, w));
    }

    dfs(1, 0, -1);

    for (int i=1; i<=N; ++i) {
        cout << color[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 9216
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())



def main():
    n,m,k = map(int,input().split())
    friend = [[] for i in range(n)]
    block = [[] for i in range(n)]

    for i in range(m):
        a,b = map(lambda x: int(x)-1,input().split())
        friend[a].append(b)
        friend[b].append(a)
    # print(friend)
    
    for i in range(k):
        c,d = map(lambda x:int(x)-1,input().split())
        block[c].append(d)
        block[d].append(c)
    
    # print(block)

    un = UnionFind(n)
    
    for i in range(len(friend)):
        for j in range(len(friend[i])):
            # print(i,friend[i][j])
            un.union(i,friend[i][j])
    
    ans = []
    for i in range(len(block)):
        cnt = 0
        for j in range(len(block[i])):
            # print(i,block[i][j])
            if un.find(i) == un.find(block[i][j]):
                cnt += 1
        ans.append(str(un.size(i)-len(friend[i]) - cnt - 1))

    # for i in range(n):
    #     # ans.append(str(len((set(un.members(i)) - (set(block[i])|set(friend[i]))))-1))
    #     print(un.size(i))
    #     print(len(friend[i]))
    #     print(len(block[i]))
    #     ans.append(str( un.size(i) - len(friend[i]) - len(block[i]) -1))

    print(' '.join(ans))

    return


if __name__ == "__main__":
    main()




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

int main(){
int N,K;
string S="";
cin>>N>>K;
cin>>S;
  transform(S.begin(), S.begin()+K, S.begin(), ::tolower);
    transform(S.begin(), S.begin()+K-1, S.begin(), ::toupper);
  cout<<S<<endl;
}

Measured memory_bytes: 256
/*
Author - Glitched
Yeet!!
*/
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define loop(i,x,n) for(ll i = x;i<n;i++)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    double n;
    cin>>n;
    n = n*M_PI*2;
    cout<<fixed<<setprecision(10)<<n;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    string S;
    cin >> S;
    if (S == "Sunny"){
        cout << "Cloudy" << endl;
    }
    else if (S == "Cloudy"){
        cout << "Rainy" << endl;
    }
    else if (S == "Rainy"){
        cout << "Sunny" << endl;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <complex>
#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,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main() {
    cin>>N;
    ll f = 0, n = N;
    while(n > 0){
        f += n%10;
        n /= 10;
    }
    cout<<(N%f == 0 ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int pref[110];
int suff[110];

int main()
{
  int n;
  cin >> n;
  int ara[n+10],freak[n+10];
  for(int i=1; i<=n; i++)
  {
      cin >> ara[i];
  }
  for(int i=1; i<=n; i++)
  {
      cin >> freak[i];
  }

  for(int j=1; j<=n; j++)
  {
      pref[j] += pref[j-1] + ara[j] ;
  }
  for(int j=n; j>=1; j--)
  {
      suff[j] += suff[j+1] + freak[j] ;
  }

  int mx = 0;
  for(int i=1; i<=n; i++)
  {
      mx = max(mx,pref[i]+suff[i]);
  }
  cout << mx << endl;


}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

int main(){


  int n;cin>>n;
  if(n==1){
    cout<<1<<endl;
    return 0;
  }
  LP x[n];
  REP(i,n){
    LP p;
    cin>>p.first>>p.second;
    x[i] = p;
  }

  vector<LP> v;
  REP(i,n){
    for(int j=i+1;j<n;j++){
      P p;
      p.first = x[i].first - x[j].first;
      p.second = x[i].second - x[j].second;
      v.pb(p);
    }
  }

  ll ans = INF;
  REP(i,v.size()){
    ll zeroCount = 0;
    LP now = v[i];
    REP(j,n){
      for(int k = j+1;k<n;k++){
        if((x[j].first - x[k].first) == now.first && (x[j].second - x[k].second) == now.second){
          zeroCount++;
        }else if((x[j].first - x[k].first) == now.first*(-1) && (x[j].second - x[k].second) == now.second*(-1) ){
          zeroCount++;
        }
      }
    }
    ans = min(ans,n-zeroCount);
  }

  cout<<ans<<endl;
 

  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
study_days = map(int, input().split())

# リストにM個の数字を、入力したい
# study_days_list = []
# study_days_list.append(study_days)
# print(study_days_list)

total_study_days = sum(study_days)

answer = (N - total_study_days)

if answer < 0:
    print(-1)
else:
    print(answer)

Measured memory_bytes: 9516