akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
#define pint pair<int, int>
#define vint vector<int>
using namespace std;

const int INF=1e9+7;
const ll LINF=1e18;
const int MOD=1e9+7;
//const int MOD=998244353;

int main(){
	int n;
	string a,b,c;
	cin>>n>>a>>b>>c;
	int ans=0;
	FOR(i,0,n){
		if(a[i]==b[i]&&c[i]==b[i]&&a[i]==c[i]){

		}else if(a[i]!=b[i]&&c[i]!=b[i]&&a[i]!=c[i]){
			ans+=2;
		}else{
			ans++;
		}
	}
	co(ans);
}


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

namespace abacus {
  class Program {
    static void Main(string[] args) {
      string[] num = {
        "*****     ",
        "     *****",
        "==========",
        " **** ****",
        "* **** ***",
        "** **** **",
        "*** **** *",
        "**** **** "
      };

      bool flg = false;
      for (string s; (s = Console.ReadLine()) != null; ) {
        if (flg) Console.WriteLine();

        for (int i = 0, len = s.Length; i < 5 - len; i++) {
          s = s.Insert(0, "0");
        }
        for (int i = 0; i < 8; i++) {
          for (int j = 0; j < 5; j++) {
            Console.Write(num[i][s[j] - '0']);
          }
          Console.WriteLine();
        }
        flg = true;
      }
    }
  }
}

Measured memory_bytes: 8852
#include <bits/stdc++.h>
  
using namespace std;
  
int main()
{
    int N, M, T, a;
    cin >> N >> M >> T;
    vector<bool> used(T+1, 0);
    for (int i = 0; i < N; i++) {
        cin >> a; 
        for (int j = a; j >= max(a-M, 0); j--) {
            used[j] = 1;
        }
        for (int j = a; j < min(a+M, T); j++) {
            used[j] = 1;
        }
    }
    cout << count(used.begin(), used.end()-1, 0) << endl;
    return 0;
}

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

int main() {
  ll n,k; cin>>n>>k;
  ll res=1e18;
  ll t=n/k;
  res=n-t*k;
  res=min(res, k-res);
  cout<<res<<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] array = br.readLine().split(" ");
        int count = 0;

        for (int i = 0; i < n - 1; i++) {
            int min0 = Integer.parseInt(array[i]);
            int min1 = Integer.MAX_VALUE;
            int indexOfMin1 = 0;
            for (int j = i + 1; j < n; j++) {
                int aj = Integer.parseInt(array[j]);
                if (aj < min1) {
                    min1 = aj;
                    indexOfMin1 = j;
                }
            }
            if (min1 < min0) {
                String tmp = array[i];
                array[i] = array[indexOfMin1];
                array[indexOfMin1] = tmp;
                count++;
            }
        }

        System.out.println(String.join(" ", array));
        System.out.println(count);
    }
}

Measured memory_bytes: 24888
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int id = -1;
			int max = 0;
			for (int i = 0; i < n; i++) {
				int a = scanner.nextInt();
				int b = scanner.nextInt();
				int c = scanner.nextInt();
				int total = b + c;
				if (max < total) {
					id = a;
					max = total;
				}
			}
			System.out.println(id + " " + max);
		}
	}
}

Measured memory_bytes: 157956
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main()
{
    
    int k, n;
    cin >> k >> n;
    vector<int>a(n);
    long long int x = 0, y = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n - 1; i++) {
        x += a[i + 1] - a[i];
        y = max((int)y, a[i + 1]- a[i]);
    }
    x += k + a[0] - a[n - 1];
    y = max((int)y, k + a[0] - a[n - 1]);
    cout << x - y << endl;
    
    return 0;

}

Measured memory_bytes: 1024
using System;


namespace ConsoleApplication9
{
    class Program
    {
        static void Main(string[] args)
        {
            String input = Console.ReadLine();
            char[] m = input.ToCharArray();
            int iLength = m.Length;
            for (int x = 0; x < iLength; x++)
            {
                if (char.IsUpper(m[x]))
                {
                    char a = char.ToLower(m[x]);
                    Console.Write(a);
                }
                else if (char.IsLower(m[x]))
                {
                    char b = char.ToUpper(m[x]);
                    Console.Write(b);
                }
                else
                {
                    Console.Write(m[x]);
                }
                if(x == iLength - 1)
                {
                    Console.WriteLine();
                }
            }
        }
    }
}

Measured memory_bytes: 9028
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
T = list("AKIHABARA")

idx = [0, 4, 6, 8]

for x in product([0, 1], repeat=len(idx)):
	TC = T.copy()
	tmp = ""
	for i in range(len(idx)):
		if x[i]:
			TC[idx[i]] = ""
	if "".join(TC) == S:
		print("YES")
		break
else:
	print("NO")


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


int N;
int F[100][10];
int P[100][11];

int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 10; j++){
            cin >> F[i][j];
        }
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= 10; j++){
            cin >> P[i][j];
        }
    }
    long long ans = -1000000000;
    for(int i = 1; i < (1 << 10); i++){
        long long profit = 0;
        for(int j = 0; j < N; j++){
            int c = 0;
            for(int k = 0; k < 10; k++){
                if(((i >> k) & 1 == 1) && (F[j][k] == 1)){
                    c++;
                }
            }
            profit += P[j][c];
        }
        ans = max(ans, profit);
    }
    cout << ans << endl;
            
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int f(int a, int k){
	if(a < k) return 0;
	if(a % k == 0) return a/k;
	int haba = a/k + 1;
	int df = a - (a/k*k);
	return f(a - (df+haba-1)/haba * haba, k);
}

int main()
{
	int n; read(n);
	int nim = 0;
	for(;n--;){
		int a, k; read(a, k); nim ^= f(a, k);
	}
	puts(nim ? "Takahashi" : "Aoki");
	return 0;
}


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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  ll n, l, r, ans = 0;
  cin >> n;
  rep(i, n) {
    cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int main(){
	int a, b, m; cin >> a >> b >> m;
	vector<int> ap;
	vector<int> bp;
	int ans = inf;
	while( a-- ){
		int t; cin >> t;
		ap.push_back(t);
	}
	while( b-- ){
		int t; cin >> t;
		bp.push_back(t);
	}
	while( m-- ){
		int x, y, c; cin >> x >> y >> c;
		ans = min(ans, ap[x-1]+bp[y-1]-c);
	}
	cout << min(ans, *min_element( ap.begin(), ap.end() )+*min_element( bp.begin(), bp.end() ) ) << endl;
	
}

Measured memory_bytes: 1400
#include<iostream>
#include<vector>
#include<queue>
#include<string.h>
#include<algorithm>
#include<stack>
#include<set>

using namespace std;
typedef pair<int, int> P;

int main(){
  int N;cin>>N;
  int X[N],L[N];
  P p_l[N];
  for (int i = 0; i < N; i++) {
    cin>>X[i]>>L[i];
    p_l[i].second=X[i]-L[i];
    p_l[i].first=X[i]+L[i];
  }
  sort(p_l,p_l+N);
  int ans=0;
  int now=-1000000000;
  for(int i=0;i<N;i++){
    if(now<=p_l[i].second){
      now=p_l[i].first;
      ans++;
    }
  }
  cout<<ans<<"\n";

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
    ll a,b,v,w,t;
    cin >> a >> v >> b >> w >> t;
    ll dis=abs(b-a);
    ll spd=v-w;
    if(dis>spd*t)cout << "NO" << endl;
    else cout << "YES" << endl;
    
}

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;

public class Main {

	static List<List<edge>> graph;

	static int[] d;

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		graph = new ArrayList<>();

		d = new int[n];

		for (int i = 0; i < n; i++) {
			String[] node_edge = br.readLine().split(" ");

			int k = Integer.parseInt(node_edge[1]);
			List<edge> node_edges = new ArrayList<>();
			for (int j = 0; j < k; j++) {
				node_edges.add(
						new edge(i, Integer.parseInt(node_edge[2 + j * 2]), Integer.parseInt(node_edge[3 + j * 2])));
			}
			graph.add(node_edges);
		}
		/*
		 * for(int i=0; i<graph.size(); i++){ for(edge e: graph.get(i)){
		 * System.out.println(e.from+""+e.to+""+e.cost); } }
		 */
		dijk(0);

		for (int i = 0; i < d.length; i++) {
			System.out.println(i + " " + d[i]);
		}
	}

	static void dijk(int sx) {

		Arrays.fill(d, Integer.MAX_VALUE / 2);
		d[sx] = 0;

		Queue<node> dq = new PriorityQueue<>();

		dq.offer(new node(0,0));

		while(!(dq.isEmpty())){
			node nd = dq.poll();

			int v = nd.v;

			int now_total_cost = nd.nowcost;

			
			if(d[v] < now_total_cost){
				continue;
			}

			for(edge e: graph.get(v)){
				if(d[e.to]> d[v]+e.cost){
					d[e.to] = d[v]+e.cost;
					dq.offer(new node(e.to,d[e.to]));
				}
			}
		}

	}

	static class node implements Comparable<node>{
		int nowcost;

		int v;
		public node(int node_number, int nowcost) {
			this.v = node_number;
			this.nowcost = nowcost;
		}
		@Override
		public int compareTo(node o) {
			// TODO ?????????????????????????????????????????????
			return nowcost-o.nowcost;
		}
	}

	static class edge {

		int to;

		int from;

		int cost;

		public edge(int from, int to, int cost) {
			this.from = from;
			this.to = to;
			this.cost = cost;
		}
	}

}

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

#define int long long

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

int N, M;
int A[300][300];
int score[301];
bool unused[301] = {};

signed main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cin >> A[i][j];
        }
    }
    int ans = LLONG_MAX;
    for (int i = 0; i < M; i++) {
        memset(score + 1, 0, M * sizeof(int));
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < M; k++) {
                if (!unused[A[j][k]]) {
                    score[A[j][k]]++;
                    break;
                }
            }
        }
        int max_score = 0, max_idx = 0;
        for (int j = 1; j <= M; j++) {
            if (score[j] > max_score) {
                max_score = score[j];
                max_idx = j;
            }
        }
        unused[max_idx] = true;
        ans = min(ans, max_score);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int a, b;
    char op;

    int ans;
    while(1) {
        cin >> a >> op >> b;
        if (op == '+') {
            cout << a + b << endl;
        } else if (op == '-') {
            cout << a - b << endl;
        } else if (op == '*') {
            cout << a * b << endl;
        } else if (op == '/') {
            cout << a / b << endl;
        } else if (op == '?') {
            break;
        }
    }
    
}


Measured memory_bytes: 3100
N = int(input())
*b, = map(int, input().split())
ans = []

for i in range(N)[::-1]:
    n = i+1
    if b[i]:
        ans.append(n)
        for j in range(1, int(n**0.5)+1):
            if n%j==0:
                b[j-1] ^= 1
                if j!=n//j:
                    b[n//j-1] ^= 1

M = len(ans)
print(M)
if ans:
    print(*ans)


Measured memory_bytes: 73820
#include <stdio.h>

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

Measured memory_bytes: 580
//By Don4ick 
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qewr1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int N = 805;

using namespace std;

int n, m, k, dp[N][N], nw[N][N];
string s[N];
bool used[N][N];

bool good(int x, int y)
{
	return x >= 0 && x < n && y >= 0 && y < m;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie();
	cout.tie();		

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//~read
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	//~solve
	memset(dp, -1, sizeof(dp));
	memset(nw, -1, sizeof(nw));
	int x1 = -1, y1 = -1;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			if (s[i][j] == 'S')
			{
				x1 = i, y1 = j;
				s[i][j] = '.';
			}
		}
	}
	dp[x1][y1] = 0;
	int d = 0;
	vector < pair < int, int > > v;
	v.pb({x1, y1});
	used[x1][y1] = true;
	while(true)
	{
		vector < pair < int, int > > t;
		for (auto it : v)
		{
			int i = it.first, j = it.second; 
			if (dp[i][j] == -1)
				continue;
			if (i == 0 || j == 0 || i == n - 1 || j == m - 1)
			{
				cout << (d + k - 1) / k << endl;
				return 0;
			}
			for (int dir = 0; dir < DIR; dir++)
			{
				int tx = i + X[dir];
				int ty = j + Y[dir];
				if (good(tx, ty)  && dp[i][j] >= bool(s[tx][ty] == '#'))
				{
					int ndp = dp[i][j] - bool(s[tx][ty] == '#') + k * bool((d + 1) % k == 0);
					if (!used[tx][ty])
						t.pb({tx, ty}), used[tx][ty] = true;
					nw[tx][ty] = max(nw[tx][ty], ndp);
				}
			}
			nw[i][j] = max(nw[i][j], dp[i][j] + bool((d + 1) % k == 0) * k);   
		}
		for (auto it : t)
			v.pb(it);
		for (auto it : v)
		{
			int i = it.first, j = it.second;
			dp[i][j] = nw[i][j];
			nw[i][j] = -1;
		}
		d++;
	}

	return 0;
}



Measured memory_bytes: 12536
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

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

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	println((s <= "2019/04/30" ? "Heisei" : "TBD"));
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<int,int> P;
typedef unsigned long long int ull;
const int MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const int INF=1e9;

int main(){
    ll n;cin>>n;
    if(n%2==1){
        cout<<0<<endl;
        return 0;
    }
    ll ans=n/10;
  n/=10;
    while(n>0){
        ans+=n/5;
        n/=5;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3576
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        boolean bool = false;
        String s;
        boolean flag=false;
        while((s = br.readLine())!=null){	
        	String[] str = s.split(" ");
        	for(int i = 0 ; i < str.length;i++){
	        	if(str[i].length()<3 || str[i].length()>5){
	        		continue;
	        	}
		        for(int j = 0 ;j<26;j++){
		            bool = check(str[i],j+1);
		            if(bool == true){
		                if(flag == false){
		                	print(str,j+1);
		                	System.out.println("");
		                	//System.exit(0);
		                	flag = true;
		                }
		            }
		        }
        	}
        	flag = false;
        }
    }
    public static void print(String[] str,int n){
        for(int i = 0 ; i < str.length;i++){
            for(int j = 0 ; j < str[i].length();j++){
                if(str[i].charAt(j)=='.')
                    System.out.print(".");
                else if(str[i].charAt(j)<97+n)
                    System.out.print((char)(str[i].charAt(j)+26-n));
                else
                    System.out.print((char)(str[i].charAt(j)-n));
            }
            if(i+1<str.length){
            	System.out.print(" ");
            }
        }
    }
    public static boolean check(String a,int n){
        String th = "";
        for(int i = 0 ; i < a.length(); i++){
            if(a.charAt(i)<97+n)
                th+=(char)(a.charAt(i)+26-n);
            else
                th+=(char)(a.charAt(i)-n);
        }
        //System.out.println(th);
        if(th.equals("this")||th.equals("the")||th.equals("that")){
            return true;
        }
        th=th.substring(0, th.length()-1);
        if(th.equals("this")||th.equals("the")||th.equals("that")){
            return true;
        }
        return false;
    }
}

Measured memory_bytes: 17308
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int n;
	cin >> n;
	int x;
	x = n * 800;
	int y;
	y = n / 15;
	cout << x - (200 * y) << endl;

} 

Measured memory_bytes: 3592
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header


int N;
vector<int> a;

i64 dfs(int i, bool even) {
    if (i >= N) return even;

    i64 ret = 0;
    reps(k, a[i]-1, a[i]+1) {
        ret += dfs(i+1, even | (k % 2 == 0));
    }

    return ret;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    read(N);
    a.resize(N);
    rep(i, N) read(a[i]);

    print(dfs(0, false));

    return 0;
}


Measured memory_bytes: 256
X, Y, Z, K = list(map(int,input().split()))
ALPHA = []
for i in range(3):
    ALPHA.append(sorted(list(map(int,input().split())), reverse=True))

counter = 0
p_queue = []
already_queued = []
p_queue.append([0, 0, 0, sum([x[0] for x in ALPHA])])
already_queued.append([0, 0, 0, sum([x[0] for x in ALPHA])])
while True:
    if len(p_queue) == 0:
        break
    p_queue.sort(key=lambda x: x[3])
    max_choice = p_queue.pop(-1)
    print(max_choice[3])
    counter += 1
    if counter == K:
        break
    if max_choice[0] + 1 < X:
        item = [max_choice[0]+1, max_choice[1], max_choice[2], \
                    max_choice[3] - ALPHA[0][max_choice[0]] + ALPHA[0][max_choice[0] + 1]]
        if item not in already_queued:
            p_queue.append(item)
            already_queued.append(item)
    if max_choice[1]+1 < Y:
        item = [max_choice[0], max_choice[1]+1, max_choice[2], \
                    max_choice[3] - ALPHA[1][max_choice[1]] + ALPHA[1][max_choice[1] + 1]]
        if item not in already_queued:
            p_queue.append(item)
            already_queued.append(item)

    if max_choice[2]+1 < Z:
        item = [max_choice[0], max_choice[1], max_choice[2]+1, \
                    max_choice[3] - ALPHA[2][max_choice[2]] + ALPHA[2][max_choice[2] + 1]]
        if item not in already_queued:
            p_queue.append(item)
            already_queued.append(item)


Measured memory_bytes: 4468
#include <iostream>
#include <vector>

using namespace std;
typedef unsigned long long ull;

void swap(ull &a, ull &b)
{
    ull temp = b;
    b = a;
    a = temp;
}

ull euclid(ull a, ull b)
{
    if (b > a)
        swap(a, b);
    if (b == 0)
        return a;
    ull r = a % b;
    return euclid(b, r);
}

int main()
{
    int N;
    cin >> N;
    vector<ull> array(N);

    for (int i = 0; i < N; i++)
    {
        cin >> array.at(i);
    }

    vector<ull> L(N);
    vector<ull> R(N);

    for (int i = 0; i < N - 1; i++)
    {
        L.at(i + 1) = euclid(array.at(i), L.at(i));
        R.at(N - i - 2) = euclid(array.at(N - 1 - i), R.at(N - i - 1));
    }

    ull ans = 0, gcd;
    for (int i = 0; i < N; i++)
    {
        gcd = euclid(L.at(i), R.at(i));
        ans = gcd > ans ? gcd : ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
/**
 * Title: C - 高橋君とカード / Tak and Cards
 * Url: https://atcoder.jp/contests/abc044/tasks/arc060_a
 */
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>

using namespace std;

#define ll long long

const int MAX_N = 51;
const int MAX_A = 10000;

int n, a;

ll dp[MAX_N][MAX_N][MAX_A];

ll rec(int i, int s, int num, vector<int> x) {
    if(dp[i][num][s]!=-1) return dp[i][num][s];
    if(i>=n) {
        if(num==0) return 0;
        if(s/(double)num==(double)a) return 1;
        return 0;
    }
    ll ans = rec(i+1, s+x[i], num+1, x) + rec(i+1, s, num, x);
    dp[i][num][s] = ans;
    return ans;
}

int main() {
    cin >> n >> a;
    vector<int> x(n);
    for(int i=0; i<n; i++) cin >> x[i];
    for(int i=0; i<MAX_N; i++) {
        for(int j=0; j<MAX_N; j++) {
            for(int k=0; k<MAX_A; k++) {
                dp[i][j][k] = -1;
            }
        }
    }
    cout << rec(0, 0, 0, x) << endl;
    return 0;
}

Measured memory_bytes: 203520
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
int n, k, v[100005], tab[100005];
int knap(int obj){
    if(tab[obj]!=INF){
        return tab[obj];
    }
    if(obj==n){
        return tab[obj]=0;
    }
    if(obj>n){
        return tab[obj]=INF;
    }
    return tab[obj]=min(abs(v[obj]-v[obj+1])+knap(obj+1), abs(v[obj]-v[obj+2])+knap(obj+2));
}
int main()
{
    memset(tab, INF, sizeof(tab));
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> v[i];
    }
    cout << knap(1) << endl;
    return 0;
}

Measured memory_bytes: 2560
import fractions

def div(n):
  l =[]
  for i in range(1,n+1):
    if n%i ==0:
      l.append(i)
  return l

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      if i not in table:
        table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

A,B = list(map(int,input().split()))
maxy = fractions.gcd(A,B)

l2 = prime_decomposition(maxy)
print(len(l2) + 1)


Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n;
    cin >> n;
    int a[n+1]={0};
    for(int i=0;i<n;i++)
    	cin >> a[i];
    int c=1000;
    for(int i=0;i<n;i++){
    	if(a[i+1]>a[i]){
    		int x=c/a[i];
    		c+=x*(a[i+1]-a[i]);
    	}
    }
    cout << c << '\n';
}


Measured memory_bytes: 3624
A, B, C, D = map(int, input().split())

m = C // B  # 青木君の耐えうるターン
if C % B != 0:
    m = m + 1

n = A // D  # 高橋君の耐えうるターン
if A % D != 0:
    n = n + 1

if n >= m:
    print('Yes')
else:
    print('No')


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

int binarySearch(vector<int> A, int k, int n){
    int left = 0;
    int right = n;
    while(left < right){
        int mid = (left + right) / 2;
        if(A[mid] == k){
            return 1;
        }else if(A[mid] > k){
            right = mid;
        }else{
            left = mid+1;
        }
    }
    return 0;
}

int main()
{
    int n; cin >> n;
    set<int> S;
    rep(i,n){
        int Ai; cin >> Ai;
        S.insert(Ai);
    }
    int q; cin >> q;
    rep(i,q){
        int k; cin >> k;
        if(S.count(k)) cout << 1 << endl;
        else cout << 0 << endl;
    }
}


Measured memory_bytes: 7776
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 C = sc.nextInt();

        System.out.println(Math.max(C - (A - B), 0));
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
using namespace std;

signed main() {
    int r;
    cin >> r;
    if (r < 1200) {
        cout << "ABC" << endl;
    } else if (r < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		long ans = 0;
		for(int i = 0;i < n;i++){
			int val = s.nextInt();
			int ele = val;
			int count = 0;
			while(true){
				if(ele%2!=0)
					break;
				ele = ele/2;
				count++;
			}
			ans += count;
		}
			System.out.println(ans);
	}
}


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

int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b){
        cout << c << endl;
    }else if(a == c){
        cout << b << endl;
    }
    else{
        cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X % n)
    return int(X % n)


def main():
    n = int(input())
    alphabets = list(chr(i)for i in range(97, 123))
    ans = ''
    while n != 0:
        n -= 1
        ans += alphabets[n % 26]
        n //= 26
    print(ans[::-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 9132
h, w = map(int,input().split())
S = [input() for i in range(h)]

M = [[] for i in range(h*w)]

for i in range(h*w):
    a = i // w
    b = i % w
    for d in [[-1, 0], [1, 0], [0, -1], [0, 1]]:
        aa = d[0] + a
        bb = d[1] + b
        if 0 <= aa < h and 0 <= bb < w \
            and S[a][b] != S[aa][bb]:
            M[a*w+b].append(aa*w+bb)

# print(M)

ans = 0
V = [0] * (h*w)
D = {".":0, "#":1}
for i in range(h*w):
    if V[i] == 0:
        ANS = [0, 0]
        Q = [i]
        s = 0
        V[i] = 1
        ANS[D[S[i//w][i%w]]] += 1
        while s < len(Q):
            i = Q[s]
            for x in M[i]:
                if V[x] == 0:
                    V[x] = 1
                    ANS[D[S[x//w][x%w]]] += 1
                    Q.append(x)
            s += 1
        # print(ANS)
        ans += ANS[0] * ANS[1]
print(ans)

Measured memory_bytes: 68612
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
using namespace std;

void b_cakes_and_donuts(void) {
	int n;
	string judge = "No";
	cin >> n;
	for (int i = 0; i <= 25; i++) {
		if (4 * i > n)continue;
		for (int j = 0; j <= 14; j++) {
			if (4 * i + 7 * j == n) {
				judge = "Yes";
				break;
			}
		}
		if (judge == "Yes") break;
	}
	cout << judge << endl;
}

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

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

string s;
char which_turn;

bool game_end() {
	char first = s[0];
	for (int i = 1; i < s.size(); i++) 
		if (s[i] != first) return false;
	return true;
}

void next_phase() {
	if (which_turn == 'o') {
		if (s[0] == 'x') {
			int i = 0;
			while (s[i] == 'x') s[i++] = 'o';
		} else if (s[s.size()-1] == 'x') {
			int i = s.size()-1;
			while (s[i] == 'x') s[i--] = 'o';
		} // else Do Nothing
		which_turn = 'x';
	} else {
		if (s[0] == 'o') {
			int i = 0;
			while (s[i] == 'o') s[i++] = 'x';
		} else if (s[s.size()-1] == 'o') {
			int i = s.size()-1;
			while (s[i] == 'o') s[i--] = 'x';
		} // else Do Nothing
		which_turn = 'o';
	}
}

char winner() {
	while (!game_end()) {
		next_phase();
	}
	return s[0];
}

int main() {
	which_turn = 'o';
	getline(cin, s);
	cout << winner() << endl;
	return 0;
}

Measured memory_bytes: 1164
import math
N = int(input())
num = list(map(int, input().split()))
#N = 10**6
#num = list(range(1, N+1))

MAXX = 10**6 + 1
MAXZ = int(math.sqrt(MAXX)+2)
furui = [[] for _ in range(MAXX)]

furui[1].append(1)
count = [0]*MAXX
for i in range(2, MAXX):
    if len(furui[i]) == 0:
        for k in range(i, MAXX, i):
            furui[k].append(i)

setwise = True
pairwise = True
for i in range(N):
    if not setwise and not pairwise: break
    for fu in furui[num[i]]:
        count[fu] += 1
        if fu > 1 and count[fu] >= N:
            setwise = False
            pairwise = False
            break
        elif fu > 1 and count[fu] > 1:
            pairwise = False

if pairwise:
    print('pairwise coprime')
elif setwise:
    print('setwise coprime')
else:
    print('not coprime')


Measured memory_bytes: 281804
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  char c;
  cin >> c;
  if (c >= 'a' && c <= 'z')
    cout << "a" << endl;
  else if (c >= 'A' && c <= 'Z')
    cout << "A" << endl;
}

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

vector<int> forintinput(int n) {
	vector<int> x(100000);
	for(int i = 0;i < n;i++) cin >> x[i];
	return x;
}
int main(){
	int r;
	cin >> r;
	const double PI = acos(-1);
	cout << r * 2 * PI << endl;
}

Measured memory_bytes: 3760
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    double t,a;
    int i,n,m;
    cin >> n >> t >> a;
    double h[n],x=99999999;
    for(int j=0;j<n;j++){
        cin >> h[j];
        h[j]=t-h[j]*0.006;
    }
    for(i=0;i<n;i++){
        if(fabs(h[i]-a)<=x){
            x=fabs(h[i]-a);
            m=i;
        }       
    }
    cout << m+1;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		double r = scanner.nextDouble();
		double pi = Math.PI;
		double area = r * r * pi;
		double circum = 2 * r * pi;
		System.out.println(String.format("%.6f",area) + " " + String.format("%.6f",circum));
	}
}


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

int main() {
    unsigned long N;
    cin >> N;
    unsigned long sum = 0;
    for(unsigned long  i = 1; i <= N; i++) {
        if(i % 3 != 0 && i % 5 != 0) {
            sum += i;
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3192
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
al = [0]*(n+1)
bl = [0]*(m+1)
al[0] = 0
bl[0] = 0

for i in range(1,n+1):
    al[i] = al[i-1]+a[i-1]

for j in range(1,m+1):
    bl[j] = bl[j-1]+b[j-1]

ans = 0
l = m

for m in range(n+1):
    if al[m] > k:
        break

    while bl[l] > k - al[m]:
        l -= 1
           
    ans = max(ans,m+l)


print(ans)

Measured memory_bytes: 118272
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n,i,j,len,score_t=0,score_h=0;
    string taro,hanako;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> taro >> hanako ;
        if(taro==hanako) {
            score_t++;
            score_h++;
        }
        else{
            if(taro.size()>hanako.size()) len=taro.size();
            else len=hanako.size();
            for(j=0;j<len;j++){
                if(taro[j]==hanako[j]) continue;
                else if(taro[j]>hanako[j]) {
                    score_t+=3;
                    break;
                }
                else if(taro[j]<hanako[j]) {
                    score_h+=3;
                    break;
                }
            }
        }
    }
    cout << score_t <<" "<< score_h << endl;
}



Measured memory_bytes: 3192
#![allow(dead_code,unused_variables,unused_imports)]
use proconio::{fastout, input};
use proconio::marker::Chars;

#[fastout]
fn main() {
    input!(n:usize,m:usize);

    let t = 1900 * m + 100 * (n-m);
    let p = 2u32.pow(m as u32) as usize;

    println!("{}",t*p);

}

Measured memory_bytes: 2160
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N = readline().decode('utf8').rstrip()
S = [int(x) for x in list(N)]

print('Yes' if int(N) % sum(S) == 0 else 'No')


Measured memory_bytes: 3060
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n,m,x = nm()
a=nl()

left=0
right=0
for ai in a:
  if ai < x:
    left+=1
  if ai > x:
    right+=1
print(min(left,right))

Measured memory_bytes: 62004
N = int(input())
A = list(map(int, input().split()))
memo = {}
for a in A:
    try:
        memo[a] += 1
    except:
        memo[a] = 1
    try:
        memo[a+1] += 1
    except:
        memo[a+1] = 1
    try:
        memo[a-1] += 1
    except:
        memo[a-1] = 1

ans = max(memo.values())
print(ans)


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

int N;
vector<int> D;

int solve(){
    int ans = 0;
    for(int i=0;i<D.size();++i){
        for(int j=i+1;j<D.size();++j){
            ans+=D[i]*D[j];
        }
    }
    return ans;
}

int main(){
    while(cin>>N && N>0){
        D.resize(N);
        for(auto& x: D) cin >> x;
        cout << solve() << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);

    final int a = scanner.nextInt();
    final int b = scanner.nextInt();
    final int h = scanner.nextInt();

    System.out.println((a + b) * h / 2);
  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define LL long long
#define REP(i, n) for(int i=0;i<(n);++i)
#define REPA(i, n) for(int i=1;i<(n);++i)
#define lp(i, n) for(int i=-;i<(n);++i)
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define DEKAI ((int)1e9+7)
#define ALL(x) (x).begin(), (x).end()
#define BIT(x) (1<<(x))
#define foreach(i, n) for(auto &i:(n))
using namespace std;

int main(){
    while(true)
    {
        int n, l, r; cin>>n>>l>>r;
        if(n+l+r==0) break;

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

        int ans=0;
        for(int x=l;x<=r;x++){
            bool flag=false;
            for(int i=0;i<n;i++){
                if(x%a[i]==0){
                    flag=true;    
                    if(i%2==0){
                        ans++;
                    }
                    break;
                }
            }
            if(!flag and n%2==0){
                ans++;
            }
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3104
#!/usr/bin/env python3
h,n = map(int,input().split())
a = [0]*n
b = [0]*n
for i in range(n):
    a[i],b[i] = map(int,input().split())
#  dp[i] i 以上の攻撃力を与えるための最小魔力
b,a = zip(*sorted(zip(b,a))) #魔力でソート
dp = [0]*(h+1)
dp[0] = 0
for i in range(1,h+1):
    dp[i] = 10**12
    for j in range(n):#すべての種類の魔法に対してループ
        if i -a[j] >= 0:#魔法が使えるなら
            dp[i] = min(dp[i],dp[i-a[j]]+b[j])
        else: dp[i] = min(dp[i],b[j])
"""print(dp)
print(a,b)"""
print(dp[h])


Measured memory_bytes: 41964
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int n,m,h[200001],a,b,ans=0;
    vec G[200001];
    cin>>n>>m;
    rep(i,n) cin>>h[i];
    rep(i,m) cin>>a>>b,G[a].push_back(b),G[b].push_back(a);
    rep(i,n){
        int z=1;
        for(auto j:G[i+1]) if(h[i]<=h[j-1]) z=0;
        if(z) ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 12212
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 100005;
int cnt[N];
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		cnt[x]++;
	}
	int ans = 0;
	for (int i = 0; i < 1e5; i++)
		ans = max(ans, cnt[i] + cnt[i + 1] + cnt[i + 2]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N+1];

		for(int i=1;i<=N;i++) {
			a[i] = sc.nextInt();
		}

		int i=1;

		int push = 0;
		for(int j=0;j<N;j++) {
			if(i == 2) {
				System.out.println(push);
				return;
			}else {
				push++;
				i = a[i];
			}
		}
		System.out.println(-1);
	}

}


Measured memory_bytes: 52376
local function reada(n,m)m=m or 1 r={}for i=1,m do r[i]={}end for i=1,n do for j=1,m do r[j][i]=io.read"*n"end end return unpack(r)end
N=io.read"*n"
A=reada(N)

local function count(t)
	local ret=0
	for _,_ in pairs(t)do ret=ret+1 end
	return ret
end

lt={}rt={}
for i=1,N do
	local l=i-A[i]
	if(lt[l]==nil)then lt[l]={}end
	table.insert(lt[l],i)
	
	local r=i+A[i]
	if(rt[r]==nil)then rt[r]={}end
	table.insert(rt[r],i)
end

s=0
for k,v in pairs(rt)do
	if(lt[k])then
		s=s+count(v)*count(lt[k])
	end
end
print(s)


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

using namespace std;

int main(){
    int x1, y1, x2, y2, a=0, b=0;
    cin >> x1 >> y1 >> x2 >> y2;
    a=x2-x1;
    b=y2-y1;
    cout << x2-b << " " << y2+a << " " << x2-b-a << " " << y2+a-b << endl;
    return 0;
}

Measured memory_bytes: 256
import bisect
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

A = sorted(A)

ma = A[-1]
A = A[:-1]
mi = -1
mid = ma/2

mid_ind = bisect.bisect_left(A, mid)
l = n-1
if mid_ind >= l:
    mi = A[-1]
elif mid_ind <= 0:
    mi = A[0]
else:
    if abs(A[mid_ind]-mid) > abs(A[mid_ind-1]-mid):
        mi = A[mid_ind-1]
    else:
        mi = A[mid_ind]
print(ma, mi)


Measured memory_bytes: 14432
#include <iostream>
#include <utility>

using namespace std;

int minStep(int gx, int gy, int p)
{
    // マタタビ:1はいける,0はいけない
    bool Vert[gx + 1][gy + 1] = {};
    bool Horiz[gx + 1][gy + 1] = {};

    // 上端、左端
    for (int i = 0; i < gx + 1; i++)
    {
        Vert[i][0] = 1;
    }
    for (int i = 0; i < gy + 1; i++)
    {
        Horiz[0][i] = 1;
    }

    // 入力
    for (int i = 0; i < p; i++)
    {
        int x1, x2, y1, y2;
        cin >> x1 >> y1 >> x2 >> y2;

        if (x1 == x2)
        {
            Vert[x1][max(y1, y2)] = 1;
        }
        if (y1 == y2)
        {
            Horiz[max(x1, x2)][y1] = 1;
        }
    }

    // DPで計算
    int map[gx + 1][gy + 1];

    for (int i = 0; i < gx + 1; i++)
    {
        for (int j = 0; j < gy + 1; j++)
        {
            int step = 0;

            // 0なら
            if (i == 0 && j == 0)
            {
                step = 1;
            }

            // 上から行ける
            if (!Vert[i][j])
            {
                step += map[i][j - 1];
            }

            // 左から行ける
            if (!Horiz[i][j])
            {
                step += map[i - 1][j];
            }

            map[i][j] = step;
        }
    }
    return map[gx][gy];
}

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

    for (int i = 0; i < count; i++)
    {
        int gx, gy, p;
        cin >> gx >> gy >> p;
        int ans = minStep(gx, gy, p);

        if (ans == 0)
        {
            cout << "Miserable Hokusai!" << endl;
        }
        else
        {
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 3140
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,a,b;
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>a>>b;
	cout<<min(a*n,b)<<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 rrep(i,n) for(int i = 1; i <= (n); ++i)
#define ll long long
#define pii pair<int,int> 
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
const int INF = 1001001001;
//int 2×10の9乗
//vector<vector<int>> a(n, vector<int>(m));
//rep(i,n) rep(j,m) cin >> a[i][j]; 
//cout << fixed << setprecision(10);
//int gcd(int x, int y){
//if(y==0) return x;
//return gcd(y, x%y);
//}
//sort小さい順(昇順)
//g++ code.cpp   ./a.out 
int main(){
  while(true){
    int n; cin >> n;
    if(n==0) break;
    map<char,int> m;
    int s1=0, s2=0;
    char u;
    bool h=false;
    rep(i,n){
      char s; cin >> s; m[s]++;
      if(m[s]>s1) {
      if (u!=s) s2=s1;
      u=s;
      s1=m[s];}
      else s2=max(s2,m[s]);
      if(s1 > s2+n-i-1 && !h){
        cout << u << " " << i+1 << endl;
        h=true;
      } 
    }
    if (!h) cout <<  "TIE" << endl;
}
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	ll i,j,k,m,n,t;
	string s;
	cin>>s;
	ll sum=0;
	for(auto x:s)
	{
		sum+=x-48;
	}
	if(sum%9==0)
	cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 3724
#include <iostream>

long int max(long int x, long int y);
long int min(long int x, long int y);
long int GCD(long int x, long int y);
long int LCM(long int x, long int y);

int main(int argc, char const *argv[]) {
  long int A,B;
  A=B=0;

  while((A==B) || (A<1) || (B<1) || (A>100000) || (B>100000)){
    scanf("%ld %ld", &A,&B);
  }

  printf("%ld\n", LCM(A,B));

  return 0;
}

long int  GCD(long int x, long int y) {
  long int p = max(x, y), q = min(x, y);
  long int gcd;
  if (p % q == 0)
  gcd = q;
  else
  gcd = GCD(q, p % q);

  return gcd;
}

long int LCM(long int x, long int y) {
  long int   lcm;
  lcm = (x * y) / GCD(x, y);
  return lcm;
}

long int  max(long int x, long int y) {
  if (x > y)
  return x;
  else
  return y;
}
long int min(long int x, long int y) {
  if (x < y)
  return x;
  else
  return y;
}

Measured memory_bytes: 256
def inp() a=gets.chomp.split(" ").map(&:to_i)end 
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b = na(a.max+1); a.each{|n|b[n]+=1};return b end
def na(n=0,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
n = inp[0]
d = inp
max = d.size
d.sort!
now = d[0]
st = 1
d.delete_at(0)
(d.size).times do |i|
  if(now*2 >= d[i])
    now += d[i]
    st += 1
  else
    max -= st 
    now = d[i] + now
    st = 1
  end
end
p max

Measured memory_bytes: 10496
let n = read_int()
let arr = Array.make 100001 true
let rec f i k =
  if i = n then print_int (k - 1 + k mod 2)
  else
    let a = Scanf.scanf " %d" (fun a -> a) in
    if arr.(a) then (arr.(a) <- false; f (i + 1) (k + 1))
    else f (i + 1) k
let () = f 0 0

Measured memory_bytes: 5248