akhauriyash/Code-Regression huggingface dataset:
/**
 * Created by hiramekun at 19:03 on 2019-08-26.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}


template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    string s;
    cin >> s;

    ll n = s.size();
    vvl dp(n + 1, vl(13)); // dp[i][j]: 先頭から見てi桁目であまりがjのものの個数

    dp[0][0] = 1;
    rep(i, n) {
        if (s[i] == '?') {
            rep(j, 13) {
                rep(k, 10) {
                    ll idx = (j * 10 + k) % 13;
                    dp[i + 1][idx] += dp[i][j];
                    dp[i + 1][idx] %= mod;
                }
            }
        } else {
            ll now = s[i] - '0';
            rep(j, 13) {
                ll idx = (j * 10 + now) % 13;
                dp[i + 1][idx] += dp[i][j];
                dp[i + 1][idx] %= mod;
            }
        }
    }
    cout << dp[n][5] << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}



Measured memory_bytes: 13568
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main(void)
{
	for (int u = 0; u < 5; u++)
	{
		long long n, m;
		char a[1000], b[1000], p[100000];

		cin >> n;
		if (n == 0)
		{
			return 0;
		}
		for (long i = 0; i < n; i++)
		{
			cin >> a[i] >> b[i];
		}

		cin >> m;
		for (long long j = 0; j < m; j++)
		{
			cin >> p[j];
		}


		for (long long j = 0; j < m; j++)
		{
			for (long i = 0; i < n; i++)
			{
				if (p[j] == a[i])
				{
					p[j] = b[i];
					break;
				}
			}
		}


		for (int j = 0; j < m; j++)
		{
			cout << p[j];
		}
		cout << endl;
	}
}




Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, X,ans=0;
	for (;;) {
		ans = 0;
		cin >> N >> X;
		if (N == 0 && X == 0) {
			
			return 0;
		}
		for (size_t i = 1; i <= N; i++)
		{
			for (size_t j = i+1; j <= N; j++)
			{
				for (size_t k = j+1; k <= N; k++)
				{
					if (i + j + k == X) ans++;
				}
			}
		}
		cout << ans<<endl;
	}
}


Measured memory_bytes: 3080
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <map>
#define REP(i,n) for(int i = 0; i < (int)n; i++)
using namespace std;

long long mod = 1000000007;
long long mul(long long a, long long b){
  return ((a%mod)*(b%mod))%mod;
}

int main(){
  int n;
  cin >> n;
  string s1,s2;
  cin >> s1 >> s2;
  long long ans = 1;
  int i = 0;
  bool prev_vertical = true;
  while(i < n){
    if(s1[i]==s2[i]){//縦
      if(i==0){
        ans = mul(ans,3);
      }else{
        if(prev_vertical){
          ans = mul(ans,2);
        }else{
          ans = ans;
        }
      }
      prev_vertical = true;
      i++;
    }else{//横
      if(i==0){
        ans = mul(ans,6);
      }else{
        if(prev_vertical){
          ans = mul(ans,2);
        }else{
          ans = mul(ans,3);
        }
      }
      prev_vertical = false;
      i+=2;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> ac(n),pena (n);
  rep(i,m){
    int p;
    string s;
    cin>>p>>s;
    --p;
    if(ac[p]) continue;
    if(s=="AC"){
      ac[p]=1;
    }
    else{
      pena[p]++;
    }
  }
  int sum=0;
  int psum=0;
  for(auto x:ac){
    sum+=x;
  }
  rep(i,n){
    if(ac[i]){
    psum+=pena[i];
    }
  }
  cout<<sum<<" "<<psum<<endl;
}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
int c[5];
int main()
{
  int a,b;
  cin>>a>>b;
  c[a]=1;c[b]=1;
  for(int i=1;i<=3;i++)
  {
    if(c[i]==0){cout<<i<<endl;break;}
  }
  return 0;
}

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

N = int(input())
X = list(input())
X = list(map(int, X))

def num_to_X(num):
    new_X = []
    new_N = int(math.log(num,2))+1
    for i in range(new_N):
        new_X.append(num>>i&1)
    return new_X[::-1]

def X_to_num(X):
    value = 0
    X = X[::-1]
    for i in range(len(X)):
        value += X[i]*pow(2,i)
    return value

def mode(X, mod):
    X = X[::-1]
    next_X = 0
    mod_2_i = 1
    for i in range(len(X)):
        next_X = (next_X+(X[i]*mod_2_i))%mod
        mod_2_i = (mod_2_i*2)%mod
    return next_X

def f(N, X, k):
    mod = sum(X)
    next_X = mode(X,mod)
    if next_X == 0:
        return k+1
    else:
        new_X = num_to_X(next_X)
        return f(len(new_X), new_X, k+1)

base_mod = sum(X)
# base_modが1なら, 操作は0回.
if base_mod == 1:
    for i in range(N):
        # 100 -> 000
        if X[i] == 1:
            print(0)
        # 100 -> 110
        elif i != N-1:
            print(1)
        # 100 -> 101
        else:
            print(2)
    exit(0)

plus_amari = mode(X, base_mod+1)
# print(X_to_num(X), base_mod+1, X_to_num(X)%(base_mod+1), plus_amari)
minus_amari = mode(X, base_mod-1)
# print(X_to_num(X), base_mod-1, X_to_num(X)%(base_mod-1), minus_amari)

results = []
modplus_2_i = 1
modminus_2_i = 1
X_hanten = X[::-1]

# print('----')
# print(X)
# print('----')

for i in range(N):
    # modが増えるパターン
    if X_hanten[i] == 0:
#         now_num = X_to_num(X)+pow(2,i)
#         now_mod = base_mod+1
        amari = (plus_amari+modplus_2_i)%(base_mod+1)
    else:
#         now_num = X_to_num(X)-pow(2,i)
#         now_mod = base_mod-1
        amari = (minus_amari-modminus_2_i)%(base_mod-1)
#     print(now_num, now_mod, now_num%now_mod,amari)

    if amari != 0:
        new_X = num_to_X(amari)
        results.append(f(len(new_X),new_X,1))
    else:
        results.append(1)

    modplus_2_i = (modplus_2_i*2)%(base_mod+1)
    modminus_2_i = (modminus_2_i*2)%(base_mod-1)

# print('---')
for result in results[::-1]:
    print(result)

Measured memory_bytes: 108036
n=int(input())
ans=[0]*n

for x in range(1,100):
	for y in range(1,100):
		for z in range(1,100):
			v=x**2 + y**2 + z**2 + x*y +y*z +x*z
			if v>n:
				break
			ans[v-1]+=1

print(*ans)

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    vector<int> data(n);
    set<int> funami;
    for (int i = 0; i < n; i++) {
        cin >> data[i];
        if (i % 2) {
            funami.insert(data[i]);
        }
    }

    //rep(i, n) cout << data[i] << " "; cout << endl;
    sort(all(data));
    //rep(i, n) cout << data[i] << " "; cout << endl;

    int ans = 0;
    for (int i = 1; i < n; i += 2) {
        if (funami.find(data[i]) == funami.end()) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3456
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	String[] initial = scan.nextLine().split(" ");
	int n = Integer.parseInt(initial[0]);
	int q = Integer.parseInt(initial[1]);
	MyQueue processes = new MyQueue(n);
	for (int i = 0; i < n; i++) {
	    String[] input = scan.nextLine().split(" ");
	    String name = input[0];
	    int time = Integer.parseInt(input[1]);
	    Process p = new Process(name, time);
	    processes.enqueue(p);
	}
	
	int processTime = 0;
	while (!processes.isEmpty()) {
	    Process p = processes.dequeue();
	    if (p.time > q) {
		processTime += q;
	    } else {
		processTime += p.time;
	    }
	    p.time = p.time - q;
	    if (p.time > 0) {
		processes.enqueue(p);
	    } else {
		System.out.println(p.name + " " + processTime);
	    }
	}
    }
    
}
class Process {
    String name;
    int time;
    Process (String name, int time) {
	this.name = name;
	this.time = time;
    }
}
class MyQueue {
    int top;
    Process[] processes;
    MyQueue (int n) {
	processes = new Process[n];
	top = -1;
    }
    void enqueue (Process p) {
	processes[++top] = p;
    }
    Process dequeue () {
	Process p = processes[0];
	for (int i = 0; i < top; i++) {
	    processes[i] = processes[i+1];
	}
	processes[top--] = null;
	return p;
    }
    boolean isEmpty () {
	return top == -1;
    }
}

Measured memory_bytes: 104960
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static readonly long INF = 10000000000000;
    static void Main()
    {
        var ABQ = ReadLine().Split().Select(int.Parse).ToArray();
        int A = ABQ[0];
        int B = ABQ[1];
        int Q = ABQ[2];
        var S = new long[A + 2];
        var T = new long[B + 2];
        S[0] = -INF;S[A + 1] = INF;
        T[0] = -INF;T[B + 1] = INF;
        for (int i = 1; i < A+1; i++)
        {
            S[i] = long.Parse(ReadLine());
        }
        Array.Sort(S);
        for (int i = 1; i < B+1; i++)
        {
            T[i] = long.Parse(ReadLine());
        }
        Array.Sort(T);

        var ST = new long[2][] { S, T };
        var ans = Enumerable.Repeat(long.MaxValue, Q).ToArray();
        for (int i = 0; i < Q; i++)
        {
            var x = long.Parse(ReadLine());
            for (int j = 0; j < 2; j++)
            {
                var WE = SearchPos(ST[j], x);
                long w = WE.w;
                long e = WE.e;
                
                var West = SearchPos(ST[(j + 1) % 2], w);
                var distw = Abs(x - w) + Min(Abs(w - West.w), Abs(w - West.e));

                var East = SearchPos(ST[(j + 1) % 2], e);
                var diste = Abs(x - e) + Min(Abs(e - East.w), Abs(e - East.e));
                ans[i] = Min(ans[i], Min(distw, diste));
            }
            
        }
        foreach (var i in ans)
        {
            WriteLine(i);
        }
    }
    static (long w,long e) SearchPos(long[] C,long now)
    {
        int lb = 0, ub = C.Length-1;
        while (ub - lb > 1)
        {
            int mid = (ub + lb) / 2;
            if (C[mid] < now) lb = mid;
            else ub = mid;
        }
        return (C[lb],C[ub]);
    }
}


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

int main()
{
  int n;
  cin >> n;
  if (n < 10)
    cout << n << endl;
  else
  {
    string s = to_string(n);
    int cnt = 0;
    int sum = 0;
    for (int i = 0; i < s.size(); ++i)
    {
      if (s[i] != '0')
        cnt++;
      sum += s[i] - '0';
    }
    if (cnt == 1 && s[0] == '1')
      cout << 10 << endl;
    else
      cout << sum << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

typedef int Weight;
struct Edge{
    int from, to;
    Weight weight;
    int rev;     // 無向グラフの対の辺
    Edge(int from, int to, Weight weight) :
        from(from), to(to), weight(weight) { }
    Edge(int from, int to, Weight weight, int rev) :
        from(from), to(to), weight(weight), rev(rev){ }
};
bool operator < (const Edge &a, const Edge &b){
    if(a.weight != b.weight) return a.weight > b.weight;
    if(a.from != b.from) return a.from > b.from;
    return  a.to > b.to;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void addFlowEdge(Graph &g, int a, int b, Weight c){
    g[a].push_back(Edge(a, b, c, g[b].size()));
    g[b].push_back(Edge(b, a, 0, g[a].size() - 1));
}
void addUndirectedEdge(Graph &g, int a, int b, Weight c){
    g[a].push_back(Edge(a, b, c, g[b].size()));
    g[b].push_back(Edge(b, a, c, g[a].size() - 1));
}

signed main(){
	int N, M;
	cin >> N >> M;
	Graph g(N+1);
	for(int i = 0; i < M; ++i){
		int l, r, d;
		cin >> l >> r >> d;
		g[l].push_back(Edge(l, r, d));
		g[r].push_back(Edge(r, l, -d));
	}
	vector<int> vst(N + 1), dist(N + 1);
	for(int i = 1; i <= N; ++i) if (!vst[i]) {
		queue<pair<int,int>> Q;
		Q.push(make_pair(i, 0));
		vst[i] = 1;
		dist[i] = 0;
		while(!Q.empty()) {
			int v = Q.front().first;
			int d = Q.front().second;
			Q.pop();

			EACH(j, g[v]) if(!vst[j->to]){
				vst[j->to] = 1;
				dist[j->to] = dist[v] + j->weight;
				Q.push(make_pair(j->to, dist[j->to]));
			}
		}
	}
	string res = "Yes";
	for(int i=1; i <= N; ++i) {
		EACH(j, g[i]) {
			if(dist[j->from] + j->weight != dist[j->to]) {
				res = "No";
			}
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 23552
H, W=map(int, input().split())
def yyy(h, w):
  if h%3==0:
    return 0
  else:
    return w
  
def yyt(h, w):
  out=h*w
  for i in range(1, w):
    temp=[(h//2+h%2)*(w-i), (h//2)*(w-i), h*i]
    if out>max(temp)-min(temp):
      out=max(temp)-min(temp)
  return out

def tty(h, w):
  return yyt(w, h)

def ttt(h, w):
  return yyy(w, h)

print(min(yyy(H, W), yyt(H, W), tty(H, W), ttt(H, W)))

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

int main()
{
    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;

    vector<int> v1, v2;

    int cnt = 0;
    rep(i, n)
    {
        if (cnt > k)
            break;
        if (s[i] == 'o')
        {
            v1.push_back(i);
            i += c;
            cnt++;
        }
    }
    cnt = k - 1;
    for (int i = n - 1; i >= 0; i--)
    {
        if (cnt < 0)
            break;
        if (s[i] == 'o')
        {
            v2.push_back(i);
            i -= c;
            cnt--;
        }
    }
    reverse(all(v2));
    rep(i, k) if (v1[i] == v2[i]) cout << v1[i] + 1 << endl;
    return 0;
}


Measured memory_bytes: 5616
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<numeric>
#include<limits.h>
#include<utility>
#include<cstdlib>
#define LP(i,n) for(int i=0;i<n;i++)
#define LPIN(n,a) for(int i=0;i<n;i++)cin >> a[i]
using namespace std;
 
int main(){
  int a,b;
  cin >> a >> b;
  
    cout << a -b + 1 << endl; 
return 0;
}

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

using namespace std;

int main(void) {
    int N;
    int64_t A, B;
    cin >> N >> A >> B;
    vector<int64_t> h(N);
    for(int i=0; i<N; i++) {
        cin >> h[i];
    }

    A -= B;

    int64_t ng = -1, ok = 1'000'000'000L;
    while(ng + 1 < ok) {
        int64_t mid = (ok + ng) / 2;
        int64_t tmp = 0;
        for(int i=0; i<N; i++) {
            tmp += (max(h[i] - mid*B, 0L) + A-1) / A;
        }
        if(tmp <= mid) {
            ok = mid;
        } else {
            ng = mid;
        }
    }

    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 1024
s = input()

res = 0

i = True
p = 1
for c in s:
    if p == 1:
        p = 0
    elif c != '9':
        i = False
        break

if len(s) == 1:
    res = int(s)
elif i:
    res += int(s[0])
else:
    res += int(s[0]) - 1

res += (len(s) - 1) * 9
print(res)

Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String a = sc.next();
      String b = a.toLowerCase();
      if(a==b){
        System.out.println("a");
      }else if(a!= b){
        System.out.println("A");
      }
    }
}
      

Measured memory_bytes: 35540
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
int main(){
    int N;
    cin >> N;
    int a = 800 * N;
    int b = (N / 15) * 200;
    cout << a - b << endl;
    return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	string S, T; cin >> S >> T;
	vector<int> s(26, -1), g(26, -1);
	for (int i = 0; i < S.size(); ++i) {
		int a = S[i] - 'a';
		int b = T[i] - 'a';
		if (s[a] != -1 || g[b] != -1) {
			if (s[a] != b || g[b] != a) {
				cout << "No" << endl;
				return;
			}
		}
		s[a] = b;
		g[b] = a;
	}
	cout << "Yes" << endl;
	return;
}
int main() {
	solve();
	return 0;
}

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

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

void code() {
    ll n;
    cin>>n;
    ll ans=0;
    vector<ll> A(n+1);
    for(ll i=1; i<=n; i++) {
        cin>>A[i];
    }
    sort(A.begin(), A.end());
    for(int i=1; i<n; i++) {
        ans += A[n-i/2];
    }
    cout << ans << "\n";
}

signed main() {
    std::ios_base::sync_with_stdio(false);
    ll t=1;
    // cin>>t;
    for(ll i=0; i<t; i++) {
        code();
    }
}


Measured memory_bytes: 4828
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<mp> a;
	int p;
	int cnt =1;
	if(s[0]=='#')p=0;
	else p = 1;

	int res = inf;
	int b = 0;
	int w = 0;
	for(int i=0;i<n;i++){
		if(s[i]=='.')w++;
	}
		res = min(res,w+b);
	for(int i=0;i<n;i++){
		if(s[i]=='.'){
			w--;
		}else{
			b++;
		}
		res = min(res,w+b);
	}
	cout<<res<<endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n), s(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s[i] = a[i] + (i ? s[i - 1] : 0);
    }
    ll ans = 1e18;
    int j = 0, k = 2;
    for (int i = 1; i < n - 2; i++) {
        while (j + 1 < i && s[j] < s[i] - s[j]) {
            j++;
        }
        while (k + 1 < n - 1 && s[k] - s[i] < s[n - 1] - s[k]) {
            k++;
        }
        for (int u = j - 1; u <= j; u++) {
            for (int v = k - 1; v <= k; v++) {
                if (0 <= u && i < v) {
                    vector<ll> x = {s[u], s[i] - s[u], s[v] - s[i], s[n - 1] - s[v]};
                    sort(x.begin(), x.end());
                    ans = min(ans, x[3] - x[0]);
                }
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int h,w,x,y;
	double ans = 0.0;
	cin >>h>>w>>x>>y;
	ans = (double)h * w / 2.0;
	printf("%.9lf\n", ans);
	cout << (((double)y * 2.0 == (double)w) and ((double) x * 2.0 == (double)h))
	     << endl;
}

Measured memory_bytes: 3736
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>


/* ---------- Namespace ---------- */

using namespace std;


/* ---------- Type Abbreviation ---------- */

template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

using ll = long long;
using PL = P<ll, ll>;
using PS = P<string, ll>;

using VI = V<int>;
using VVI = V<VI>;
using VL = V<ll>;
using VVL = V<VL>;
using VS = V<string>;
using VB = V<bool>;
using VVB = V<VB>;
using VPL = V<PL>;
using VPS = V<PS>;

#define fst first
#define snd second


/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)


/* ---------- container ---------- */

#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define GSORT(c) sort(ALL(c), greater<decltype((c).front())>())
#define SZ(x) (LL((x).size()))


/* ---------- repetition ---------- */

#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)

#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// Usual REP runs from 0 to n-1 (R: n to 0)
// Natural REP runs from 1 to n (R: n to 1)


/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
const ll INF = 1LL << 50;
// const double PI = 3.14159265358979;
// const ll dx[4] = {0, -1, 1, 0};
// const ll dy[4] = {-1, 0, 0, 1};
// const ll dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const ll dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};


/* ---------- Short Functions ---------- */

template <typename T>
T square(T a) {
    return a * a;
}


/* ---------- Debug ---------- */
#define GET_VAR_NAME(variable) #variable

#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;
#define testP(p) cout << GET_VAR_NAME(p) << " = (" << (p).fst << ", " << (p).snd << ")" << endl;


/* ^^^^^^^^^^^^^^^ Settting Part ^^^^^^^^^^^^^^^ */

/* ---------- Variances ---------- */


/* ---------- Functions ---------- */


/* ---------- Main Function ---------- */

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

    ll N;
    cin >> N;

    VL A(N + 1);
    VL S(N + 2);
    S[0] = 0;
    NREP(i, N) {
        cin >> A[i];
        S[i] = S[i - 1] + A[i];
    }
    S[0] = 0;
    S[N + 1] = INF;

    SORT(S);
    ll ans = 0;
    ll cnt = 1;
    REP(i, N + 1) {
        if (S[i] == S[i + 1]) {
            cnt++;
        } else {
            ans += cnt * (cnt - 1) / 2;
            cnt = 1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define Liny "Yes\n"
#define Linn "No\n"

int main() {
  int A,B; cin >>A>>B;
  string s; cin >> s;
  bool r = true;
  REP(i,s.size()){
    bool h = (s[i]=='-');
    if(i==A){ if(!h){ r = false; break;} }
    else if(h){ r = false; break;}
  }
   cout << (r?Liny:Linn);
}


Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
//    ifstream in("input.txt");
//    cin.rdbuf(in.rdbuf());
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int d;
    cin >> d;
    
    if (d==25) cout << "Christmas" << endl;
    if (d==24) cout << "Christmas Eve" << endl;
    if (d==23) cout << "Christmas Eve Eve" << endl;
    if (d==22) cout << "Christmas Eve Eve Eve" << endl;
    
    return 0;
}

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

template <typename T>
T gcd(T a, T b){ return b%a==0 ? a : gcd(b%a, a); }

template <typename T>
T lcm(T a, T b){ return (a/gcd(a, b))*b; }

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

    cout << lcm<i64>(a, b) << endl;
    return 0;
}

Measured memory_bytes: 256
def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z = x%y
            x = y
            y = z
        else:
            return z
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = a[0]
for i in range(1,n):
     ans = min(ans,gcd(ans,a[i]))
print(ans) 


Measured memory_bytes: 62704
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Hassan El Desouky
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define el '\n'
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i <= b; ++i)
#define FORD(i,a,b) for(int i = a; i >= b; --i)
#define RI(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(n)-1)
#define SQR(x) (x)*(x)
#define all(v)  	((v).begin()),((v).end())
typedef long long ll;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef long double ld;
typedef vector<int>		vi;
typedef vector<int>		vll;
typedef vector<pii>		vpii;
const double EPS = 1e-9;
const int N = 1e3+2, M = 3e5+5, OO = 0x3f3f3f3f;
int dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; // 4 Direction
//int dx[] = {1,-1,0,0,1,1,-1,-1}, dy[] = {0,0,1,-1,1,-1,1,-1}; // 8 Direction
/* int dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* int dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction


class BBetweenAAndB {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll a, b, x; in >> a >> b >> x;
        if (a % x == 0) {
            out << (b/x)-(a/x)+1;
            return;
        }
        out << (b/x) - (a/x) << el;
	}
};


int main() {
	BBetweenAAndB solver;
    ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
from math import factorial as fac

def comb(n,r):
    if ( r<0 or r>n ):
        return 0
    return fac(n)/(fac(r)*fac(n-r))


n=int(input())
k=int(input())

nn=str(n)
keta=len(nn)

ans=0

if keta<k:
    print(0)
    exit()

zero=0

# for i in range(keta):
#     if int(nn[i])==0:zero+=1
#     ans+=comb(keta-i-1,k-i+zero)*9**(k-i)
#     if int(nn[i])-1>=0:
#         ans+=(int(nn[i])-1)*comb(keta-i-1,k-i-1+zero)*9**(k-i-1+zero)
#
# if keta-zero==k:ans+=1

def search(n,k):
    if k<=0:return
    global ans
    nn = str(n)
    keta = len(nn)
    ans += comb(keta - 1, k ) * 9 ** k
    if int(nn[0])-1>0:
        ans+=(int(nn[0])-1)*comb(keta-1,k-1)*9**(k-1)
    ne=n-int(nn[0])*10**(keta-1)
    search(ne,k-1)


search(n,k)
for i in range(keta):
    if nn[i]=="0":zero+=1
if keta-zero>=k:ans+=1
print(int(ans))

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int i,l,x;
	char a[101];
	x=700;
	cin>>a;
	for(i=0;i<3;i++){
		if(a[i]=='o'){
			x=x+100;
		}
	}
	
	cout<<x<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll a, b, q;

    cin >> a >> b >> q;

    vector<ll> s(a), t(b);
    ll x;

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

    s.push_back(INF);
    s.push_back(-INF);
    sort(s.begin(), s.end());

    for (int i = 0; i < b; i++)
    {
        cin >> t[i];
    }

    t.push_back(INF);
    t.push_back(-INF);
    sort(t.begin(), t.end());

    for (int i = 0; i < q; i++)
    {
        cin >> x;
        ll ans = INF;

        int ds = lower_bound(s.begin(), s.end(), x) - s.begin();

        int dt = lower_bound(t.begin(), t.end(), x) - t.begin();

        for (int k = ds - 1; k <= ds; k++)
        {
            for (int j = dt - 1; j <= dt; j++)
            {
                ans = min(ans, abs(s[k] - x) + abs(s[k] - t[j]));
                ans = min(ans, abs(t[j] - x) + abs(s[k] - t[j]));
            }
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 2912
#include <cstdio>
#include <algorithm>
using namespace std;
#define N 100050
long long d[N],e[N],f[N];
int a[N],b[N],c[N],n,i;
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	for (i=1;i<=n;i++) scanf("%d",&b[i]);
	for (i=1;i<=n;i++) scanf("%d",&c[i]);
	sort(a+1,a+n+1);sort(b+1,b+n+1);sort(c+1,c+n+1);
	for (i=1;i<=n;i++) d[i]=i;
	for (i=1;i<=n;i++) e[i]=e[i-1]+d[lower_bound(a+1,a+n+1,b[i])-a-1];
	for (i=1;i<=n;i++) f[i]=f[i-1]+e[lower_bound(b+1,b+n+1,c[i])-b-1];printf("%lld\n",f[n]);
	return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
#include<array>
#include<algorithm>
#include<queue>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
#include<bitset>
#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}
//long nHr(int n,int r) {
//	n = n + r - 1;
//	return nCr(n,r);
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI N, D,res = 0;
	cin >> N >> D;
	vector<vector<double>>vec(N);
	for (int i = 0; i < N;i++) {
		vec[i].resize(D);
	}
	for (int i = 0; i < N;i++) {
		for (int j = 0; j < D;j++) {
			cin >> vec[i][j];
		}
	}
	double sum = 0;
	for (int i = 0; i < N;i++) {
		for (int j = i; j < N;j++) {
			sum = 0;
			if (i != j) {
				for (int k = 0; k < D; k++) {
					sum += pow(abs(vec[i][k] - vec[j][k]), 2);
				}
				sum = (double)sqrt(sum);
				if (ceil(sum) == floor(sum)) {
					res++;
				}
			}	
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int ans = ((a+b+c)%2 == max({a,b,c})%2 ? max({a,b,c}) : max({a,b,c})+1);
    cout << (3*ans - (a+b+c))/2 << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h> 
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define ForkD(i,k,n) for(int i=n;i>=k;i--)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define Forpiter(x) for(int &p=iter[x];p;p=next[p])  
#define Lson (o<<1)
#define Rson ((o<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,0x3f,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define MEMx(a,b) memset(a,b,sizeof(a));
#define INF (0x3f3f3f3f)
#define F (1000000007)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int> 
#define pi pair<int,int>
#define SI(a) ((a).size())
#define Pr(kcase,ans) printf("Case #%d: %lld\n",kcase,ans);
#define PRi(a,n) For(i,n-1) cout<<a[i]<<' '; cout<<a[n]<<endl;
#define PRi2D(a,n,m) For(i,n) { \
						For(j,m-1) cout<<a[i][j]<<' ';\
						cout<<a[i][m]<<endl; \
						} 
#pragma comment(linker, "/STACK:102400000,102400000")
#define ALL(x) (x).begin(),(x).end()
#define gmax(a,b) a=max(a,b);
#define gmin(a,b) a=min(a,b);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
ll mul(ll a,ll b){return (a*b)%F;}
ll add(ll a,ll b){return (a+b)%F;}
ll sub(ll a,ll b){return ((a-b)%F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
	while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();}
	return x*f;
} 
int main()
{
//	freopen("A.in","r",stdin);
//	freopen(".out","w",stdout);
	int n=read();
	int a=read(),b=read();
	int t=(b-a)%2;
	if(t==0)puts("Alice");else puts("Borys"); 
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	int n, m,temp;
	cin >> n >> m;
	vi a(m), b(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
	}
	
	for (int i = 1; i <= n; i++) {
		temp = 0;
		for (int j = 0; j < m; j++) {
			if (a[j] == i) temp++;
		}
		for (int j = 0; j < m; j++) {
			if (b[j] == i) temp++;
		}
		cout << temp << endl;
	}

	return 0;
}

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


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

    int k;
    cin >> k;
    string s;
    rep (i, k) s+= "ACL";
    cout << s << endl;
    return 0;
}

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

int s(int num){
   int ans = 0;
   for(;num > 0; num /=10){
      ans += num % 10;
   }
   return ans;
}

int main(){
   int n;
   cin >> n;
   cout << ((n % s(n) == 0) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}



int main() {
    ll n,a[200010],b[200010];
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
        b[i] = a[i];
    }
    sort(a,a+n);
    if(a[n-1] == a[n-2]){
        for (int i = 0; i < n; i++) {
            std::cout << a[n-1] << std::endl;
        }
    }else{
        for (int i = 0; i < n; i++) {
            if(b[i] != a[n-1]){
                std::cout << a[n-1] << std::endl;
            }else{
                std::cout << a[n-2] << std::endl;
            }
        }
    }
}




Measured memory_bytes: 4736
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>

using namespace std;

vector<int> list[1000];
int item[1000];

int saiki(int num){
	if(list[num].empty()==1){
		return item[num];
	}
	
	int cont=0;
	for(int i=0;i<list[num].size();i++){
		cont+=saiki(list[num][i]);
	}
	
	return min(cont,item[num]);
}

int main(){
	
	map<string,int> name;
	
	while(1){
	
	int n,m;
	cin>>n;
	if(n==0){
		break;
	}
	for(int i=0;i<n;i++){
		string a;int b;
		cin>>a>>b;
		name[a]=i;
		item[i]=b;
	}
	
	for(int i=0;i<n;i++){
		list[i].clear();
	}
	
	cin>>m;
	for(int i=0;i<m;i++){
		string a;int b;
		cin>>a>>b;
		for(int j=0;j<b;j++){
			string c;
			cin>>c;
			list[name[a]].push_back(name[c]);
		}
	}
	string a;
	cin>>a;
	
	printf("%d\n",saiki(name[a]));
	}
	
	
}

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

#define rep(i, n)     for (int i = 0; i < n; ++i)
#define rep1(i, n)    for (int i = 1; i < n + 1; ++i)
#define repN(i, m, n) for (int i = m; i < n; ++i)
#define repR(i, n)    for (int i = n - 1; i >= 0; --i)

using namespace std;

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

	if (x >= 30) {
		cout << "Yes";
	} else {
		cout << "No";
	}

	return 0;
}


Measured memory_bytes: 3632
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner scn=new Scanner(System.in);
    String s=scn.next();
    if(Character.isUpperCase(s.charAt(0))) {
  	  	System.out.println("A");
	}else {
    	System.out.println("a");
	}
  }
}

Measured memory_bytes: 35612
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, T;
    cin >> n >> T;
    int ans = INF;
    rep(i, 0, n){
        int c, t;
        cin >> c >> t;
        if(t <= T){
            chmin(ans, c);
        }
    }
    if(ans == INF) cout << "TLE" << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm> 
#include <cmath>

using namespace std;

typedef long long LL;

const int MOD = 1000000007;
const int MAXN = 2 * 100005;

LL H, W;
LL A, B;
LL fact[MAXN];

// Exponentiation by squaring
LL expsq(LL x, LL p) {
	LL res = 1;
	while (p > 0) {
		if (p & 1) {
			res = (res * x) % MOD;
		}
		x = (x * x) % MOD;
		p /= 2;
	}
	return res;
}

// Extended Euler's algorithm
LL modinv(LL x) {
	return expsq(x, MOD - 2);
}

LL C(LL n, LL k) {
	return (fact[n] * modinv(fact[n - k] * fact[k] % MOD)) % MOD;
}

int main() {
	cin >> H >> W >> A >> B;
	fact[0] = 1;
	for (int i = 1; i < MAXN; i++) {
		fact[i] = fact[i - 1] * i;
		fact[i] %= MOD;
	}

	LL ans = 0;
	for (LL i = B; i <= W - 1; i++) {
		LL res = C(H - A - 1 + i, i);
		LL end = C(W - i - 1 + A - 1, A - 1);
		res *= end;
		res %= MOD;

		ans += res;
		ans %= MOD;
	}

	cout << ans << endl;
}

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

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

  int x = -1;
  int y = -1;
  int z = -1;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N - i; j++) {
      int sum = 10000 * i + 5000 * j + 1000 * (N - i - j);
      if (sum == Y) {
        x = i;
        y = j;
        z = N - i - j;
        break;
      }
    }
  }

  if (x == -1) cout << "-1 -1 -1" << endl;
  else cout << x << " " << y << " " << z << endl;
}


Measured memory_bytes: 256
#include<cstdio>

int main(){
	int a, b;
	scanf("%d %d", &a, &b);
	int d = a/b;
	int r = a%b;
	double f = (double)a/(double)b;
	printf("%d %d %f\n", d, r, f);

	return 0;

}

Measured memory_bytes: 1064
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (n, _): (usize, usize) = parse!(it, 2);
    let a: Vec<_> = parse!(it, n);
    let mut pairs = std::collections::HashMap::new();
    let mut min = std::usize::MAX;
    for i in 0..n {
        if min < a[i] {
            *pairs.entry(a[i] - min).or_insert(0) += 1;
        }
        min = std::cmp::min(min, a[i]);
    }
    let mut max = 0;
    let mut ret = 0;
    for (k, v) in pairs {
        if max < k {
            ret = v;
            max = k;
        }
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 14588
import java.util.Scanner;
import java.util.Map;
import java.util.TreeMap;
import java.util.Iterator;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        TreeMap<String, Integer> S = new TreeMap<String, Integer>();               
        String tmp;
        int max = 1;
        int count;

        for(int i=0; i<N; i++){
            tmp = sc.next();
            
            if(S.containsKey(tmp)){
                count = S.get(tmp)+1;
                if(max < count){
                    max = count;
                }
                S.put(tmp,count);
            } else {
                S.put(tmp,1);
            }
            
            
        }
        for(Iterator<String> it = S.keySet().iterator();it.hasNext();){
            String result = it.next();

            if(S.get(result) == max){
                System.out.println(result);
            }
        }
        
    }
}


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

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

  int ans = 0;
  for (int i = 0; i < S.size(); ++i) {
    int cnt = 0;
    if (S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'G' || S.at(i) == 'T') {
      for (int j = i; j < S.size(); ++j) {
        if (S.at(j) == 'A' || S.at(j) == 'C' || S.at(j) == 'G' || S.at(j) == 'T') {
          cnt++;
        }
        else {
          break;
        }
      }
    }
    ans = max(ans, cnt);
  }

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


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def solve(maze, st_tuple):
    st_row, st_col = st_tuple
    W, H = len(maze[0]), len(maze)
    visited = [[0 for _ in range(W)] for __ in range(H)]
    steps = [[0 for _ in range(W)] for __ in range(H)]
    q = deque()
    q.append((st_row, st_col, 0))
    visited[st_row][st_col] = 1
    steps[st_row][st_col] = 0
    while q:
        cur_row, cur_col, count = q.popleft()
        for dr, dc in zip(DR, DC):
            next_row = cur_row + dr
            next_col = cur_col + dc
            if 0 <= next_row < H and 0 <= next_col < W:
                pass
            else:
                continue
            if maze[next_row][next_col] == '#':
                continue
            if visited[next_row][next_col]:
                continue
            q.append((next_row, next_col, count + 1))
            visited[next_row][next_col] = 1
            steps[next_row][next_col] = count + 1
    max_count = 0
    for r in range(H):
        for c in range(W):
            max_count = max(max_count, steps[r][c])
    return max_count

def main():
    H, W = LI()
    maze = []
    for _ in range(H):
        maze.append(S())
    num = 0
    axes = [(s_r, s_c) for s_r in range(H) for s_c in range(W)]
    for st_row, st_col in axes:
        if maze[st_row][st_col] == '#':
            continue
        a = solve(maze, (st_row, st_col))
        num = max(num, a)
    print(num)
main()



Measured memory_bytes: 72152