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

using namespace std;

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

#define fi				first
#define se 				second
#define pb 				push_back
#define mp 				make_pair
#define all(v)			v.begin(),v.end()
#define sz(v)			s.size()
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define per(i,a,b) 		for(int i=a;i>=b;i--)
#define fill(a,v)		memset(a,v,sizeof(a))
#define tc				int T;cin>>T;while(T--)
#define nl				printf("\n")
#define aya				printf("yaha aya\n")
#define debug(x,y)		printf("%d %d\n",x,y)
#define fast_io			ios_base::sync_with_stdio(false);cin.tie(NULL);
#define grt				greater<int>()

const int mod = 1e9+7;
const int mod2= 1e9+9;

inline int pow_(ll a, int n, int p=mod){
	int r=1;while(n){if(n&1)r=r*a%p;n>>=1;a=a*a%p;}return r;
}

int main(void)
{
	ll n;cin>>n;
	vll div;
	for(ll i =1 ;i*i <= n ;i++)
	{
		if(n%i == 0)
		{
			div.pb(i);
			if(i*i != n) div.pb(n/i);
		}
	}
	ll ans = 0;
	for(auto i : div){
		ll temp = i-1;
		if(temp == 0) continue;
		if(n/temp == n%temp) ans += temp;
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 384
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,m,a[100],tot,L;
int main(void){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i];
        tot+=a[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    L=(tot+m*4-1)/(m*4);
    for(int i=0;i<m;i++){
        if(a[i]<L){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
dic = {}
ans = 0
for i in range(M):
    p,s = input().split()
    if s == "AC":
        if p in dic:
            ans += dic[p]
        dic[p] = 0
    else:
        if p in dic:
            if dic[p] != 0:
                dic[p] += 1
        else:
            dic[p] = 1

print(len([1 for i in dic.values() if i==0]),ans)

Measured memory_bytes: 17112
#!/usr/bin/env python3
n,k = map(int,input().split())
h = list(map(int,input().split()))
INF = 10**12
dp = [INF]*n
dp[0] = 0 #初期化
dp[1] = abs(h[1]-h[0])
for i in range(2,n):
    for j in range(1,k+1):
        if i - j >= 0: 
            dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[n-1])

Measured memory_bytes: 52448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	// your code goes here
	ll n;
	cin>>n;
	double a[n];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
	}
	double dp[n+1][n+1];			// first index : heads
								// second index : tails
	dp[0][0]=1;
	for(ll i=1;i<=n;i++)
	{
		dp[i][0] = dp[i-1][0]*a[i-1];
	}
	for(ll i=1;i<=n;i++)
	{
		dp[0][i] = dp[0][i-1]*(1-a[i-1]);
	}
	for(ll i=1;i<n;i++)
	{
		for(ll j=1;j<n;j++)
		{
			if(i+j<=n)
			dp[i][j] = dp[i-1][j]*a[j+i-1] + dp[i][j-1]*(1-a[j+i-1]);
		}
	}
	double sum=0;
	for(ll i=0;i<=n;i++)
	{
		for(ll j=0;j<=n;j++)
		{
			if(i+j==n&&i>j)
			{
				
				sum+=dp[i][j];
			}
		}
	}
	printf("%.12lf\n",sum);
	return 0;
}

Measured memory_bytes: 70272
S = raw_input()
if "HA" not in S and "H" in S:
    S = S.replace("H", "HA")
if "BA" not in S and "B" in S:
    S = S.replace("B", "BA")
if "RA" not in S and "R" in S:
    S = S.replace("R", "RA")
if S[0] != "A":
    S = "A" + S
if S == "AKIHABARA":
    print "YES"
else:
    print "NO"



Measured memory_bytes: 2568
def is_the_day(m,d):
    return d >= 22 and (d%10) >= 2 and (d//10) >= 2 and (d%10)*(d//10) == m

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

ans = 0

for m in range(1,M+1):
    for d in range(1,D+1):
        ans += int(is_the_day(m,d))

print(ans)

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

int main()
{
	int a, b, c;
	int count = 0;

	cin >> a >> b >> c;

	int i = a;
	while (i <= b) {
		if (c%i == 0) {
			count++;
		}
		i++;
	}

	cout << count << "\n";
    return 0;
}




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

using namespace std;

void boost() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
    boost();
    long long n;
    cin >> n;
    map <long long, bool> u;
    long long arr[n + 1];
    for (int i = 1; i <= n; ++ i) {
        cin >> arr[i];
        if (u[arr[i]] == true) {
            cout << "NO";
            return 0;
        }
        u[arr[i]] = true;
    }
    cout << "YES";
    return 0;
}


Measured memory_bytes: 14336
package main

import (
	"fmt"
)

func main() {
	var v string
	fmt.Scan(&v)

	var a byte

	if v[0] == 'A' {
		a = 'T'
	} else if v[0] == 'T' {
		a = 'A'
	} else if v[0] == 'C' {
		a = 'G'
	} else if v[0] == 'G' {
		a = 'C'
	}
	fmt.Println(string(a))
}


Measured memory_bytes: 1768
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,k; cin >> n >> k;
    vector<int> h(n);
    vector<int> dp(n,INT_MAX);

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

    dp[0] = 0;

    for(int i=0;i<n;i++){
    	for(int j=i+1;j<=i+k;j++){
    		if(j<n){
    			dp[j] = min(dp[j],dp[i] + abs(h[i] - h[j]));
    		}
    	}
    }

    cout << dp[n-1] << endl;


    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    string s,t,k;
    cin >> s;
    int n = s.size();
    bool ok = 1;
    for(int i=0;i<n/2;i++){
        if(s[i] != s[n-1-i])ok = 0;
    }
    for(int i=0;i<n/2;i++){
        t.push_back(s[i]);
        k.push_back(s[n-1-i]);
    }
    n = t.size();
    for(int i=0;i<n/2;i++){
        if(t[i] != t[n-1-i])ok = 0;
        if(k[i] != k[n-1-i])ok = 0;
    }
    cout << (ok?"Yes":"No") << endl;
}

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

int main() {
        int a;
        int b;
        int x;

        cin >> a >> b;

        x = a * b;

        if (x % 2 == 0) {
                cout << "Even" << endl;
        }
        else {
                cout << "Odd" << endl;
        }
}


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

using namespace std;

#define int long long

int a, b, x, y, n;

main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> a >> b;
    if (a>b)
        return cout << 0, 0;
    if (n==1 && a!=b)
        return cout << 0, 0;
    int x=a*(n-1)+b,
    y=b*(n-1)+a;
    cout << y-x+1;
    return 0;
}
//Easy Peasy



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve() {
  string S, T;
  int ans = 0;
  cin >> S; cin >> T;
  REP0(i, 3) ans += (S[i]==T[i]);
  cout << ans << endl;
}

int main(int argc, char const *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout<<std::fixed<<std::setprecision(10);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int a, b;
  char op;
  while(std::cin >> a >> op >> b, op != '?'){
    if (op == '+') {
      std::cout << a + b << std::endl;
    } else if (op == '-') {
      std::cout << a - b << std::endl;
    } else if (op == '*') {
      std::cout << a * b << std::endl;
    } else {
      std::cout << a / b << std::endl;
    }
  }
}


Measured memory_bytes: 3096
#include<iostream>
// #include<string>
#include<math.h>
using namespace std;

int main(){
    long long int p= pow(10,9)+7;
    long long int N;
    cin >> N;
    long long int A[N];
    long long int sum=0;
    for(int i=0; i<N; i++){
        cin >> A[i];
        sum+= A[i];
        sum%= p;
    }

    long long int a=0;
    for(int i=0; i<N; i++){
        sum-= A[i];
        if(sum<0) sum+= p;
        a+= A[i]*sum;
        a%= p;
    }
    cout << a << endl;
    
    return 0;
}

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

typedef long long ll;

const int MAXN = 3002;

ll dp[MAXN][MAXN];
bool vis[MAXN][MAXN];
int A[MAXN],N;

ll solve(int i,int j)
{
	if(vis[i][j]) return dp[i][j];
	vis[i][j] = 1;
	if(i == j) return dp[i][j] = A[i];
	return dp[i][j] = max(A[i] - solve(i+1,j), A[j] - solve(i,j-1));
}

int main()
{
	cin >> N;
	for(int i = 1;i<=N;i++){
		cin >> A[i];
	} 
	cout << solve(1,N) <<"\n";
}

Measured memory_bytes: 58692
# a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


K = int(input())
ans = 0

for i in range(K):
    for j in range(K):
        for k in range(K):
            ans += gcd(gcd(i+1, j+1), k+1)
print(ans)

Measured memory_bytes: 69116
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
	int n;
	long long int S=0LL;
	cin >> n;
	vector<long int>a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(&a[0], &a[n]);
	for (int i = 0; i < n; i++) {
		S += a[i];
	}
	cout << a[0] << " " <<  a[n - 1] << " "<< S<<endl;
}

Measured memory_bytes: 1296
def shellSort(A,N):
    cnt = 0
    G = []
    h = 1
    while h<=N:
        G.append(h)
        h = 3*h +1

    for i in range(0, len(G)):
        cnt = cnt + insertionSort(A, N, G[len(G)-i-1])

    print(len(G))
    for i in range(len(G)):
        print(G[len(G)-i-1], end=" ")
    print()
    print(cnt)
    for i in range(N):
        print(A[i])

def insertionSort(A, N, g):
    cnt = 0
    for i in range(g, N):
        v = A[i]
        j = i - g
        while j>= 0 and A[j]>v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return cnt

listnum=[]
n = int(input())
for i in range(n):
    listnum.append(int(input()))

shellSort(listnum, n)



Measured memory_bytes: 45516
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
#include<set>

using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)

#define shosu setprecision(10)
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
typedef pair<Q,ll> R;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。
//↑はあんまり気にしなくていい。

int main(){
    int a,p;
    cin>>a>>p;
    cout<<(3*a+p)/2<<endl;
    
    return 0;
}

Measured memory_bytes: 256
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

const int MAXV = 1000010;
int N, X, dp[MAXV + 10], isPrime[MAXV + 10];
 
signed main() {
    fill(isPrime, isPrime + MAXV, true);
    isPrime[0] = isPrime[1] = false;
    for(int k=2; k<=MAXV; k++) {
        if(isPrime[k]) {
            for(int i=k+k; i<=MAXV; i+=k) {
                isPrime[i] = false;
            }
        }
    }

    while(cin >> N >> X, N) {
        memset(dp, 0, sizeof(dp));
        dp[0] = true;
        for(int i=0; i<N; i++) {
            int val; cin >> val;
            for(int p=0; p<=X-val; p++) {
                dp[p+val] |= dp[p];
            }
        }

        int ans = -1;
        for(int i=2; i<=MAXV; i++) {
            if(isPrime[i] and dp[i]) {
                ans = max(ans, i);
            }
        }

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


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

const int INF = 1e9;

int main()
{
    string s;
    cin >> s;
    if(s.length() == 2){
        cout << s << endl;
    }else{
        for(int i = s.length()-1; i >= 0; i--){
            cout << s[i];
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9
typedef pair<mp,mp> mmp;
int dx[] = {0,1,0,-1};//h
int dy[] = {1,0,-1,0};//w

int main(){
	while(1){
	int w,h;
	cin>>w>>h;
	if(w==0)break;
	priority_queue<mmp,vector<mmp> ,greater<mmp> > q;
	vector<vector<vector<int> > > dp(h+2,vector<vector<int> >(w+2,vector<int>(4,inf ) ) );
	vector<vector<int> > s(h+2,vector<int>(w+2,0) );
	int c[4];
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>s[i][j];
		}
	}
	for(int i=0;i<4;i++)cin>>c[i];

	//dp[1][1] = 0;
	q.push(mmp(mp(0,0),mp(1,1) ));
	int res = inf;
	while(!q.empty()){
		mmp now = q.top();
		q.pop();
		int cost = now.first.first;
		int dir = now.first.second;
		int x = now.second.first;
		int y = now.second.second;
		if(cost >= dp[x][y][dir])continue;
		dp[x][y][dir] = cost;
		if(s[x][y]!=4){
			int nd = (dir+s[x][y])%4;
			int nx = x+dx[nd];
			int ny = y+dy[nd];
			if(1<=nx&&nx<=h&&1<=ny&&ny<=w){
				q.push(mmp(mp(cost,nd),mp(nx,ny) ) );
			}
		}
		for(int i=0;i<4;i++){
			int nc = cost+c[i];
			int nd = (dir+i)%4;
			int nx = x+dx[nd];
			int ny = y+dy[nd];
			if(1<=nx&&nx<=h&&1<=ny&&ny<=w){
				q.push(mmp(mp(nc,nd),mp(nx,ny) ) );
			}
		}
	}
	for(int i=0;i<4;i++){
		res = min(res,dp[h][w][i]);
	}
	cout<<res<<endl;
	/*	for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				cout<<dp[i][j]<<' ';
			}
			cout<<endl;
		}*/
	}
	return 0;
}



Measured memory_bytes: 3696
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin>>N;
  string s;
  cin>>s;
  //1
  vector<int> v(N+1,0);
  for(int i=1;i<=N;i++)
    v[i]=s[i-1]=='.'? v[i-1]+1:v[i-1];
  //2
  int ans=N;
  for(int i=0;i<=N;i++)
    ans=min(ans,i-v[i]+v[N]-v[i]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1412
#include "bits/stdc++.h"
using namespace std;
vector <int> g[2222];
int a[2222];
bool vis[2222];
int opt;

void dfs(int x) {
	vis[x] = true;
	opt = min(opt, x);
	for(int i : g[x]) {
		if(vis[i] == false) {
			dfs(i);
		}
	}
}
vector <int> merge(vector <int> &p, vector <int> &q) {
	reverse(p.begin(), p.end());
	reverse(q.begin(), q.end());
	vector <int> ans;

	while(!(p.empty() && q.empty())) {
		if(p.empty()) {
			ans.push_back(q.back());
			q.pop_back();
		} else if (q.empty()) {
			ans.push_back(p.back());
			p.pop_back();
		} else if (p.back() < q.back()) {
			ans.push_back(q.back());
			q.pop_back();
		} else {
			ans.push_back(p.back());
			p.pop_back();
		}
	}
	return ans;
}

vector <int> dp[2222];
vector <int> aux[2222];
bool done[2222];

void solve(int x) {
	done[x] = true;
	sort(g[x].begin(), g[x].end());
	for(auto i : g[x]) {
		if(done[i] == false) {
			solve(i);
			aux[x].push_back(i);
		}
	}
	for(auto i : aux[x]) {
		dp[x] = merge(dp[i], dp[x]);
	}
	dp[x].insert(dp[x].begin(), x);
}
int main(int argc, char const *argv[])
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; i++) {
		for(int j = i + 1; j <= n; j++) {
			if(__gcd(a[i], a[j]) > 1) {
				g[i].push_back(j);
				g[j].push_back(i);
			}
		}
	}

	vector <int> ans;
	for(int i = 1; i <= n; i++) {
		if(vis[i] == false) {
			opt = n;
			dfs(i);
			solve(opt);
			ans = merge(ans, dp[opt]);
		}
	}
	for(auto i : ans) {
		printf("%d ", a[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 27136
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll x,t;
    cin >> x >>t;
    
    if (t > x)cout << 0 << endl;
    else cout << x - t << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 35;
const int MAXK = 510;
const int MAXQ = 200010;

int a[MAXN], n, f[MAXN];
ll res[MAXN], gt[MAXN], rev[MAXN];
vector<int> b;

ll mu(ll a, ll b) {
    if (b == 0) return 1;
    if (b == 1) return a % MODBASE;
    ll g = mu(a, b/2);
    if (b % 2) return g * g % MODBASE * a % MODBASE;
    return g * g % MODBASE;
}

ll C(int n, int k) {
    if (k > n) return 0;
    if (k < 0) return 0;
    return gt[n] * rev[n - k] % MODBASE * rev[k] % MODBASE;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    gt[0] = 1;
    rev[0] = mu(gt[0], MODBASE-2);
    FOR(i,1,100001) {
        gt[i] = gt[i-1] * i % MODBASE;
        rev[i] = mu(gt[i], MODBASE-2);
    }

    cin >> n;
    FOR(i,1,n+1) cin >> a[i];
    FOR(i,1,n+1) f[a[i]]++;
    int vt = 0;
    FOR(i,1,n)
        if (f[i] == 2) vt = i;
    // cout << vt << endl;
    FOR(i,1,n+1)
        if (a[i] == vt) b.emplace_back(i);
    int g = b[0] - 1;
    int h = n + 1 - b[1];
    //cout << g << ' ' << h << endl;
    g += h;
    res[1] = 1;
    FOR(i,2,n+1) res[i] = C(g, i-1);

    // FOR(i,1,n+1) cout << res[i] << ' ';
    // cout << endl;
    FOR(i,1,n+1) cout << (C(n+1, i) - res[i] + MODBASE) % MODBASE << "\n";
    return 0;
}

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


int main(){
  int n;
  cin >> n;
  bool ok=false;
  int cnt=0;
  for(int i=0;i<n;++i){
    int d1,d2;
    cin >> d1 >> d2;
    if(d1==d2)cnt++;
    else cnt=0;

    if(cnt>=3) ok=true;
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
string s;
int l;
int main()
{
    cin>>s;
    l=s.size();
    for(register int i=0;i<l;i++)
    {
        if(s[i]=='C')
        {
            for(register int j=i+1;j<l;j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll K;
  cin >> K;
  bool ok = false;
  ll cnt = 1;
  ll now = 7;
  while (cnt <= K) {
    if (now % K == 0) {
      ok = true;
      break;
    }
    now = (now * 10) % K + 7;
    now %= K;
    cnt += 1;
  }
  if (ok) {
    cout << cnt << "\n";
  }
  else {
    cout << -1 << "\n";
  }
}


Measured memory_bytes: 3644
import itertools

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

E = [set() for _ in range(N + 1)]

for _ in range(M):
    a, b = map(int, input().split())
    E[a].add(b)
    E[b].add(a)

ret = 0
for path in itertools.permutations(range(2, N + 1)):
    if path[0] not in E[1]:
        continue
    f = True

    for i in range(N - 2):
        if path[i + 1] not in E[path[i]]:
            f = False
            break
    if f:
        ret += 1

print(ret)


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

signed main()
{
  int w, a, b;

  cin >> w >> a >> b;

  if (abs(a - b) <= w) {
    cout << 0 << endl;
  } else {
    cout << abs(a - b) - w << endl;
  }

  return (0);
}


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

using namespace std;

typedef long long ll;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;
int n,m,cnt;
int f[MAXN];

int find(int x){
	if(x == f[x])
	    return x;
	else
	    return f[x] = find(f[x]);
}

int main()
{
	cin>>n>>m;
	for(int i = 1;i <= n;i++)
	    f[i] = i;
	
	while(m--){
		int x,y,z;
		cin>>x>>y>>z;
		int fx = find(x);
		int fy = find(y);
		if(fx != fy){
			f[fx] = fy;
			cnt++;
		}
	}
	cout<<n-cnt<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int gcd(int a,int b){
  if(b == 0) return a;
  return gcd(b,a%b);
}

int main(){
  int n,x;
  cin >> n >> x;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  vector<int> d(n);
  rep(i,n) d[i] = abs(x - v[i]);
  int g;
  rep(i,n){
    if(i == 0) g = d[0];
    else g = gcd(g,d[i]);
  }
  cout << g << endl;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int h, w;
  cin >> h >> w;
  char t[h][w];
  rep(i, h) rep(j, w) cin >> t[i][j];

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

  bool ok = true;
  rep(i, h) rep(j, w) if (t[i][j] == '#') {
    bool f = false;
    rep(k, 4) {
      int y = i + dy[k];
      int x = j + dx[k];
      if (!(0 <= y && y < h && 0 <= x && x < w)) continue;
      if (t[y][x] == '#') f = true;
    }
    if (!f) ok = false;
  }

  cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>//
#include <vector>//
#include <map>
#include <cstdlib>
#include <numeric>
#include <algorithm>//ソート等に使用
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <thread>///////////////////
#include <queue>//幅優先等のキュー
#include <stack>
#include <bitset>

#define rep(i,m,n) for(int i=(m);i<(n);i++)
#define mer(i,m,n) for(int i=(m);i>(n);--i)

#define MOD 1000000007
//#define MOD 998244353
//#define MAX 

using namespace std;

using ll = long long int;
using ld = long double;
using std::swap;

vector<int> v;
vector<int> w;
vector<long long int> vll;
vector<long long int> wll;
//vector<vector<int>> vec(50, vector<int>(4, 0));
vector<vector<int>> vv;
vector<vector<int>> ww;
//vector<char> vc;
vector<string> vs;




int main() {
	
	int D;
	cin >> D;
	v.resize(D + 1,0);
	w.resize(27, 0);
	vector<int> x(27, 0);
	vector<int> y(27, 0);
	vector<int> c(27);
	vv.resize(D + 1, vector<int>(27, 0));

	rep(i, 1, 27)cin >> c[i];
	rep(i, 1, D+1) {
		rep(j, 1, 27)cin >> vv[i][j];
	}

	y[0] -= 99999;
	rep(i, 1, D + 1) {
		rep(j, 1, 27) y[j] = vv[i][j] + c[j] * (i - x[j]) - c[j] * (D - i);
		int max_num = max_element(y.begin(), y.end()) - y.begin();
		x[max_num] = i;
		cout << max_num << '\n';
	}
	/*
	rep(i, 1, D+1) {
		int t, ans = 0;
		cin >> t;
		rep(j, 1, 27) {
			if (j == t)ans += vv[i][j];
			else ans -= c[j] * (i - x[j]);
		}
		x[t] = i;
		v[i] = ans + v[i - 1];
	}
	*/
	//rep(i, 1, D + 1)cout << v[i] << '\n';
	return 0;
}

Measured memory_bytes: 3684
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}


// クラスカル法　O(ElogV)
#define MAX_E (100000)
struct edge { ll u, v, cost; };
vector<edge> es;
int V, E; // V:頂点数、E:辺数

bool comp(const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

ll kruskal() {
    sort(es.begin(), es.end(), comp); // 辺をコストが小さい順に並べておく
    UnionFind G(V); // 集合XをUnionFindで管理
    ll res = 0;
    for (int i = 0; i < E; i++) {
        edge e = es[i];
        if (!G.same(e.u, e.v)) { // コストが最も小さく、閉路が出来ない辺を選ぶ
            G.unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}


struct POINT { ll id, x, y; };
vector<POINT> point;
vector<POINT> orderx;
vector<POINT> ordery;
int N;

bool compx(const POINT& p1, const POINT& p2) {
    return p1.x < p2.x;
}
bool compy(const POINT& p1, const POINT& p2) {
    return p1.y < p2.y;
}


int main() {

    cin >> N;

    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        point.push_back(POINT{ i,x,y });
        orderx.push_back(POINT{ i,x,y });
        ordery.push_back(POINT{ i,x,y });
    }

    sort(orderx.begin(), orderx.end(), compx);
    sort(ordery.begin(), ordery.end(), compy);

    for (int i = 0; i < orderx.size()-1; i++) {
        ll diff_x = orderx[i + 1].x - orderx[i].x;
        es.push_back(edge{ orderx[i + 1].id,orderx[i].id,diff_x });
        es.push_back(edge{ orderx[i].id,orderx[i+1].id,diff_x });
    }
    for (int i = 0; i < orderx.size() - 1; i++) {
        ll diff_y = ordery[i + 1].y - ordery[i].y;
        es.push_back(edge{ ordery[i + 1].id,ordery[i].id,diff_y });
        es.push_back(edge{ ordery[i].id,ordery[i + 1].id,diff_y });
    }

    E = es.size();
    V = N;

    ll ans = kruskal();

	cout << ans << endl;

	return 0;

}


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

struct UnionFind{
    vector<int> par;
    UnionFind(int N) : par(N){
        for(int i = 0; i < N; i++){
            par[i] = -1;
        }
    }
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        else{
            if(par[rx] > par[ry]) swap(rx, ry);
            par[rx] += par[ry];
            par[ry] = rx;
       }
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    void check(){
        for(auto x : par){
            cout << x << " ";
        }
        cout << endl;
    }
};

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

    vector<int> A = {1, 3, 5, 7, 8, 10, 12};
    vector<int> B = {4, 6, 9, 11};
    vector<int> C = {2};

    UnionFind UF(13);

    for(int i = 0; i < A.size() - 1; i++){
        UF.unite(A[i], A[i + 1]);
    }
    for(int i = 0; i < B.size() - 1; i++){
        UF.unite(B[i], B[i + 1]);
    }

    int x, y;
    cin >> x >> y;
    cout << (UF.same(x, y) ? "Yes" : "No") << endl;



    return 0;
}

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

int main() {
  long A, B ,K;
  cin >> A >> B >> K;
  if ( K<=A ){
    cout <<A-K<<" "<<B <<endl;
  }
  else if ( K<=(A+B) ){
    cout << 0 << " "<< A+B-K<< endl;
  }
  else{
    cout << 0 << " "<< 0<< endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;
signed main(){
    int A,B,Q; cin>>A>>B>>Q;
    vector<int> s(A+1,-INF),t(B+1,-INF);
    rep(i,A) cin>>s.at(i+1);
    s.push_back(INF);
    rep(i,B) cin>>t.at(i+1);
    t.push_back(INF);
    rep(i,Q){
        int x,a1,a2,b1,b2; cin>>x;
        a1=lower_bound(all(s),x)-s.begin();
        a2=a1-1;
        b1=lower_bound(all(t),x)-t.begin();
        b2=b1-1;
        cout<<min({abs(s.at(a1)-x)+abs(s.at(a1)-t.at(b1)),abs(t.at(b1)-x)+abs(t.at(b1)-s.at(a1)),abs(s.at(a1)-x)+abs(s.at(a1)-t.at(b2)),abs(t.at(b2)-x)+abs(t.at(b2)-s.at(a1)),abs(s.at(a2)-x)+abs(s.at(a2)-t.at(b1)),abs(t.at(b1)-x)+abs(t.at(b1)-s.at(a2)),abs(s.at(a2)-x)+abs(s.at(a2)-t.at(b2)),abs(t.at(b2)-x)+abs(t.at(b2)-s.at(a2))})<<endl;
    }
}

Measured memory_bytes: 2912
#include<bits/stdc++.h>
using namespace std;
int main(){
int k;
cin>>k;
int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int i=k-1;
    cout<<arr[i]<<endl;
    return 0;
}

Measured memory_bytes: 3584
f=lambda a:any(all(b)for b in a)|all(a[i][i]for i in(0,1,2))   
a=eval('list(map(int,input().split())),'*3)
exec('b=int(input());a=[[u*(u!=b)for u in t]for t in a];'*int(input()))
a=[[not u for u in t]for t in a]
print('NYoe s'[f(a)|f([t[::-1]for t in zip(*a)])::2])

Measured memory_bytes: 3060
import java.util.*;

public class Main{

  public static void main(String args[]){

    Scanner sc = new Scanner(System.in);
    char[] s = sc.next().toCharArray();

    for(int i=0; i<s.length; i++){
      char s_tmp = s[i];

      int t_count = 1;
      int f_count = 0;
      
      for(int j=i+1; j<s.length; j++){ 
        if(s[j]==s_tmp){
          t_count++;
          if(t_count>f_count){
            pl((i+1) + " " + (j+1));
            return;
          }
        }else{
          f_count++;
          if(t_count>f_count){
            pl((i+1) + " " + (j+1));
            return;
          }else if(t_count<f_count){
            break;
          }
        }
      }

    }
    pl("-1 -1");

  }

  private static void pr(Object o){
    System.out.print(o);
  }
  private static void pl(Object o){
    System.out.println(o);
  }

}


Measured memory_bytes: 26428
#include <stdio.h>

main (){

int a=0;

int W,H,x,y,r=0;

scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

if(x-r>=0&&x+r<=W){

if(y-r>=0&&y+r<=H){

a=1;

}

}

else{

a=0;

}

if(a==1){

printf("Yes\n");

}

else if(a==0){

printf("No\n");

}

return 0;

}

Measured memory_bytes: 584
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  s <- getInt

  d <- VM.new 2001
  VM.set d (-1::Int)

  let p :: Int
      p = 10^9 + 7

      f :: Int -> IO Int
      f x | x <= 2 = return 0
          | x <= 5 = return 1
          | otherwise = do t <- VM.read d x
                           if t >= 0
                             then return t
                             else do t' <- loop x 3 0
                                     let res = (1 + t') `mod` p
                                     VM.write d x res
                                     return res
        where loop :: Int -> Int -> Int -> IO Int
              loop x y res | y == x = return res
                           | otherwise = do
                               t <- f (x - y)
                               if t == 0
                                 then return res
                                 else loop x (y+1) ((res+t) `mod` p)

  ans <- f s
  print ans


Measured memory_bytes: 5928
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=3e5+9;


int main()
{
/*#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif*/
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    if(n%1000==0)cout<<0;
    else {
        int ned=n/1000;
        if(n%1000!=0)ned++;
        cout<<(1000*ned)-n<<endl; 

    }




    return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>

int main(){
  int a,b,c,atm;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);

  scanf("%d",&atm);

  if(a>=b && a>=c){
  for(int i=0;i<atm;i++){
    a*=2;
  }
  printf("%d",a+b+c);
}

  if(b>=a && b>=c){
  for(int i=0;i<atm;i++){
    b*=2;
  }
  printf("%d",a+b+c);
}

  if(c>=a && c>=b){
  for(int i=0;i<atm;i++){
    c*=2;
  }
  printf("%d",a+b+c);
}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define ford(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

void solve()
{
    int n;
    cin>>n;
    int found = 0;
    while( n > 0 )
    {
        int d = n % 10;
        if ( d == 7 )
        {
            found = 1;
            break;
        }
        n /= 10;
    }

    if ( found == 1 )
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;

int main(void)
{
    int N, K;
    cin >> N >> K;
    vector<int> vec(N);
    set<int> st;
    for (int i = 0; i < K; ++i)
    {
        int tmp;
        cin >> tmp;
        for (int j = 0; j < tmp; ++j)
        {
            int who;
            cin >> who;
            st.insert(who);
        }
    }
    cout << N - st.size() << "\n";
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define ll long long
#define coYes cout << "Yes" << endl
#define coYES cout << "YES" << endl
#define coyes cout << "yes" << endl
#define coNo cout << "No" << endl
#define coNO cout << "NO" << endl
#define cono cout << "no" << endl
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
int gcd(int a, int b){ //最大公約数
    if(a%b == 0){
        return b;
    }else{
    return gcd(b, a%b);
    }
}

int main(){
    string s;
    cin >> s;
    rep0(i,2){
        if(s[i]!=s[i+1]){ 
            coYes;
            return 0;
        }
    }
    coNo;
    return 0;
}

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

typedef long long ll;

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int x, y;
	cin >> x >> y;
	if (x >= y) {
		cout << "No";
		return 0;
	}
	int a = y - 2 * x;
	int b = 4 * x - y;
	if (a >= 0 && b >= 0 && a % 2 == 0 && b % 2 == 0) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3628
import java.lang.reflect.Array;
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

  static int N;
  static int K;
  static long Q;
  static int A;
  static long B;
  static long C;
  // static int[][] map;
  static int min = 9999999;
  static long ans = 0;

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);


    int X = scanner.nextInt();
  int Y = scanner.nextInt();

    System.out.println(X + (Y / 2));
  }
}


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

int main(){
 int n,k,p;
 cin>>n;

 for(int i=0;i<n;i++){
	cin>>k>>p;
	if(k%p==0){
		cout<<p<<endl;
	}
	else{
		cout<<k%p<<endl;
	}
 }

 return 0;
}

Measured memory_bytes: 3100
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import unicode_literals
import sys

n = int(input())
before = str(input())
after = str(input())
cnt = n

while True:
    if cnt == 0:
        print(len(before) + len(after) - cnt)
        break
    start = after[:cnt]
    last = before[-cnt:]
    if last == start:
        print(len(before) + len(after) - cnt)
        break
    cnt -= 1

Measured memory_bytes: 3064
fun main(args: Array<String>) {

    val (n, m) = readLine()!!.split(" ").map { it.toInt() }

    val nc = if (n < 2) 0 else (n * (n - 1) / 2)
    val mc = if (m < 2) 0 else (m * (m - 1) / 2)

    println(nc+mc)
}

Measured memory_bytes: 36428
#include<stdio.h>

int A1,A2,B1,B2;

int main(void){
	scanf("%d%d%d%d",&A1,&A2,&B1,&B2);
	if(A1+A2>B1+B2)
		puts("Left");
	else if(A1+A2==B1+B2)
		puts("Balanced");
	else
		puts("Right");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
 
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
 
#define FOREACH(x,a) for(auto& (x) : (a) )
 
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
 
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
 
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl
 
#define ALL(obj) (obj).begin(),(obj).end()
 
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
 
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision; // cpp_int
 
#define P pair<int,int>
#define V vector<ll>
#define M map<int,int>
#define S set<int>
#define L list<int>
 
#define pb(a) push_back(a)
#define mp make_pair

S Eratosthenes(int n){
  S set_;
  FOR(i,2,n+1)set_.insert(i);
  FOREACH(s,set_){
    if(s>sqrt(n))break;
    FOREACH(ss,set_){
      if(ss>s&&ss%s==0)set_.erase(ss);
    }
  }
  return set_;
}

int main(){

  CIN(n);
  S set_ = Eratosthenes(n);
  V v;
  FOREACH(s,set_)v.pb(s);

  V soin_all(set_.size());
  int ii=0;
  FOREACH(s,set_){
    FOR(i,1,INF){
      int ana = n/pow(s,i);
      if(ana==0)break;
      soin_all[ii]+=ana;
    }
    ii++;
  }

  ll ans=1;
  REP(i,set_.size()){
    if(soin_all[i]!=0){
      ans*=soin_all[i]+1;
      ans%=MOD;
    }
  }
  COUT(ans);

  return 0;
}


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

void solve(){
    ll a,b;
    cin >> a >> b;
    if(a > b) {
        a -= (a/b)*b;
    }
    cout << min(a,b-a) << "\n";
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    while(t--)
        solve();
    return  0;
}


Measured memory_bytes: 3668
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	[ a, b ] <- readInts
	print $ ( b - 1 + ( a - 1 ) - 1 ) `div` ( a - 1 )

Measured memory_bytes: 380
#include <bits/stdc++.h>
#include <cstdint>
#include <sys/time.h>

typedef std::int_fast32_t  s32;
typedef std::uint_fast32_t u32;
typedef std::int_fast64_t  s64;
typedef std::uint_fast64_t u64;

const unsigned long mod = 1000000007;
const double EPS = 0.00000001;
const int INF = (1 << 29);

typedef std::pair<int, int> P;

template<typename T>
void print_array(T *A_, s32 size) {
  //printf("%d\n", size);
  if( size != 0 ) {
    for(int i = 0; i < size - 1; ++i) {
      printf("%d ", A_[i]);
    }
    printf("%d\n", A_[size - 1]);
  }
}

std::pair<std::string, std::string> split(std::string str, int i) {
  std::string res1, res2;
  for(int k = 0; k < i; ++k) {
    res1 += str[k];
  }
  for(int k = i; k < (int)str.size(); ++k) {
    res2 += str[k];
  }
  return std::pair<std::string, std::string>(res1, res2);
}

int main() {

  int n;
  std::cin >> n;
  
  for(int i = 0; i < n; ++i) {
    std::string str;
    std::cin >> str;
    int s = str.size();

    int res = 0;

    std::vector<std::string> vstr;
    for(int j = 1; j < s; ++j) {

      auto strs1 = split(str, j);

      std::string str1, str2, str1r, str2r;
      str1r = str1 = strs1.first;
      str2r = str2 = strs1.second;
      std::reverse(str1r.begin(), str1r.end());
      std::reverse(str2r.begin(), str2r.end());

      vstr.push_back( str1  + str2  );
      vstr.push_back( str1r + str2  );
      vstr.push_back( str1  + str2r );
      vstr.push_back( str1r + str2r );
      vstr.push_back( str2  + str1  );
      vstr.push_back( str2r + str1  );
      vstr.push_back( str2  + str1r );
      vstr.push_back( str2r + str1r );
    }
    
    std::sort(vstr.begin(), vstr.end());
    vstr.erase(std::unique(vstr.begin(), vstr.end()), vstr.end());
    res = vstr.size();
    
    std::cout << res << std::endl;
  }
  
  return 0;
}

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

using namespace std;

int a1, a2, a3;
int main(int argc, char* argv[]) {
  scanf("%d %d %d", &a1, &a2, &a3);
  cout << abs(min({a1 - a2, a2 - a1, a2 - a3, a3 - a2, a1 - a3, a3 - a1})) << endl;
  return 0;
}


Measured memory_bytes: 256