akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <numeric>
#include <bitset>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define vl vector<long long>
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
/******************************define**********************************/
vector<vector<int>> chl('z'-'a' + 1,vector<int>(0));
/*****************************functions********************************/

/****************************main function*****************************/
int main(void){
    int N; cin >> N;
    string S; cin >> S;
    for(int i = 0;i < N;i++){
        chl[S[i] - 'a'].push_back(i);
    }
    int ans = 0;
    for(int i = 0;i < N - 1;i++){
        int cnt = 0;
        for(int j = 0;j < 'z' - 'a' + 1;j++){
            if(chl[j].size() == 0) continue;
            if(i >= chl[j][0] && i + 1 <= chl[j][chl[j].size() - 1]) cnt++;
        }
        ans = max(ans,cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
    a_ = int(input())
    a.append([list(map(int, input().split())) for _ in range(a_)])

result = [0]
for i in range(1, 2**n):
    h = format(i, "0"+str(n)+"b")
    c = [int(j) for j in list(h)]
    checker = True
    for j in range(n):
        if c[j]:
            for x, y in a[j]:
                if c[x-1]!=y:
                    checker = False
                    break
    if checker:
        result.append(c.count(1))
print(max(result))

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

using namespace std;

typedef complex<double> P;

double cross(P p1, P p2) {
	return p1.real() * p2.imag() - p1.imag() * p2.real();
}

int main() {
	int Q; cin >> Q;
	for (int q = 0; q < Q; ++q) {
		int x0, y0, x1, y1, x2, y2, x3, y3; cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
		P p0 = P(x0, y0), p1 = P(x1, y1);
		P p2 = P(x2, y2), p3 = P(x3, y3);

		P a = p1 - p0, b = p3 - p2;
		P t = p2 + b * abs(cross(p2 - p0, a)) / abs(cross(a, b));

		printf("%.10f %.10f\n", t.real(), t.imag());
	}
}

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

int main(){
    string S,ans;
    cin >> S;
    int s = atoi(S.c_str());
    int b = s%100;
    int a = (s-b) / 100;
    if(1<=a && a <= 12){
        if (1<=b &&b<=12){
            ans = "AMBIGUOUS";
        }else ans = "MMYY";
    }else if(1<=b &&b<=12){
        ans = "YYMM";
    }else ans = "NA";

    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int wMax=sc.nextInt();
    int[] w=new int[n];
    int[] v=new int[n];
    for(int i=0;i<n;i++){
      w[i]=sc.nextInt();
      v[i]=sc.nextInt();
    }
    long[][] dp=new long[n+1][wMax+1];
    /*
      dp[i][j]:=i番目以上の品を使わずに重さj以下で実現できる最大価値
      dp[0][j]=0
      dp[i][0]=0
      dp[i][j]=MAX(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
    */
    for(int i=1;i<=n;i++){
      for(int j=1;j<=wMax;j++){
        dp[i][j]=dp[i-1][j];
        if(j-w[i-1]>=0){
          dp[i][j]=Math.max(dp[i-1][j-w[i-1]]+v[i-1],dp[i][j]);
        }
      }
    }
    long ans=dp[n][wMax];
    System.out.println(ans);
    /*
      System.err.println(Arrays.toString(w));
      System.err.println(Arrays.toString(v));
      System.err.println(Arrays.deepToString(dp));
    */
  }
}

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

int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}
	
	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}
	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
    return 0;
}


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

using namespace std;

using ll = long long;

const ll INF = 1e12;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    int cnt0 = 0, cnt1;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] == 0) cnt0++;
        else if (a[i] < 0) cnt1++;
    }

    ll ans = 0;
    if (cnt0 > 0 || cnt1 % 2 == 0) {
        for (int i = 0; i < n; i++) {
            ans += abs(a[i]);
        }
    } else {
        ll minv = INF;
        for (int i = 0; i < n; i++) {
            ans += abs(a[i]);
            minv = min(minv, abs(a[i]));
        } 
        ans += -minv * 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
typedef long long ll;

int n,m,k;
string s,t;
int a[1005];
bool dp[105][11000];

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

  dp[0][0]=true;
  rep(i,n)rep(j,10001)if(dp[i][j]){
    dp[i+1][j]=true;
    dp[i+1][j+a[i]]=true;
  }
  int ans=0;
  rep(j,10001)if(j%10 &&dp[n][j]) chmax(ans,j);
  cout << ans << endl;
}

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

ll pwm(ll x,ll y)
{
    if(y==0)
      return 1;
    if(y==1)
      return x;
    ll ans=pwm(x,y/2)%md;
    ans=(ans*ans)%md;
    if(y%2==1)
        ans=(ans*x)%md;
    return ans;
}
 

int main() {
	// your code goes here
	md=2019;
    string s;
    cin>>s;
    ll n=s.size();
    ll dp[n+5];
    dp[n]=0;
    ll ans=0;
    ll rec[3000]={0};
    rec[0]=1;
    for(int i=n-1;i>=0;i--)
    {
        ll tmp=((int)s[i]-48)%2019;
        tmp=(tmp*pwm(10,n-i-1))%2019;
        dp[i]=(dp[i+1]+tmp)%2019;
        ans+=rec[dp[i]];
        rec[dp[i]]++;
    
    }
    // for(int i=0;i<=n;i++)
    //   cout<<dp[i]<<" ";
    //   cout<<endl;
    cout<<ans;
	return 0;
}


Measured memory_bytes: 5340
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b, t;
  cin >> a >> b >> t;
  int ans=0;
  for(int i=1;i*a<=(double)t+0.5;i++){
    ans+=b;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
 
int main() {
    char c;
    cin>>c;
    c+=1;
    cout<<c<<endl;

 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
vector<string> s;
vector<char> ans;
map<pair<pair<int, int>, pair<int, int> >, bool> mp; 
int n;
bool dfs(int now, int a, int b, int c){
	if(now == n && a >= 0 && b >= 0 && c >= 0) return true;
	if(a < 0 || b < 0 || c < 0) return false;
	string t = s[now];
	if(t == "AB"){
		if(!mp[{{now + 1, a + 1}, {b - 1, c}}]){
			mp[{{now + 1, a + 1}, {b - 1, c}}] = true;
			if(dfs(now + 1, a + 1, b - 1, c)){
				ans.pb('A');
				return true;
			}
		}
		if(!mp[{{now + 1, a - 1}, {b + 1, c}}]){
			mp[{{now + 1, a - 1}, {b + 1, c}}] = true;
			if(dfs(now + 1, a - 1, b + 1, c)){
				ans.pb('B');
				return true;
			}
		}
	}else if(t == "BC"){
		if(!mp[{{now + 1, a}, {b - 1, c + 1}}]){
			mp[{{now + 1, a}, {b - 1, c + 1}}] = true;
			if(dfs(now + 1, a, b - 1, c + 1)){
				ans.pb('C');
				return true;
			}
		}
		if(!mp[{{now + 1, a}, {b + 1, c - 1}}]){
			mp[{{now + 1, a}, {b + 1, c - 1}}] = true;
			if(dfs(now + 1, a, b + 1, c - 1)){
				ans.pb('B');
				return true;
			}
		}
	}else{
		if(!mp[{{now + 1, a - 1}, {b, c + 1}}]){
			mp[{{now + 1, a - 1}, {b, c + 1}}] = true;
			if(dfs(now + 1, a - 1, b, c + 1)){
				ans.pb('C');
				return true;
			}
		}
		if(!mp[{{now + 1, a + 1}, {b, c - 1}}]){
			mp[{{now + 1, a + 1}, {b, c - 1}}] = true;
			if(dfs(now + 1, a + 1, b, c - 1)){
				ans.pb('A');
				return true;
			}
		}
	}
	return false;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> n >> a >> b >> c;
    s.resize(n);
    for(int i=0;i<n;i++) cin >> s[i];
    if(dfs(0, a, b, c)){
    	cout << "Yes" << endl;
    	reverse(be(ans));
    	for(auto i: ans){
    		cout << i << endl;
    	}
    }else{
    	cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 35844
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]

for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])

ans, j = 0, M

for i in range(N + 1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j -= 1
    ans = max(ans, i + j)

print(ans)


Measured memory_bytes: 47292
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
struct node{
	int l,r;
}a[100000+20];
bool cmp(node a,node b)
{
	if(a.r==b.r)
		return a.l<b.l;//右边相同比较左边
	return a.r<b.r;//对数据右排序
}
int main ()
{
	int n,m,i;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++)
		scanf("%d %d",&a[i].l,&a[i].r);
	int mn=a[0].r;
	for(i=0;i<m;i++)
		mn=min(a[i].r,mn);
		
	sort(a,a+m,cmp);//排序
int now=mn,ans=1;//找到最小的
	for(i=1;i<m;i++)
	{
		if(a[i].l>=now)
		{
			now=a[i].r;//如果下一个数据的左边大于切断桥的右边则仍然需要切桥
			ans++;
		}
 
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


H,W,h,w = MI()
q1,r1 = H//h,H % h
q2,r2 = W//w,W % w

if r1 == 0 and r2 == 0:
    print('No')
else:
    print('Yes')
    if r2 != 0:
        A = []
        for _ in range(q2):
            A += [2*10**6]*(w-1)+[-(2*10**6)*(w-1)-1]
        A += [2*10**6]*r2
        for _ in range(H):
            print(*A)
    else:
        for i in range(1,H+1):
            if i % h != 0:
                print(*([2*10**6]*W))
            else:
                print(*([-(2*10**6)*(h-1)-1]*W))


Measured memory_bytes: 74356
/*input
2000 20000000
*/
#include <bits/stdc++.h>

using namespace std;

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


#define FileIn(file) freopen(file, "r", stdin)
#define FileOut(file) freopen(file, "w", stdout)
#define syso(n) cout<<n<<endl;
#define sysom(message, n) cout<<message<<n<<endl;
#define all(c) c.begin(), c.end() 
#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define present(container, element) (container.find(element) != container.end())  //map, set
#define cpresent(container, element) (find(all(container),element) != container.end()) //vector
#define what_is(x) cout << #x << " is " << x << endl; 


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

ll lcm(ll fir, ll sec){
	return (fir*sec)/(gcd(fir, sec));
}


const int MOD = 1e9 + 7;
const string small_alphabets = "abcdefghijklmnopqrstuvwxyz";
const int month_days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
// --
// -- 
// -- 
// std::cout << std::fixed;
// std::cout << std::setprecision(5) << f << '\n';

vector<int> v;


// n amount, y coins
bool count(int n, int amount){
	for (int i = 0; i <= n; ++i){
		for (int j = 0; j <= n; ++j){
			int k = n-(i+j);
			if(k<0)
				continue;
			if((10000*i + 5000*j + 1000*k) == amount){
				cout<<i<<" "<<j<<" "<<k<<endl;
				return true;
			}
		}
	}
	return false;
}

int main(){
	int n, y;
	cin>>n>>y;
	if(!count(n,y))
		cout<<"-1 -1 -1"<<endl;
	return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
L = []
for i in range(H):
  L.append(input())
row = [False]*H
col = [False]*W
for i in range(H):
  for j in range(W):
    if L[i][j] == '#':
      row[i] = True
      col[j] = True
for i in range(H):
  if row[i] == True:
    for j in range(W):
      if col[j] == True:
        print(L[i][j],end = '')
    print()

Measured memory_bytes: 4468
#include <cstdio>
#include <cstring>

using namespace std;

void Get_Val(int &Ret)
{
	Ret = 0;
	char ch;
	while (ch = getchar(), ch > '9' || ch < '0')
		;
	do
	{
		(Ret *= 10) += ch - '0';
	}
	while (ch = getchar(), ch >= '0' && ch <= '9');
}

const int Max_M(100050);
const int MOD(1000000000 + 7);
typedef long long int LL;

inline int Mult(const int &a, const int &b)
{
	return static_cast<int>(static_cast<LL>(a) * static_cast<LL>(b) % static_cast<LL>(MOD));
}

inline void update(int &a, const int &b)
{
	((a += b) >= MOD) ? (a -= MOD) : 0;
}

inline int get(const int &a, const int &b)
{
	return a + (b << 1);
}

int N, M, X[Max_M];

struct Matrix
{
	Matrix() {memset(v, 0, sizeof(v));}
	int v[4][4];
};
Matrix zy1, zy2;

Matrix operator*(const Matrix &a, const Matrix &b)
{
	Matrix c;
	for (int i = 0;i <= 3;++i)
		for (int j = 0;j <= 3;++j)
			for (int k = 0;k <= 3;++k)
				update(c.v[i][j], Mult(a.v[i][k], b.v[k][j]));
	return c;
}

Matrix operator^(Matrix a, int n)
{
	Matrix c;
	for (int i = 0;i <= 3;++i)
		c.v[i][i] = 1;
	while (n)
	{
		if (n & 1)
			c = c * a;
		a = a * a, n >>= 1;
	}
	return c;
}

void init()
{
	Get_Val(N), Get_Val(M);
	for (int i = 1;i <= M;++i)
		Get_Val(X[i]), ++X[i];
	for (int a = 0;a <= 1;++a)
		for (int b = 0;b <= 1;++b)
		{
			++zy2.v[get(a, b)][get(a, b)];
			if (a == 0)
				++zy2.v[get(a + 1, b)][get(a, b)];
			if (b == 0)
				++zy2.v[get(a, b + 1)][get(a, b)];
			if (a == 0 && b == 0)
				++zy2.v[get(a + 1, b + 1)][get(a, b)];
		}
	zy1 = zy2;
	for (int a = 0;a <= 1;++a)
		for (int b = 0;b <= 1;++b)
			++zy1.v[get(a, b)][get(1, 1)];
}

void work()
{
	Matrix Ans;
	Ans.v[get(0, 0)][0] = 1;
	for (int i = 1;i <= M;++i)
	{
		Ans = (zy1 ^ (X[i] - X[i - 1] - 1)) * Ans;
		Ans = zy2 * Ans;
	}
	Ans = (zy1 ^ (N - X[M])) * Ans;
	printf("%d\n", Ans.v[get(1, 1)][0]);
}

int main()
{
	init();
	work();
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    while (n != 0)
    {
        vector<int> s(n);
        double avg = 0;
        for (int i = 0; i < n; ++i)
        {
            cin >> s[i];
            avg += s[i];
        }
        avg /= n;
        double ans = 0;
        for (int i = 0; i < n; ++i)
        {
            ans += (avg - s[i]) * (avg - s[i]);
        }
        ans /= n;
        printf("%.10f\n", sqrt(ans));
        cin>>n;
    }
    return 0;
}


Measured memory_bytes: 3164
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def primes(N, n):
    L = [v for v in range(3, N+1)]
    while L:
        p = L.pop(0)
        if p % 10 == n:
            yield p
        L = list(filter(lambda x: x % p != 0, L))


N = int(input())
cnt = 0
ans = []
for p in primes(3000, 1):
    ans.append(p)
    cnt += 1
    if cnt == N:
        print(" ".join(map(str, ans)))
        break


Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
  int turu = 2;
  int tart = 4;
  int x, y;
  int judge = 0;
  scanf("%d%d", &x, &y);
  for(int i = 1; i <= x; i++) {
    if(turu * i + tart * (x-i) == y) {
      judge = 1;
    } else if(tart * i + turu * (x-i) == y) {
      judge = 1;
    }
  }
  if(judge == 1) {
    printf("Yes");
  } else {
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 1708
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>

const int64_t cc = pow( 10, 9 ) + 7;

int main()
{
   int64_t a,b,c,d;
   std::cin>> a;

   c = 5;
   d = 0;

   for( int i = 0; i < 5; i++ )
   {
       std::cin>> b;

       if( d == 0
           || b < d )
       {
           d = b;
       }
   }

   c += ( a - 1 ) / d;

   std::cout<< c;
}


Measured memory_bytes: 256
n,a,b = map(int, input().split())
s = input()
arr_a_b = []
arr_b = []
for i in range(n):
  if s[i] == 'a':
    if len(arr_a_b) < a + b:
      arr_a_b.append(1)
      print('Yes')
    else:
      print('No')
  elif s[i] == 'b':
    if len(arr_a_b) < a + b and len(arr_b) < b:
      arr_a_b.append(1)
      arr_b.append(1)
      print('Yes')
    else:
      print('No')
  else:
    print('No')

Measured memory_bytes: 5552
from collections import Counter

n = int(input())
s = [input() for i in range(n)]
cs = [Counter(x) for x in s]
r = Counter()
res = []
for k, v in cs[0].items():
    r[k] = v
    for c in cs:
        r[k] = min(r[k], c[k])
    res += ([k] * r[k])
res.sort()
res = ''.join(res)
print(res)


Measured memory_bytes: 3444
#include <stdio.h>
int main ( void ) {
    int sya[30]={0},i,n;
    i=0;
    while(scanf("%d",&n)!=EOF){
        if(n!=0){
            sya[i]=n;
            i++;
        }else{
            i=i-1;
            printf("%d\n",sya[i]);
        }
    }
    
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

bool p[3000000];
vector<int> prime;

void init(){
    memset(p,1,sizeof(p));
    p[0] = p[1] = false;
    for(int i = 2; i <= 1000000; i++){
        if(!p[i]) continue;
        for(long long j = 1LL*i*i; j <= 1000000; j += i)
            p[j] = false;
        prime.push_back(i);
    }
}

int CntPrime(int n){
    vector<int>::iterator it = lower_bound(prime.begin(), prime.end(), n);
    if(it == prime.end()) return prime.size();
    if( *it > n) it--;
    return (it - prime.begin()+1);
}

int main(){
    init();
    int n;
    while(cin >> n){
        cout << CntPrime(n)<< endl;
    }
    return 0;
}

Measured memory_bytes: 6156
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>

#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>

#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;

template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

const int N = 1 << 20;

struct Edge { int src, dst; ll cost; };

int main() {
  int n;
  cin >> n;
  static vector<Edge> v[N];
  static ll cost[N];
  REP(i,n-1) {
    Edge s; cin >> s.src >> s.dst >> s.cost;
    s.src--; s.dst--;
    v[s.src].push_back(s);
    swap(s.src, s.dst);
    v[s.src].push_back(s);
  }

  REP(i,N) cost[i] = 1LL << 60LL;
  queue<Edge> qu;
  for (qu.push((Edge){ -1, 0, 0 }); qu.size(); qu.pop()) {
    Edge e = qu.front();
    if (e.cost >= cost[e.dst]) continue;
    cost[e.dst] = e.cost;
    // cout << "# " << e.src << ' ' << e.dst << endl;
    REP(i,v[e.dst].size()) {
      qu.push((Edge) { v[e.dst][i].src, v[e.dst][i].dst, v[e.dst][i].cost + e.cost });
    }
  }
  REP(i,n) cout << cost[i] % 2 << endl;
}


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

int main() {
	int i, j, H, W;
	char a[510][510], b[510][510], r[510][510];
	scanf("%d%d", &H, &W);
	for (i=0;i<H;i++) scanf("%s", &a[i]);

	for (i=0;i<H;i++) {
		r[i][0] = '#';
		for (j=1;j<W-1;j++) {
			if (i%2 == 0) r[i][j] = '#';
			else if (a[i][j] == '#') r[i][j] = '#';
			else r[i][j] = '.';
		}
		r[i][W-1] = '.';
		r[i][W] = '\0';
	}
	for (i=0;i<H;i++) {
		b[i][0] = '.';
		for (j=1;j<W-1;j++) {
			if (i%2 == 1) b[i][j] = '#';
			else if (a[i][j] == '#') b[i][j] = '#';
			else b[i][j] = '.';
		}
		b[i][W-1] = '#';
		b[i][W] = '\0';
	}

	for (i=0;i<H;i++) printf("%s\n", r[i]);
	printf("\n");
	for (i=0;i<H;i++) printf("%s\n", b[i]);

	return 0;
}


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

int main() {
    int n, i;
    double x[100], y[100], d, di;

    cin >> n;
    for (i = 0; i < n; i++) cin >> x[i];
    for (i = 0; i < n; i++) cin >> y[i];

    for (i = 0, d = 0; i < n; i++) {
        d += abs(x[i] - y[i]);
    }
    printf("%.6lf\n", d);

    for (i = 0, d = 0; i < n; i++) {
        d += (x[i] - y[i]) * (x[i] - y[i]);
    }
    printf("%.6lf\n", sqrt(d));

    for (i = 0, d = 0; i < n; i++) {
        d += abs((x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]));
    }
    printf("%.6lf\n", pow(d, 1.0/3.0));

    // Chebyshev distance
    for (i = 0, d = 0; i < n; i++) {
        di = abs(x[i] - y[i]);
        if (d < di) d = di;
    }
    printf("%.6lf\n", d);

    return 0;
}

Measured memory_bytes: 1284
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<utility>

using namespace std;

int main(){

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

	for(int i=0;i<201;i++){
		for(int j=0;j<n;j++){
			ans[i]+=(a[j]-(i-100))*(a[j]-(i-100));
		}
	}

	sort(ans,ans+201);
	cout<<ans[0];

	cout<<endl;

	return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

int main() {
  llong N, K;
  vector<llong> A, plus, minus;
  llong zero = 0;

  cin >> N >> K;
  A.resize(N);
  for (auto &in: A) {
    cin >> in;
    if (in == 0) {
      ++zero;
    }
    else if (in > 0) {
      plus.push_back(in);
    }
    else {
      minus.push_back(-in);
    }
  }
  sort(ALL(A));
  sort(ALL(plus));
  sort(ALL(minus));

  llong ok = -inf, ng = inf;
  K;
  while (abs(ok - ng) > 1) {
    llong mid = (ok + ng) >> 1;
    llong res = 0;

    if (mid == 0) {
      res += minus.size() * plus.size();
    }
    else if (mid > 0) {
      res += minus.size() * plus.size();
      res += zero * (zero - 1) / 2;
      res += zero * (plus.size() + minus.size());
      for (int i = 0; i < (int)plus.size() - 1; ++i) {
        res += upper_bound(plus.begin() + i + 1, plus.end(), mid / plus[i]) - (plus.begin() + i + 1);
        if (mid % plus[i] == 0) {
          res -= upper_bound(plus.begin() + i + 1, plus.end(), mid / plus[i]) - lower_bound(plus.begin() + i + 1, plus.end(), mid / plus[i]);
        }
      }
      for (int i = 0; i < (int)minus.size() - 1; ++i) {
        res += upper_bound(minus.begin() + i + 1, minus.end(), mid / minus[i]) - (minus.begin() + i + 1);
        if (mid % minus[i] == 0) {
          res -= upper_bound(minus.begin() + i + 1, minus.end(), mid / minus[i]) - lower_bound(minus.begin() + i + 1, minus.end(), mid / minus[i]);
        }
      }
    }
    else {
      for (int i = 0; i < (int)plus.size(); ++i) {
        res += minus.end() - upper_bound(ALL(minus), -mid / plus[i]);
      }
    }

    (res < K ? ok : ng) = mid;
  }

  cout << ok << endl;

  return 0;
}

/*

K 番目を超える最小を求める
mid >= A[i] * A[j] := mid / A[i] >= A[j] になる j の個数 を数える
mid が下から

*/

Measured memory_bytes: 3956
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>


const int kN = 100000 + 5;
int n;
int a[kN];


int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n - 1; ++ i) {
        int x, y, z;
        scanf("%d%d%d", &x, &y, &z);
        a[x] ^= z;
        a[y] ^= z;
    }
    std::vector<int> cnt(1 << 4);
    for (int i = 0; i < n; ++ i)
        cnt[a[i]] ++;
    int groups = cnt[0];
    cnt[0] = 0;
    for (int i = 1; i <= 15; ++ i) {
        groups += cnt[i] / 2;
        cnt[i] %= 2;
    }
    std::vector<int> b;
    for (int i = 1; i <= 15; ++ i)
        if (cnt[i])
            b.emplace_back(i);
    std::vector<int> f(1 << b.size());

    auto check = [&](int mask) {
        int val = 0;
        for (int i = 0; i < b.size(); ++ i)
            if (mask >> i & 1)
                val ^= b[i];
        return val == 0;
    };
    for (int mask = 1; mask < 1 << b.size(); ++ mask) {
        for (int t_mask = mask; t_mask; t_mask = t_mask - 1 & mask) {
            if (check(t_mask))
                f[mask] = std::max(f[mask], f[mask ^ t_mask] + 1);
        }
    }
    int mx = 0;
    for (int i = 0; i < 1 << b.size(); ++ i)
        mx = std::max(mx, f[i]);
    printf("%d\n", n - groups - mx);
}


Measured memory_bytes: 768
#include <iostream>

using namespace std;

int main(){
	int cnt;
	string str;
	cin >> cnt >> str;
	
	int max = 0;
	for(int j = 2; j < cnt; ++j){
		string front = str.substr(0, j);
		string rear = str.substr(j, cnt - j);
		int ans = 0;
	   	for(int i = 0; i < 26; ++i)
			if(front.find(char('a'+i)) != string::npos && rear.find(char('a'+i)) != string::npos)
				++ans;
		if(max < ans)
			max = ans;
	}

	cout << max << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

#include <bits/stdc++.h>
using namespace std;

signed main(){
    int N; cin>>N;
  string S; cin>>S;
  if(N>=3200) Out(S);
  else Out("red");
}

Measured memory_bytes: 256
/**
 *      author  : kyomukyomupurin
 *      created : 2018/08/19
**/
//ABC 105 B

#include <bits/stdc++.h>
using namespace std;

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

    for (int i = 0; i < 30; ++i){
        if (N % 4 == 0 || N % 7 == 0){
            cout << "Yes"; break;
        }
        else if (N < 4){
            cout << "No"; break;
        }
        else {
            N -= 4;
        }
    }


    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
n = int(input())
va = [0] + list(map(int, input().split())) + [0]
diffs = []

total = 0
for i, j in zip(va, va[1:]):
    total += abs(j-i)

for i, j, k in zip(va, va[1:], va[2:]):
    print(total-(abs(j-i)+abs(k-j)-abs(k-i)))



Measured memory_bytes: 13920
//
//  main.cpp

#include <iostream>
using namespace std;


int main(){
	while(1){
		int sum;
		int input;
		int SUM=0;
		cin >> sum;
		if(sum == 0)break;
		for(int i=0;i<9;i++){
			cin >> input;
			SUM += input;
		}
		cout << sum - SUM << endl;
	}
	return 0;
}

Measured memory_bytes: 3052
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int k; cin >> k;
	queue<ll> q;
	for (ll i = 1; i <= 9; ++i)q.push(i);
	int cnt = 0;
	ll res = 0;
	while (cnt < k)
	{
		res = q.front();
		q.pop();
		if (res % 10 != 0)q.push(res * 10 + res % 10 - 1);
		q.push(res * 10 + res % 10);
		if (res % 10 != 9)q.push(res * 10 + res % 10 + 1);
		++cnt;
	}
	cout << res << endl;
}

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

int main() {
    Int A;
    double B;
    cin >> A >> B;
    Int C = B*100 + 0.5;
    cout << (A *C)/100 << endl;
}

Measured memory_bytes: 3692
#include <iostream>
#include <string.h>
using namespace std;

int main(){
  string s;
  char c[3]="00";
  int a,b;
  	cin>>s;
  c[0]=s[0];
  c[1]=s[1];
  a=atoi(c);
  c[0]=s[2];
  c[1]=s[3];
  b=atoi(c);
  if((12<a||a==0)&&(12<b||b==0)){
   cout<<"NA"; 
 	return 0; 
  }
  if(12<a||a==0){
   cout<<"YYMM"; 
 	return 0; 
  }
  if(12<b||b==0){
   cout<<"MMYY"; 
 	return 0; 
  }
  
   cout<<"AMBIGUOUS"; 
 	return 0; 
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

string s;
bool done[334][334][334];
int memo[334][334][334];

int solve(int i, int j, int k){
	int l;
	if(done[i][j][k]){
		return memo[i][j][k];
	}
	done[i][j][k] = true;
	if(i==j){
		return memo[i][j][k] = 1;
	}else if(i>j){
		return memo[i][j][k] = 0;
	}
	memo[i][j][k] = max(solve(i+1,j,k),solve(i,j-1,k));
	if(s[i]==s[j]){
		memo[i][j][k] = max(memo[i][j][k],solve(i+1,j-1,k)+2);
	}else if(k){
		memo[i][j][k] = max(memo[i][j][k],solve(i+1,j-1,k-1)+2);
	}
	return memo[i][j][k];
}

int main(void){
	int k;
	cin >> s >> k;
	cout << solve(0,s.l_ength()-1,k) << endl;
	return 0;
}


Measured memory_bytes: 166016
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;cin>>n;
	set<string>q;
	for(int i = 0; i < n; i++) {
		string s;cin>>s;
		q.insert(s);
	}
	cout << q.size() << endl;
	return 0;
}

Measured memory_bytes: 19180
#include <bits/stdc++.h>
#define int long long int
#define L_T_S_k  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 
using namespace std;
const int N = 1e6;
const int mod = 1e9 + 7;

int mul(int x , int y){
  return ((x % mod) * (y % mod))%mod;
}
int add(int x , int y){
  return (x % mod + y % mod) % mod;
}
int32_t main() {    
 L_T_S_k;
 int n;
 cin >> n;
 int a[n];
 for(int i = 0 ; i < n ;i++){
    cin >> a[i];
 }
 int ans = 0;
 for(int i = 0 ; i <= 60 ;i++){
  int cnt = 0;
  for(int j = 0 ; j < n ; j++){
      if(a[j] & (1ll << i))cnt++;
  }
  int temp = mul(mul(n - cnt, cnt) , (1ll << i));
  ans = add(ans , temp);
 }
 cout << ans << "\n";
 return 0;
}


Measured memory_bytes: 2560
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

const int N = 1001;

int n, k;
int arr[N];

int main()
{
  cin >> n >> k;
  for(int i = 0; i < n; i++)
    cin >> arr[i];
  sort(arr, arr + n);
  int ans = 0;
  for(int i = 0; i < k; i++)
    ans += arr[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

struct data
{
    int num;
    int ini;
    char c;
};

void swap(struct data *a, struct data *b)
{
    struct data temp = *a;
    *a = *b;
    *b = temp;
}

int partition(struct data A[], int p, int r)
{
    int x = A[r].num;
    int i = p - 1;
    for (int j = p; j < r; j++)
    {
        if (A[j].num <= x)
        {
            i++;
            swap(&A[i], &A[j]);
        }
    }
    swap(&A[i + 1], &A[r]);
    return i + 1;
}

void quicksort(struct data A[], int p, int r)
{
    if (p < r)
    {
        int q = partition(A, p, r);
        quicksort(A, p, q - 1);
        quicksort(A, q + 1, r);
    }
}

int main()
{
    int n;
    scanf("%d", &n);
    struct data array[n];
    for (int i = 0; i < n; i += 1)
    {
        scanf("%s %d", &array[i].c, &array[i].num);
        array[i].ini = i;
    }

    quicksort(array, 0, n - 1);

    int f = 1;
    for (int i = 1; i < n; i++)
    {
        if (array[i - 1].num < array[i].num || (array[i - 1].num == array[i].num && array[i - 1].ini < array[i].ini))
        {
            continue;
        }
        else
        {
            f = 0;
            break;
        }
    }
    if (f)
    {
        puts("Stable");
    }
    else
    {
        puts("Not stable");
    }

    for (int i = 0; i < n; i++)
    {
        printf("%c %d\n", array[i].c, array[i].num);
    }

    return 0;
}


Measured memory_bytes: 2896
#include <bits/stdc++.h>
#define For(i,a,b) for(ll i=a;i<=b;i++)
#define X first
#define Y second
#define maxn 302
#define eps 0.0000001
#define inf 1e9
#define pb push_back
#define maxD 15
#define ll long long
using namespace std;
int n,m;
int a[maxn][maxn];
int used[maxn];
int head[maxn];
int cnt[maxn];
main(){
	cin >> n >> m;
	For(i,1,n) For(j,1,m) scanf("%d",&a[i][j]);
	For(i,1,n) head[i] = 1;
	int ans = inf;
	For(k,1,m){
		memset(cnt,0,sizeof(cnt));
		For(i,1,n){
			while(used[a[i][head[i]]]) head[i]++;
			cnt[a[i][head[i]]]++;
		}
		int t = 1;		
		For(i,2,m){
			if(cnt[i]>cnt[t]) {
				t = i;				
			}
		}		
		used[t] = true;
		ans = min(ans,cnt[t]);
	}
	cout << ans;	
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a;
    b=a/100;
    c=a%100;
    if(1<=b && b<=12){
        if(1<=c && c<=12)
            cout<<"AMBIGUOUS"<<endl;
        else
            cout<<"MMYY"<<endl;
    }
    else{
        if(1<=c && c<=12)
           cout<<"YYMM"<<endl;
        else
            cout<<"NA"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;

namespace AOJ0031
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;

                int weight = int.Parse(input);
                bool[] count = new bool[10];
                string output = "0";
                int position = 0;
                if (weight != 0)
                {
                    for (int i = 9; i >= 0; i--)
                    {
                        int num = (int)Math.Pow(2, i);
                        if (weight == num)
                        {
                            count[i] = true;
                            break;
                        }
                        if (weight > num)
                        {
                            weight -= num;
                            count[i] = true;
                        }
                    }

                    for (int i = 0; i <= 9; i++)
                    {
                        if (count[i])
                        {
                            output = ((int)Math.Pow(2, i)).ToString();
                            position = i;
                            break;
                        }
                    }
                    if (position != 9)
                    {
                        for (int i = position + 1; i <= 9; i++)
                        {
                            if (count[i])
                            {
                                output += " " + ((int)Math.Pow(2, i)).ToString();
                            }
                        }
                    }
                }
               
                Console.WriteLine(output);
            }
        }
    }
}

Measured memory_bytes: 9240
#include<stdio.h>
int main()
{

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

  if(a < b) printf("a < b\n");
  if(a == b) printf("a == b\n");
  if(a > b) printf("a > b\n");

  return 0;
  
}

Measured memory_bytes: 580
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
#define DIV0 1000000007
#define M 1000000007
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
ll mpow(ll x, ll n){ //x^n (mod M)
    ll ans = 1;
    while(n != 0){
        //したの桁から見ていって、その桁にあったら*xして、nをシフトするにつれxを二乗する
        if (n & 1) ans = ans * x % M;
        x = x * x % M;
        n = n >> 1;
    }
    return ans;
}
int main()
{
    int H,W,K;
    cin >> H >> W >> K;
    string s[H];
    REP(i,H){
        cin >> s[i];
    }
    int ans = 0;
    REP(i,mpow(2,H)){
        REP(j,mpow(2,W)){
            int black = 0;
            REP(n,H){
                REP(m,W){
                    if(((i >> n)&1) == 0 &&((j >> m)&1) == 0 && s[n][m] == '#'){
                        black++;
                    }
                }
            }
            if(black == K) ans++;
        }
    }
    fin(ans);
    return 0;
}

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
string s;
cin>>s;
ll ans=0;
for(int i=1;i<s.size()/2;i++){
    string tmp=s.substr(0,i)+s.substr(0,i);
    if(tmp==s.substr(0,i*2)){
        chmax(ans,(ll)i*2);
    }
}
cout<<ans<<endl;
}












Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a, b;
	scanf ("%d", &a);
	scanf ("%d", &b);
	
	if (a < b) {
		printf ("a < b\n");
	} else if (a > b) {
		printf ("a > b\n");
	} else if (a == b) {
		printf ("a == b\n");
	}
	
	return 0;
}


Measured memory_bytes: 2124
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#include <iomanip>
#define rep(i,N) for(ll i=0;i<N;i++)
#define disp(a) cout << a << endl;
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(20) << ** << endl;
typedef long long ll;
using namespace std;
double deg2rad(double degree)
{
    return degree * PI / 180.0000000000;
}
int main()
{
	ll X,N,K1=0,K2=101;
	vector<ll>V(102,0);
	cin>>X>>N;
	rep(i,N){
		ll t;
		cin>>t;
		V[t]=1;
	}
	for(ll i=X;i>=1;i--){
		if(V[i]==0){
			K1=i;
			break;
		}
	}
	for(ll i=X;i<=100;i++){
		if(V[i]==0){
			K2=i;
			break;
		}
	}
	if(abs(X-K1)<=abs(X-K2)){
		cout<<K1<<endl;
	}
	else{
		cout<<K2<<endl;
	}
}

Measured memory_bytes: 3168
let main () =
  let a, b, c, d = Scanf.scanf "%d %d %d %d" (fun a b c d -> (a,b,c,d)) in
  if (abs @@ (-) b a <= d && abs @@ (-) c b <= d) || abs @@ (-) a c <= d  then
    print_string "Yes\n"
  else
    print_string "No\n"

let _ = main ()


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S,T;
  cin>>S>>T;
  sort(S.begin(),S.end());
  sort(T.begin(),T.end());
  reverse(T.begin(),T.end());
  if(S<T){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}
  


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func do(m [][]int, ci []int, c int, preChanged []int) ([]int, int, []int, bool) {
	ci2 := make([]int, len(ci))
	copy(ci2, ci)
	checked := make([]bool, len(m))
	changed := make([]int, 0, len(m))
	flag := false
	j := len(m[0])
	for _, i := range preChanged {
		if checked[i] {
			continue
		}
		if ci[i] >= j {
			continue
		}
		n := m[i][ci[i]]
		if checked[n-1] {
			continue
		}
		if ci[n-1] >= j {
			flag = false
			break
		}
		if m[n-1][ci[n-1]] == i+1 {
			ci[i] = ci[i] + 1
			checked[i] = true
			ci[n-1] = ci[n-1] + 1
			checked[n-1] = true
			flag = true
			c++
			changed = append(changed, i)
			changed = append(changed, n-1)
		}
	}
	if !flag {
		return nil, c, nil, true
	}
	return ci, c, changed, false
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	var n int
	fmt.Scan(&n)
	m := make([][]int, n)
	for i := 0; i < n; i++ {
		v := nextInts(n - 1)
		m[i] = v
	}
	var day int
	var c int
	ci := make([]int, len(m))
	max := (n * (n - 1)) / 2
	preChanged := make([]int, 0, len(m))
	for i := 0; i < len(m); i++ {
		preChanged = append(preChanged, i)
	}
	for c < max {
		checked := make([]bool, len(m))
		changed := make([]int, 0, len(m))
		flag := false
		j := len(m[0])
		for _, i := range preChanged {
			if checked[i] {
				continue
			}
			if ci[i] >= j {
				continue
			}
			n := m[i][ci[i]]
			if checked[n-1] {
				continue
			}
			if ci[n-1] >= j {
				flag = false
				break
			}
			if m[n-1][ci[n-1]] == i+1 {
				ci[i] = ci[i] + 1
				checked[i] = true
				ci[n-1] = ci[n-1] + 1
				checked[n-1] = true
				flag = true
				c++
				changed = append(changed, i)
				changed = append(changed, n-1)
			}
		}
		if !flag {
			day = -1
			break
		}
		preChanged = changed
		day++
	}
	fmt.Println(day)
}


Measured memory_bytes: 18304
import sys
s = input()
t = input()

dic = {}
dic2 = {}
for i in range(len(s)):
  tmp = dic.get(s[i],-1)
  tmp2 = dic2.get(t[i],-1)
  if tmp != -1 and tmp != t[i]:
    print('No')
    sys.exit(0)
    
  if tmp2 != -1 and tmp2 != s[i]:
    print('No')
    sys.exit(0)
    
  if tmp == -1:
    dic[s[i]] = t[i]
    
  if tmp2 == -1:
    dic2[t[i]] = s[i]

print('Yes')

Measured memory_bytes: 41968
#include <stdio.h>

int main(int argc,char* argv[]){
  double xA,yA,xB,yB,xC,yC,xD,yD;
  double xAB,yAB,xCD,yCD;

  while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&xA,&yA,&xB,&yB,&xC,&yC,&xD,&yD) != EOF){
    xAB = xA - xB;
    yAB = yA - yB;
    xCD = xC - xD;
    yCD = yC - yD;
    
    printf("%s\n",(xAB*xCD + yAB*yCD == 0) ? "YES" : "NO"); 
  }


  return 0;
  
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
    ll n;
    cin>>n;
    ld dp[n+1];
    dp[0]=1;
    for(ll i=1;i<=n;i++)
        dp[i]=0;
    for(ll i=1;i<=n;i++)
    {

        ld p;
        cin>>p;
        for(ll j=n;j>0;j--)
            dp[j]=p*dp[j-1]+(1-p)*dp[j];
        dp[0]*=(1-p);
    }
    ld ans=0;
    for(ll i=(n+1)/2;i<=n;i++)
        ans+=dp[i];
    cout<<setprecision(10)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256