akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)
vector<bool> seen;
void dfs(vector<ll> G[], int i)
{
    for (int e : G[i])
    {
        if(!seen[e]){
            seen[e] = true;
            dfs(G,e);
        }
    }
}
int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> G[n];
    seen.resize(n, false);
    repi(i, m, 0)
    {
        int x, y, z;
        cin >> x >> y >> z;
        x--;
        y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    ll ans = 0;
    repi(i,n,0){
        if(!seen[i]){
            dfs(G,i);
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,sum=0;
    cin>>n>>m;
    for(int i=1;i<n;i++){
        sum+=i;
    }
    for(int i=1;i<m;i++){
        sum+=i;
    }
    cout<<sum<<endl;
}





Measured memory_bytes: 256
#include <stdio.h>

#define rep(i, n) for (int i = 0; i < n; i = i + 1)
#define MAX 10010
#define MAX_INT 9223372036854775807

int main() {
  long long A;
  double B;
  scanf("%lld%lf", &A, &B);

  // printf("A: %lld\n", A);
  // printf("B: %lf\n", B);
  long long i_B = B * 100 + 0.5;
  // printf("i_B: %lld\n", i_B);
  // printf("A * i_B: %lld\n", A * i_B);
  // printf("A * i_B / 100: %lld\n\n", A * i_B / 100);

  printf("%lld\n", A * i_B / 100);
  return 0;
}


Measured memory_bytes: 1748
n = int(input())
a = list(map(int, input().split()))

l = [0,0,0]

r = 1000000007

ans = 1

for i in range(n):
    if a[i] == l[0]:
        if a[i] == l[1]:
            if a[i] == l[2]:
                ans *= 3
            else:
                ans *= 2
        l[0] += 1
    elif a[i] == l[1]:
        if a[i] == l[2]:
            ans *= 2
        l[1] += 1
    elif a[i] == l[2]:
        l[2] += 1
    else:
        ans = 0
    ans %= r

print(ans)

Measured memory_bytes: 52824
//#include<bits/stdc++.h>
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<cstring>
#include<utility>
#include<iostream>
#include<algorithm>
#include<functional>
//#include<unordered_map>
using namespace std;

typedef long long ll;
typedef long double ld;

#define pa pair<int,int>
#define sc(n) scanf("%d",&n)
#define ss(s) scanf("%s",s)
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define of(i,a,b) for(int i=a;i>=b;i--)
#define mem(a,b) memset(a,b,sizeof a)
#define uint unsigned int

const  int N = 4e5 + 10;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;

int a[N];
int t, n, m;


int main()
{
	/*ios::sync_with_stdio(false);*/
	cin >> n;
	fo(i, 1, n)
		sc(a[i]);
	sort(a + 1, a + n + 1);
	double ans = (a[1]+a[2])/2.0;
	fo(i, 3, n)
		ans = (ans + a[i]) / 2.0;
	printf("%.6f\n", ans);
	return 0;
}

Measured memory_bytes: 256
n = int(input())
s_list = [input() for x in range(n)]

cnt = 0
a_cnt = 0
b_cnt = 0
ab_cnt = 0
for x in s_list:
    cnt += x.count("AB")
    if (x[-1] == "A")&(x[0] != "B"):
        a_cnt += 1
    if (x[0] == "B")&(x[-1] != "A"):
        b_cnt += 1
    if (x[-1] == "A")&(x[0] == "B"):
        ab_cnt += 1
if ab_cnt == 0:
    print(cnt+min(a_cnt,b_cnt))
elif (a_cnt+b_cnt>0)&(ab_cnt != 0):
    print(cnt+ab_cnt+min(a_cnt,b_cnt))
elif (a_cnt+b_cnt==0):
    print(cnt+ab_cnt-1)

Measured memory_bytes: 3700
#include <algorithm>
#include <numeric>
#include <map>
#include <vector>
#include <cmath>
#include <iostream>

using namespace std;
#define int long long //これはやばい
typedef pair<int, int> P;

int extgcd(int a, int b, int& x, int& y) {
  int d = a;
  if (b != 0) {
	d = extgcd(b, a % b, y, x);
	y -= (a / b) * x;
  } else {
	x = 1; y = 0;
  }
  return d;
}

int mod_inverse(int a, int m) {
  int x, y;
  extgcd(a, m, x, y);
  return (m + x % m) % m;
}

bool allminus(vector<int> B) {
  for (int i = 0; i < (int)B.size(); i++) {
	if (B[i] >= 0)
	  return false;
  }
  return true;
}

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

P linear_congruence(const vector<int>& B, const vector<int>& M) {
  int x = 0, m = 1;
  int n = B.size();
  if (allminus(B)) return P(-1, -1);
  for (int i = 0; i < n; i++) {
	if (B[i] < 0) continue;
	int a = m, b = B[i] - x, d = gcd(M[i], a);
	if (b % d != 0) return P(0, -1);
	int t = b / d * mod_inverse(a / d, M[i] / d) % (M[i] / d);
	x = x + m * t;
	m *= M[i] / d;
  }
  return P(x % m , m);
}

signed main() {
  int n, m, d;
  cin >> n >> m >> d;
  vector<int> M(m);
  for (int i = 0; i < m; i++)
	cin >> M[i];

  vector<int> B[d];
  for (int i = 0; i < d; i++) {
	for (int j = 0; j < m; j++) {
	  int r;
	  cin >> r;
	  B[i].push_back(r);
	}
  }

  for (int i = 0; i < d; i++) {
	P p = linear_congruence(B[i], M);
	if (p.first == -1 && p.second == -1) continue;
	if (p.first == 0 && p.second == -1) {
	  cout << -1 << endl;
	  return 0;
	}
	if (n >= p.first) {
	  int t = (n - p.first) / p.second;
	  n = p.first + p.second * t;
	} else {
	  cout << -1 << endl;
	  return 0;
	}
  }
  cout << n << endl;
}

Measured memory_bytes: 1228
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCorder
{
    public static class Program
    {
        static public void Main(string[] args)
        {
            long[] input1 = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long[] input2 = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

            Array.Sort(input2);
            Array.Reverse(input2);

            Boolean flg = false;
            decimal total = 0;
            foreach (long num in input2)
            {
                total = num + total;
            }

            for (int i = 0; i < input1[1]; i++)
            {
                if (input2[i] >= total / (input1[1] * 4))
                {
                    flg = true;
                }
                else
                {
                    flg = false;
                    break;
                }
            }

            if (flg)
            {
                Console.WriteLine("Yes");

            }
            else
            {
                Console.WriteLine("No");

            }




        }
    }
}




Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int main(){
    int x,y,z,Y,N;
	cin>>N>>Y;
	int flag=0;
	for(x=0;x<=N;x++){
		for(y=0;y<=N-x;y++){
			z=N-x-y;
			if(10000*x+5000*y+1000*z==Y){
				flag=1;
				break;
			}
			}
		if(flag==1)break;
		}
	if(flag==1)cout<<x<<" "<<y<<" "<<z<<" ";
		else cout<<"-1 -1 -1";
	return 0;


}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#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))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

const ll INF = 1LL << 50;

const ll mod = 1e9 + 7;

int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = min(n % k, k - n % k);

  cout << ans << endl;

  return 0;
}


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

#define rep(i,n) for(int i = 0;i < n;++i)
#define rep2(i,n,m) for(int i = n;i < m;++i)
#define all(v) v.begin(),v.end()

using namespace std;
using ll = long long;

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

    ll n,k,l=0,sum = 0;
    cin >> n >> k;
    priority_queue<int> h;
    rep(i,n){
        cin >> l;
        h.push(l);
    }
    rep(i,k){
        h.pop();
        if(h.empty()) break;
    }
    while(!h.empty()){
        ll a = h.top();
        h.pop();
        sum += a;
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int seat[17] = {0};
	int X = 0;
	int stop[100] = {0};
	int time = 0;
	queue<int> Q;
	while(X < 100){
		int x;
		if(time%5 == 0 && time < 500){
			Q.push(time/5);
		}
		while(1){
			if(Q.size())x = Q.front();
			else x = -1;
			bool f = false;
			
			if(~x){
				int people = (x%5==1?5:2);
				int use = 19 + 3 * (x%3) + 17 * (x%2);
				rep(i,17-people+1){
					bool flag = true;
					rep(j,people){
						flag &= seat[i+j] == 0;
					}
					if(flag){
						rep(j,people){
							seat[i+j] = use;
						}
						f = true;
						break;
					}
				}
			}
			if(f){	
				stop[x] = time - x * 5;
				Q.pop();
				X++;
			}
			if(!f)break;
		}
		rep(i,17){
			seat[i] = max(0,seat[i]-1);
		}
		time++;
	}
	int n,c=0;
	while(cin >> n){
		cout << stop[n] << endl;
		c++;
	}
	while(c>=10){};
	
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
	int w,h,x,y,r;
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	if(x-r>=0 && y-r>=0 && x+r<=w && y+r<=h){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 584
s=input()

n=len(s)

def isok(s):
    n=len(s)
    if n%2==0:
        m=int(n/2)
        if s[0:m]==s[m:n]: return True
    return False

for i in range(n-1,0,-1):
    s=s[0:i]
    if isok(s): print(i) ; break

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define Rep(i,n) for(int i=1;i<=(n);++i)
using LL = long long;
using ULL = unsigned long long;

int main()
{
	string s;
	cin >> s;
	puts(s[3] == s[2] && s[5] == s[4] ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void fl()
{
    freopen(".in","r",stdin);
    freopen(".out","w",stdout);
}
int main()
{
//	  fl();
	int k;
	scanf("%d",&k);
	string cur="1";
	for(int i=2;i<=k;i++)
	{
		bool check=false;
		for(int j=(int)cur.length()-1;j>0;j--)
			if(cur[j]-cur[j-1]!=1&&cur[j]!='9')
			{
				cur[j]++;
				for(int k=j+1;k<(int)cur.length();k++)
				{
					if(cur[k-1]!='0') cur[k]=cur[k-1]-1;
					else cur[k]='0';
				}
				check=true;
				break;
			}
		if(!check)
		{
			if(cur[0]!='9')
			{
				cur[0]++;
				for(int j=1;j<(int)cur.length();j++)
				{
					if(cur[j-1]!='0') cur[j]=cur[j-1]-1;
					else cur[j]='0';
				}
			}
			else 
			{
				int l=(int)cur.length();
				cur="1";
				while(l--) cur+='0'; 
			}
		}
	} 
	cout<<cur<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
int n,K;
ll dp[55][55][5005];
int main()
{
    scanf("%d%d",&n,&K);
    if(K&1){printf("0\n");return 0;}
    dp[0][0][0] = 1;
    for(int i=0;i<n;i++)
        for(int j=0;j<=i;j++)
        for(int k=0;k<=n*n;k++)
    {
        dp[i+1][j][k+j]=(dp[i+1][j][k+j]+dp[i][j][k])%mod;
        dp[i+1][j+1][k+j+1]=(dp[i+1][j+1][k+j+1]+dp[i][j][k])%mod;
        dp[i+1][j][k+j]=(dp[i+1][j][k+j]+dp[i][j][k]*2*j)%mod;
        if(j>0) dp[i+1][j-1][k+j-1]=(dp[i+1][j-1][k+j-1]+dp[i][j][k]*j*j)%mod;
    }
    printf("%lld\n",dp[n][0][K/2]);
}


Measured memory_bytes: 108800
import sys
sys.setrecursionlimit(100000)  # set the maximum depth as 10000

n=int(input())
A=[int(x) for x in input().split()]
minA=min(A)
sumA=0
for i in A:
    sumA+=i
    


q=int(input())
M=[int(x) for x in input().split()]


def solve(i,m):
    global n
    global A
    global minA
    global sumA
    
    if m<0 or m>sumA:
        return False
    if m==0:
        return True
    if i>=n:
        return False
    
    return solve(i+1,m) or solve(i+1,m-A[i])
    
    
for m in M:
    if m<minA or m>sumA:
        print('no')
    else:
        if solve(0,m):
            print('yes')
        else:
            print('no')


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

using namespace std;
#define _for(i,j,N) for(int i = (j); i < (N);i++)
#define _rep(i,j,N) for(int i = (j); i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define LL long long

int get_int(){int x;scanf("%d",&x);return x;}
LL get_long(){LL x;scanf("%lld",&x);return x;}

LL N;
int main()
{
    N = get_long();
    _rep(h,1,3500){
        _rep(w,1,3500){
            LL a = ((4*h - N)*w - h*N);
            if(a <= 0) continue;
            LL b = h*N*w;
            if(__gcd(a,b) == a){
                printf("%d %d %d\n",h,w,b/__gcd(a,b));
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <cmath>
using namespace std;
#define   E    2.718282 
const int N = 1e8 +5;
int s[N];
int cnt;
int main()
{
	int n,k;
	cin >> n >> k;
	while(n != 0){
		n = n/k;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
main(){int n,X,Y,W,H,N,x,y,a;for(std::cin>>n;std::cin>>X>>Y>>W>>H>>N;printf("%d\n",a))for(a=N;N-->0;a-=X>x|x>X+W|Y>y|y>Y+H)std::cin>>x>>y;}

Measured memory_bytes: 0
h, w = map(int, input().split())
d = []
for i in range(10):
    d.append(list(map(int, input().split())))
a = []
for i in range(h):
    a.append(list(map(int, input().split())))
for k in range(10):
    for i in range(10):
        for j in range(10):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

#for k in range(0, 10):
#    print(c[k])
#for k in range(0, 10):
#    print(d[k])
#print(d[8][1])

ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j] != -1:
            ans += d[a[i][j]][1]
print(ans)


Measured memory_bytes: 40924
import java.util.Scanner;

public class Main {

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

		int a = ac.nextInt();
		int b = ac.nextInt();
		int c = ac.nextInt();
		
		int[] n = {a, b, c};
		
		int min = 10001;
		for (int i = 0; i < 3; i++){
			if ( n[i] <min){
				min = n[i];
			}
		}
		
		int max = 0;
		for (int i = 0; i < 3; i++){
			if ( n[i] > max){
				max = n[i];
			}
		}
		
		if (min < a && a < max){
			System.out.println(min +" " + a + " " + max);
		}else if (min < b && b < max){
			System.out.println(min +" " + b + " " + max);
		}else{
			System.out.println(min +" " + c + " " + max);
		}
	}

}



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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  string r;
  for (int i = 0; i < n; i++) {
    r.push_back(s[i]);
    r.push_back(t[i]);
  }
  cout << r << endl;
}

Measured memory_bytes: 256
import java.io.*;

public class Main{
    public static void main(String[]args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        String p = br.readLine();
        int cnt = 0;

        for(int i = 0; i < s.length(); i++){
            cnt = 0;
            for(int j = 0; j < p.length(); j++){
                if(s.charAt((i+j) % s.length()) == p.charAt(j)){
                    cnt++;
                }else{
                    break;
                }
            }
            if(cnt == p.length()){
                break;
            }
        }
        if(cnt == p.length()){
            System.out.println("Yes");
        }else{
        System.out.println("No");
        }
    }
}

Measured memory_bytes: 24440
table = [[[0]*10 for i in range (0,3)] for k in range (0,4)]
 
N = int(input())
 
for loop in range(N):
    b,f,r,v = map(int,input().split())
    table[b-1][f-1][r-1] += v
 
 
x=0
for i in range(4):
    if x != 0:
        print("#"*20)
    x += 1
 
    for a in range(3):
        for b in range(10):
            print(" %d"%(table[i][a][b]),end = "")
        print()


Measured memory_bytes: 5624
import collections
n,m = map(int,input().split())
d = {}
indegree = [0]*n
for _ in range(m):
    x,y = map(int,input().split())
    d[x-1] = d.get(x-1,[]) + [y-1]
    indegree[y-1] += 1
dp = [0]*n
q = collections.deque([i for i in range(n) if indegree[i] == 0])
while q:
    node = q.popleft()
    for nei in d.get(node,[]):
        indegree[nei] -= 1
        dp[nei] = max(dp[nei],dp[node]+1)
        if indegree[nei] == 0:
            q.append(nei)
print(max(dp))

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

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  int C = N * A;
  if(B>C){
    cout << C << endl;
  }
  if(B==C){
    cout << C << endl;
  }
  if(B<C){
    cout << B << endl;
  }
}

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

int main() {
  int q,w,e,r,t;
  cin >> q >> w >> e >> r >> t;
  if(q == 0){
    cout << 1;
    }
  if(w == 0){
    cout << 2;
    }
  if(e == 0){
    cout << 3;
    }
  if(r == 0){
    cout << 4;
    }
  if(t == 0){
    cout << 5;
    }
  return 0;
}

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

int n, m, k;
int a[10000];

void solve(int level, int sum)
{
  if(level == 0)
    a[(sum-k > 0)?sum-k:1]++;
  else
    for(int i = 1; i <= m; i++) solve(level-1,sum+i);
}

int main()
{
  while(1){
    cin >> n >> m >> k;
    if(n == 0 && m == 0 && k == 0) break;
    fill(a,a+n*m-k+1,0);
    solve(n,0);
    double e = 0;
    for(int i = 1; i <= n*m-k; i++) e += a[i]*i;
    e /= pow(m,n);
    printf("%.8lf\n", e);
  }
}

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

int main(void){
    int n ;
    int cnt=0;
    cin >> n;
    vector<int> a;
    for(int i=0;i<n;i++){
        int awork;
        cin >> awork;
        a.push_back(awork);
    }
    for(int i=0;i<n;i++){
        if(a.at(i)%2!=0 && (i+1)%2 !=0){
            cnt++;
        }
    }
    cout << cnt;
    
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
  // c_p_c();
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  if(a + b >= k)
  {
    if(k <= a)
    {
      cout<<k<<endl;
    }
    else
    {
      cout<<a<<endl;
    }
  }
  else
  {
    int rem = k - (a + b);
    cout<<a-rem<<endl;
  }
  return 0;
}



Measured memory_bytes: 3608
#include<cmath>
#include<queue>
#include<ctime>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7fffffff
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
} 
int n;
int a[200005],mid,l,r,cntl,cntr; 
ll sum[200005],ans=1LL<<30*1LL<<20,mx,mn;
pair<int,int> zuo[2],you[2];
int main()
{
	int i,j;
	//freopen("D.in","r",stdin);
	//freopen("D.out","w",stdout);
	n=read();
	for(i=1;i<=n;i++) a[i]=read(),sum[i]=sum[i-1]+a[i];
	mid=2,l=1,r=3;
	while(mid<=n-2)
	{
		cntl=cntr=0;mx=1LL<<50,mn=0;
		while(abs(sum[l]-(sum[mid]-sum[l]))>abs(sum[l+1]-(sum[mid]-sum[l+1])))l++;
		while(abs((sum[r]-sum[mid])-(sum[n]-sum[r]))>abs((sum[r+1]-sum[mid])-(sum[n]-sum[r+1]))) r++;
		mx=max(max(sum[l],sum[mid]-sum[l]),max(sum[r]-sum[mid],sum[n]-sum[r]));
		mn=min(min(sum[l],sum[mid]-sum[l]),min(sum[r]-sum[mid],sum[n]-sum[r]));
		ans=min(ans,mx-mn);
		mid++;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
 
typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;
 
#define for01(k,n)  for (ll i=k; i<n; i++)
#define for02(k,n)  for (ll j=k; j<n; j++)
#define for03(k,n)  for (ll k=k; k<n; k++)
#define for11(k,n)  for (ll i=k; i<=n; i++)
#define for12(k,n)  for (ll j=k; j<=n; j++)
#define for13(k,n)  for (ll k=k; k<=n; k++)
 
#define pb push_back
#define mp make_pair
#define pf push_front
#define popf pop_front
#define popb pop_back
#define vll vector<ll>
#define F first
#define S second
#define pp pair <ll, ll>
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define si size()
#define bk back()
#define deci(n)  fixed<<setprecision(n)
 
#define p0(a) cout << a << " "
#define p1(a) cout << a << "\n"
 
 
#define MAX LLONG_MAX
 
#define MIN LLONG_MIN
 
using namespace std;
 
int main()
{
  ll n,k;
  cin >> n >> k;
  ll p ;
  p = k;
  for(ll i = 1; i<n;i++)
     p = p * (k-1);
  
  p1(p); 
  return 0;
}

Measured memory_bytes: 256
c = 3.times.map{gets.split.map(&:to_i)}
if c[0][1] - c[0][0] != c[1][1] - c[1][0] || c[0][1] - c[0][0] != c[2][1] - c[2][0] then
    puts 'No'; exit;
end
if c[0][2] - c[0][0] != c[1][2] - c[1][0] || c[0][2] - c[0][0] != c[2][2] - c[2][0] then
    puts 'No'; exit;
end
puts 'Yes'

Measured memory_bytes: 1788
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main()
{
	char c[12];
	rep(i,12) cin >> c[i];
	rep(i,12){
		if(i==4) cout << " ";
		cout << c[i];
	}
	cout << endl;
	return 0;
}

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

typedef long long ll;
#define int ll


int m,n;
int a[100010];



struct LazySegmentTree {
private:
    int n;
    vector<ll> node, lazy;
 
public:
    LazySegmentTree(const vector<ll>& v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);
 
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
    }
 
    void eval(int k, int l, int r) {
        if(lazy[k] != 0) {
            node[k] += lazy[k];
            if(r - l > 1) {
                lazy[2*k+1] += lazy[k] / 2;
                lazy[2*k+2] += lazy[k] / 2;
            }
            lazy[k] = 0;
        }
    }
 
    void add_inter(int a, int b, ll x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            eval(k, l, r);
        }
        else {
            add_inter(a, b, x, 2*k+1, l, (l+r)/2);
            add_inter(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }
 
    ll get_inter(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        eval(k, l, r);
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];
        ll vl = get_inter(a, b, 2*k+1, l, (l+r)/2);
        ll vr = get_inter(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};

signed main()
{
	cin >> n >> m;

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

	int sum = 0;

	LazySegmentTree seg(vector<ll>(3 * m,0LL));

	for(int i = 1;i < n;i++)
	{
		int from = a[i - 1];
		int to = a[i];
		if(from > to) to += m;
		//from < to
			

		int dist = (to - from)% m;

		sum += dist;
		
		to = a[i] + 1;
		from =  a[i] - (dist - 1) + 1;
		
		if(from >= 0)
		{
			seg.add_inter(from , to,1);
			seg.add_inter(to,to + 1,-(dist - 1));
			from += m;
			to += m;


			seg.add_inter(from , to,1);
			seg.add_inter(to,to + 1,-(dist - 1));
		}
		else
		{
			from += m;
			to += m;
			seg.add_inter(from , to,1);
			seg.add_inter(to,to + 1,-(dist - 1));
			from += m;
			to += m;


			seg.add_inter(from , to,1);
			seg.add_inter(to,to + 1,-(dist - 1));
		}


	}

	ll minus = 0;

	for(int i = 0;i < 3 * m;i++)
	{
		//cout << seg.get_inter(0,i + 1) << endl;
		minus = max(minus , seg.get_inter(0,i + 1));
	}

	//cout << sum << " " << minus << endl;
	cout << sum - minus << endl;
}



Measured memory_bytes: 19712
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

const int PRIME_MAX = 32800;

bool is_prime[PRIME_MAX];

int main() {

    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i < PRIME_MAX; ++i) is_prime[i] = true;
    for (int i = 2; i < PRIME_MAX; ++i) {
        if (is_prime[i]) {
            for (int j = i+i; j < PRIME_MAX; j += i) {
                is_prime[j] = false;
            }
        }
    }

    int N;
    while (cin >> N) {
        if (N == 0) break;
        int ans = 0;
        for (int i = 2; i < N; ++i) {
            if (!is_prime[i]) continue;
            for (int j = i; j < N; ++j) {
                if (!is_prime[j]) continue;
                if (i + j == N) ans++;
            }
        }
        cout << ans << endl;
    }

	return 0;
}

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

int main() {
  int N, A, B;
	cin >> N >> A >> B;
	
	double x;
	x = B/A;

	if (N <= x){
		cout << A*N << endl;
	} 
  else if (x < N){
	  cout << B << endl;
	}
}


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

//階乗を求める関数
int kai(int x){
    if(x>0){
        return x + kai(x-1);
    }else{
        return 0;
    }
}


int main(){
    int a,b,n;
    
    cin >> a >> b;
    n = b-a-1;
    cout << kai(n) - a << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,x,y,z,a,b,c,flga[101]={0},cnt,i,flgb[101]={0},flgc[101]={0},flg[101]={0};
	scanf("%d %d",&n,&x);
	for(i=0;i<x;i++){
		scanf("%d",&a);
		flga[a]=1;
	}
	scanf("%d",&y);
	for(i=0;i<y;i++){
		scanf("%d",&b);
		flgb[b]=1;
	}
	scanf("%d",&z);
	for(i=0;i<z;i++){
		scanf("%d",&c);
		flgc[c]=1;
	}
	cnt=0;
	for(i=1;i<=n;i++){
		if(flgc[i]==1&&flga[i]==0||flgc[i]==1&&flgb[i]==1){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}


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

typedef long long ll;

void solve()
{
    string s, t;
    cin >> s >> t;
    int ans = t.length(), cur = 0;
    for (int i = 0; i < s.length() - t.length() + 1; i++)
    {
        cur = 0;
        for (int j = 0; j < t.length(); j++)
        {
            if (s[i + j] != t[j])
                cur++;
        }
        ans = min(ans, cur);
    }
    cout << ans << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; i++)
    {
        // cout << "Case #" << i << ": ";
        solve();
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/rope>
using namespace __gnu_cxx;
using namespace std;
#define mst(a,b) memset(a,b,sizeof(a))
#define ALL(x) x.begin(),x.end()
#define pii pair<int, int>
#define debug(a) cout << #a": " << a << endl;
#define eularMod(a, b) a < b ? a : a % b + b
#define X first
#define Y second
#define lc rt << 1
#define rc rt << 1 | 1
inline int lowbit(int x){ return x & -x; }
typedef long long LL;
typedef unsigned long long ULL;
const int N = 3000 + 10;
const int M = 1e7 + 10;
const int mod = (int) 1000000007;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1.0);
const double eps = 1e-6;

LL v[N];

int main() {
#ifdef purple_bro
    freopen("in.txt", "r", stdin);
//    freopen("out.txt","w",stdout);
#endif
    LL x, y;

    scanf("%lld%lld", &x, &y);

    int res = 0;

    for (; x <= y; x <<= 1)
        res++;

    printf("%d\n", res);

    return 0;
}


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

int main(void){
    int A,B,K;
    cin >> A >> B >> K;
    vector<int> n;
    for(int i = 1 ; i <= 100 ; i++){
        if(A % i == 0 && B % i == 0){
            n.push_back(i);
        }
    }
    sort(n.begin(),n.end(),greater<int>());
    cout << n[K-1] << endl;
    return 0;
}

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

int main()
{
	string s;
    cin>>s;
    bool flag=false;
    for(int i=0;i<s.size();i+=2)
    {
    	if(s[i]=='h'&&s[i+1]=='i')
    		continue;
    	else
    		flag=true;
	}
    if(!flag)
    	cout<<"Yes";
    else
    	cout<<"No";

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstring>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;
const long long MAXN=55;
long long n;
long long A;
long long a[MAXN];
long long dp[MAXN][MAXN][MAXN*MAXN];
int main()
{
	scanf("%lld %lld",&n,&A);
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+n+1);
	n++;
	a[n]=0;
	dp[0][0][0]=1;
	for(long long i=1;i<=n;i++)
	{
		for(long long j=1;j<=i;j++)
		{
			for(long long k=a[i];k<MAXN*MAXN;k++)
			{
				for(long long l=0;l<i;l++)
				{
					dp[i][j][k]+=dp[l][j-1][k-a[i]];
				}
			}
		}
	}
	long long ans=0;
	for(long long i=2;i<=n;i++)
	{
		ans+=dp[n][i][A*(i-1)];
	}
	printf("%lld\n",ans);
}

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

const int N = 5e3 + 5;
int a[N];

int main() {
	long long sum = 0;
	int n, k, ans = 0; cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n, greater<int>());
	for (int i = 0; i < n; i++) {
		sum += a[i];
		if (sum < k)ans++;
		else sum -= a[i], ans = 0;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using ll=long long; 
using ld=long double; 
using namespace std;
int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout); 
  #endif
  int n,x,t; cin>>n>>x>>t; 
  int k=(n%x==0)?n/x:n/x+1; 
  cout<<k*t<<"\n"; 
  return 0; 
}

Measured memory_bytes: 3592
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int n, u, v;
    cin >> n >> u >> v;
    u--, v--;
    yukari<int> g(n);
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    queue<int> q;
    akari<int> ds(n, -1), ds2(n, -1);
    ds[u] = 0;
    q.push(u);
    while (!q.empty())
    {
        int curv = q.front();
        q.pop();
        for (int nv : g[curv])
        {
            if (ds[nv] != -1)
            {
                continue;
            }
            ds[nv] = ds[curv] + 1;
            q.push(nv);
        }
    }
    // for (int val : ds)
    // {
    //     cout << val << ' ';
    // }
    // cout << endl;

    ds2[v] = 0;
    q.push(v);
    while (!q.empty())
    {
        int curv = q.front();
        q.pop();
        for (int nv : g[curv])
        {
            if (ds2[nv] != -1)
            {
                continue;
            }
            ds2[nv] = ds2[curv] + 1;
            q.push(nv);
        }
    }
    // for (int val : ds2)
    // {
    //     cout << val << ' ';
    // }
    // cout << endl;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (ds[i] < ds2[i])
        {
            ans = max(ans, ds2[i] - 1);
        }
    }
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 6656
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#define ll long long
using namespace std;
int main()
{
	int a[3];
	int s;
	int flag = 0;
	for(int i = 0; i < 3; i++){
		cin>>a[i];
	}
	sort(a, a+3);
	if(a[0]+a[1] == a[2])cout<<"Yes";
	else cout<<"No";
	
	
	return 0;
 } 

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

int main() {
  int N, M;
  int f=0;
  int a;
  int x=100*100*100*100;
  cin >> N;
  M=N;
  for (int i=0;i<9;i++){
    a=N/x;
    f+=a;
    N-=a*x;
    x/=10;
  }
  if (M%f==0){
    cout << "Yes" << endl;
  }
  if (M%f!=0){
    cout << "No" << endl;
  }
  
  
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    K = int(input())
    S = input().strip()

    if len(S) <= K:
        print(S)
    else:
        print(S[:K] + "...")




if __name__ == '__main__':
    main()


Measured memory_bytes: 9104
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    private const long INF = 1000000007;
    public static void Main()
    {
        int[] HW = IntLine();
        int H = HW[0], W = HW[1];
        List<int>[] cost = new List<int>[10];
        for (int i = 0; i < 10; i++) { cost[i] = new List<int>(IntLine()); }

        for (int i = 0; i < 10; i++)
            for (int j = 0; j < 10; j++)
                for (int k = 0; k < 10; k++)
                    cost[j][k] = Math.Min(cost[j][k], cost[j][i] + cost[i][k]);

        long ans = 0;
        for (int i = 0; i < H; i++)
        {
            foreach (var j in IntLine())
            {
                if (j == -1) continue;
                ans += cost[j][1];
            }
        }
        Console.WriteLine(ans);
    }
}

public class Atcoder
{
    public static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static long GCD(long a, long b)
    {
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return b;
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = StrReverce(ret);
        return ret;
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static long LongRead()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] LongLine()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static int[] IntLine()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
}


Measured memory_bytes: 15444
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int  long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int N=1e6+100;
ll mod=1e9+7;

ll fac[N];
ll power(ll n, ll k){
    if (k==0){
        return 1;
    }
    else{
        if (k%2==0){
            ll x=power(n,k/2);
            return x*x%mod;
        }
        else{
            ll x=power(n,k/2);
            x=x*x%mod;
            return x*n%mod;
        }
    }
}
ll fm[N];
ll ent(ll k, ll n){
	if (k==0 || k==n){
        return 1;
	}

	return (((fac[n]*fm[k])%mod)*fm[n-k])%mod;
}
int32_t main(){
    fac[0] = 1;

	for(int i=1;i<N;i++) {
        fac[i]=(fac[i-1]*i)%mod;
	}
	for(int i=0;i<N;i++) {
        fm[i]=power(fac[i],mod-2);
	}
    ll x,y;
    cin >> x >> y;
    if ((x+y)%3!=0){
        cout << 0 << endl;
        return 0;
    }
    ll z=(x+y)/3;
    if (z>x || z>y){
        cout << 0;
        return 0;
    }
    x-=z;
    y-=z;
    cout << ent(x,x+y);

}



Measured memory_bytes: 15872
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		
		
		
		if(N%2 == 1){
			int M = (N-1)*(N-1)/2;
			System.out.println(M);
			for(int a=1; a<N; a++){
				for(int b=a+1; b<=N; b++){
					if(a+b != N)System.out.println(a+" "+b);
				}
			}
		}
		
		if(N%2 == 0){
			int M = N*(N-2)/2;
			System.out.println(M);
			for(int a=1; a<N; a++){
				for(int b=a+1; b<=N; b++){
					if(a+b != N+1)System.out.println(a+" "+b);
				}
			}
		}
		
		sc.close();
	}

	
}


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


int main() {
  int N,K;
  cin>>N>>K;
  int ans=1;
  while(N>=K){
      ans++;
      N/=K;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
ll MOD=1000000007;
ll mod=998244353;
int inf=1000000000;
ll INF=10000000000000000;
int main(){
    int n;
    cin >> n;
    double ans=0,m;
    rep(i,n) {
        cin >> m;
        ans+=1/m;
    }
    cout << fixed << setprecision(10) << 1/ans << endl;
}

Measured memory_bytes: 256
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> inline void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> inline void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

int main() {
    string s,t; cin >> s >> t;
    ll ans = 0;
    rep(i, s.size()) {
        if (s[i]!=t[i]) ans++;
    }
    print(ans);
    return 0;
}


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


int main()
{
	int H, W;
	cin >> H >> W;

	while (H != 0 || W != 0){
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				if ((i + j) % 2 == 0){
					cout << "#";
				}
				else{
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
		cin >> H >> W;
	}
	
	return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

struct UnionFind {
  vector<int> p;
  UnionFind(int n) : p(n, -1) {}

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);

    if (x == y) return false;

    if (size(x) < size(y)) swap(x, y);
    p[x] += p[y];
    p[y] = x;
    return true;
  }

  int size(int x) { return -p[root(x)]; }

  int root(int x) {
    if (p[x] < 0) return x;
    return p[x] = root(p[x]);
  }

  bool same(int x, int y) { return root(x) == root(y); }
};

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

  vector<P> d(m);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    d[i] = P(a, b);
  }

  UnionFind uf(n);
  ll now = (ll)n * (n - 1) / 2;
  vector<ll> ans(m);
  for (int i = m - 1; i >= 0; --i) {
    ans[i] = now;
    int x = d[i].first;
    int y = d[i].second;
    ll sx = uf.size(x), sy = uf.size(y);
    if (uf.unite(x, y)) now -= sx * sy;
    now = max(now, 0LL);
  }

  rep(i, m) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 5092
#include<stdio.h>
int main()
{
	int a,b,c,d=0;
	scanf("%d %d %d",&a,&b,&c);
	for(a;a<=b;a++){
		if(c%a==0){
			d++;
		}
	}
	printf("%d\n",d);
	return 0;
}

Measured memory_bytes: 2692
#include<stdio.h>
int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	int a[200005];
	int i;
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	int min, mid, max;
	min = 0;
	max = 0;
	for (i = 0; i < n; i++)
		if (max < a[i])
			max = a[i];
	int cnt;
	while (max - min > 1)
	{
		mid = (max + min) / 2;
		cnt = 0;
		for (i = 0; i < n; i++)
			if ((a[i] + mid - 1) / mid > 0)
				cnt += (a[i] + mid - 1) / mid - 1;
		if (cnt > k)
			min = mid;
		else
			max = mid;
	}
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 2504
#include <cstdio>
#include <cstring>
#include <stack>
#include <utility>
using namespace std;
typedef pair<int,int> P; //[high][pos]
int T[500][501],H,W; //[H][W]
char M[500][501];
int count(int histogram[501]) {
	histogram[W]=0;
	stack<P> ST;
	int max_s=0;
	for(int i=0;i<=W;i++) {
		if(ST.empty()) {
			ST.push(P(histogram[i],i));
		}else {
			if(ST.top().first<histogram[i]) {
				ST.push(P(histogram[i],i));
			}else if(ST.top().first>histogram[i]) {
				int target=i;
				while(!ST.empty()&&ST.top().first>=histogram[i]) {
					int s=(ST.top().first)*(i-ST.top().second);
					if(max_s<s) max_s=s;
					target=ST.top().second;
					ST.pop();
				}
				ST.push(P(histogram[i],target));
			}
		}
	}
	return max_s;
}
int main() {
	while(scanf("%d %d",&H,&W),H) {
		for(int i=0;i<H;i++) {
			scanf("%s",M[i]);
		}
		memset(T,0,sizeof(T));
		for(int i=0;i<H;i++) {
			for(int j=0;j<W;j++) {
				if(i>0) T[i][j]=T[i-1][j];
				if(M[i][j]=='.') T[i][j]++;
				else T[i][j]=0;
			}
		}
		int max_s=0;
		for(int i=0;i<H;i++) {
			int s=count(T[i]);
			if(max_s<s) max_s=s;
		}
		printf("%d\n",max_s);
	}
}

Measured memory_bytes: 2268
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 200000000000;
struct edge {int to,cost;};
typedef std::pair<int,int> P;

    int N;
    int A[100010];
    int ans=0;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        cin>>A[i];
    }
    sort(A,A+N);
    int pos=0;
    REP(i,N){
        if(A[i]!=A[i+1]){
            if((i-pos+1)%2==1)ans++;
            pos=i+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int N, M;
vector<int> S[10];
int P[10];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M;
	rep(i, 0, M) {
		int k; cin >> k;
		rep(j, 0, k) {
			int s; cin >> s; s--;
			S[i].push_back(s);
		}
	}
	rep(i, 0, M) cin >> P[i];

	int ans = 0;
	rep(msk, 0, 1 << N) {
		int ok = 0;
		rep(m, 0, M) {
			int cnt = 0;
			fore(s, S[m]) if (msk & (1 << s)) cnt++;
			if (cnt % 2 == P[m]) ok++;
		}
		if (ok == M) ans++;
	}
	cout << ans << endl;
}















Measured memory_bytes: 256
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<set>
#include<vector>
#include<map>
#include<queue>
#define ll long long
using namespace std;
int main(){
	double P=3.1415926;
	double X;
	cin>>X;
	double XX=X*2.0*P;
	cout<<XX<<endl;
	return 0;
}


Measured memory_bytes: 3788
try:
    while True:
        T = tuple(map(float,input().strip().split(",")))
        z = complex(T[0]-T[2],T[1]-T[3])
        P = complex(T[0],T[1])
        Q = complex(T[4],T[5])
        R = P + (Q-P).conjugate() * z / z.conjugate()
        print("%.6f %.6f" % (R.real,R.imag))
except EOFError:
    pass


Measured memory_bytes: 5584