akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>

using namespace std;

struct Node {
	int parent = -1;
	vector<int> child;
};

vector<Node> node;

int get_depth(int id, int depth) {
	if (node[id].parent == -1) {
		return depth;
	}
	else {
		get_depth(node[id].parent, depth + 1);
	}
}

string get_type(int id) {
	if (node[id].parent == -1) {
		return "root";
	}
	else if (node[id].child.size() == 0) {
		return "leaf";
	}
	else {
		return "internal node";
	}
}

int main() {
	int n, id, k, child;

	cin >> n;
	node.resize(n);

	for (int i = 0; i < n; i++) {
		cin >> id >> k;
		for (int j = 0; j < k; j++) {
			cin >> child;
			node[id].child.push_back(child);
			node[child].parent = id;
		}
	}

	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": ";
		cout << "parent = " << node[i].parent << ", ";
		cout << "depth = " << get_depth(i, 0) << ", ";
		cout << get_type(i) << ", [";
		for (int j = 0; j < node[i].child.size(); j++) {
			cout << node[i].child[j];
			if (j < node[i].child.size() - 1) {
				cout << ", ";
			}
		}
		cout << "]\n";
	}

	return 0;
}

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

int main(void){
    long long int i, j, n, x, d, t, s, a, b, c, ans=0, po=0;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    ans = a*c;
    if(ans<a*d) ans = a*d;
    if(ans<b*c) ans = b*c;
    if(ans<b*d) ans = b*d;
    printf("%lld", ans);
    
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    string s,t="CODEFESTIVAL2016";
    cin>>s;
    int ans=0;
    REP(i,0,s.size()){
        if(s[i]!=t[i])ans++;
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import bisect


n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
for i in range(n):
    ans += bisect.bisect_left(A, B[i]) * (n - bisect.bisect_right(C, B[i]))
print(ans)


Measured memory_bytes: 23092
-- | Main entry point to the application.
module Main where
 
import Control.Applicative
import Control.Monad
import Data.List
import Debug.Trace
import Text.Printf
import Data.Array

zipWith' f l1 l2 = [ f e1 e2 | (e1, e2) <- zipWith k l1 l2 ]
            where
                k x y = x `seq` y `seq` (x,y)

solve :: [Int] -> Int
solve ns = maximum $ zipWith' (-) (tail ns) $ scanl1 min ns

-- | The main entry point.
main :: IO ()
main = do
    _ <- getLine
    ns <- concatMap (fmap (read :: String -> Int) . words) . lines <$> getContents
    -- let ns = [5,3,1,3,4,3]
    -- let ns = [1..200000]
    putStrLn $ show $ solve ns

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

int main(){
  string S, T;
  cin >> S >> T;
  
  int ans = 0;
  for(int i = 0; i < S.size(); i++){
    if(S[i] == T[i]){
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
# define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <unordered_set>
# include <unordered_map>
# include <climits>
# include <complex>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define STR(x) string x;cin>>x;
# define ALL(x) begin(x),end(x)
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<int> vi;
typedef vector<lint> vl;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }


int main()
{
	while (true)
	{
		int n, m, p, a, b;
		cin >> n >> m >> p >> a >> b;
		if (!n)break;
		vi t(n);
		FOR(i, n)cin >> t[i];
		sort(ALL(t));
		double cost[40][40];
		FOR(i, 40)FOR(j, 40)cost[i][j] = -1.0;
		FOR(i, p)
		{
			int x, y;
			double z;
			cin >> x >> y >> z;
			cost[x][y] = cost[y][x] = z;
		}
		double ans = (double)INF;
		bool ok = false;
		typedef pair<double, pii> P;
		do
		{
			priority_queue< P,vector<P>,greater<P> > que;
			double flag[40];
			FOR(i, 40)flag[i] = (double)INF;
			P start(0.0, pii(a, 0));
			que.push(start);
			while (!que.empty())
			{
				P now = que.top(); que.pop();
				if (now.second.first == b)
				{
					ans = min(ans, now.first);
					ok = true;
					break;
				}
				if (now.second.second == n)continue;
				FOR(i, 40)
				{
					if (cost[now.second.first][i] > 0
						&&flag[i]>now.first+cost[now.second.first][i]/t[now.second.second])
					{
						P next = now;
						next.first += cost[now.second.first][i] / t[now.second.second];
						next.second.first = i;
						next.second.second++;
						que.push(next);
						flag[next.second.first] = next.first;
					}
				}

			}
		} while (next_permutation(ALL(t)));
		if (ok)printf("%.8f\n", ans);
		else cout << "Impossible" << endl;
	}
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1000000007;
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


const int N=1000005;
ll fact[N],invfact[N];
ll power(ll x,ll y){
  if(y<=0) return 1LL;
  ll z=power(x,y/2);
  if(y%2) return (((z*z)%mod)*x)%mod;
  return (z*z)%mod;
}

void pre(){
  fact[0]=invfact[0]=invfact[1]=fact[1]=1;
  rep(i,2,N) fact[i]=(i*fact[i-1])%mod;
  rep(i,2,N) invfact[i]=(invfact[i-1]*power(i,mod-2))%mod;
}
ll nCr(ll n,ll k){ return (((fact[n]*invfact[n-k])%mod)*invfact[k])%mod; }



const int N1=1e6+1;
vector<int> isprime(N1,1),prime;
void seive(){
  rep(i,2,sqrt(N1)+1){
      if(isprime[i]){
        for(int j=i*i;j<N1;j+=i) isprime[j]=0;
        prime.pb(i);
      }
  }
  rep(i,sqrt(N1)+1,N1) if(isprime[i]) prime.pb(i);
}



struct dsu {
    vector<int> par, rank;
    dsu(int n): par(n+1), rank(n+1) {
        for (int i = 0; i <= n; i++) {
            par[i] = i;
            rank[i]= 1;
        }
    }
    int root(int a) {
        if (a == par[a]) return a;
        return par[a] = root(par[a]);
    }
    void merge(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rank[a] > rank[b]) swap(a, b);
        par[b] = a;
    }
    set<int> parent(int n){
        set<int> s;
        for(int i=1;i<=n;i++){
            s.insert(root(i));
        }
        return s;
    }
};

void solve(){
  ll h,w,d,x;
  cin>>h>>w>>d;
  ll cnt=0;
  map<ll,pii> m1;
  int a[h][w];
  set<int> s1;
  rep(i,0,h){
    rep(j,0,w){
      cin>>a[i][j];
      s1.insert(a[i][j]);
      m1[a[i][j]]={i,j};
    }
  }
  int mx=*max_element(all(s1));
  map<int,int> m2;
  for(auto i:s1){
    m2[i]=0;
    for(int j=i+d;j<=mx;j+=d){
      if(s1.find(j)!=s1.end()){
        s1.erase(j);
        m2[j]=m2[j-d]+abs(m1[j-d].f-m1[j].f)+abs(m1[j-d].s-m1[j].s);
      }
      else break;
    }
  }
  int q;
  cin>>q;
  while(q--){
    int l,r;
    cin>>l>>r;
    cout<<m2[r]-m2[l]<<endl;
  }
}

int main(){
    optimizeIO();
    int r=1;
    {solve();}
}


Measured memory_bytes: 21612
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;

    vector<int> vec;
    if(S.at(0) == '0') {
        vec.push_back(0);
    }
    int count = 1;
    for(int i=1; i<N; i++) {
        if(S.at(i) == S.at(i-1)) {
            count ++;
        } else {
            vec.push_back(count);
            count = 1;
        }
    }
    vec.push_back(count);
    if(S.at(N-1) == '0') {
        vec.push_back(0);
    }

    int M = vec.size();
    if(M <= 2*K+1) {
        cout << N << endl;
    } else {
        int sum = accumulate(vec.begin(), vec.begin()+2*K+1, 0);
        int ans = sum;
        int end = (M-1)/2-K;
        for(int i=0; i<end; i++) {
            int start = 2*(i+1);
            sum += -vec.at(start-2) - vec.at(start-1) + vec.at(2*K+start-1) + vec.at(2*K+start);
            ans = max(ans, sum);
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main()
{
    int input;
    scanf("%d",&input);
    if(input/10 == 9 || input%10 == 9)
    {
        printf("Yes\n");
    }
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int n, k;
int t[105];

bool dp[100005];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		cin >> t[i];
	}
	dp[0] = false;
	for (int i = 1; i <= k; ++i) {
		for (int j = 1; j <= n; ++j) {
			int x = i-t[j];
			if (x < 0) break;
			if (dp[x] == false) {
				dp[i] = true;
			}
		}
	}
	if (dp[k]) cout << "First\n";
	else cout << "Second\n";
	return 0;
}

/*
	dp[i] = pinossa i kiveä, true jos pelaaja jonka vuoro on voittaa, false jos häviää
*/


Measured memory_bytes: 384
#include <iostream>

using namespace std;

bool data_end(int x, int y);
void print_asc(int x, int y);
int main()
{
	int x,y;

	while(cin >> x >> y && !data_end(x,y)){
		print_asc(x,y);	
	}
	return 0;
}
bool data_end(int x,int y)
{
	if ( x == 0 && y == 0 ) return true;
	return false;
}
void print_asc(int x, int y)
{
	if( x <= y ) cout << x << ' ' << y << '\n';
	else cout << y << ' ' << x << '\n';
}

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;
int main(){
    int a,b,min=1001;
    cin >> a >> b;
    vector<int> x(a);
    vector<int> y(a);
    vector<int> z;

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

    for(int i = 0;i < a;i++){
        if(y[i] <= b){
            z.push_back(i);
        }
    }
    
    for(int i= 0;i < z.size();i++){
        if(x[z[i]] < min)
            min = x[z[i]];
    }

    if(min < 1001)
        cout << min << endl;
    else
        cout << "TLE" << endl;
    
}


Measured memory_bytes: 256
def main():
    N = int(input())
    S = input()
    ec = S.count('E')
    wc = 0
    min = ec
    for k in S:
        if k == 'E':
            ec -= 1
            if min > ec + wc: min = ec + wc
        else:
            wc += 1
    print(min)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3700
#include <iostream>
#include <stdint.h>
#include <vector>
#include <limits.h>
#include <utility>
#include <memory>
#include <set>
#include <map>

using namespace std;

using Group = set<int>;

uint64_t calc_convenience(Group& group)
{
  uint64_t island_count = group.size();
  return island_count * (island_count-1) / 2;
}

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

  vector<pair<int,int>> bridges;
  
  for (int m=0; m<M; ++m) {
    int a,b;
    cin >> a >> b;
    bridges.push_back(pair<int,int>(a,b));
  }

  map<int,shared_ptr<Group>> island2group;
  set<shared_ptr<Group>> groups;

  for (int n=0; n<N; ++n) {
    Group new_group = {n+1};
    auto ptr_new_group = make_shared<Group>(new_group);
    island2group[n+1] = ptr_new_group;
    groups.insert(ptr_new_group);
  }

  vector<uint64_t> conveniences = {0};

  for (int m=M-1; m>=0; m--) {
    auto bridge = bridges[m];
    int a = bridge.first, b = bridge.second;
    auto group_a = island2group[a];
    auto group_b = island2group[b];
    uint64_t convenience_prev = calc_convenience(*group_a) + calc_convenience(*group_b);
    if (group_a != group_b) {
      if (group_b->size() > group_a->size())
	swap(group_a,group_b);

      for (int island_b : *group_b) {
	group_a->insert(island_b);
	island2group[island_b] = group_a;
      }
      groups.erase(group_b);
      uint64_t convenience_now = calc_convenience(*group_a);
      conveniences.push_back(conveniences.back()+convenience_now-convenience_prev);
    } else {
      conveniences.push_back(conveniences.back());
    }
  }
  
  for (auto itr = conveniences.rbegin()+1; itr != conveniences.rend(); ++itr) {
    cout << conveniences.back() - *itr << endl;
  }
  
  return 0;
}

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

int main() {

  int n;
  cin >> n;
  
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n-1);
  
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n-1) cin >> c[i];
  
  int ans = 0;
  
  rep(i,n) {
    ans += b[a[i]-1];
    if(a[i]+1 == a[i+1]) ans += c[a[i]-1];
  }
  
  cout << ans << endl;

}


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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

const int M = 998244353;

int add(int a, int b) {
        a += b;
        if (a >= M)
                return a - M;
        if (a < 0)
                return a + M;
        return a;
}

int mul(int a, int b) {
        return a * (ll) b % M;
}

int pw(int a, int b) {
        int r = 1;
        while (b) {
                if (b & 1)
                        r = mul(r, a);
                a = mul(a, a);
                b /= 2;
        }
        return r;
}

int dv(int a, int b) {
        return mul(a, pw(b, M - 2));
}

const int N = (int) 2e5 + 7;
int n, pw2[N];
int x[N], y[N], ord[N], p11[N], p22[N], p33[N];
map<int, int> xs;
int fent[N];

void clr() {
        for (int i = 1; i <= n; i++)
                fent[i] = 0;
}

void add(int i) {
        while (i <= n) {
                fent[i]++;
                i += i & (-i);
        }
}

int sma(int i) {
        int sol = 0;
        while (i) {
                sol += fent[i];
                i -= i & (-i);
        }
        return sol;
}

bool cmp(int i, int j) {
        return y[i] < y[j];
}

int main() {
        ios::sync_with_stdio(false);
        cin.tie(0);
        pw2[0] = 1;
        for (int i = 1; i < N; i++)
                pw2[i] = mul(pw2[i - 1], 2);
        cin >> n;
        for (int i = 1; i <= n; i++) {
                cin >> x[i] >> y[i];
                xs[x[i]] = 0;
                ord[i] = i;
        }
        sort(ord + 1, ord + n + 1, cmp);
        int trans = 0;
        for (auto &it : xs)
                it.second = ++trans;
        for (int i = 1; i <= n; i++)
                x[i] = xs[x[i]];
        for (int it = 1; it <= n; it++) {
                int i = ord[it];
                p11[i] = sma(x[i]);
                p22[i] = it - 1 - p11[i];
                add(x[i]);
        }
        clr();
        for (int it = n; it >= 1; it--) {
                int i = ord[it];
                p33[i] = n - it - sma(x[i]);
                add(x[i]);
        }
        int ans = 0;
        for (int i = 1; i <= n; i++) {
                int con;
                con = pw2[n - 1];
                int p1 = p11[i], p2 = p22[i], p3 = p33[i], p4 = n - 1 - p1 - p2 - p3, a1 = add(pw2[p1], -1), a2 = add(pw2[p2], -1), a3 = add(pw2[p3], -1), a4 = add(pw2[p4], -1);
                con = add(con, mul(pw2[p2 + p4], mul(a1, a3)));
                con = add(con, mul(pw2[p1 + p3], mul(a2, a4)));
                con = add(con, -mul(mul(a1, a2), mul(a3, a4)));
                ans = add(ans, con);
        }
        cout << ans << "\n";
        return 0;
}


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

int a[105];
int main() {
    // freopen("party.in", "r", stdin);
    // freopen("party.out", "w", stdout);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int ans = 99999999;
    for (int i = 1; i <= 100; i++){
        int cnt = 0;
        for (int j = 1; j <= n; j++)
            cnt += (a[j] - i) * (a[j] - i);
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

A = [x-y for x,y in zip(A,B)]

# +2 or -1

two = 0
one = 0
for x in A:
    if x == 0:
        continue
    if x > 0:
        one += x
        continue
    if x < 0:
        if x&1:
            x -= 1
            one += 1
        two += (-x)//2

answer = 'Yes' if one <= two else 'No'
print(answer)

Measured memory_bytes: 4596
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	int N;
	cin >> N;
	vector<int>A(N), B(N), C(N);
	ll count = 0;
	for (int i = 0; i < N; ++i)cin >> A[i];
	for (int i = 0; i < N; ++i)cin >> B[i];
	for (int i = 0; i < N; ++i)cin >> C[i];
	sort(A.begin(), A.end());
	sort(C.begin(), C.end());
	for (int i = 0; i < N; ++i) {
		count += ((lower_bound(A.begin(), A.end(), B[i])-A.begin())*(C.end() - upper_bound(C.begin(), C.end(), B[i])));
	}
	cout << count << endl;
    return 0;
}

Measured memory_bytes: 1408
// 提出時に消す


import java.util.Scanner;

// 提出時にMainに変更する
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 1000 - n % 1000;
        if (ans == 1000) {
            ans = 0;
        }

        System.out.println(ans);

        sc.close();
    }
}

Measured memory_bytes: 35628
#include <iostream>
#include <string>

int main() {
  std::string N;

  std::cin >> N;

  if (std::stoi(N) < 1000) {
    std::cout << "ABC" << std::endl;
  } else {
    std::cout << "ABD" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
x1,y1,x2,y2=map(int,input().split())
d=(x2-x1,y2-y1)
d=(-d[1],d[0])
x3=x2+d[0]
y3=y2+d[1]
d=(-d[1],d[0])
x4=x3+d[0]
y4=y3+d[1]
print(x3,y3,x4,y4)







Measured memory_bytes: 38384
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    double n;
    n=sc.nextInt();
    double k;
    if(n%2==0){
      k=n/2;
    }else{
      k=n/2+0.5;
    }
    double d;
    d=k/n;
    System.out.printf("%.10f",k/n);
  }
}


Measured memory_bytes: 22228
#include<iostream>
using namespace std;
int main() {
	int s[1];
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c) {
		s[0] = 1;
	}
	else {
		if (a == b) {
			s[0] = 2;
		}
		if (b == c) {
			s[0] = 2;
		}
		if (a==c){
			s[0] = 2;
		}
		if (a != b && a != c && b != c) {
			s[0] = 3;
		}
	}
	cout << s[0] << endl;
	return 0;
}

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

int main(){
    int a[3];
    for(int i=0;i<3;i++){
        cin>>a[i];
    }
    sort(a,a+3);
    cout<<a[0]+a[1]+10*a[2]<<endl;

    return 0;
}

Measured memory_bytes: 3612
A, B, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = [0]*m
y = [0]*m
c = [0]*m
for i in range(m):
    x[i], y[i], c[i] = map(int ,input().split())

ans = min(a) + min(b)
for i in range(m):
    ans = min(ans, a[x[i]-1] + b[y[i]-1] - c[i])

print(ans)

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

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

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

vector<int> lpf;
void init(int N=2000000) {
    lpf.resize(N);
    iota(all(lpf), 0);
    for (int p = 2; p < N; ++p) {
        if (lpf[p] != p) continue;
        for (int q = 2*p; q < N; q += p) {
            if (lpf[q] != q) continue;
            lpf[q] = p;
        }
    }
}

int main() {
    int N;
    cin >> N;
    vl A(N);
    rep(i,N) cin >> A[i];

    int flag_pairwise = true;
    int g = A[0];
    init();
    map<int, int> usedPrimes;
    rep(i,N) {
        ll a = A[i];
        g = gcd(g, a);
        while (a > 1) {
            ll p = lpf[a];
            if (usedPrimes[p]) flag_pairwise = false;
            usedPrimes[p] = 1;
            while (a % p == 0) a /= p;
        }
    }
    int flag_setwise = (g == 1);
    if (flag_pairwise) {
        cout << "pairwise coprime" << endl;
    } else if (flag_setwise) {
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }
    return 0;
}


Measured memory_bytes: 22324
import math
(n, m)  =map(int, input().split())
sqm = math.sqrt(m)
map = {}
i = 2
y = m
while m != 1 and sqm >= i:
    if m % i == 0 :
        m = m / i
        if i in map:
            map[i] += 1
        else:
            map[i] = 1
    else:
        i += 1
if m > 1:
    map[m] = 1

sum = 1
for i in map:
    tmpn = n + map[i] - 1
    c = 1
    d = 1
    e = 1
    for j in range(map[i]):
        c = c * (tmpn - j)
        d = d * (map[i] - j)
    e = e * c // d
    
    sum = sum * e % 1000000007
print(sum )

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int N, M;
int main() {
    cin >> N >> M;
    vector<int> city(N, 0);
    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        city.at(a-1)++;
        city.at(b-1)++;
    }

    for(int i = 0; i < N; ++i) {
        cout << city.at(i) << endl;
    }
}

Measured memory_bytes: 256
#include <list>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#define INF (1LL << 60)
using namespace std;
bool used[100]; long long dist[100];
long long prim(int V, vector<pair<int, long long> > X[]) {
	priority_queue<pair<long long, int>, vector<pair<long long, int> >, greater<pair<long long, int> > > Q;
	for (int i = 0; i < V; i++) dist[i] = INF, used[i] = false;
	dist[0] = 0; Q.push(make_pair(0, 0));
	while (!Q.empty()) {
		pair<int, long long> pa = Q.top(); Q.pop();
		long long a1 = pa.first, a2 = pa.second; used[a2] = true;
		for (int i = 0; i < X[a2].size(); i++) {
			int to = X[a2][i].first; long long leng = X[a2][i].second;
			if (dist[to] > leng && !used[to]) {
				dist[to] = leng; Q.push(make_pair(dist[to], to));
			}
		}
	}
	long long sum = 0;
	for (int i = 0; i < V; i++) sum += dist[i];
	return sum;
}
int n, m, u, v, w; vector<pair<int, long long> > G[100];
int main() {
	while(cin >> n >> m, n) {
		for(int i = 0; i < n; i++) G[i].clear();
		for(int i = 0; i < m; i++) {
			cin >> u >> v >> w;
			G[u].push_back(make_pair(v, w));
			G[v].push_back(make_pair(u, w));
		}
		cout << prim(n, G) << endl;
	}
}

Measured memory_bytes: 3104
#include <iostream>
#include <math.h>
using namespace std;

int main(){

	const int N_MAX=1000000;
	int i,j,n[32],ni,soi,max;
	int so[N_MAX],count[N_MAX];
	
	for(i=0;i<N_MAX;i++)
		count[i]=so[i]=0;
	ni=0;
	max=0;
	while(cin>>n[ni])
		if(n[ni++]>max)
			max=n[ni-1];
	int sq_max = (int)sqrt(max);
	so[0]=so[1]=1;
	for(soi=0,i=2;i<=sq_max;i++){
		if(so[i]>0)continue;
		for(j=i*2;j<=max;j+=i)
			so[j]=1;
	}
	for(i=2;i<=max;i++){
		count[i] = count[i-1]+1-so[i];
	}
	for(i=0;i<ni;i++)
		cout << count[n[i]] << endl;

	return 0;
}

Measured memory_bytes: 8972
#include <iostream>
 
using namespace std;
 
int main() {
    string s;
    long long sum = 0;
    cin >> s;
    int n = s.size();
 
    for(int i = 0; i < (1 << (n - 1)); i++) {
        long long tmp = (s[0] - '0');
        long long tmp2 = 0;
        for(int j = 1; j < n; j++) {
            if((i >> (j-1)) & 1) {
                tmp2 += tmp;
                tmp = (s[j] - '0');
            } else {
                tmp *= 10;
                tmp += (s[j] - '0');
            }
        }
        tmp2 += tmp;
        sum += tmp2;
    }
 
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> pii;
typedef std::pair<long long, long long> pll;

using namespace std;

const long long mod = 1000000007;

void solve(vector<pii>* node, bool* ans, int t, int parent) {
	rep(i, node[t].size()) {
		pii p = node[t][i];
		if (p.first != parent) {
			if (p.second & 1) {
				ans[p.first] = !ans[t];
				solve(node, ans, p.first, t);
			}
			else {
				ans[p.first] = ans[t];
				solve(node, ans, p.first, t);
			}
		}
	}
}

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

	int n;
	cin >> n;
	vector<pii>* node;
	node = new vector<pii>[n];

	rep(i, n - 1) {
		int u, v, w;
		cin >> u >> v >> w;

		node[u - 1].push_back(pii(v - 1, w));
		node[v - 1].push_back(pii(u - 1, w));
	}

	bool* ans;
	ans = new bool[n];
	memset(ans, 0, sizeof(bool)*n);

	solve(node, ans, 0, -1);

	rep(i, n) {
		if (ans[i]) cout << 0 << "\n";
		else cout << 1 << "\n";
	}

	return 0;
}

Measured memory_bytes: 9472
#include <iostream>

using namespace std;

int main(void){

  int N;
  int L[100];
  int a, b, c;
  int ans = 0;

  cin >> N;

  for(int i=0; i<N; i++) cin >> L[i];

  for(int i=0; i<N; i++){
    a = L[i];
    for(int j=0; j<N; j++){
      if(i<j && L[j]!=a){
        b = L[j];
        for(int k=0; k<N; k++){
          if(j<k && L[k]!=a && L[k]!=b){
            c = L[k];
            if(a+b>c && b+c>a && c+a>b) ans++;
          }
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>

#define ll long long

using namespace std;

int main(){
    int K;
    cin >> K;
    if(K%2==1){
        cout << (K/2)*(K/2+1) << endl;
    }
    else{
        cout << pow(K/2,2) << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;
 
 
signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,m; cin>>n>>m;
  vector<vpll> G(n);
  rep(i,m){
    ll l,r,c; cin>>l>>r>>c;
    l--,r--;
    G[l].emplace_back(r,c);
    G[r].emplace_back(l,c);
  }
  rep(i,n-1){
    G[i+1].emplace_back(i,0);
  }
  vll dist(n,LINF);
  dist[0]=0;
  priority_queue<pll, vector<pll>, greater<pll>> q;
  q.emplace(0,0);
  while(!q.empty()){
    auto p=q.top(); q.pop();
    ll v=p.second, c=p.first;
    if(dist[v]<c) continue;
    for(auto np: G[v]){
      ll nv=np.first, nc=np.second;
      if(chmin(dist[nv],dist[v]+nc)){
        q.emplace(dist[nv],nv);
      }
    }
  }
  ll ans=dist[n-1];
  if(ans<LINF) cout<<dist[n-1]<<endl;
  else cout<<-1<<endl;
}

Measured memory_bytes: 12664
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  ll q, h, s, d, n;
  cin >> q >> h >> s >> d >> n;

  ll sumq = n * 4 * q;
  ll sumh = n * 2 * h;
  ll sums = n * s;
  ll sumd = n / 2 * d;

  if (n & 1)
    sumd += min({4 * q, 2 * h, s});
  cout << min({sumq, sumh, sums, sumd}) << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
    int n, k; cin >> n >> k;
    string s; cin >> s;
    char c = *min_element(s.begin(), s.end());
    if (k > 15) {
        cout << string(n, c) << endl;
        return 0;
    }
    s += s;
    reverse(s.begin() + n, s.end());

    vector<int> ps;
    int len = 1;
    for (int i = 0; i < n; ) {
        i = s.find(c, i);
        if (i == string::npos || i > n) break;
        int j = s.find_first_not_of(c, i);
        if (j == string::npos) j = 2*n - i;
        if (j - i > len) {
            len = j - i;
            ps.clear();
            ps.push_back(i);
        } else if (j - i == len) {
            ps.push_back(i);
        }
        i = j;
    }

    if (int rest = n - (len << (k-1)); rest <= 0) {
        cout << string(n, c) << endl;
    } else {
        int ansp = -1;
        for (int p : ps) {
            if (ansp == -1 || s.compare(p + len, rest, s, ansp + len, rest) < 0) ansp = p;
        }
        cout << string(n - rest, c) << s.substr(ansp + len, rest) << endl;
    }
}


Measured memory_bytes: 3152
#include <iostream>

using namespace std;

int main(){
    string s;
    cin >> s;
    if(s[0] != 'A'){
        cout << "WA" << endl;
    }
    else{
        int cnt = 0;
        int upper = 0;
        for(int i=2;i<s.size()-1;i++){
            if(s[i] == 'C')
                cnt++;
            if('A' <= s[i] && s[i] <= 'Z')
                upper++;
        }
        if('A' <= s.back() && s.back() <= 'Z')
            upper++;
        if('A' <= s[1] && s[1] <= 'Z')
            upper++;

        cout << ((cnt == 1 && upper == 1) ? "AC" : "WA") << endl;

    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>

using namespace std;
#define out(s) cout<<(s)<<endl;
using ll = long long;


int main()
{
	string w;
	cin >> w;
	map<char, int> map;
	for (char i = 'a'; i < 'z'; i++)
	{
		map[i] = 0;
	}
	for (auto c : w) {
		map[c]++;
	}
	for (char i = 'a'; i < 'z'; i++)
	{
		if (map[i] % 2 == 1) {
			out("No");
			return 0;
		}
	}
	out("Yes");

	return 0;
}


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

int main() {
int n, i, j, k = 0, combi;

std::cin >> n;
long a[n];
for (i = 0; i < n; i++) {
  std::cin >> a[i];
}

combi = n*(n-1) / 2;
long diff[combi];
for (i = 0; i < n-1; i++) {
  for (j = i+1; j < n; j++) {
    diff[k] = abs(a[i] - a[j]);
    k++;
  }
}
long max = diff[0];
for (i = 0; i < combi; i++) {
  if (max < diff[i]) {
    max = diff[i];
  }
}
std::cout << max << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
using namespace std;
struct structure{
        int h,w,count;
};
int main(){
        int H,W;
        string fields[50];
        cin >> H >>W;
        for(int i=0 ; i<H ; i++ )
                cin>>fields[i];
        queue<structure> circle;
        structure tmp;
        tmp.h=tmp.w=tmp.count=0;
        circle.push(tmp);
        bool dp[60][60]={false};
        int direction[5]={-1,0,1,0,-1};
        structure now;
        bool sign=false;
        while(circle.size()!=0){
                now=circle.front();circle.pop();
                if(now.h<0 || now.w<0 || now.h>=H || now.w>=W )continue;
                if(dp[now.h][now.w])continue;
                if(fields[now.h][now.w]=='#')continue;
                if(now.h==H-1 && now.w==W-1){
                        sign=true;
                        break;
                }
                dp[now.h][now.w]=true;
                for(int i=0 ; i<4 ; i++ ){
                        tmp.h=now.h+direction[i];
                        tmp.w=now.w+direction[i+1];
                        tmp.count=now.count+1;
                        circle.push(tmp);
                }
        }
        int count=0;
        for(int i=0 ; i<H ; i++ ){
                for(int j=0 ; j<W ; j++ ){
                        if(fields[i][j]=='.')
                                count++;
                }
        }
        if(sign)
                cout << count-now.count-1 << endl;
        else
                cout<<-1<<endl;
        return 0;
}

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

int main(){
    long long int n,m;
    cin>>n>>m;
    if(2*n>=m){
        cout << m/2;
    }else{
        cout << n+(m-2*n)/4;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            switch (Console.Read())
            {
                case 'a':
                case 'i':
                case 'u':
                case 'e':
                case 'o':
                    Console.WriteLine("vowel");
                    break;
                default:
                    Console.WriteLine("consonant");
                    break;
            }
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
int main(){
    int num;
    int j;
    int num1;
    scanf("%d",&num);
    num1=num;
    for (int i = 0; i < 3; i++)
    {
        j=num%100;
        if (j==11||j==22||j==33||j==44||j==55||j==66||j==77||j==88||j==99||j==0)
        {
            printf("Bad\n");
            break;
        }
        num=num/10;
    }
    if (num<10&&num1>=100)
    {
        printf("Good\n");
    }
    
    
    
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int64_t N, M;
  cin >> N >> M;
  int64_t S = 0;
  priority_queue<int64_t> pq;
  for (int i = 0; i < N; i++)
  {
    int64_t a;
    cin >> a;
    pq.push(a);
  }
  for (int i = 0; i < M; i++)
  {
    int64_t r = pq.top() / 2LL;
    pq.pop();
    pq.push(r);
  }
  for (int i = 0; i < N; i++)
  {
    S += pq.top();
    pq.pop();
  }
  cout << S << endl;
}

Measured memory_bytes: 1400
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
int main () {
  int a, b;
  cin >> a >> b;
  if((a + b) % 2 == 0) cout << (a + b) / 2;
  else cout << "IMPOSSIBLE";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin >> N;
	vector<int> p(N);
	for(auto&v:p)cin >> v;
	for(int i=0;i<N;++i){
		if(p[i]!=i+1){
			swap(p[i],p[p[i]-1]);
			break;
		}
	}
	bool ans = is_sorted(begin(p),end(p));
	cout << (ans?"YES":"NO") << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int n,x;
	int a[200];
	int sum = 0;
	int min = 1000000;
	cin >> n >> x;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
		if (min > a[i]) {
			min = a[i];
		}
	}
	x -= sum;
	int d;
	d = x/min;
	cout << n + d << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
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;
}

/* 二項係数 C(n,k) mod p を計算 */
const int MAX = 114514 * 2;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll a , ll b){
  if (b == 0) return 1;

  if (b%2 == 0){
    ll  t = modpow(a, b/2)%MOD;
    return t*t % MOD;
  }else{
    ll t = modpow(a, (b-1)/2)%MOD;
    return a*t %MOD * t % MOD;
  }
}

ll inverse (ll a){
  return modpow(a,MOD-2)%MOD;
}

int main() {
  string s;
  cin >> s;

  int n = s.size();
  ll ans = 0;
  int cnt_a = 0;
  bool now = false; //連続列か
  int i = 0;

  while(i < n - 1){
    if(s[i] == 'A'){
      if(now){
        cnt_a++;
      }else{
        now = true;
        cnt_a = 1;
      }
      i++;
    }else if (now){
      if(s[i]=='B' && s[i+1] == 'C'){
        ans += cnt_a;
        i += 2;
      }else{
        cnt_a = 0;
        i++;
        now = false;
      }
    }else{
      i++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 644
;; -*- coding:utf-8 -*-

;; Header
(defparameter *file-path* *load-pathname*)
(defun clip-to-string ()
  (with-output-to-string (out)
    (sb-ext:run-program "C:/msys64/usr/bin/cat.exe" '("/dev/clipboard") :output out)))
(defun test ()
  (with-input-from-string (*standard-input* (delete #\return (clip-to-string)))
    (main)))
(defmacro print-line (obj &optional (stream '*standard-output*))
  `(prog1 (princ ,obj ,stream) (terpri ,stream)))
(eval-when (:compile-toplevel)
  (defparameter *optimize* '(optimize (speed 3) (safety 0))))

;; Hauptteil

;; 1, 2, ... N
;; i駅から発する列車は Si+Fi*n秒(n>=0)に発車する

(defstruct stop
  (duration 0 :type fixnum)
  (offset 0 :type fixnum)
  (interval 0 :type fixnum))

;; (deftype unum nil '(integer 0 100000000))
(defun get-time (lst &optional (elapsed 0))
  ;; (declare #.*optimize*
  ;; 	   (unum elapsed))
  (if (null lst)
      elapsed
      (get-time (cdr lst)
		(let ((stop (car lst)))
		  (+ (stop-duration stop)
		     (if (<= elapsed (stop-offset stop))
			 (stop-offset stop)
			 (* (stop-interval stop)
			    (ceiling elapsed (stop-interval stop)))))))))
		
(defun main ()
  (let* ((num (- (read) 1))
	 (stops (loop for idx from 0 below num
		      collect (make-stop :duration (read)
					 :offset (read)
					 :interval (read)))))
    (loop for lst on stops do
	 (print-line (get-time lst))
       finally (print-line (get-time nil)))))

#-swank(main)


;; Für Benchmark
(defparameter *dat-path* (merge-pathnames "test.dat" *file-path*))

#+swank
(with-open-file (out *dat-path*
		     :direction :output :if-exists :supersede)
  )

(defun bench ()
  (let ((*standard-output* (make-broadcast-stream)))
    (with-open-file (*standard-input* *dat-path*)
      (time (main)))))


Measured memory_bytes: 11872
import java.io.*;
import java.util.*;
 
public class Main {
 
	void submit() {
	    int A = nextInt();
	    int B = nextInt();

	    if(A == 1 && B == 2 || B == 1 && A == 2 ){
            out.println(3);
	    }else if(A == 2 && B == 3 || B == 2 && A == 3){
            out.println(1);	        
	    }else{
            out.println(2);	        
	    }
	}

	void preCalc() {
 
	}
 
	void stress() {
 
	}
 
	void test() {
 
	}
 
	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}
 
	static final Random rng = new Random();
 
	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}
 
	public static void main(String[] args) throws IOException {
		new Main();
	}
 
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
 
	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}
 
	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
 
	int nextInt() {
		return Integer.parseInt(nextToken());
	}
 
	long nextLong() {
		return Long.parseLong(nextToken());
	}
 
	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 19412
#include<stdio.h>

int main(){
  
  int j,i,k,N,v,A[1000];
  
  scanf("%d",&N);
  for( i = 0; i < N; i++){
    scanf("%d",&A[i]);
  }
  
  for(k = 0; k < N-1; k++){
    printf("%d ",A[k]);
  }
printf("%d",A[k]);
  printf("\n"); 
  for(i = 1; i <= N-1; i++){
    v = A[i];
    j = i-1;
    
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
      
    }
    
    for(k = 0; k < N-1; k++){
      printf("%d ",A[k]);
    }
    printf("%d\n",A[k]);
    
  }
  
  return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <bits/stdc++.h>
#include <iomanip>
#include<math.h>
# define M_PI           3.14159265358979323846  /* pi */
#define ll long long
#define ld long  double
int max(long long int array[],long long int n );
using namespace std;
int  main(){
  ios_base::sync_with_stdio(0);
  	cin.tie(0);
  	cout.tie(0);
    int n;
    cin>>n;
    int array[n]={0},array1[n+1]={0},i;
    for(i=1;i<n;i++)
      cin>>array[i];

    for(i=1;i<n;i++){
      array1[array[i]]+=1;
    }
    for(i=1;i<=n;i++){
      cout<<array1[i]<<" ";
    }

  }


Measured memory_bytes: 5224
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

bool isin(int m) {
  return (m >= 1 && m <= 12);
}

int main() {
  string S;
  while (cin >> S) {
    int y = (S[0] - '0') * 10 + (S[1] - '0');
    int m = (S[2] - '0') * 10 + (S[3] - '0');
    if (isin(m) && isin(y)) cout << "AMBIGUOUS" << endl;
    else if (isin(m)) cout << "YYMM" << endl;
    else if (isin(y)) cout << "MMYY" << endl;
    else cout << "NA" << endl;
  }
}

















Measured memory_bytes: 256
k = gets.split.map(&:to_i)
a,b=gets.split.map(&:to_i)

y = (b/k[0]).to_i+1
i = 1
for i in 1..y
    if (a <= k[0]*i) && (k[0]*i <= b)
        puts 'OK'
        break            
    end
    if i == y
        puts 'NG'
        break
    end
end

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

vector<long long> divisors(long long n) {
  vector<long long> res;
  for (long long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i * i != n) {
        res.push_back(n / i);
      }
    }
  }
  return res;
}


int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, K; cin >> N >> K;
  vector<int> A(N);
  int S = 0;
  rep(i, N) cin >> A[i], S += A[i];
  int ans = 1;
  for (int d : divisors(S)) {
    vector<int> x(N);
    rep(i, N) x[i] = A[i] % d;
    sort(x.begin(), x.end());
    int i = 0;
    int j = N - 1;
    ll cnt = 0;
    while (i < j) {
      int use = min(x[i], d - x[j]);
      x[i] -= use;
      x[j] += use;
      cnt += use;
      if (x[i] == 0) {
        i++;
      }
      if (x[j] == d) {
        j--;
      }
    }
    if (i > j && cnt <= K) {
      ans = max(ans, d);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256