akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> pii;
int N;

bool fa_sd(pii A, pii B){
    if(A.first != B.first){
      return A.first < B.first;
    }else{
      A.second > B.second;
    }
  }
bool sd_fd(pii A, pii B){
    if(A.second != B.second){
      return A.second > B.second;
    }else{
      A.first > B.first;
    }
  }

struct Solver{
  vector<pii> _r;
  vector<pii> _b;
  explicit Solver(vector<pii> r, vector<pii> b) : _r(r), _b(b){
    sort(_b.begin(), _b.end(), fa_sd);
    sort(_r.begin(), _r.end(), sd_fd);
  }
  bool check(pii Blue, pii Red){
    if(Blue.first > Red.first && Blue.second > Red.second){
      return true;
    }else{
      return false;
    }
  }
  int solve(){
    int ans=0;
    for(int i=0; i<N; i++){
      int M = (int)_r.size();
      for(int j=0; j<M; j++){
        if(check(_b[i], _r[j])){
          ans++;
          _r.erase(_r.begin()+j);
          break;
        }
      }
    }
    return ans;
  }
};

void read_input(int N, vector<pii> &x){
  for(int i=0; i<N; i++){
    pii init; cin >> init.first >> init.second;
    x.push_back(init);
  }
}

int main(){
  cin >> N;
  vector<pii> red,blue;
  
  read_input(N, red);
  read_input(N, blue);
  Solver solver(red,blue);
  cout << solver.solve() << "\n";
}

Measured memory_bytes: 256
import bisect

N = int(input())
X = [int(_) for _ in input().split()]

X2 = sorted(X)
r = X2[N // 2 ]
l = X2[N // 2 -1]

for i in range(N):
    if bisect.bisect_left(X2, X[i]) < N // 2:
        print(r)
    else:
        print(l)

Measured memory_bytes: 25776
N = int(input())

def to_n(X, n):
    if (int(X / n)):  return to_n(int(X / n), n) + str(X % n)
    return str(X % n)

ans = 10 ** 9 + 7
for i in range(N + 1):
    N6 = to_n(N - i, 6)
    N9 = to_n(i, 9)
    res = 0
    for j in N6:  res += int(j)
    for j in N9:  res += int(j)
    ans = min(res, ans)
print(ans)

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

using namespace std;

const int N = 1e5 + 5 , MOD = 1e9 + 7;
int p[N] , memo[N][14];
string s;

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

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

int solve (int i , int m) {
    if (i == s.size())
        return m == 5;

    int &ret = memo[i][m];
    if (~ret)
        return ret;

    if (s[i] != '?')
        return ret = solve(i + 1 , add(m , mul(s[i] , p[s.size() - i - 1] , 13) , 13));

    ret = 0;

    for (int j = 0 ;j <= 9 ;j++)
        ret = add(ret , solve(i + 1 , add(m , mul(j , p[s.size() - i - 1] , 13) , 13)) , MOD);

    return ret;
}

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

    p[0] = 1;
    for (int i = 1 ;i < N ;i++)
        p[i] = p[i - 1] * 10 % 13;

    cin >> s;
    for (char &c : s) if (c != '?') c -= '0';
    memset(memo , -1 , sizeof memo);
    cout << solve(0 , 0);
}


Measured memory_bytes: 17392
#include <iostream>
#include <cmath>
#include <string>
#include<set>
#include<vector>
#define MAX 5000
using namespace std;
bool p_judge(int x) {
    for(int i=2; i<=x/2; i++) {
        if(x%i==0)
            return false;
    }
    return true;
}

int main(void) {
    int n, i, j=1;
    cin >> n;
    for(i=11; j<=n; i+=10) {
        if(p_judge(i)) {
            printf("%d ", i);
            j++;
        }
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		for (int i = 0; i < g.adjList.size(); i++) {
			g.bfs(i);
		}
	}
}
//template code, C343, 2019


class Graph {
	private int totalVertex;
	LinkedList<LinkedList<Integer>> adjList;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	
	public void bfs(int tgtIndex) {
		boolean[] visited = new boolean[adjList.size()];
		
		Queue<Integer> q = new LinkedList<>(); 
		q.add(0);
		
		int[] distances = new int[visited.length];
		
		int ct = 0;
		while (q.isEmpty() == false) {
			int tgt = q.remove();
			if (visited[tgt]) {
				continue;
			}
			
			if(tgt == tgtIndex) {
				System.out.println((tgtIndex + 1)+" "+distances[tgt]);
				return;
			}
			visited[tgt] = true;
			
			
			LinkedList<Integer> tgtList = adjList.get(tgt);
			for (int i = 0; i < tgtList.size(); i++) {
				int newitm = tgtList.get(i);
				
				if (visited[newitm] == false) {
					if (distances[newitm] > 0) {
						distances[newitm] = Integer.min(distances[newitm], distances[tgt] + 1);
					}else {

						distances[newitm] = distances[tgt] + 1;
					}
					q.add(newitm);
				}
				
				if (newitm == tgtIndex) {
					//we have the target and are done
					System.out.println((tgtIndex + 1)+" "+distances[newitm]);
					return;
				}
				
			}
			
		}
		System.out.println((tgtIndex + 1)+" "+-1);
		
	}
}




Measured memory_bytes: 29796
import qualified Data.ByteString.Char8 as BS

add :: Int -> Int -> Int
add i1 i2 = mod (i1 + i2) 1000000007

add3 :: Int -> Int -> Int -> Int
add3 i1 i2 i3 = add i1 $ add i2 i3 

mul3 :: Int -> Int
mul3 i = add3 i i i 

mul2 :: Int -> Int
mul2 i = add i i 

foldfunc :: Char -> (Int,Int) -> (Int,Int)
foldfunc c (tn,r)
  | c == '0' = (tn3,r)
  | c == '1' = (tn3, add3 1 tn (mul2 r) )
  | otherwise = (tn,r)
  where
    tn3 = mul3 tn

solve :: BS.ByteString -> Int
solve s = 1 + (snd $ BS.foldr' foldfunc (1,0) s)

main = do
    bs <- BS.getLine
    print $ solve bs


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

int main(){
    int n; cin >>n;
    int m1 = 0;
    int m2 = 0;
    int m1_ind = 0;
    for(int i=0; i<n; ++i){
        int a; cin >> a;
        if(a>m1){
            m2 = m1;
            m1 = a;
            m1_ind = i;
        }
        else if(a>m2) m2=a;
    }
    for(int i=0; i<n; ++i){
        if(i==m1_ind) cout << m2 << endl;
        else cout << m1 << endl;
    }
}

Measured memory_bytes: 1664
from functools import reduce
N = int(input())
A = list(map(int, input().split()))
A.sort()
if A[0] == 0:
    print(0)
else:
    p = 1;
    for i in range(N):
        p *= A[i];
        if p > 10**18:
            p = -1;
            break;
    print(p)


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

long long m, n, p[31], ans=1;

int main() {
    cin >> m >> n;
    p[0] = m;
    for (int i=1; i<31; i++) {
        p[i] = (p[i-1]*p[i-1])%1000000007;
    }
    for (int i=0; i<31; i++) {
        if (n%2==1) ans=ans*p[i];
        n/=2;
        ans = ans%1000000007;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime MOD
    mint inv() const { return pow(MOD-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination MOD prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
    mint p(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[n-k];
    }
} comb(10000007);
// comb(5, 2) → 10, comb.p(5, 2) → 20
// comb.fact[4] → 24, 2のN乗 → mint(2).pow(N)

mint dp[13];

int main() {
    string S;
    cin >> S;
    dp[0] = 1;
    vector<int> ten(10);
    rep(i, 10) ten[i] = i;
    for (char s : S) {
        vector<int> A;
        if (s == '?') A = ten;
        else {
            int cur = s - '0';
            A = {cur};
        }
        mint prev[13];
        memset(prev, 0, sizeof(prev));
        swap(dp, prev);
        for (int a : A) {
            for (int i = 0; i < 13; i++) {
                int next = (i * 10 + a) % 13;
                dp[next] += prev[i];
            }
        }
    }
    cout << dp[5] << '\n';
    return 0;
}

Measured memory_bytes: 159812
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int sum = min(a, k);
  k -= min(a, k);
  k -= min(b, k);
  sum -= min(c, k);
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;

class Problem {
    private int A;
    private int B;

    Problem() {
        Scanner sc = new Scanner(System.in);

        A = sc.nextInt();
        B = sc.nextInt();
    }

    int solve() {
        if (B % A == 0) {
            return A + B;
        } else {
            return B - A;
        }
    }
}

public class Main {
    public static void main(String[] args) {
        System.out.println(new Problem().solve());
    }
}


Measured memory_bytes: 21844
n=int(input())
s=[]
for i in range(n):
  tmp_input = input()
  tmp_input = ''.join(sorted(tmp_input))
  s.append(tmp_input)

results = {}
for i in range(n):
  if s[i] in results:
    results[s[i]] += 1
  else:
    results[s[i]] = 1

def choose2(n):
  return n*(n-1)//2

count = 0
for value in results.values():
  count += choose2(value)
print(count)

Measured memory_bytes: 23676
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cmath>
//#include<>
using namespace std;

typedef long long ll;
#define rep(i,j) for(i=0;i<j;i++)
#define rev_rep(i,j) for(i=j;i>=0;i--)

int not_[3]={2,1,0};
int and_[3][3]={{0,0,0},{0,1,1},{0,1,2}};
int or_[3][3]={{0,1,2},{1,1,2},{2,2,2}};

int i,p,q,r;
int rec(string s)
{
  stack<char>key;
  int ans=0,v;
  key.push('+');
  while(i<s.size())
    {
      if(s[i]==')')
	{return ans;}
      else if(s[i]=='+'||s[i]=='-'||s[i]=='*')
	  key.push(s[i++]);
      else
	{
	  if(s[i]=='(')
	    {i++;v=rec(s);}
	  else if(s[i]=='P')v=p;
	  else if(s[i]=='Q')v=q;
	  else if(s[i]=='R')v=r;
	  else
	      v=s[i]-'0';
	  while(!key.empty())
	    {
	      if(key.top()=='+')
		ans=or_[ans][v];
	      else if(key.top()=='-')
		{
		  v=not_[v];
		  if(key.size()==1)ans=v;
		}
	      else if(key.top()=='*')
		ans=and_[ans][v];
	      key.pop();
	    }
	  i++;
	}
    }
  return ans;
}

int main()
{
  string s;
  while(cin>>s)
    {
      if(s[0]=='.')return 0;
      int a,b,c;
      int cnt=0;
      rep(a,3)rep(b,3)rep(c,3)
	{
	  p=a;q=b;r=c;
	  i=0;
	  if(rec(s)==2)cnt++;
	}
      cout<<cnt<<endl;
    }
  return 0;
}

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

typedef long long LL;
typedef pair<int, int> II;

const int MAXN = (int)1e5 + 10;
int n, s, t;
vector<int> adj[MAXN];
int ds[MAXN], dt[MAXN];

void dfs(int u, int *d, int p = -1) {
    for (int i = 0; i < (int)adj[u].size(); ++i) {
        int v = adj[u][i];
        if (v != p) {
            d[v] = d[u] + 1;
            dfs(v, d, u);
        }
    }
}

int main() {
    scanf("%d%d%d", &n, &s, &t);
    for (int i = 1; i <= n - 1; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    dt[t] = 0;
    dfs(t, dt);

    ds[s] = 0;
    dfs(s, ds);

    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (ds[i] >= dt[i]) {
            continue;
        }
        ans = max(ans, dt[i] - 1);
    }
    for (int i = 1; i <= n; ++i) {
        if (ds[i] == dt[i] && ds[i] + dt[i] == ds[t]) {
            ans = max(ans, dt[i]);
        }
    }

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

Measured memory_bytes: 12928
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define vi vector<int>
#define vl vector<long long>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define INF 1e18
#define MOD 1e9+7

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

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

const int MAX_N = 1010;
int dp[MAX_N][MAX_N];
string X, Y;
//dp[i+1][j+1]:Xのi文字目とYのj文字目までのLCS
void LCS(int n, int m) {
    dp[0][0] = 0;
    REP(i, n) {
        REP(j, m) {
            if (X[i] == Y[j]) {
                dp[i+1][j+1] = dp[i][j]+1;
            } else {
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
    }
}

int main() {
    int q;
    cin >> q;
    REP(j, q) {
        cin >> X >> Y;
        int n = X.length();
        int m = Y.length();
        LCS(n, m);
        cout << dp[n][m] << endl;
    }
    return 0;
}


Measured memory_bytes: 7048
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include<fstream>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define f(n) for(int i=0;i<n;++i)
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	long long n;
	cin >> n;
	vector<long long> a;
	REP(i, n) {
		long long hoge;
		cin >> hoge;
		a.push_back(hoge);
	}
	long long ans = 0;
	while (true) {
		int failed = 0;
		for (int i = 0;i < n;++i) {
			if (a[i] >= n) {
				failed = 1;
				for (int q = 0;q < n;++q) {
					if (i != q) {
						a[q] += a[i] / n;
					}
				}
				ans += a[i] / n;
				a[i] = a[i] % n;
			}
		}
		if (failed == 0) break;
		failed = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x) cout<<#x<<" = "<<(x)<<endl;
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  string t; cin >> t;
  int n = t.size();
  REP(i,n) {
    if (t[i] == '?') cout << 'D';
    else cout << t[i];
  }
  cout << endl;
  return 0;
}


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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int height = sc.nextInt();
		int width = sc.nextInt();		
		List<List<Integer>> listHeight = new ArrayList<>();

		for(int cntHeight = 0 ; cntHeight < height ; cntHeight++){
			String str = sc.next();
			List<Integer> listWidth = new ArrayList<>();
			for(int cntWidth = 0 ; cntWidth < width ; cntWidth++){				
				char chr = str.charAt(cntWidth);
				int input = (chr == '#') ? 1 : 0;
				listWidth.add(input);
			}
			listHeight.add(listWidth);
		}
		sc.close();

		for(int cntHeight = height-1 ; cntHeight > -1 ; cntHeight--){
			int sum = 0;
			for(int cntWidth = 0 ; cntWidth < width ; cntWidth++){				
				sum = sum + listHeight.get(cntHeight).get(cntWidth);			
			}
			if(sum == 0){
				listHeight.remove(cntHeight);
				height--;
			}
		}

		for(int cntWidth = width-1 ; cntWidth > -1 ; cntWidth--){
			int sum = 0;
			for(List<Integer> list :listHeight){
				sum = sum + list.get(cntWidth);
			}			
			if(sum == 0){
				for(List<Integer> list :listHeight){
					list.remove(cntWidth);					
				}
				width--;
			}
		}
		
		for(List<Integer> list : listHeight){
			for(int cntWidth = 0 ; cntWidth < width ; cntWidth++){	
				System.out.print(list.get(cntWidth)==1 ? "#" : ".");
			}
			System.out.println("\n");
		}
	}
}

Measured memory_bytes: 25936
# by the authority of GOD     author: manhar singh sachdev #

import os,sys
from io import BytesIO, IOBase

def main():
    n = int(input())
    mod = 10**9+7
    print((pow(10,n,mod)-2*pow(9,n,mod)+pow(8,n,mod))%mod)

#Fast IO Region
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == '__main__':
    main()

Measured memory_bytes: 62624
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)

using namespace std;
const int IINF = INT_MAX;
using ll = long long;
using P = pair<int,int>;
#define INF 100000000

int main(){
    int k;
    string s;
    cin >> k >> s;
    
    
    if(s.size() <= k)  cout << s << endl;
    else {
     rep(i,k)cout << s[i];
     cout << "..." << endl;
    }
    return 0;	
}

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


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

  rep(i,3) {
    if(a[i] % 2 == 0){
      cout << 0 << endl;
      return 0;
    }
  }

  sort(a,a+3,greater<int>());

  cout << ((a[0]+1)/2 - a[0]/2) *a[1]*a[2] << endl;

  return 0;
}


Measured memory_bytes: 256
// Written By Mahtab Tanim
#include<bits/stdc++.h>
using namespace std;
#define MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define nl "\n"
#define End return 0
#define ll long long int
#define mp make_pair
#define pb push_back
#define ull unsigned long long int
#define pi acos(-1)
#define forn(i,a,b) for (int i=a;i<=b;i++)
#define PI acos(-1)
int main()
{
int n,m;
cin>>n>>m;
int j,sum=0;
for(int i=0;i<m;i++)
{
	cin>>j;
	sum+=j;
}
if(sum<=n) cout<<n-sum;
else cout<<-1<<endl;
End;
}


Measured memory_bytes: 3624
N, T = map(int, input().split())
c, t = [0] * N, [0] * N
for i in range(N):
    c[i], t[i] = map(int, input().split())

smallest_cost = 2000
for i in range(N):
    if t[i] > T:
        continue
    if c[i] > smallest_cost:
        continue
    smallest_cost = c[i]

if smallest_cost == 2000:
    smallest_cost = 'TLE'

print(smallest_cost)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  vector<ll> s, l;
  for(int i = 0; i < n / 2; i++) {
    s.push_back(a[i]);
  }
  for(int i = n - 1; i >= n / 2; i--) {
    l.push_back(a[i]);
  }
  ll ans = 0;
  ll c = s[0], d = l[0];
  ans += abs(c - d);
  for(int i = 1; i < n / 2; i++) {
    if(i % 2 == 0) {
      ans += abs(c - s[i]);
      c = s[i];
      ans += abs(d - l[i]);
      d = l[i];
    } else {
      ans += abs(c - l[i]);
      c = l[i];
      ans += abs(d - s[i]);
      d = s[i];
    }
  }
  if(n % 2 != 0) {
    ans += max(abs(c - *(l.end() - 1)), abs(d - *(l.end() - 1)));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5056
#include <bits/stdc++.h>
 #define fastcode  ios_base::sync_with_stdio(false);    cin.tie(NULL);
  using namespace std;
  /*  
  - Our collaboration is a thing of beauty.
  - And for those who fear Allah , He will make their path easy. 
  */


  int main()
  {
    fastcode
    int n;
    cin>>n;
    int a[n+2];
    int sum=0;
    for(int i =1 ; i<=n ; i++ )
    {
      cin>>a[i];
      sum+=a[i];
    }
    int t;
    cin>>t;
    int idx,neww;
    while (t--)
    {
      cin>>idx>>neww;
      cout<<sum+(neww-a[idx])<<endl;
    }
    
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,m;
  cin >> n >> m;
  vector<int>ans(n);
  for(int i=0;i<n;i++){
    ans.at(i)=0;
  }
  bool judge=false;
  for(int i=0;i<m;i++){
    int s,c;
    cin >> s >> c;
    if(ans.at(s-1)!=0&&ans.at(s-1)!=c){
      judge=true;
      break;
    }
    if(n>1&&s-1==0&&c==0){
      judge=true;
    }
    ans.at(s-1)=c;
  }
  if(judge){
    cout << "-1" << endl;
    return 0;
  }
  if(n>1&&ans.at(0)==0){
    ans.at(0)=1;
  }
  for(int i=0;i<n;i++){
    cout << ans.at(i);
  }
  cout << endl;
}
  


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b;

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

Measured memory_bytes: 580
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	cin>>n;
	vint v(n);
	rep(i,n) cin>>v[i];
	sort(ALL(v));
	reverse(ALL(v));
	map<int,int> ma;
	rep(i,n) ma[v[i]]++;
	vint w;
	for(auto &x: ma){
		while(x.se>=2){
			w.PB(x.fi);
			x.se-=2;
		}
	}
	if(w.size()>=2){
		cout<<1LL*w[w.size()-1]*w[w.size()-2]<<endl;
	}
	else{
		cout<<0<<endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 5376
#include<stdio.h>
#define N 501

static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,t,data[N][N],C[N],d[N],f[N];

void dfs_1(int u)
{
  int a;

  C[u] = GRAY;
  t++;
  d[u] = t;

  for(a=0; a<n; a++){
    if(data[u][a] == 0){
      continue;
    }
    if(C[a] == WHITE){
      dfs_1(a);
    }
  }

  C[u] = BLACK;
  f[u] = ++t;
}

void dfs_2()
{
  int i,b;

  for(i=0; i<n; i++){
    C[i] = WHITE;
  }

  t = 0;

  for(b=0; b<n; b++){
    if(C[b] == WHITE){
      dfs_1(b);
    }
  }

  for(i=0; i<n; i++){
    printf("%d %d %d",i+1,d[i],f[i]);
    printf("\n");
  }
}

int main()
{
  int i,j,u,k,v;

  scanf("%d",&n);

  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      data[i][j] = 0;
    }
  }

  for(i=0; i<n; i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0; j<k; j++){
      scanf("%d",&v);
      v--;
      data[u][v] = 1;
    }
  }

  dfs_2();

  return 0;
}


Measured memory_bytes: 2064
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;

int main() {
	int n;

	while(cin >> n, n) {
		vector<vector<char> > table(n, vector<char>(2));

		REP(i, n) {
			char before, after;
			cin >> before >> after;
			
			table[i][0] = before;
			table[i][1] = after;
		}

		int m;
		cin >> m;
		string str;

		REP(i, m) {
			char c;
			cin >> c;

			REP(j, n) {
				if(c == table[j][0]) {
					c = table[j][1];
					break;
				}
			}

			str.push_back(c);
		}

		cout << str << endl; 
	}
}

Measured memory_bytes: 1116
import java.io.InputStream;
import java.io.PrintStream;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {
	public Pair(K key, V value) {
		super(key, value);
	}
}

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	List<List<Pair<Integer, Integer>>> g;
	int[] c;

	private void rec(int n, int z) {
		if (c[n] != -1)
			return;
		c[n] = z;
		for (Pair<Integer, Integer> p : g.get(n)) {
			if (p.getValue() % 2 == 0) {
				rec(p.getKey(), z);
			} else {
				rec(p.getKey(), z ^ 1);
			}
		}
	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		g = new ArrayList<>(N + 1);

		for (int i = 0; i <= N; i++) {
			g.add(new ArrayList<>());
		}

		for (int i = 1; i < N; i++) {
			int u = sc.nextInt();
			int v = sc.nextInt();
			int w = sc.nextInt();

			g.get(u).add(new Pair<>(v, w));
			g.get(v).add(new Pair<>(u, w));
		}

		c = new int[N + 1];
		Arrays.fill(c, -1);

		rec(1, 0);

		for (int i = 1; i <= N; i++) {
			out.println(c[i]);
		}

		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 117028
#include <stdio.h>

void swap(float*a, float*b);
int max(float n, float m);

int main(void)
{
	int n;
	float pp, tp;
	float piza;
	float top[100];
	int i, j;
	float ans;

	scanf("%d", &n);
	
	scanf("%f %f", &pp, &tp);
	
	scanf("%f", &piza);

	for (i = 0; i < n; i++){
		scanf("%f", &top[i]);
	}

	for (i = 0; i < n - 1; i++){
		for (j = i; j < n; j++){
			if (top[i] < top[j]){
				swap(&top[i], &top[j]);
			}
		}
	}

	ans = piza / pp;

	for (i = 0; i < n; i++){
		piza += top[i];
		pp += tp;
		ans = max(ans, piza/pp);
	}

	printf("%d\n", (int)ans);

	return (0);
}

void swap(float* a, float* b)
{
	*a += *b;
	*b = *a - *b;
	*a -= *b;
}

int max(float n, float m)
{
	if (n > m){
		return (n);
	}
	else {
		return (m);
	}
}

Measured memory_bytes: 628
#include <stdio.h>

int n;
int A[1000];
void print(){
  int i;
  for(i=0;i<n;i++){
    if(i!=n-1)printf("%d ",A[i]);
    else printf("%d",A[i]);
  }
  printf("\n");
}

void insertion(){
  int i;
  int v,j;
  for(i=1;i<n;i++){
    v = A[i];
    j = i-1;
    while(j>=0 && A[j]>v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    print();
  }
}

int main(){
  scanf("%d",&n);
  int i;
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  print();
  insertion();
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int main() {
    ll n, d;
    cin >> n >> d;

    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= d * d) {
            ans++;
        }
    }
 
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int gcd(int A, int B) {
	if (B == 0) return A;
	return gcd(B, A % B);
}


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


	int N;
	cin >> N;
	int A[200000];
	rep(i, N) cin >> A[i];

	int kotae = A[0];
	rep1(i, N - 1) {
		kotae = gcd(kotae, A[i]);
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 640
h,w,k=map(int,input().split())
c=[input() for i in range(h)]
ans=0
for i in range(2**h):
  for j in range(2**w):
    cnt=0
    for p in range(h):
      for q in range(w):
        if i&(1<<p) and j&(1<<q):
          if c[p][q]=='#':
            cnt+=1
    if cnt==k:
      ans+=1
print(ans)

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

int main(){
  int a,b,c,d,e;
  cin >> a >>  b >>  c >>  d  >> e;
  if (a==0){
    cout << "1";
  }
  else if (b==0){
    cout << "2";
  }
  else if (c==0){
    cout << "3";
  }
  else if (d==0){
    cout << "4";
  }
  else{
    cout << "5";
  }
}

Measured memory_bytes: 3104
import math
a,b=map(int,input().split())
x=math.gcd(a,b)
bun=[0]*(int(math.sqrt(x)+1))
bun[1]=1
for i in range(2,len(bun)):
  while x%i==0:
    if bun[i]==0:
      bun[i]+=1
    x=x//i
ans=sum(bun)
if x>1:
  ans+=1
print(ans)  

Measured memory_bytes: 16336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    int N, K;
    cin >> N >> K;
    int score;
    int count = 0;
    double ans = 0;
    rep(i, 1, N + 1)
    {
        score = i;
        count = 0;
        while (score < K)
        {
            count++;
            score *= 2;
        }
        ans += 1. / (N * (1 << count));
    }
    cout << fixed << setprecision(15) << ans << endl;
}

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

int main() {
	int n, a;
	cin >> n >> a;
	
	for (;;) {
		if (n < 500) {
			break;
		}
		n -= 500;
	}

	if (n <= a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <assert.h>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <random>
#include <cmath>
#include <chrono>
#include <bitset>

#define ld long double
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;

const int INF = 2e18;
const int MOD = 1e9 + 7;
const int MB = 20;

vector<int> getZ(string& s) {
	vector<int> z(s.size());
	int l = 0, r = 0;
	for (int i = 1; i < s.size(); i++) {
		if (r >= i) z[i] = min(r - i + 1, z[i - l]);
		while (z[i] + i < s.size() && s[z[i] + i] == s[z[i]]) z[i]++;
		if (z[i] + i - 1 > r) {
			l = i;
			r = z[i] + i - 1;
		}
	}
	return z;
}

void solve() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	
	int ans = 0;
	for (int i = 0; i < n - 1; i++) {
		vector<int> z = getZ(s);
		for (int j = 1; j < s.size(); j++) {
			ans = max(ans, min(z[j], j));
		}
		s.erase(s.begin(), s.begin() + 1);
	}
	cout << ans;
}
signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(12);
	solve();
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def main():

    X, N = map(int, input().split())
    p = list(map(int, input().split()))

    for i in range(101):
        if (X - i) not in p:
            ans = X - i
            break

        elif (X + i) not in p:
            ans = X + i
            break

    print(ans)


if __name__ == "__main__":
    main()

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

char a[4];

int ans = 0;

int main() {
    for (int i = 0; i <= 3; ++i) a[i] = getchar();
    for (int i = 0; i <= 2; ++i) if (a[i] == a[i + 1]) ans = 1;
    puts(ans == 1 ? "Bad" : "Good");
}


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

int main() {
    int n;
    cin>>n;
    int a[n+1],b[n];
    long long ans=0;
    for(int i=0;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {
        cin>>b[i];
    }
    for(int i=0;i<n;i++)
    {
        long long tmp=min(a[i],b[i]);
        a[i] -= tmp;
        b[i] -= tmp;
        ans += tmp;
        tmp=min(a[i+1],b[i]);
        a[i+1] -= tmp;
        b[i] -= tmp;
        ans += tmp;
    }
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n;cin>>n;
    set<string> s;
    for(int i=0;i<n;i++){
        string ss;cin>>ss;
        s.insert(ss);
    
        
    }
    cout<<s.size();
    
}

Measured memory_bytes: 19200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)

ll b0(ll p){
  return 1-(p%2);
}

ll b1(ll p){
  if(p==0) return 2;
  return p%2;
}

ll dat[1000020],n,a[500010]={};
const ll INF=1e17;

void init(ll n_){
  n=1;
  while(n<n_) n*=2;
  fr(i,2*n-1) dat[i]=INF;
}

void ud(ll k,ll c){
  k+=n-1;
  dat[k]=c;
  while(k>0){
    k=(k-1)/2;
    dat[k]=min(dat[2*k+1],dat[2*k+2]);
  }
}

ll mn(ll be,ll en,ll k=0,ll l=0,ll r=n){
  if(r<=be||en<=l) return INF;
  if(be<=l&&r<=en) return dat[k];
  return min(mn(be,en,k*2+1,l,(l+r)/2),mn(be,en,k*2+2,(l+r)/2,r));
}




int main(){
  ll l,a[200010],b[200010],s[2][3][200010]={},gh[200010]={};
  cin>>l;
  fr(i,l) cin>>a[i];
  fr(i,l){
    s[0][0][i+1]=s[0][0][i]+b0(a[i]);
    s[0][1][i+1]=s[0][1][i]+a[i];
    s[0][2][i+1]=min(s[0][2][i]+b1(a[i]),s[0][1][i+1]);
  }
  ifr(i,l){
    s[1][0][i]=s[1][0][i+1]+b0(a[i]);
    s[1][1][i]=s[1][1][i+1]+a[i];
    s[1][2][i]=min(s[1][2][i+1]+b1(a[i]),s[1][1][i]);
  }
  init(l+1);
  fr(G,l+1) ud(G,s[0][0][G]+s[1][2][G]);
  ll ans=INF;
  fr(S,l+1) ans=min(ans,s[0][2][S]-s[0][0][S]+mn(S,l+1));
  cout<<ans<<endl;
}

Measured memory_bytes: 17280
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int dp[100007];
ll arr[100007];
int recur(ll i,ll n){
 if(dp[i]!=-1){
   return dp[i]; }
 else if(i>=n)
    dp[i]=INT_MAX;
 else if(i==n-1)
    dp[i]=0;
 else{
    dp[i]= min(recur(i+1,n)+abs(arr[i+1]-arr[i]),recur(i+2,n)+abs(arr[i+2]-arr[i]));
 }
 return dp[i];
}
int main(){
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++)
        cin>>arr[i];
    memset(dp,-1,sizeof(dp));
    cout<<recur(0,n)<<endl;
    return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>

int main(void)
{
	int D1,D2,D3;
	scanf("%d %d %d",&D1,&D2,&D3);
	/*1回目*/
	int tmp_a;
	if(D1>D2) {tmp_a = D2, D2 = D1, D1 = tmp_a;};
	int tmp_b;
	if(D2>D3) {tmp_b = D3, D3 = D2, D2 = tmp_b;};
	/*2回目*/
	int tmp_c;
	if(D1>D2) {tmp_c = D2, D2 = D1, D1 = tmp_c;};
	printf("%d %d %d\n",D1,D2,D3);
return 0;
}

Measured memory_bytes: 596
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a[] = new int[N];
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}
		int cnt = 0;
		for(int i = 0; i < N; i++) {
			while(a[i] % 2 == 0) {
				a[i] = a[i] / 2;
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 36164
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        // 主処理
        boolean judge = 8 <= 15 - s.replaceAll("[^x]", "").length();
        String result = judge ? "YES" : "NO";

        // 出力
        System.out.println(result);
    }
}


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

typedef long long int ll;
ll MOD = 1000000007;

// ====================================================================

int main() {
  string s;
  cin >> s;
  vector<vector<ll>> dp(s.size(), vector<ll>(13, 0));

  if (s[0] == '?')
    for (int i = 0; i < 10; i++) dp[0][i] = 1;
  else
    dp[0][s[0] - '0'] = 1;

  // DPをしていく
  for (int k = 0; k < s.size() - 1; k++) {
    if (s[k + 1] == '?') {  // 自由に決めれる
      for (int i = 0; i < 13; i++) {
        for (int j = 0; j < 10; j++) {
          dp[k + 1][(i * 10 % 13 + j) % 13] += dp[k][i];
          dp[k + 1][(i * 10 % 13 + j) % 13] %= MOD;
        }
      }
    } else {  // 桁指定
      for (int i = 0; i < 13; i++) {
        dp[k + 1][(i * 10 % 13 + (s[k + 1] - '0')) % 13] += dp[k][i];
        dp[k + 1][(i * 10 % 13 + (s[k + 1] - '0')) % 13] %= MOD;
      }
    }
  }

  cout << dp[s.size() - 1][5] << endl;
}


Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,ans=0;
    cin >> n;
    int a[n];
    ans =0;
    for(int i =0;i<n;i++){
        cin >> a[i];
        ans += a[i];
    }
    ans -= n;
    // cerr<<GCD(6,12)<<endl;
    cout << ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <string.h>
#include <stdlib.h>

using namespace std;
// vector push_back push front top empty pop make_pair long long insert begin end  
typedef long long ll;
typedef vector<int> vi;
typedef vector<pair <int,int> > vpi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define B begin()
#define RB rbegin()
#define E end()
#define RE rend()
#define Z size()
#define REP(i,a,b) for (int i = a; i < b; i++)
#define L length()
#define show(a) cerr << " *** " << a << endl;
#define show1(a) cerr << " /// " << a << endl;
#define valid(a,b,c) (a >= b && a < c ? 1 : 0)
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int mod = (int)1e9 + 7;
ll gcd(ll a, ll b) {return (b==0? a:gcd(b,a%b));}
ll egcd(ll a, ll b, ll & x, ll & y) {if (a == 0){x = 0;y = 1;return b;}ll x1, y1;ll d = egcd(b % a, a, x1, y1);x = y1 - (b / a) * x1;y = x1;return d;}
ll mbinp(ll a, ll b){a %= mod;if (b == 0)return 1;ll ans = mbinp(a, b/2);ll tmp = (ans * ans) % mod;if (b % 2)return ((tmp * a) % mod);return ((tmp) % mod);}
ll binp(ll a, ll b){if (b == 0)return 1;ll ans = binp(a, b/2);ll tmp = (ans * ans);if (b % 2)return ((tmp * a));return ((tmp));}
const int maax = 3050;

double dp[maax][maax];
int n;
double tab[maax];

double solve(int pos, int has)
{
	if (has < 0)
		return (dp[pos][has] = 0);
	if (pos == n)
		return (dp[pos][has] = 1);
	if ((ll)dp[pos][has] != -1)
		return dp[pos][has]; 
	double res = 0;
	res += solve(pos+1, has) * tab[pos];
	res += solve(pos+1, has-1) * (1 - tab[pos]);
	return (dp[pos][has] = res);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin >> n;
	REP(i,0,n)
		cin >> tab[i];
	//memset(dp,-1,sizeof(dp));
	REP(i,0,maax)
		REP(j,0,maax)
			dp[i][j] = -1;
	double ans = solve(0,n/2-(n%2== 0));
	cout << fixed << setprecision(10) << ans;
}


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

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

    n %= 10;
    if(n == 3){
        put("bon");
    }else if(n == 0 || n == 1 || n == 6 || n == 8){
        put("pon");
    }else{
        put("hon");
    }
}

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

using namespace std;

#define endl '\n'
#define ll long long
#define int long long
const int32_t INFint = 1e9;
const ll INFll = 1e18;
const ll INF = 1LL << 60;
#define MOD 1000000007ll
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

#define vi vector<int>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define foreach(it, v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)

#define deb1(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << " | " << #y << ": " << y << endl
#define deb3(x, y, z) cout << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl
#define deb4(a, b, c, d) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl
#define deb5(a, b, c, d, e) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define deb6(a, b, c, d, e, f) cout << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl
#define nl cout << endl
// void bfs(vector<int> &dist, vector<vector<int>> &edges, int index)
// {
//     queue<pair<int, int>> q;
//     dist[index] = -1;
//     q.push(mp(index, 0));
//     while (!q.empty())
//     {
//         pair<int, int> top = q.front();
//         // deb2(top.ff,top.ss);
//         q.pop();
//         if (dist[top.ff] != -1)
//             continue;
//         // deb3(top.ff,top.ss,dist[top.ff]) ;
//         dist[top.ff] = top.ss;
//         for (int i = 0; i < edges[top.ff].size(); i++)
//         {
//             if (dist[edges[top.ff][i]] == -1)
//             {
//                 q.push(mp(edges[top.ff][i], dist[top.ff] + 1));
//             }
//         }
//     }
// }
int32_t main()
{
    fast;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    double long t;
    cin >> t;
    // cout<<t<<endl;
    double long a = 100.0 ; 
    int c = 0 ; 
    while(a<t)
    {
        c++ ;
        int j = a/100 ; 
        a = a + j ;
    }
    cout<<c<<endl;
}

Measured memory_bytes: 3776
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
  while(!feof(stdin)) {
    int n;
    double sum=1;
    scanf("%d", &n);
    if (feof(stdin)) break;
    for(int i=1;i<=n;i++)
      sum*=i;
    printf("%.0f\n", sum);
  }
}

Measured memory_bytes: 1220