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

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

long long MOD = 1000000000 + 7;
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};


int main(){
  cout << setprecision(10);
  ll N,M;
  cin >> N >> M;
  vector<pii> v(M);
  for(int i = 0; i < M; i++){
    int tmp1,tmp2;
    cin >> tmp1 >> tmp2;
    tmp1--;
    tmp2--;
    v.at(i) = make_pair(tmp1,tmp2);
  }
  reverse(v.begin(), v.end());

  UnionFind tree(N);

  vector<ll> ans;
  ll now = N * (N-1) / 2;
  ans.push_back(now);

  for(int i = 0; i < M; i++){
    int tmp1 = v[i].first;
    int tmp2 = v[i].second;

    if(tree.root(tmp1) != tree.root(tmp2)){
      now -= (ll)tree.size(tmp1) * (ll)tree.size(tmp2);
      tree.unionSet(tmp1,tmp2);
    }

    ans.push_back(now);
  }
  reverse(ans.begin(), ans.end());
  for(int i = 1; i < ans.size(); i++){
    cout << ans[i] << endl;
  }


}


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ll n;
	cin>>n;
	ll sum=0;
	map<ll,ll>m;
	ll a[n];
	for(int i=0;i<n;i++)
	cin>>a[i],m[a[i]]++,sum+=a[i];
	int q;
	cin>>q;
	while(q--)
	{
		ll x,b;
		cin>>x>>b;
		int fr=m[x];
		sum-=(fr*x);
		m[x]=0;
		sum+=(fr*b);
		m[b]+=fr;
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 10320
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

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 (a>b) { a=b; return 1; } return 0; }
const ll LINF = 1e18;

int main()
{
  string S; ll K; cin >> S >> K;
  for (int i = 0; i < min(K, (ll)S.size()); ++i) {
    if (S[i] != '1') {
      cout << S[i] << endl;
      return 0;
    }
  }

  cout << 1 << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {


    public void solve() throws IOException {
        long k = nextLong();
        if (k == 0) {
            out.print("4\n" +
                    "3 3 3 3");
            return;
        }

        if (k < 10000000000000000l) {
            if (k % 2 == 1) {
                out.println(2);
                out.print(k / 2);
                out.print(" ");
                out.print(k + 1 - k / 2);
            } else {
                out.println(2);
                out.print((k + 2) / 2);
                out.print(" ");
                out.print((k + 2) / 2);
            }
            return;
        }
        out.println(50);
        long mas[] = new long[50];
        for (int i = 0; i < 50; i++) {
            mas[i] = k / 50 - 1;
        }
        for (long l = 0; l < k % 50; l++) {
            mas[(int) l] += 101 - k % 50;
        }
        for (long i = k % 50; i < 50; i++) {
            mas[(int) i] += 50 - k % 50;
        }
        for (int i = 0; i < 50; i++) {
            out.print(mas[i] + " ");
        }
    }


    BufferedReader br;
    StringTokenizer sc;
    PrintWriter out;

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        new Main().run();
    }

    void run() throws IOException {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
//            br = new BufferedReader(new FileReader("sum2.in"));
//            out = new PrintWriter(new File("sum2.out"));
            solve();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    String nextToken() throws IOException {
        while (sc == null || !sc.hasMoreTokens()) {
            try {
                sc = new StringTokenizer(br.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return sc.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
}

Measured memory_bytes: 21076
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
import java.util.*
import kotlin.math.*

fun main() {
    var fs = Atcoder.FastReader()
    var n =fs.nextInt()
    var d = fs.nextInt()
    var ans = 0
    for (i in 0 until n) {
        var p = fs.nextInt()
        var q = fs.nextInt()
        if(sqrt(p*p.toDouble() + q*q.toDouble()) <= d) ans++
    }
    println(ans)
}

class Atcoder {
    internal class FastReader {
        private var br: BufferedReader = BufferedReader(InputStreamReader(System.`in`))
        private var st: StringTokenizer? = null

        operator fun next(): String {
            while (st == null || !st!!.hasMoreElements()) {
                try {
                    st = StringTokenizer(br.readLine())
                } catch (e: IOException) {
                    e.printStackTrace()
                }

            }
            return st!!.nextToken()
        }

        fun nextInt(): Int {
            return Integer.parseInt(next())
        }

        fun nextLong(): Long {
            return java.lang.Long.parseLong(next())
        }

        fun nextDouble(): Double {
            return java.lang.Double.parseDouble(next())
        }

        fun nextLine(): String {
            var str = ""
            try {
                str = br.readLine()
            } catch (e: IOException) {
                e.printStackTrace()
            }
            return str
        }

        fun readIntArray(n: Int): IntArray {
            val a = IntArray(n)
            for (i in 0 until n) a[i] = nextInt()
            return a
        }

        fun readLongArray(n: Int): LongArray {
            val a = LongArray(n)
            for (i in 0 until n) a[i] = nextLong()
            return a
        }

        fun readDoubleArray(n: Int): DoubleArray {
            val a = DoubleArray(n)
            for (i in 0 until n) a[i] = nextDouble()
            return a
        }
    }
}


Measured memory_bytes: 55852
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  double w, h, x, y;
  cin >> w >> h >> x >> y;
  if (w/2 == x && h/2 == y) {
    cout << w*h/2 << " 1" << '\n';
  }
  else {
    cout << w*h/2 << " 0" << '\n';
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, x;
    cin >> n >> x;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    
    int p = 0;
    int cnt = 1;
    rep(i, n) {
        p += l[i];
        if (p <= x) 
            cnt++;
        else
            break;
    }

    put(cnt)

    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    int a;
    string s;
    cin >> a >> s;
    a >= 3200 ? pr(s) : pr("red");
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>


using namespace std;

struct edge{long long to,cost;};
typedef pair<long long,long long> P;

const long long INF=1LL<<30;

//???????????¢????????¢,??????
pair<long long,long long> dfs(vector<vector<long long> > &dis, vector<long long> &cnt,long long &x)
{
	const long long m=dis.size();
	vector<P> vp;
	vector<int> vis(m,0);
	stack<P> s;
	s.push(P(0,x));
	
	while(!s.empty()){
		P p=s.top(); s.pop();
		long long now=p.second;
		long long cost=p.first;
		
		if(vis[now]) continue;
		
		vp.push_back(P(cost,now));		
		
		vis[now]=1;
		for(long long i=0;i<m;i++){
			if(dis[now][i]!=INF && cnt[i]!=1) s.push(P(cost+dis[now][i],i));
		}
	}

	sort(vp.begin(),vp.end());
/*	
	for(int i=0;i<vp.size();i++){
		cout<<vp[i].first<<" "<<vp[i].second<<endl;
	}
*/	
	for(int i=vp.size()-1;i>=0;i++){
		if(cnt[vp[i].second]!=1) return vp[i];
	}


}

int main()
{
	int n;
	while(cin>>n,n){
		vector<vector<long long> > dis(n,vector<long long>(n,INF));
		for(int i=0;i<n;i++) dis[i][i]=0;
		
		vector<long long> p(n-1),d(n-1),cnt(n,0);
		for(int i=0;i<n-1;i++){
			cin>>p[i];
			p[i]--;
			//cnt[p[i]]++;
		}
		for(int i=0;i<n-1;i++) cin>>d[i];
		
		for(int i=0;i<n-1;i++){
			dis[i+1][p[i]]=dis[p[i]][i+1]=d[i];
			cnt[i+1]++;
			cnt[p[i]]++;
		}


		
		long long res=0;
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(dis[i][j]!=INF){
					if(cnt[i]==1 || cnt[j]==1) res+=dis[i][j];
					else res+=3*dis[i][j];
				}
			}
		}

		P x,y;
		for(long long i=0;i<n;i++){
			if(cnt[i]!=1){
				x=dfs(dis,cnt,i);
				break;
			}
		}
		
		y=dfs(dis,cnt,x.second);

		res-=y.first;
		cout<<res<<endl;
		
	}
}

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

using namespace std;

int main() {
  string s;
  string t = "keyence";
  cin >> s;
  int n = s.length();
  int cut = n - t.length();

  bool ok = false;
  for (int i = 0; i + cut <= n; i++) {
    string res;
    for (int j = 0; j < i; j++) {
      res += s[j];
    }
    for (int j = i + cut; j < n; j++) {
      res += s[j];
    }
    ok |= (res == t);
    cerr << res << '\n';
  }
  puts(ok ? "YES" : "NO");
  return 0;
}

Measured memory_bytes: 256
import math
N,K = map(int,input().split())

if N < K:
    p = 0;
    for i in range(1, N+1):
        p += pow(2, -math.ceil(math.log2(K/i)))/N
else:
    p = 0;
    for i in range(1, K+1):
#        print(i)
        p += pow(2, -math.ceil(math.log2(K/i)))/N
    p = p + (N-K)/N

    
print(p)

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 100
i64 N;
f64 A[MAX_N];

void solve() {
  f64 a = 0;
  REP(i, N) {
    a += 1.0 / A[i];
  }
  cout << 1.0 / a << endl;
}

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

  solve();

  return 0;
}

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

int dpTable[1400][1400];

int main() {
	int h, w;
	int t;
	cin >> h >> w;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			cin >> t;
			dpTable[i][j] = (t == 1 ? 0 : 1);
		}
	}
	int m = 0;
	if (h == 1) {
		for (int j = 0; j < w; ++j) {
			if (dpTable[0][j] != 0) {
				cout << 1 << endl;
				return 0;
			}
		}
		cout << 0 << endl;
		return 0;
	}
	if (w == 1) {
		for (int i = 0; i < h; ++i) {
			if (dpTable[i][0] != 0) {
				cout << 1 << endl;
				return 0;
			}
		}
		cout << 0 << endl;
		return 0;
	}
	for (int i = 1; i < h; ++i) {
		for (int j = 1; j < w; ++j) {
			if (dpTable[i][j] != 0) {
				int s = min({ dpTable[i - 1][j - 1], dpTable[i - 1][j], dpTable[i][j - 1] }) + 1;
				m = max(m, s);
				dpTable[i][j] = s;
			}
		}
	}
	cout << m*m << endl;
	return 0;
}


Measured memory_bytes: 10740
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 100005;

int main() {
    string s; cin >> s;
    map<char,int> mp;
    rep(i,s.size()) mp[s[i]]++;
    if (mp['a'] != 1 || mp['b'] != 1 || mp['c'] != 1) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stack>
using namespace std;
int main(){
  int n;
  stack <int> s;
  while(cin >>n){
    if(n==0){
      cout <<s.top()<<endl;
      s.pop();
    }
    else{
      s.push(n);
    }
  }
    return 0;
  }
      
  

Measured memory_bytes: 1200
# AtCoder Beiginner Contest 071B

index = 0

flag = Array.new(26,false)

string = gets.chomp
#puts string

array = ('a'..'z').to_a
#puts array

string.length.times do |i|
        index = 0
        26.times do |k|
                index = index + 1
                if string[i] == array[k]
                        #print array[k],index
                        flag[k] = true
                end
        end
end

26.times do |k|
        if flag[k] == false
                puts array[k]
                break
        end
end

puts "None"      if flag.all?

Measured memory_bytes: 1916
#include<stdio.h>
int main(void)
{
	int n,a,b,c,d;
	int s,ss;
	scanf("%d",&n);
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);

	s=a/c;
	//printf("%d\n",s);
	if(a%c!=0){
	s=s+1;
	}
	ss=b/d;
//	printf("%d\n",ss);
	if(b%d!=0){
		ss=ss+1;
	}
	
	if(s>=ss){
		n=n-s;
		printf("%d\n",n);
	}
	else if(ss>s){
		n=n-ss;
		printf("%d\n",n);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)

llong GCD(llong A[],int n){
    llong a,b,c;
    a=A[0];
    b=A[1];
    int i=1;
    while(1){
        if(a<b) swap(a,b);
        while(1){
            if(a%b==0) break;
            c=b;
            b= a%b;
            a=c;
        }
        i+=1;
        if(i==n) break;
        a=A[i];
    }
    return b;
}


signed main(){
    int n;
    cin >> n;
    int A[n];
    REP(i,n) scanf("%lld",&A[i]);

    int mae[n],usiro[n];
    mae[0] = A[0];
    FOR(i,1,n){
        int B[2] = {mae[i-1],A[i]};
        mae[i] = GCD(B,2);
    }
    usiro[0] = A[n-1];
    FOR(i,1,n){
        int B[2] = {usiro[i-1],A[n - 1 - i]};
        usiro[i] = GCD(B,2);
    }
    int ans = 1;
    REP(i,n){
        if(i != 0 and i != n-1){
        int B[2] = {mae[i-1],usiro[n-2-i]};
        ans = max(ans,GCD(B,2));
        }
        else{
            if(i == 0) ans = max(ans, mae[n-2]);
            else ans = max(ans, usiro[n-2]);
        } 
    }

    cout << ans << endl;

}


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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SORT(v, n) sort(v, v+n);
#define SSORT(v, n) sort(v, v+n, greater<int>())

int main(){
	int a,b;
	cin >> a >> b;
	if(a<9 && b<9) cout << "Yay!" << endl;
	else cout << ":(" << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    H,N=map(int,input().split())
    A=list(map(int,input().split()))
    print('Yes' if sum(A)>=H else 'No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 53316
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
    
#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
//#define int long long int
    
using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_mset = tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
    
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    
const ll mod = 1000000007;
const int INF = 0x3f3f3f3f;
//const ll INFLL = (ll)1e17;
const int MAXN = 1123;
const double pi = 3.14159265359;
const double eps = 0.00000001;

bool mat[MAXN][MAXN];
int dp[MAXN];

int main() {
    int H, W;
    char ch;
    scanf("%d %d", &H, &W);
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            scanf(" %c", &ch);
            mat[i][j] = ch == '.';
        }
    }
    for (int i = 0, x = 1; i < H; ++i) {
        if (!mat[i][0]) {
            x = 0;
        }
        mat[i][0] = x;
    }
    for (int j = 0, x = 1; j < W; ++j) {
        if (!mat[0][j]) {
            x = 0;
        }
        mat[0][j] = x;
    }
    for (int i = 0; i < H; ++i) {
        dp[0] = mat[i][0];
        for (int j = 1; j < W; ++j) {
            if (mat[i][j]) {
                dp[j] += dp[j - 1];
                if (dp[j] >= mod) {
                    dp[j] -= mod;
                }
            } else {
                dp[j] = 0;
            }
        }
    }
    printf("%d\n", dp[W - 1]);
}


Measured memory_bytes: 1408
#include<stdio.h>

int gcd(int a,int b){
	int t;
	if (b>a){
		t=a;
		a=b;
		b=t;
	}
	while(b!=0){
		t=b;
		b=a%b;
		a=t;
	}
	return a;
}
int lcm(int a,int b){
	int t,inc=a,dst;
	if (b>a){
		t=a;
		a=b;
		b=t;
		inc=a;
	}
	for(;;){
		if(a%b==0){
			dst=a;
			break;
		}
		a+=inc;
	}
	return dst;
}
int main(){
	int a,b;
	while(scanf("%d %d",&a,&b)!=EOF){
		printf("%d %d\n",gcd(a,b),lcm(a,b));
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <cstdlib>
#include <vector>
 
using namespace std;
// https://qiita.com/Clpsplug/items/81fe12400d4093a8fb5a
 
int main() {
    int A, B, K;
    cin >> A >> B >> K;
    int N;
    if (A > B) {
        N = B;
    } else {
        N = A;
    }

    vector<int> v;

    for (int i=1; i<N+1; i++) {
        if (A%i == 0 && B%i == 0) {
            v.push_back(i);
        }
    }

    cout << v[v.size()-K
    ] << endl;
}

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

int main() {
  int N, i, dif;
  cin >> N;
  vector<int> V(N);
  vector<int> C(N);
  for (i = 0; i < N; i++) {
    cin >> V[i];
  }
  for (i = 0; i < N; i++) {
    cin >> C[i];
  }
  int value = 0;
  for (i = 0; i < N; i++) {
    if ((dif = V[i] - C[i]) > 0) {
      value += dif;
    }
  }
  cout << value << endl;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE OverloadedStrings #-}
import Text.Parsec
import Control.Applicative (liftA, liftA2, (<$>), (<*>), (*>), (<*))
import Data.Complex
import Data.List
import qualified Data.ByteString.Char8 as BC
import Data.ByteString (ByteString)
import qualified Data.ByteString.Lazy.Char8 as BLC

type Comp = Complex Integer

-- {{{ Parsing
number :: Parsec ByteString u (Maybe Comp)
number = validate . (:+0) . read <$> many1 digit
    <|>
        const (Just (0:+1)) <$> char 'i'

unit :: Parsec ByteString u (Maybe Comp)
unit = char '(' *> calc <* char ')' <|> number

term :: Parsec ByteString u (Maybe Comp)
term = foldl1' (*:) <$> unit `sepBy1` char '*'

calc :: Parsec ByteString u (Maybe Comp)
calc = do
    t0 <- term
    fs <- many $
            (+:) <$> (char '+' *> term)
        <|>
            flip (-:) <$> (char '-' *> term)
    return $ foldl' (\acc f -> f acc) t0 fs
-- }}}

-- {{{ Calculation
neg :: Comp -> Comp
neg (a:+b) = negate a :+ negate b
add :: Comp -> Comp -> Comp
add (a:+b) (c:+d) = (a+c) :+ (b+d)

mul :: Comp -> Comp -> Comp
mul (a:+b) (c:+d) = (a*c-b*d) :+ (b*c+d*a)

sub :: Comp -> Comp -> Comp
sub z w = add z (neg w)

threshold :: Integer
threshold = 10000

validate :: Comp -> Maybe Comp
validate (c@(a :+ b)) = if abs a <= threshold && abs b <= threshold
                            then Just c
                            else Nothing

(+:) :: Maybe Comp -> Maybe Comp -> Maybe Comp
(+:) z w = validate =<< liftA2 add z w
(*:) :: Maybe Comp -> Maybe Comp -> Maybe Comp
(*:) z w = validate =<< liftA2 mul z w
(-:) :: Maybe Comp -> Maybe Comp -> Maybe Comp
(-:) z w =  validate =<< liftA2 sub z w
-- }}}

-- {{{ output
answer :: Maybe Comp -> BLC.ByteString
answer Nothing = "overflow"
answer (Just (0:+0)) = "0"
answer (Just (0:+b)) = BLC.pack $ show b ++ "i"
answer (Just (a:+b)) = BLC.pack $ case signum b of
                           1 -> show a ++ "+" ++ show b ++ "i"
                           -1 -> show a ++ show b ++ "i"
                           0 -> show a
unright :: Either ParseError (Maybe Comp) -> Maybe Comp
unright (Right r) = r
-- }}}

main = BC.getContents >>=
        mapM_ (BLC.putStrLn . answer . unright . parse calc "") . BC.lines
-- vim:foldmethod=marker

Measured memory_bytes: 4480
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

int dp[31] = { 1,1,2,4 };

int a(int n) {
	if (dp[n])return dp[n];
	dp[n] += dp[n - 1] ? dp[n - 1] : a(n - 1);
	dp[n] += dp[n - 2] ? dp[n - 2] : a(n - 2);
	dp[n] += dp[n - 3] ? dp[n - 3] : a(n - 3);
	return dp[n];
}

int main() {
	for (int n; cin >> n&&n;)
		cout << ceil((double)a(n) / (365 * 10)) << endl;
	return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define set_bits(a) __builtin_popcount(a)
#define pb push_back
#define pf push_front
#define mod 1000000007
#define M 998244353
#define fi first
#define se second
#define endl '\n'
#define INF 1e18
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);


int main()
{
     string s1,s2;
     cin>>s1>>s2;

     ll n1 = s1.length(), n2 = s2.length() , i, j;
     sort(s1.begin(),s1.end());
     sort(s2.begin(),s2.end());
     reverse(s2.begin(),s2.end());

     ll flag=0;
     for(i=0;i<min(n1,n2);i++)
     {
         if(s1[i]<s2[i])
         {
             flag=1;
             break;
         }
         if(s1[i]>s2[i])
         {
             flag=2;
             break;
         }
     }
     if(flag==1)
     {
         cout<<"Yes"<<endl;
     }
     else if(flag==2)
     {
         cout<<"No"<<endl;
     }
     else
     {
         if(n1<n2)
         {
             cout<<"Yes"<<endl;
         }
         else
         {
             cout<<"No"<<endl;
         }

     }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstring>
#include<string>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define SZ(a) (int)((a).size())
using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> Pii;
typedef pair <ll, int> Pli;
typedef unsigned long long ull;
const double eps = 1e-8;
const ll infll = 0x7fffffffffffffff;
const int mod = (int)(1e9) + 7;
const int inf = 0x7fffffff;
const int maxn = (int)(2e5) + 7;
const int maxm = 300;

int n, q;
ll t[maxn];

int main() {

	// freopen("in.in", "r", stdin);
	scanf("%d", &n);
	ll res = 0;
	for (int i = 1; i <= n; i++) {
		ll x;
		scanf("%lld", &x);
		t[x]++;
		res += x;
	}
	scanf("%d", &q);
	for (int i = 1; i <= q; i++) {
		ll b, c;
		scanf("%lld%lld", &b, &c);
		res += t[b] * (c - b);
		t[c] += t[b]; t[b] = 0;
		printf("%lld\n", res);
	}

	return 0;
}

Measured memory_bytes: 3872
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.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;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    vector<ll> a;
    rep(i,3){
        ll inp;
        cin >> inp;
        a.pb(inp);
    }
    
    sort(all(a));
    
    ll A = a[2]-a[0];
    ll B = a[2]-a[1];
    cerr << A << " " << B << endl;
    
    ll same = B;
    ll diff = A - B;
    
    cout << same + diff/2 + (diff%2) * 2 << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define prt(v) cout<<(v)<<"\n";
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
#define endl "\n"
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s.size()%2){
        if(s[0]==s[s.size()-1])prt("Second")
        else prt("First")
    }
    else{
        if(s[0]==s[s.size()-1])prt("First")
        else prt("Second")
    }
    return 0;
}


Measured memory_bytes: 512
n=int(input())

A=list(map(int,input().split()))
A.sort()

if n%2==0:
    X=[int(i) for i in range(1,n+1,2)]*2
elif n%2==1 and n>2:
    X=[int(i) for i in range(2,n+1,2)]*2+[0]
else:
    X=[0]    

X.sort()
ans=(2**(n//2))%(10**9+7)

for a,x in zip(A,X):
    if a!=x:
        ans=0
print(ans)

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
#define INF 1000000000
#define pb push_back
#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define tr(c, i) for (typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c, x) (c.find(x) != c.end())
#define cpresent(c, x) (find(all(c), x) != c.end())

ll bigmod(ll a, ll b, ll m)
{

    if (b == 0)
        return 1;
    ll x = bigmod(a, b / 2, m);
    x = (x * x) % m;

    if (b % 2)
        x = (x * a) % m;
    return x;
}

ll bigsum(ll a, ll b, ll m)
{
    ll s;
    if (b == 0)
        return b;
    if (b == 1)
        return a + 1;
    if (b % 2)
    {
        b = b / 2;
        s = bigsum(a, b, m) % m;
        s = (s * bigmod(a, b + 1, m)) % m;
        return s;
    }
    else
    {
        s = bigsum(a, b - 1, m) % m;
        s = (a * s + 1) % m;
        return s;
    }
}


int main()
{

    char s[2000005];
    ll l,n=0,i;
    cin>>s;
    l = strlen(s);

    for(i=0;i<l;i++){
        n+= s[i]-'0';
    }

    if(n%9==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3820
#include <cstdlib>
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<cmath>
#define ll long long
const ll INF=0x3f3f3f3f;
#define mod 1000000007
#define mem(a,b) memset(a,b,sizeof(a))
#define  INF 0x3f3f3f3f
//__builtin_popcount
using namespace std;
//priority_queue
const ll MAX=100000;
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
ll kc(ll a,ll b)
{
    ll c=1;
    while(b)
    {
        if(b&1)c=(c*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return c;
}

ll F[100003];
ll Find(ll a)
{
    return F[a]<0?a:F[a]=Find(F[a]);
}
ll same(ll a,ll b)
{
    if(Find(a)==Find(b))return 1;
    return 0;
}
void up(ll a,ll b)
{
    ll x,y;
    x=Find(a);
    y=Find(b);//cout<<F[x]<<" "<<F[y]<<endl;
    if(x!=y)
        F[y]+=F[x],F[x]=y;


}
int a[200003],b[200003];
int sum[200003];
int main()
{
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)
    scanf("%d",&a[i]),b[i]=a[i],sum[a[i]]++;
  sort(b+1,b+1+n);
  for(int i=1;i<=n;i++)
  {
      if(a[i]!=b[n])cout<<b[n]<<endl;
      else {
        if(sum[b[n]]==1)cout<<b[n-1]<<endl;
        else cout<<b[n]<<endl;
      }
  }
}

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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int Q;
    cin >> Q;
    for(int q=0;q<Q;++q){
        int k;
        cin >> k;
        i64 ans = 0;
        i64 d = 0, m = 0, dm = 0;
        for(int i=0;i<n;++i){
            if(i >= k){
                if(s[i-k] == 'D'){
                    d--;
                    dm -= m;
                }else if(s[i-k] == 'M'){
                    m--;
                }
            }
            if(s[i] == 'D'){
                d++;
            }else if(s[i] == 'M'){
                m++;
                dm += d;
            }else if(s[i] == 'C'){
                ans += dm;
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1412
/*==================================
 Author : Amrito
 Email  : amritohstu@gmail.com
 ===================================*/

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

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

//definition
#define PI acos(-1)
#define MAX 1000000010
#define MOD 1000000007
#define vi vector<int>
#define vit vector<int>::iterator
#define miit map<int, int>::iterator
#define msit map<string, int>::iterator
#define all(v) v.begin(), v.end()
#define mem(a,b) memset(a, b, sizeof(a))
#define loop(i, x) for(__typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define rloop(i, x) for(__typeof((x).rbegin()) i=(x).rbegin(); i!=(x).rend(); ++i)

//variables and functions
template<typename T> inline T sqr(T n) { return n * n; }
template<typename T> inline T pmod(T n, T m) { return ((n % m) + m) % m; }
template<typename T> T power(T n, ll p) { if(!p) return 1; else { T res = sqr(power(n, p >> 1)); if(p & 1) res *= n; return res; } }
template<typename T> T bigmod(T n, ll p, T m) { if(!p) return 1; else { T r = sqr(bigmod(n, p >> 1, m)) % m; if(p & 1) r = (r * n) % m; return r; } }
template<typename T> T exgcd(T a, T b, T& x, T& y) { if(!b) { x = 1; y = 0; return a; } else { T g = exgcd(b, a % b, y, x); y -= (a / b) * x; return g; } }
template<typename T> T modinv(T a, T m) { T x, y; exgcd(a, m, x, y); return pmod(x, m); }
/*------------------------------------------------------------------------------------*/

//global declaration
int test, cas = 1;

//main code
int main()
{
#ifdef LOCAL
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    // start code
    string s;
    cin >> s;
    int a = MAX, z = -1;
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'A' && a > i)
            a = i;
        if(s[i] == 'Z' && z < i)
            z = i;
    }
    cout << z - a + 1 << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  int h,w,cnt=0;
  cin >> h >> w;
  char c[10][10]={};
  for(int i=0; i<h; i++) {
    for(int j=0; j<w; j++) {
      cin >> c[i][j];
      if(c[i][j]=='#') {
        cnt++;
      }
    }
  }
  if(cnt==h+w-1) {
    cout << "Possible" << endl;
  }
  else {
    cout << "Impossible" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
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; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

int main(){
  int n,m;
  cin>>n>>m;
  int ansn=0;
  int ansm=0;
  if(n==0 or n==1){
    ansn=0;
  }else{
    ansn=n*(n-1)/2;
  }
  if(m==0 or m==1){
    ansm=0;
  }else{
    ansm=m*(m-1)/2;
  }
  cout<<ansn+ansm<<endl;
}

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

bool has3(int x);
void call(int n);

int main() {
	int n;
	cin >> n;
	call(n);
	return 0;
}

void call(int n) {
    for ( int x = 1; x <= n; x++ ) {
    	if ( x % 3 == 0 || has3(x) ) {
    		cout << " " << x;
    	}
    }
	cout << endl;
}

bool has3(int x) { //条件を満たすか返すだけ
	while (x) {
		if (x % 10 == 3) return true;
		x /= 10;
	}
	return false;
}



Measured memory_bytes: 3108
import math
import sys

stdin = sys.stdin


ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)


N = ni()

x = N % 10 

if x == 3:
    print('bon')
    exit(0)
elif x == 0 or x == 1 or x == 6 or x == 8:
    print('pon')
    exit(0)
print('hon')


Measured memory_bytes: 9192
PN = [i for i in range(1000000)]
#print(PN[0:20])
i = 2
while True:
    if i >= len(PN):
        break
    j = i * 2
    while True:
        if j >= len(PN):
            break
        PN[j] = 0
        j += i
    while True:
        i += 1
        if i >= len(PN):
            break
        if PN[i] != 0:
            break
PN[1] = 0
#print(PN[0:20])
cntPN = []
for i in range(1000000):
    if i == 0:
        cntPN.append(0)
    elif PN[i] == 0:
        cntPN.append(cntPN[i - 1])
    else:
        cntPN.append(cntPN[i - 1] + 1)

#print(cntPN[0:20])

import sys

a = []
for line in sys.stdin:
    a.append(int(line))

for i in a:
    print(cntPN[i])


Measured memory_bytes: 53000
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define ull  unsigned long long
typedef string str;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int INF = 1e9 + 5;
const int N = 2e5 + 123;
str a[4];
int main(){
    speed;
    str s;
    cin >> s;
    a[0] = "dream";
    a[1] = "dreamer";
    a[2] = "erase";
    a[3] = "eraser";
    str t = "";
    for(int i = s.size() - 1; i >= 0; --i){
        t = s[i] + t;
        for(int j = 0; j < 4; ++j){
            if(t == a[j]){
                // cout << t;
                t = "";
            }
        }
    }
    if(t == ""){
        cout << "YES";
        return 0;
    }
    cout << "NO";
}

Measured memory_bytes: 3816
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class Date
{
    long long countDate() const
    {
        int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        if((y % 4 == 0 && y % 100 != 0) || y % 400 == 0)
            ++ days[2];

        long long ret = (y-1) * 365LL + (y-1) / 4 - (y-1) / 100 + (y-1) / 400;
        for(int i=1; i<m; ++i)
            ret += days[i];
        ret += d - 1;

        return ret;
    }
public:
    long long y;
    int m, d;
    Date(long long y0, int m0, int d0)
    {
        y = y0;
        m = m0;
        d = d0;
    }
    long long operator-(const Date& other) const
    {
        return countDate() - other.countDate();
    }
    Date operator+(long long x) const
    {
        int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

        x += countDate();
    
        Date ret(0, 1, 0);
        ret.y = 0;
        ret.y += x / (365 * 400 + 97) * 400;
        x -= (365 * 400 + 97) * (ret.y / 400);
        ret.y += min(300LL, x / (365 * 100 + 24) * 100);
        x -= (365 * 100 + 24) * (ret.y % 400 / 100);
        ret.y += x / (365 * 4 + 1) * 4;
        x -= (365 * 4 + 1) * (ret.y % 100 / 4);
        ret.y += min(3LL, x / 365);
        x -= 365 * (ret.y % 4);
        ++ ret.y;

        if((ret.y % 4 == 0 && ret.y % 100 != 0) || ret.y % 400 == 0)
            ++ days[2];
        while(x >= days[ret.m]){
            x -= days[ret.m];
            ++ ret.m;
        }

        ret.d = (int)x + 1;

        return ret;
    }
};

int main()
{
    int x[] = {13, 20, 20, 18, 20};

    for(;;){
        string s;
        cin >> s;
        if(s == "#")
            return 0;
        istringstream iss(s);

        if(count(s.begin(), s.end(), '.') == 2){
            long long y;
            int m, d;
            char c;
            iss >> y >> c >> m >> c >> d;

            long long a = Date(y, m, d) - Date(2012, 12, 21);

            vector<int> ret(5);
            for(int i=4; i>=0; --i){
                ret[i] = a % x[i];
                a /= x[i];
            }
            for(int i=0; i<4; ++i)
                cout << ret[i] << '.';
            cout << ret[4] << endl;
        }else{
            long long a = 0;
            for(int i=0; i<5; ++i){
                int b;
                char c;
                iss >> b >> c;
                a *= x[i];
                a += b;
            }

            Date ret(2012, 12, 21);
            ret = ret + a;

            cout << ret.y << '.' << ret.m << '.' << ret.d << endl;
        }
    }
}

Measured memory_bytes: 1236
#include <stdio.h>

int main(){
    int n,i,j,s;
    char d ;
    scanf("%d",&n);
    bool card[4][13] ;
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            card[i][j]=false;
        }
    }
    for(i=1;i<=n;i++){
        scanf("\n%c%d",&d,&s);
        if(d == 'S'){
            card[0][s-1] = true;
        }
        if(d == 'H'){
            card[1][s-1] = true;
        }
        if(d == 'C'){
            card[2][s-1] = true;
        }
        if(d == 'D'){
            card[3][s-1] = true;
        }                
    }
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(card[i][j] == false){
                if(i == 0){
                    printf("S %d\n",j+1);
                }
                if(i == 1){
                    printf("H %d\n",j+1);
                }
                if(i == 2){
                    printf("C %d\n",j+1);
                }
                if(i == 3){
                    printf("D %d\n",j+1);
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2740
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N, long M, long[] A) {
    string[long] nums;
    if (A.canFind(1)) nums[2] = "1";
    if (A.canFind(2)) nums[5] = "2";
    if (A.canFind(3)) nums[5] = "3";
    if (A.canFind(4)) nums[4] = "4";
    if (A.canFind(5)) nums[5] = "5";
    if (A.canFind(6)) nums[6] = "6";
    if (A.canFind(7)) nums[3] = "7";
    if (A.canFind(8)) nums[7] = "8";
    if (A.canFind(9)) nums[6] = "9";
    
    const NONE = "X";
    string[long] memo;
    string maxNumMadeOf(long matches) {
        if (matches in memo)
            return memo[matches];
        if (matches == 0)
            return "";
        if (matches < 0)
            return NONE;

        string[] cands;
        foreach (pair; nums.byKeyValue) {
            auto x = maxNumMadeOf(matches - pair.key);
            if (x != NONE)
                cands ~= pair.value ~ x;
        }

        if (cands.length <= 0)
            return NONE;

        return memo[matches] = cands.reduce!((a, b) => lt(a, b) ? b : a);
    }

    return maxNumMadeOf(N);
}


bool lt(string a, string b) {
    if (a.length != b.length)
        return a.length < b.length;
    return a < b;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long M;
    M = input.front.to!long;
    input.popFront;

    long[] A = new long[](cast(size_t) (M));
    foreach (i; 0 .. cast(size_t) (M)) {
        A[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, M, A);
    else
        solve(N, M, A).writeln;
}


Measured memory_bytes: 77820
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
ans = 0
e = 10**6
for i in range(n):
    if e >= abs(a - (t-h[i]*0.006)):
        e = abs(a - (t-h[i]*0.006))
        ans = i
print(ans+1)


Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
U = 5000 * 5000 + 10

inf = 10 ** 18
dp1 = [-inf] * U
dp1[0] = N
for a, b in zip(A, B):
    for i in range(N - a + 1):
        dp1[i + a] = max(dp1[i + a], dp1[i] + b - a)

for i in range(N + 1):
    N = max(N, dp1[i])

dp2 = [-inf] * U
dp2[0] = N
for a, b in zip(A, B):
    for i in range(N - b + 1):
        dp2[i + b] = max(dp2[i + b], dp2[i] + a - b)

for i in range(N + 1):
    N = max(N, dp2[i])

print(N)

Measured memory_bytes: 425240
#include <stdio.h>

int main(void)
{
    int H, W, i, j;

    while (1) {
        scanf("%d %d", &H, &W);
        if (H == 0 && W == 0) {
            break;
        }
        for (i = 0; i < H; i++) {
            for (j = 0; j < W; j++) {
                if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
                    fputc('#', stdout);
                } else {
                    fputc('.', stdout);
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 576
#include <stdio.h>
#include <math.h>

int main(){
    FILE *fp=fopen("a.txt", "w");    
    int n;
    int a[100];

    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
    }
    for(int i=n-1; i>=0; i--){
        printf("%d", a[i]);
        if(i > 0){
            printf(" ");
        }
        else{
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep2(i, x, n) for (int i = x; i < n; ++i)

int main()
{
    int a,b;
    cin >> a >> b;

    int p = 0;
    if(a>=13) p = b;
    else if(a>=6) p = b/2;

    cout << p << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;



int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> d(n);
    ll ans=0;
    rep(i,n) {
        ll a,b;
        cin >> a >> b;
        d[i]=a+b;
        ans-=b;
    }
    sort(d.begin(),d.end(),greater<>());
    rep(i,n) {
        if (i%2==0) ans+=d[i];
    }
    cout << ans << endl;
    

    return 0;   
}


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

struct Node {
    vector<int> edges;
    LL x;

    Node() {
        x = 0;
    }
    Node(vector<int> edges) {
        this->edges = edges;
        x = 0;
    }
};

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<Node> nodes;
    nodes.resize(N + 1);
    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        nodes[a].edges.push_back(b);
        nodes[b].edges.push_back(a);
    }
    vector<bool> visited;
    visited.resize(N + 1);
    fill(ALL(visited), false);

    REP(i, Q) {
        int p;
        LL x;
        cin >> p >> x;
        nodes[p].x += x;
    }

    queue<int> q;
    q.push(1);
    for(;!q.empty();) {
        int n = q.front();

        if(visited[n]) {
            continue;
        }

        visited[n] = true;
        q.pop();

        for(auto neighbor : nodes[n].edges) {
            if(visited[neighbor]) {
                continue;
            }
            nodes[neighbor].x += nodes[n].x;
            q.push(neighbor);
        }
    }
    FOR(i, 1, N + 1) {
        if(i != N) {
            cout << nodes[i].x << " ";
        }else{
            cout << nodes[i].x << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 16372