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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

string pad(string s){
    while (true){
        if(s.size() == 6){break;}
        s = "0" + s;
    }
    return s;
}

void Main() {
    ll N, M; // N: 県の数，M:市の数
    cin >> N >> M;
    vector<vector<pair<ll, ll>>> x(N); // (年, 市番号)
    rep(i, M){
        ll p, y;
        cin >> p >> y;
        p--;
        x.at(p).push_back(make_pair(y, i));
    }
    vector<string> ans(M);
    rep(i, N){
        vector<pair<ll, ll>> y = x.at(i);
        if (y.size() > 0){
            sort(y.begin(), y.end());
            rep(j, y.size()){
                ans.at(y.at(j).second) = pad(to_string(i+1)) + pad(to_string(j+1));
            }
        }
    }
    for (auto v: ans){cout << v << endl;}
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 12416
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    py = [list(map(int, input().split())) for _ in range(m)]
    #l[i]:県iの市
    l = [[] for _ in range(n+1)]
    for p, y in py:
        l[p].append(y)
    for i in range(n+1):
        l[i].sort()
    for p, y in py:
        a = bisect_left(l[p], y) + 1
        print('{:06d}{:06d}'.format(p, a))



if __name__ == '__main__':
    main()

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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    ll K,N; cin >> K >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    ll ans = LOWINF;
    for(int i = 0; i+1 < N; ++i) {
        chmin(ans,K - (A[i+1]-A[i]) );
    }
    chmin(ans, K - (A[0]+(K-A[N-1])) );
    cout << ans << endl;
    return 0;
}


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

const int mn=1e5+7;

int main()
{
	int d[mn],n,cnt=0,mx=0;
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {scanf("%d",d+i);mx=max(d[i],mx);}
	sort(d+1,d+n+1);
	if(n%2!=0) {puts("0");return 0;}
	for(int i=1;i<=mx;++i) {
		if(lower_bound(d+1,d+n+1,i)-d-1==n/2) cnt++;
	}
	cout<<cnt;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <utility>
#include <queue>

using namespace std;
typedef long long signed int ll;

constexpr int inf = INT32_MAX / 2;
constexpr int mod = 1000000007;
constexpr int maxn = 100000;

class djikstra {
private:
	ll* d = nullptr;
	map<int, map<int, ll>> p;
	int sz = 0;
public:
	void add_path(int from, int to, ll cost) {
		p[from][to] = cost;
	}
	void compute(int from,int nodes) {
		sz = nodes;
		if (d != nullptr) delete d;
		d = new ll[nodes];
		auto cmp = [this](int a, int b) {return d[a] > d[b]; };
		priority_queue <ll, vector<ll>, decltype(cmp)> q(cmp);
		for (int i = 0; i < nodes; i++) d[i] = INT64_MAX / 2;
		d[from] = 0;
		q.push(from);
		while (!q.empty()) {
			for (auto& e : p[q.top()]) {
				if (d[e.first] > d[q.top()] + e.second) {
					d[e.first] = d[q.top()] + e.second;
					q.push(e.first);
				}
			}
			q.pop();
		}
	}
	ll operator[](int node) {
		if (node >= sz) return INT64_MAX/2;
		return d[node];
	}
};

string s;
ll abc[maxn + 1], bc[maxn + 1], c[maxn + 1], q[maxn + 1];

ll dpow3[maxn + 1];
ll mpow3(ll power) {
	if (power == 0) return 1;
	if (dpow3[power] == 0) dpow3[power] = (3 * mpow3(power - 1)) % mod;
	return dpow3[power];
}

int main() {
	cin >> s;
	for (int i = s.length() - 1; i >= 0; i--) q[i] = q[i + 1] + (s[i] == '?' ? 1 : 0);
	for (int i = s.length()-1; i >= 0; i--) c[i] = ((c[i + 1] * (s[i] == '?' ? 3 : 1)) + (s[i] == '?' || s[i] == 'C' ? mpow3(q[i + 1]) : 0)) % mod;
	for (int i = s.length() - 2; i >= 0; i--) bc[i] = ((bc[i + 1] * (s[i] == '?' ? 3 : 1)) + (s[i] == '?' || s[i] == 'B' ? c[i + 1] : 0)) % mod;
	for (int i = s.length() - 3; i >= 0; i--) abc[i] = ((abc[i + 1] * (s[i] == '?' ? 3 : 1)) + (s[i] == '?' || s[i] == 'A' ? bc[i + 1] : 0)) % mod;
	std::cout << abc[0] << endl;
}


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

int main(){
   int N,flag=0;
   cin >> N;
   for(int i=1; i<=9 ; i++){
       for(int j=1; j<=9 ; j++){
           if(N==i*j){
               flag++;
               break;
           }
       }
   }
   if(flag){
       cout << "Yes" << endl;
   }else{
       cout << "No" << endl;
   }
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        List<Integer> l = new ArrayList<>();
        boolean ans = true;
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        for (int i = 0; i < s.length(); i++) {
            int x = s.charAt(i);
            l.add(x);
        }
        for (int i = 1; i < s.length(); i++) {
            if (l.get(i) == l.get(i-1)) {
                ans = false;
            }
        }
        if (ans == true) {
            System.out.println("Good");
        } else {
            System.out.println("Bad");
        }
    }
}

Measured memory_bytes: 21844
#include <cstdio>
#include <cmath>
#define PI 3.14159265358979323846

int correct(int d){
  if(d<0){
    return d+360;
  }else if(d>360){
    return d-360;
  }else{
    return d;
  }
}

int main(){
  double x=0,y=0;
  int l,d,dir=0;

  while(scanf("%d,%d",&l,&d),l){
    x += l*sin(PI*dir/180);
    y += l*cos(PI*dir/180);
    dir = correct(dir+d);
  }

  printf("%d\n%d\n",(int)x,(int)y);
}

Measured memory_bytes: 1032
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto S = new string[](N);
    auto T = new long[](N);
    foreach (i; 0 .. N)
        scan(S[i], T[i]);
    auto X = sread();
    long s;
    while (S[s] != X)
        s++;
    long ans;
    foreach (i; s + 1 .. N)
        ans += T[i];
    writeln(ans);
}


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

#ifdef DEBUG
#define debug(...) __VA_ARGS__
#else
#define endl '\n'
#define debug(...)
#endif
#define debugf(...) debug(printf(__VA_ARGS__))

using ll = long long;
const int N = 2e5 + 5;

int a[N], b[N];


int (((((main)))))() <%
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

    int n, m, k;
    cin >> n >> m >> k;

    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < m; i++)
        cin >> b[i];

    int ans = 0;
    int t = 0;

    int j = -1;
    while (j < m-1 && t + b[j+1] <= k) {
        t += b[++j];
    }
    ans = j+1;

    for (int i = 0; i < n && t <= k; i++) {
        t += a[i];
        while (t > k && j >= 0) {
            t -= b[j];
            j--;
        }

        if (t <= k)
            ans = max(ans, j+1 + i+1);
    }

    cout << ans << endl;

	return 0;
%>

Measured memory_bytes: 5180
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll n=in();
    vector<ll>p(n);for(ll i=0;i<n;++i)p[i]=in();
    ll m=p[0];
    ll cnt=0;
    for(ll i=0;i<n;++i)if((m=min(m,p[i]))>=p[i])++cnt;
    cout<<cnt<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define cl clear() ;
#define vl vector<ll>
#define sz size()
#define len length()
#define el endl;cout.flush()
#define be begin()
#define fi first
#define se second
#define br break
#define en end()
#define ro return 0
#define br break
#define eb emplace_back
#define con continue
#define ms(x) memset(x , 0, so x)
#define all(x) (x).be , (x).en
#define acc(x) accumulate((x).be , (x).en , 0ll)
#define forn(i,a,b) for(ll i=a;i<=b;++i)
#define rng_58 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define trace3(a,b,c) cerr <<"a is " << a << " b is " << b << " c is " << c << el;
#define trace4(a,b,c,d) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << el ;
#define trace5(a,b,c,d,e) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << el;
#define trace6(a,b,c,d,e,f) cerr <<"a is " << a << " b is " << b << " c is " << c <<" d is " << d << " e is " << e << " f is " << f << el ;
const ll k = 1e9 + 7 ;
#define mod %
ll exp(ll x , ll y )
{
    if(y == 0) return 1 mod k ;
    if(y & 1 ) return (((x*exp(x,y/2)) mod k ) * exp(x,y/2) mod k ) mod k ;
    else return (exp(x,y/2) * exp(x,y/2)) mod k ;
}
int main()
{
    ios;
    string ss ;
    cin >> ss;
    string s = "" ;
    ll fone = -1 ;
    forn(i , 0 , ss.len - 1) {
       if(ss[i] == '1') fone = i ;
       if(fone != -1) br ;
    }
    forn(i , fone , ss.len -1 ){
       s = s + ss[i] ;
    }
    ll n = s.len ;
    ll ones = 0 ;
    forn(i , 0 , s.len - 1 ) {
       if(s[i] == '1') ++ones ;
    }
    ll ways = 0 ;
    ll waysequal = exp(2 , ones) ;
    ways = ways + waysequal ;
    ll lone = 0 ;
    forn(i , 0 , n -1){
       if(i == 0 ){
          ll res = 0 ;
          res = res + exp(3 , n-1);
          res = res mod k ;
          ways = ways + res ;
          ways = ways mod k ;
          ++lone ;
       }
       else {
         if(s[i] == '1'){
            ll res = 0 ;
            res  = res + (exp(2 , lone ) * exp(3 , n-1 - i ) ) mod k;
            res  = res mod k ;
            ways = ways + res ;
            ways = ways mod k ;
            ++lone ;
         }
       }
    }
    ways = ways mod k ;
    cout << ways << el ;
    ro ;
}



Measured memory_bytes: 868
import sys, math

def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    T = []
    G = [[] for k in range(N+1)]
    for k in range(N-1):
        a, b = map(int,input().split())
        G[a].append(b)
        G[b].append(a)
        T.append(str(a)+"0"+str(b))

    V = [0 for k in range(N+1)]
    C = [set() for k in range(N+1)]
    ans = dict()
    m = 0
    V[1] = 1
    Q = [1]
    while len(Q) > 0:
        ima = Q.pop()
        t = 1
        for tsugi in G[ima]:
            if V[tsugi] == 0:
                V[tsugi] = 1
                while t in C[ima] or t in C[tsugi]:
                    t += 1
                m = max(m,t)
                C[ima].add(t)
                C[tsugi].add(t)
                ans[str(ima)+"0"+str(tsugi)] = t
                Q.append(tsugi)
    print(m)
    for e in T:
        print(ans[e])

if __name__ == '__main__':
    main()


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

using i64 = long long int;

int main(){
    int a, b;
    cin >> a >> b;
    if(a+b==15)cout << "+";
    else if(a*b == 15)cout << "*";
    else cout << "x";
    cout << endl;

    return 0;
}


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

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (s[i] == t[j]) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j]);
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1]);
        }
    }
    // for (auto v : dp) {
    //     for (int val : v) {
    //         cout << val << " ";
    //     }
    //     cout << endl;
    // }
    int p = n, q = m;
    string ans = "";
    while (p > 0 && q > 0) {
        if (s[p - 1] == t[q - 1] && dp[p][q] == dp[p - 1][q - 1] + 1) {
            ans = s[p - 1] + ans;
            p--;
            q--;
        } else if (dp[p][q] == dp[p - 1][q]) {
            p--;
        } else {
            q--;
        }
    }
    cout << ans << endl;
}

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

int main(){
    int b[3];
    cin >> b[0] >> b[1] >> b[2];
    if(b[0] == 0 && b[1] == 0 && b[2] == 0) cout << "Close" << endl;
    else if(b[0] == 0 && b[1] == 0 && b[2] == 1) cout << "Open" << endl;
    else if(b[0] == 0 && b[1] == 1 && b[2] == 0) cout << "Close" << endl;
    else if(b[0] == 1 && b[1] == 0 && b[2] == 0) cout << "Close" << endl;
    else if(b[0] == 1 && b[1] == 1 && b[2] ==0) cout << "Open" << endl;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
int s=0;
int judge(int n)
{
	float g=sqrt(n);
	int f=int(g);
	if(f*f==n)
		return true;
	return false;
}
int main()
{
	int n,d;
	cin>>n>>d;
	int a[n+5][d+5];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=d;j++)
			cin>>a[i][j];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i<j)
			{
				int sm=0;
				for(int k=1;k<=d;k++)
					sm+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
				if(judge(sm)==true)
					s++;
			}
	cout<<s;
	return 0;
} 

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

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int l[m]; int r[m];
    int inf = -1, sup = -1;
    for (int i=0; i<m; i++) {
        cin >> l[i] >> r[i];
        if (inf == -1 or l[i] > inf) inf = l[i];
        if (sup == -1 or r[i] < sup) sup = r[i];
    }
    
    int cnt = 0;
    for (int i=1; i<=n; i++) {
        if (i >= inf and i <= sup) cnt++;
    }
    cout << cnt << '\n';
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    vector<pair<ll, ll>> P;
    vector<vector<ll>> years;
    ll N, M;
    cin >> N >> M;
    years.resize(N);
    for(ll i = 0;i < M;i++) {
        ll p, y;
        cin >> p >> y;
        p--;
        P.emplace_back(p, y);
        years[p].push_back(y);
    }
    for(auto &i: years) sort(i.begin(), i.end());
    for(auto &i: P) {
        ll di = distance(years[i.first].begin(), lower_bound(years[i.first].begin(), years[i.first].end(), i.second));
        cout << setfill('0') << setw(6) << i.first + 1 << setfill('0') << setw(6) << di + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 8560
#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>
#include <functional>
#include <cstdlib>
#include <queue>
#include <tuple>
#include <map>
#include <cmath>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define SORT(v, n) sort(v, v+n)

using namespace std;

const double EPS =1e-9;
const long INF =999999999;
const long MINF =-999999999;

int main(){
	int i,j,r;

	long long  N,matrix[100010]={},matrix2[100010][2]={};
	long long  max=0,max1=0,max2=0;


	cin>>N;
	FOR(i,0,N) cin>>matrix[i];
	SORT(matrix,N);

	j=-1;
	FOR(i,0,N){
		if(max!=matrix[i]){
			matrix2[++j][0]=matrix[i];
			max=matrix2[j][0];
			matrix2[j][1]=1;
		}else{
			matrix2[j][1]++;
		}
	}
	
	RREP(i,j+1){
		if(matrix2[i][1]>=4){
			if(max1==0) max1=max2=matrix2[i][0];
			else max2=matrix2[i][0];

			break;
		}else if(matrix2[i][1]>=2){
			if(max1==0) max1=matrix2[i][0];
			else{
				max2=matrix2[i][0];
				break;
			}
		}
	}

	printf("%lld\n",max1*max2);

	return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int N;
    cin >> N;
    vector<string> v(N);
    vector<int> data(26, 1 << 30);
    REP (i, 0, N) cin >> v[i];
    REP (i, 0, N) {
        vector<int> temp(26, 0);
        REP (j, 0, v[i].size()) {
            temp[v[i][j] - 'a']++;
        }
        REP (j, 0, 26) data[j] = min(data[j], temp[j]);
    }
    REP (i, 0, 26) {
        REP (_, 0, data[i]) {
            cout << char(i + 'a');
        }
    }
    cout << endl;
    return 0;
}


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

map<ll, ll> prime_factors(ll n) {
    map<ll, ll> res;
    if(n == 1){
        res[n] = 1;
        return res;
    }
    for(ll i = 2, _n = n; i*i <= _n; ++i){
        while(n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}

int main() {
    ll N, P, x, y, z, ans = 1;
    cin >> N >> P;
    map<ll, ll> res = prime_factors(P);

    for(map<ll, ll>::iterator it = res.begin(), end = res.end(); it != end; ++it){
        // cout << it->first << "^" << it->second << endl;
        x = it->first;
        y = it->second;
        if(y >= N){
            z = y/N;
            // cout << x << "^" << y << endl;
            ans = ans * pow(x, z);
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;


int main(){FIN
    ll k;cin>>k;
    string s;cin>>s;
    string ans;
    if (s.size()<=k) {
        cout<<s<<endl;
        return 0;
    }

    else{
        cout<<s.substr(0,k)<<"..."<<endl;
    } 
    return 0;

}

Measured memory_bytes: 3656
import java.util.Scanner;
class Main{

	public void solve(){
    Scanner sc=new Scanner(System.in);
		
		int a=sc.nextInt();
		int b=sc.nextInt();
		
		if(a<b){
			System.out.println("a < b");
		}else if(a>b){
			System.out.println("a > b");
		}else{
			System.out.println("a == b");
		}
	
	}
	public static void main(String[] args){
        Main obj =new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17160
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
using namespace std;
typedef long long LL;
int Q;
LL a,b;
LL LLsqrt(LL x){
    LL L=0,R=1e9,mid,ans=-1;
    while (L<=R){
        mid=(L+R)>>1;
        if (mid*mid<=x)
            L=mid+1,ans=mid;
        else
            R=mid-1;
    }
    return ans;
}
int main(){
    scanf("%d",&Q);
    while (Q--){
        scanf("%lld%lld",&a,&b);
        if (a>b)
            swap(a,b);
        LL c=a*b-1;
        LL d=LLsqrt(c);
        LL ans=d+d;
        if (a!=b)
            ans--;
        if (d!=0)
            if (d==c/d)
                ans--;
        printf("%lld\n",max(ans,0LL));
    }
    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp = br.readLine().split(" ");
		int N = Integer.parseInt(tmp[0]);
		int M = Integer.parseInt(tmp[1]);
		int X = Integer.parseInt(tmp[2]);
		List<Integer> A = new ArrayList<Integer>();
		tmp = br.readLine().split(" ");
		for(int i = 0;i<M;i++){
			A.add(Integer.parseInt(tmp[i]));
		}
		int countL = 0;
		int countR = 0;
		//左へ行く場合
		for(int l = X;l>0;l--){
			if(A.contains(l))countL++;
		}
		//右へいく場合
		for(int r = X;r<=N;r++){
			if(A.contains(r))countR++;
		}

		System.out.println(Math.min(countL,countR));
	}


}


Measured memory_bytes: 22612
N,X,Y=map(int,input().split())
ls=[0 for i in range(N-1)]
for i in range(0,N-1):
  for j in range(i+1,N):
    a=min([j-i,abs(i-(X-1))+1+abs(j-(Y-1))])
    ls[a-1]+=1
for i in range(len(ls)):
  print(ls[i])

Measured memory_bytes: 3444
import java.util.Scanner;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();

		int array[] = new int[N];
		for(int i = 0; i < N; i++)array[i] = scanner.nextInt();

		out_put(array);

		int base_value,loc;
		for(int i = 1; i < N; i++){
			base_value = array[i];
			loc = i-1;
			while(loc >= 0 && array[loc] > base_value){
				array[loc+1] = array[loc];
				loc--;
			}
			array[loc+1] = base_value;

			out_put(array);
		}
	}

	private static void out_put(int array[]){

		System.out.printf("%d", array[0]);

		for(int i = 1; i < array.length; i++){
			System.out.printf(" %d", array[i]);
		}
		System.out.printf("\n");
	}
}



Measured memory_bytes: 45188
#include <stdio.h>

int min2(int a, int b){
    if(a < b) return a;
    else return b;
}

int max2(int a, int b){
    if(a > b) return a;
    else return b;
}

int max3(int a, int b, int c){
    return max2(max2(a, b), max2(b, c));
}

int main(){
    int n;
    int l[1000];

    scanf("%d", &n);
    for(int i = 0; i < n; ++i){
        scanf("%d", &l[i]);
    }

    int max = 0;
    int cnt = 0;
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            for(int k = j + 1; k < n; ++k){
                max = max3(l[i], l[j], l[k]);
                if(max == l[i]){
                    if(max < (l[j] + l[k]) && l[i] != l[j] && l[j] != l[k] && l[i] != l[k]){
                        cnt++;
                        continue;
                    }
                }
                else if(max == l[j]){
                    if(max < (l[i] + l[k]) && l[i] != l[j] && l[j] != l[k] && l[i] != l[k]){
                        cnt++;
                        continue;
                    }
                }
                else{
                    if(max < (l[i] + l[j]) && l[i] != l[j] && l[j] != l[k] && l[i] != l[k]){
                        cnt++;
                        continue;
                    }
                }
            }
        }
    }

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

    return 0;
}


Measured memory_bytes: 1740
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
    int64_t N, K;
    cin >> N >> K;
    vector<int64_t> A(N), M, P;
    for(int i=0; i<N; i++) {
        cin >> A[i];
        if(A[i] < 0) {
            M.emplace_back(A[i]);
        } else if(A[i] > 0) {
            P.emplace_back(A[i]);
        }
    }

    sort(M.begin(), M.end());
    sort(P.begin(), P.end());

    int64_t ans;
    if(K <= M.size() * P.size()) {
        int64_t low = -2'000'000'000'000'000'000;
        int64_t high = 0;
        while(low + 1 < high) {
            int64_t mid = (low + high) / 2;
            int64_t cnt = 0;
            for(int i=0; i<M.size(); i++) {
                int low2 = -1;
                int high2 = P.size();
                while(low2 + 1 < high2) {
                    int mid2 = (low2 + high2) / 2;
                    if(M[i] * P[mid2] <= mid) {
                        high2 = mid2;
                    } else {
                        low2 = mid2;
                    }
                }
                cnt += P.size() - high2;
            }
            if(cnt >= K) {
                high = mid;
            } else {
                low = mid;
            }
        }
        ans = high;
    } else if(K <= N*(N-1)/2 - M.size()*(M.size()-1)/2 - P.size()*(P.size()-1)/2) {
        ans = 0;
    } else {
        int64_t low = 0;
        int64_t high = 2'000'000'000'000'000'000;
        while(low + 1 < high) {
            int64_t mid = (low + high) / 2;
            int64_t cnt = N*(N-1)/2 - M.size()*(M.size()-1)/2 - P.size()*(P.size()-1)/2;
            for(int i=0; i<M.size(); i++) {
                int low2 = -1;
                int high2 = M.size();
                while(low2 + 1 < high2) {
                    int mid2 = (low2 + high2) / 2;
                    if(M[i] * M[mid2] <= mid) {
                        high2 = mid2;
                    } else {
                        low2 = mid2;
                    }
                }
                cnt += M.size() - max(high2, i+1);
            }
            for(int i=0; i<P.size(); i++) {
                int low2 = -1;
                int high2 = P.size();
                while(low2 + 1 < high2) {
                    int mid2 = (low2 + high2) / 2;
                    if(P[i] * P[mid2] <= mid) {
                        low2 = mid2;
                    } else {
                        high2 = mid2;
                    }
                }
                cnt += max(low2 - i, 0);
            }
            cerr << mid << ' ' << cnt << endl;
            if(cnt >= K) {
                high = mid;
            } else {
                low = mid;
            }
        }
        ans = high;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3956
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  ll n;
  cin >> n;
  vector<ll> t(5);
  bool flag = true;
  rep(i, 5) {
    cin >> t[i];
    if (t[i] < n) flag = false;
  }

  if (flag) {
    cout << 5 << endl;
    return 0;
  }

  ll ans = 0;
  vector<ll> cnt(5);
  pair<ll,ll> p;
  p.first = -1; p.second = -1;
  for (int i = 0; i < 5; ++i) {
    cnt[i] = n / t[i];
    if (n % t[i] > 0) cnt[i] += 1;
    if (p.first < cnt[i]) {
      p.second = i + 1;
      p.first = cnt[i];
    }
  }

  ans = 4 + p.first;
  cout << ans << endl;
}


Measured memory_bytes: 256
import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main() {
    val x = readLong()

    var r = 100L
    var c = 0
    while (r < x) {
        r = (r * 1.01).toLong()
        c++
    }
    println(c)
}


Measured memory_bytes: 34520
N, M = [int(x) for x in input().split()]
PY = [[x] + [int(y) for y in input().split()] + [""] for x in range(M)]
PY.sort(key=lambda x: x[2])

rd = [0]*(N+1)
for i, (x, p, y, s) in enumerate(PY):
    rd[p] += 1
    PY[i][3] = str(p).rjust(6, "0") + str(rd[p]).rjust(6, "0")

PY.sort(key=lambda x: x[0])
for py in PY:
    print(py[3])


Measured memory_bytes: 33056
/**
*   @Author : MeGaCrazy
*   @InitTime : Wed Jan 02 17:39:58 2019
*   @Idea :
*
*
*
*
*
*  Happy Solving :)
**/
#include <bits/stdc++.h>
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
 //  freopen("in","r",stdin);
   //freopen("out","w",stdout);
#endif
   long long n;
   cin>>n;
   long long l=0,r=1e15;
   if(n<6){
   	cout<<1<<endl;
   	return 0;
   }
   while((r-l)>1){
    	long long mid=(l+r)>>1;
    	if(mid*5ll + mid*6ll >=n)r=mid;
    	else l=mid+1;
   }   
   while(1ll*5*(r-1)+(1ll*6*(r-1)) >=n)r--;
   //while(1ll*5*(r)+(1ll*6*(r)) <n)r++;

   if(1ll*5*(r-1)+(1ll*6*(r))>=n){
        cout<<(r)+(r-1)<<endl;
   }else{
   	cout<<(r*2)<<endl;
   }

}

Measured memory_bytes: 256
#include <utility>
#include <iostream>
#include <cmath>
#include <deque>
#include <string>
#include <time.h>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <sstream>
#include <algorithm>
#include <bitset>

#define pii pair<ll,ll>
#define X first
#define Y second
#define mp make_pair

typedef long long ll;
using namespace std;
#define MAXN (1<<20)
#define MOD 1000000007
#define N 1048576
ll n, x, k, z, m, pos, q, ans_v;
ll x1, p1, x2, p2;
vector<ll> g[300500], f;

int main() {
    string s;
    cin >> s;
    ll x = 1;
    ll n = s.size();
    if (s[0] != '<') {
        f.push_back(0);
    }
    for (int i = 0; i + 1 < n; i++) {
        if (s[i] == s[i+1]) {
            x++;
        } else {
            f.push_back(x);
            x = 1;
        }
    }
    f.push_back(x);
    ll sum = 0;
    for (int i = 0; i < f.size(); i++) {
        sum += f[i] * (f[i] + 1) / 2;
        if (i % 2) {
            sum -= min(f[i], f[i-1]);
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 10108
n = int(input())
sus = [[] for i in range(n)]
edges = []
for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    sus[a].append(b)
    sus[b].append(a)
    edges.append((a, b))

def probaj(korijen):
    bio = [False for i in range(n)]
    maks = [0 for i in range(n)]

    def dfs(x, level):
        nonlocal bio
        nonlocal maks
        bio[x] = True
        djece = 0
        for y in sus[x]:
            if not bio[y]:
                dfs(y, level + 1)
                djece += 1
        maks[level] = max(maks[level], djece)
    
    if isinstance(korijen, tuple):
        k1, k2 = korijen
        bio[k1] = bio[k2] = True
        dfs(k1, 0)
        dfs(k2, 0)
        a, b = 1, 2
    else:
        dfs(korijen, 0)
        a, b = 1, 1

    for l in range(n):
        if maks[l]:
            b *= maks[l]
            a += 1
        else:
            break
    return a, b

p1 = min(probaj(i) for i in range(n))
p2 = min(probaj(e) for e in edges)
p = min(p1, p2)
print(p[0], p[1])


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

int main() {
  int A, B, C;
  cin >> A >> B >> C ;

 if (A * B < C  ) {
   cout << A * B << endl;
 }
 if (A * B > C ) {
   cout << C << endl;
 } 
 if (A * B == C  ) {
   cout << C << endl;
 }  
}  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
int G[505][505], n;
void solve(int l, int r, int t){
	if(l+1 == r) return;
	int m = (l+r) / 2;
	rep(i,l,m) rep(j,m,r) G[i][j] = t;
	solve(l,m,t+1); solve(m,r,t+1);
}

int main(){
	scanf("%d", &n);
	solve(0,n,1);
	rep(i,0,n) rep(j,i+1,n) printf("%d%c", G[i][j], j == n-1 ? '\n' : ' ');
}

Measured memory_bytes: 1408
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int[] N=new int[a];
		for(int i=0;i<b*2;i++) {
			int M = sc.nextInt();
			++N[M-1];
		}
		for(int i=0;i<a;i++){
			System.out.println(N[i]);
		}
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
using namespace std;
int f[1000000];
int main()
{
    int x;
    cin>>x;
    bool bl=1;
    int i=1;
    f[x]++;
    while(bl){
        i++;
        if(x%2==0){
            x/=2;
        }
        else{
            x=x*3+1;
        }

        if(f[x]>0){
            cout<<i;
            return 0;
        }
        f[x]++;
    }

    return 0;
}


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

using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define f first
#define s second
#define pii pair<int,int>
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int MAX_N = 1e5 + 1;

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int a[n];
    map<int, int> mp;
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        mp[a[i]]++;
        sum += a[i];
    }
    int q;
    cin >> q;
    while (q--) {
        int b, c;
        cin >> b >> c;
        if (!mp.count(b)) {
            cout << sum << endl;
            continue;
        }
        int col = mp[b];
        sum -= col * b;
        sum += col * c;
        mp.erase(b);
        mp[c] += col;
        cout << sum << endl;
    }
}

Measured memory_bytes: 8332
#!/usr/bin/ruby
#encoding: utf-8

# 貰うDPで書く

n = gets.to_i
h = gets.split.map(&:to_i)

dp = Array.new(n,1e9.to_i)

dp[0] = 0

(1..n-1).each do |i|
  dp[i] = [dp[i],dp[i-1] + (h[i]-h[i-1]).abs].min
  if i > 1
    dp[i] = [dp[i],dp[i-2] + (h[i]-h[i-2]).abs].min
  end
end

puts dp[n-1]

Measured memory_bytes: 11396
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

#define MOD 1000000007

int main()
{
  ll n;
  cin >> n;
  vector<string> ss = {};
  for (auto i = 0; i < n; i++)
  {
    string s;
    cin >> s;
    ss.push_back(s);
  }

  unordered_map<string, ll> counter = {};
  for (auto s : ss)
  {
    counter[s] = counter[s] + 1;
  }

  ll max_count = -1;
  for (auto &p : counter)
  {
    if (max_count < p.second)
      max_count = p.second;
  }

  vector<string> v = {};
  for (auto &p : counter)
  {
    if (max_count == p.second)
    {
      v.push_back(p.first);
    }
  }

  sort(v.begin(), v.end());
  for (auto &p : v)
  {
    cout << p << endl;
  }

  return 0;
}


Measured memory_bytes: 27376
#include <stdio.h>
int selectionSort(int A[], int N) {
	int i, j, temp, sw = 0, minj;
	for (i = 0; i < N - 1; i++) {
		minj = i;
		for (j = i; j < N; j++) {
			if (A[j] < A[minj]) minj = j;
		}
		temp = A[i];
		A[i] = A[minj];
		A[minj] = temp;
		if (i != minj) sw++;
	}
	return sw;
}

int main() {
	int A[100], N, i, sw;

	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}

	sw = selectionSort(A, N);

	for (i = 0; i < N; i++) {
		if (i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
	printf("%d\n", sw);

	return 0;
}


Measured memory_bytes: 2100
N = int(input())
plane = [0] * N
houkou = ["U", "D", "R", "L"]
up = []
down = []
right = []
left =[]
for i in range(N):
  x, y, p = list(map(str, input().split()))
  x = int(x)
  y = int(y)
  p2 = houkou.index(p)
  plane[i] = [x, y, x + y, x - y, p2]
  
#x座標が同じでぶつかる
plane = sorted(plane, key=lambda x:x[1])
plane = sorted(plane, key=lambda x:x[0])
#print(plane)
time = 10 ** 10
for k in range(1, N):
    if plane[k][0] == plane[k - 1][0]:
      if plane[k][1] > plane[k - 1][1]:
        if (plane[k][4] == 1) and (plane[k - 1][4] == 0):
          time2 = (plane[k][1] - plane[k - 1][1]) / 0.2
          time = min(time, time2)
      else:
        if (plane[k][4] == 0) and (plane[k - 1][4] == 1):
          time2 = (plane[k - 1][1] - plane[k][1]) / 0.2
          time = min(time, time2)
        
#y座標が同じでぶつかる
plane = sorted(plane, key=lambda x:x[0])
plane = sorted(plane, key=lambda x:x[1])
for k in range(1, N):
    if plane[k][1] == plane[k - 1][1]:
      if plane[k][0] > plane[k - 1][0]:
        if (plane[k][4] == 3) and (plane[k - 1][4] == 2):
          time2 = (plane[k][0] - plane[k - 1][0]) / 0.2
          time = min(time, time2)
      else:
        if (plane[k][4] == 2) and (plane[k - 1][4] == 3):
          time2 = (plane[k - 1][0] - plane[k][0]) / 0.2
          time = min(time, time2)

def go(x, y, u, t):
  if u == 0:
    return x, int(y + t * 0.1)
  elif u== 1:
    return x, int(y - t * 0.1)
  elif u == 2:
    return int(x + t * 0.1), y
  else:
    return int(x - t * 0.1), y
  
          
#和が同じでぶつかる
plane = sorted(plane, key=lambda x:x[2])
for k in range(1, N):
    one = plane[k]
    two = plane[k - 1]
                
    if plane[k][2] == plane[k - 1][2]:
      time2 = abs(one[0] - two[0]) / 0.1
      max_x = max(one[0],two[0])
      min_x = min(one[0], two[0])
      max_y = max(one[1], two[1])
      min_y = min(one[1], two[1])
      L = [[max_x, max_y], [min_x, min_y]]
      #k
      k_x, k_y = go(one[0], one[1], one[4], time2)
      #k - 1
      k2_x, k2_y = go(two[0], two[1], two[4], time2)
      if [k_x, k_y] in L:
        if [k2_x, k2_y] in L:
          if [k_x, k_y] == [k2_x, k2_y]:
            time = min(time, time2)
          
#差が同じでぶつかる
plane = sorted(plane, key=lambda x:x[3])
#print(plane)
for k in range(1, N):
    one = plane[k]
    two = plane[k - 1]
                
    if plane[k][3] == plane[k - 1][3]:
      time2 = abs(one[0] - two[0]) / 0.1
      max_x = max(one[0],two[0])
      min_x = min(one[0], two[0])
      max_y = max(one[1], two[1])
      min_y = min(one[1], two[1])
      L = [[max_x, min_y], [min_x, max_y]]
      #k
      k_x, k_y = go(one[0], one[1], one[4], time2)
      #k - 1
      k2_x, k2_y = go(two[0], two[1], two[4], time2)
      if [k_x, k_y] in L:
        if [k2_x, k2_y] in L:
          if [k_x, k_y] == [k2_x, k2_y]:
            time = min(time, time2)          
            
if time == 10 ** 10:
  print("SAFE")
else:
  print(int(time))
#print(plane)  


Measured memory_bytes: 160628
f = lambda:list(map(int,input().split()))
l = f() + f() + f()
n = int(input())
s = set()

for i in range(n):
    b = int(input())
    if b in l: s|={l.index(b)}

print(['No','Yes'][any(t<=s for t in [{0,1,2},{0,3,6},{0,4,8},{1,4,7},
                                      {2,4,6},{2,5,8},{3,4,5},{6,7,8}])])

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
int data[10000];

int main()
{
	int n;
	
	while(~scanf("%d",&n))
	{
		int i,j,sum=0,a;
		for(i=0;i<n;i++)
		{
			scanf("%d",&data[i]);
			if(data[i]%2==0)
			{
				sum++;
			}
		}
		
		a = pow(3,n)-pow(2,sum);
		
		printf("%d\n",a);
	}
	
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
using LL = long long;
using ULL = unsigned long long;
#define NUM 1000000007

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a*b, c*d) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){


	long sum = 0;
	long min = 1000000;
	long max = -1000000;
	long a = 0;
	int n;
	int i;
	scanf("%ld",&n);
		for(i = 1;i <= n;i++){
		scanf("%ld",&a);
		if(a < min){
			min = 	a;
		}
		if(a > max){
			max = a;
		}
		sum += a;
	}
	printf("%ld %ld %ld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
signed main()
{
	long long ans1,ans2,a,b,c;
	cin>>a>>b>>c;
	ans1=4*a*b;
	if((c-a-b)<=0)
	{
	cout<<"No\n";
	return 0;
	}
	ans2=(c-a-b)*(c-a-b);
	if(ans1<ans2)cout<<"Yes\n";
	else cout<<"No\n"; 
    return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>

void bubbleSort(int *A, int N);

int main(void){
  int a[100],n;
  int i;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);

  bubbleSort(a,n);

  return 0;
}

void bubbleSort(int *A, int N){

  int tmp;
  int i,j;
  int flag=1,cnt=0;

  while(flag){
    flag=0;
    for(j=N-1;j>=1;j--){
      if(A[j]<A[j-1]){
	tmp=A[j];
	A[j]=A[j-1];
	A[j-1]=tmp;
	flag=1;
	cnt++;
      }
    }
  }

  for(i=0;i<N-1;i++)
    printf("%d ",A[i]);

  printf("%d\n",A[N-1]);
  printf("%d\n",cnt);
}



Measured memory_bytes: 2140
def score(A,g):
    score = 0
    for p in g:
        if A[p[1]]-A[p[0]]==p[2]:
            score+=p[3]
    return score

def solve(m,n,g,A,dep):
    if dep==n:
        return score(A,g)
    else:
        temp_scores = []
        for i in range(A[dep],m+1):
            A[dep+1] = i
            temp_scores.append(solve(m,n,g,A,dep+1))
        return max(temp_scores)

def main():
    n,m,q = map(int,input().split())
    g = []
    for _ in range(q):
        a,b,c,d = map(int,input().split())
        g.append((a,b,c,d))
    A = [0]*(n+1)
    A[0]=1
    print(solve(m,n,g,A,0))
main()

Measured memory_bytes: 9144
A, B, K = map(int, input().split())

if K >= A:
    K = K - A
    A = 0
else:
    A = A - K
    K = 0


if K >= B:
    K = K - B
    B = 0
else:
    B = B - K
    K = 0


if A or B:
    for i in range(K):
        if A >= 1:
            A -= 1
        elif B >= 1:
            B -= 1
        else:
            pass

print('{} {}'.format(A, B))


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

int main() {
  string s;
  cin >> s;
  int n = s.size();

  LL cnt = 0, ans = 0;
  for (int i = 0; i < n; i ++) {
    if (s[i] == 'A') cnt ++;
    else if (i < n - 1 && s[i] == 'B' && s[i + 1] == 'C') {
      ans += cnt;
      i ++;
    } else {
      cnt = 0;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
S = input()
count = 0
exception = [0]
answer = "WA"

if S[0] == 'A' and S[2:-1].count('C') == 1:
    C = S.index('C')
    exception.append(C)

if len(exception) == 2:
    for j in range(len(S)):
        if j not in exception and S[j].islower():
            count += 1

if count == len(S)-2:
    answer = "AC"

print(answer)


Measured memory_bytes: 3060
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(non_snake_case)]
fn main() {
    input!{
        N: usize,
    };

    println!("{}",180 * (N-2));

}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXN = 100050;
int x[MAXN];
ll dp[MAXN];

int N, E, T;
ll f(int i,int k) {
	return x[i] + dp[k]-x[k] + max( T, 2*(x[i]-x[k+1]) );
}
ll cf(int i,int k) {
	return x[i] + dp[k]-x[k] + 2*(x[i]-x[k+1]);
}

int main() {
	scanf("%d%d%d", &N, &E, &T);
	for(int i=1;i<=N;i++) scanf("%d", &x[i]);
	dp[0] = 0;
	deque<int> deq;
	deq.PB(0);
	for(int i=1;i<=N;i++) {
		while(SZ(deq)>1 && f(i, deq[0])>=f(i, deq[1])) deq.pop_front();
		debug(" -- %d\n", deq[0]);
		dp[i]=f(i, deq[0]);
		//while(SZ(deq)>=1 && f(i, deq.back())>=f(i, i)) deq.pop_back();
		debug("PB[%d] %lld %lld\n",deq.back(), cf(i, deq.back()), cf(i, i));
		if(cf(i, deq.back()) > cf(i, i)) {
			deq.PB(i);
		}
		debug("i %d %lld\n", i, dp[i]);
	}
	cout << dp[N] + E-x[N] << endl;
	return 0;
}


Measured memory_bytes: 1408