akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a<b?a:b)
inline int read(){
	int f=1,x=0;char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')
			f=-1;
		c=getchar();
	}
	while(c<='9'&&c>='0'){
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}

inline void file(){
	freopen("1.in","r",stdin);
	freopen("1.out","w",stdout);
}

using namespace std;
const int maxn=1000+10;
int a[maxn];
int main(){
	int n;
	scanf("%d",&n);
	for(register int i=1;i<=n;++i)
		scanf("%d",&a[i]);
	int ans=0;
	sort(a+1,a+n+1);
	int qaq=-1;
	for(register int i=1;i<=n;++i){
		if(a[i]>qaq){
			++ans;
			qaq=a[i];
		}
	}
	cout<<ans;

	return 0;
}




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

int main()
{
  vector<int> a(3);
  cin >> a.at(0) >> a.at(1) >> a.at(2);
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  cout << a.at(0)*10 + a.at(1) + a.at(2) << endl;
}

Measured memory_bytes: 256
n = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())-1
print(n[k])

Measured memory_bytes: 3060
//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MOD 1000000007
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

string a, b;

int main(){
    ios::sync_with_stdio(0);
    cin >> a >> b;
    for(int i = 0, j = 0, k = 0; i < (int)a.size()+(int)b.size(); i++){
        if(i%2==0){
            cout << a[j];
            j++;
        }else{
            cout << b[k];
            k++;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <map>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>

using namespace std;
#define set_precision cout << fixed << setprecision(10)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define repit(arr) for (auto it = arr.begin(); it != arr.end(); it++)
#define vi vector<int>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define vpi vector<pair<int,int>>
#define seti set<int>
#define setl set<ll>
#define dseti set<int, greater<int>>
#define dsetl set<ll, greater<ll>>
#define mseti multiset<int>
#define msetl multiset<ll>
#define dmseti multiset<int, greater<int>>
#define dmsetl multiset<ll, greater<ll>>
#define sortA(arr) sort(arr.begin(), arr.end())
#define dsortA(arr) sort(arr.begin(), arr.end(), greater<int>())
#define ssort(arr) stable_sort(arr.begin(), arr.end())
#define nth(v,n) nth_element(v.begin,v.begin+n-1,v.end())
#define dnth(v,n) nth_element(v.begin,v.begin+n-1,v.end(), greater<int>())
#define init(a)  memset((a),0,sizeof(a))
#define pi pair<int,int>
#define pb push_back
#define pl pair<ll,ll>
#define ll long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
long double EPS = 1e-9;

/*struct comp {
  bool operator() (const int& lhs, const int& rhs) const
  {return lhs<rhs;}
};*/

ll cel(ll a,int b){return((a-1)/b+1);} 
ll gcd(ll a, ll b){
    if (a < b)swap(a, b);
    return (b == 0)? a: gcd(b, a % b);
}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

int main()
{
    FIO;
    ll n,t,x,y;
    cin>>n;vi v(n);y=0;
    rep(i,0,n){cin>>v[i];}
    sortA(v);
    rep(i,0,n){
        rep(j,i+1,n){
            rep(k,j+1,n){
                if(v[i]+v[j]>v[k]&&(v[i]!=v[j])&&(v[i]!=v[j])&&(v[j]!=v[k])){
                    y++;
                }
            }
        }
    }
    cout<<y;
    return 0;
}

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

using namespace std;

int main() {
  int n, q;
  int count = 0;
  cin >> n >> q;
  queue<pair<string,int>> que;
  pair<string, int> tmp;
  while(cin >> tmp.first >> tmp.second) que.push(tmp);
  while(!que.empty()) {
    tmp = que.front(); que.pop();
    if(tmp.second > q) {
      tmp.second -= q;
      que.push(tmp);
      count += q;
    }else {
      count += tmp.second;
      cout << tmp.first << " " << count << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 6352
import sys

S = input()
MOJI = 'AKIHABARA'
ans = 'YES'
if len(S) > 9:
    print('NO')
    sys.exit()

for i in range(9 - len(S)):
    S = S + 'A'
for i in range(9):
    if S[i] != MOJI[i]:
        if MOJI[i] != 'A':
            ans = 'NO'
            break
        else:
            S = S[0:i] + 'A' + S[i:]

print(ans)

Measured memory_bytes: 3064
//In the Name of ̲A̲l̲l̲a̲h̲

#define pb push_back
#define F first
#define S second
#define sz size()
#define ll long long

#include <bits/stdc++.h>

using namespace std;

ll n, dp[3][100001], a[3][100001], mx;

int main()
{
	ios_base::sync_with_stdio(0);
	cin >> n;
	for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> a[j][i];
        }
    }
    for (int i = 0; i < 3; i++)
        dp[i][0] = a[i][0];
    for (int i = 1; i < n; i++)
    {
        dp[0][i] = max(dp[1][i-1],dp[2][i-1]) + a[0][i];
        dp[1][i] = max(dp[0][i-1],dp[2][i-1]) + a[1][i];
        dp[2][i] = max(dp[0][i-1],dp[1][i-1]) + a[2][i];
    }
    for (int i = 0; i < 3; i++)
    {
        if (mx < dp[i][n-1])
            mx = dp[i][n-1];
    }
    cout << mx;
}

/*𝐻𝒶𝒹𝒾*/


Measured memory_bytes: 4992
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        int x = inp.nextInt();
        String op = inp.next();
        int y = inp.nextInt();
        if (op.equals("+")) System.out.println(x + y);
        else System.out.println(x - y);
    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define fi first
#define se second
#define re return
#define pb emplace_back
#define em emplace
#define er erase
#define all(x) (x).begin(), (x).end()
#define in(v); { for (auto &i : v) cin >> i; }
#define out(v); { for (auto &i : v) cout << i << ' '; cout << endl; }

///#define int long long

using namespace std;
//using namespace __gnu_cxx;
//using namespace __gnu_pbds;

const long long INFll = 1e18;



void solve() {
    int n, m; cin >> n >> m;
    cout << n / m + (n % m != 0);
}

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

    solve();
}


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

using namespace std;
#define ll long long
#define inf 998244353

ll fun(ll n,ll m)
{
    ll s=1;
    while(m)
    {
        if(m&1)
        {
            s=s*n%inf;
        }
        n=n*n%inf;
        m=m/2;
    }
    return s;
}

int main()
{
    double n;
    scanf("%lf",&n);
    double z=(n/3.0)*(n/3.0)*(n/3.0);
    printf("%.12f",z);
    return 0;
}


Measured memory_bytes: 256
l = list(input())
ans = 0
for i in range(len(l)):
  if i == i//2*2:
    if l[i] == "L":
      print("No")
      ans += 1
      break
    else:
      continue
  else:
    if l[i] == "R":
      print("No")
      ans += 1
      break
    else:
      continue
if ans == 0:
  print("Yes") 
  

Measured memory_bytes: 2940
#include  <stdio.h>
int main (){
    int m=0, f=0, r=0;
    int result;
    
    while(1){
    scanf("%d %d %d",&m, &f, &r);
        result = m + f;
        if((m == -1) && (f == -1) && (r == -1)){
            break;
        }if(m == -1 ||f == -1){
            printf("F\n");//中間試験、期末試験のいずれかを欠席した場合成績は F。
        }else if(result >= 80){
            printf("A\n");//中間試験と期末試験の合計点数が 80 以上ならば成績は A 。
        }else if(result >= 65 && result <= 80){
            printf("B\n");//中間試験と期末試験の合計点数が 65 以上 80 未満ならば成績は B。
        }else if(result >= 50 && result < 65){
            printf("C\n");//中間試験と期末試験の合計点数が 50 以上 65 未満ならば成績は C。
        }else if(result >=30 && result < 50){
            if(r >= 50){
                printf("C\n");//中間試験と期末試験の合計点数が 30 以上 50 未満ならば成績は D。 ただし、再試験の点数が 50 以上ならば成績は C。
            }else{
                printf("D\n");
            }
        }else{
                printf("F\n");
        }
    }
    
    return 0;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    char str1,str2,str3,str4,str5,str6;
  cin >> str1;
    cin >> str2; 
    cin >> str3;
    cin >> str4;
    cin >> str5;
    cin >> str6;
    
    if(str3 == str4 && str5 == str6){
      cout << "Yes" <<endl;
    }
  else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <bitset>


int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout << std::fixed << std::setprecision(10);

    long long int n; std::cin >> n;

    if(n==1)
    {
        std::cout << 0 << std::endl;
    }

    long long int prod_ma = 0;
    
    for(long long int i=1; i*i<=n; i++)
    {
        long long int prod = std::__gcd(n, i);
        prod_ma = std::max(prod, prod_ma);
    }

    std::cout << prod_ma + n/prod_ma - 2 << std::endl;
 
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,T,A;
    cin >> N >> T >> A;
    vector<int> H(N);
    for (int i=0;i<N;i++) {
        cin >> H.at(i);
    }
    int cnt=0;
    double minnum = 10000000;
    for (int i=0;i<N;i++) {
        double num=0;
        num = abs(A - (T - H.at(i) * 0.006));
        if (num<minnum) {
            minnum = num;
            cnt = i+1;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define debug(v) cout << #v<< ": " << v <<endl;
#define fst first
#define snd second
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;
ll INF = 1LL<<60;
ll M = 1000000007;

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int main(){
    ll n, k; cin >> n >> k;
    vll a(n);
    rep(i, 0, n){
        cin >> a[i];
    }
    vll x = a;
    sort(x.begin(),x.end());
    vll ans(n, 0);
    rep(i, 0, n){
        ll c = 0;
        rep(j, i+1, n){
            if(a[i] > a[j]){
                c++;
            }
        }
        ans[i] = c;
    }
    mint res = 0;
    rep(i, 0, n){
        mint g = ans[i];
        g *= k;
        res += g;
    }
    rep(i, 0, n){
        mint h = n-(x.end()-lower_bound(x.begin(), x.end(), a[i]));
        if(k%2 == 0){
            h *= k-1;
            h *= k/2;
        }else{
            h *= (k-1)/2;
            h *= k;
        }
        res += h;
    }
    prtl(res);
}


Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main()
{
    int a = 0, a1 = 0, a2 = 0, a3 = 0;
    cin >> a;
    a1 = a / 100;
    a2 = (a % 100) / 10;
    a3 = ((a % 100) % 10) / 1;
    cout << a1 + a2 + a3 << endl;
    return 0;
}


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

//Mysterious Worm
public class Main{
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			String s = sc.next();
			if(s.equals("0"))break;
			int n = s.length();
			Set<String> set = new HashSet<String>();
			set.add(s);
			int step = 0;
			boolean ans = false;
			List<String> l = new ArrayList<String>();
			l.add(s);
			while(!l.isEmpty()){
				List<String> next = new ArrayList<String>();
				for(String u:l){
					char[] c = u.toCharArray();
					char ch = c[0];
					boolean f = true;
					for(int i=1;i<n;i++){
						if(c[i]!=ch){
							f = false;break;
						}
					}
					if(f){
						ans = true;
						next.clear();
						break;
					}
					for(int i=0;i<n-1;i++){
						if(c[i]!=c[i+1]){
							char a = c[i];
							char b = c[i+1];
							char v = a!='r'&&b!='r'?'r':a!='g'&&b!='g'?'g':'b';
							c[i] = c[i+1] = v;
							String st = new String(c);
							if(!set.contains(st)){
								set.add(st);
								next.add(st);
							}
							c[i] = a;
							c[i+1] = b;
						}
					}
				}
				step++;
				l = next;
			}
			System.out.println(ans?--step:"NA");
		}
	}
}

Measured memory_bytes: 16000
import java.io.InputStream;
import java.util.Scanner;

/**
 * Created on 2017/10/29.
 */
public class Main {
    public static void main(String args[]){
        int R = 0;
        int x = 0;
        int G = 0;

        Scanner sc = new Scanner(System.in);

        R = sc.nextInt();
        G = sc.nextInt();

        x = 2*G-R;

        System.out.println(x);

    }

}


Measured memory_bytes: 25172
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	ll N;
	cin >> N;
	ll x;
	cin >> x;
	vector<ll> candies(N);
	for (int i = 0; i < N; i++)cin >> candies[i];
	sort(candies.begin(), candies.end());
	int ans = 0;
	while (x > 0 && !candies.empty()) {
		if (x >= candies[0]) {
			ans++;
			x -= candies[0];
			candies.erase(candies.begin());
		}
		else break;
	}
	if (x > 0 && ans != 0 && candies.empty())ans--;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
    char name[100];
    int t;
}P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
    Q[tail] = x;
    tail = (tail + 1) % LEN;
}

P dequeue(){
    P x = Q[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a, int b){
    return a < b ? a : b;
}

int main(){
    int elaps = 0, c;
    int i, q;
    P u;
    scanf("%d%d",&n,&q);
    for(i=1;i <= n;i++){
        scanf("%s",&Q[i].name);
        scanf("%d",&Q[i].t);
    }
    head = 1;
    tail = n+1;

    while(head != tail){
        u = dequeue();
        c = min(q,u.t);
        u.t -= c;
        elaps += c;
        if(u.t >0){
            enqueue(u);
        }else{
            printf("%s %d\n",u.name,elaps);
        }
    }

    return 0;
}


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

int main(){  
    int H, A;  cin >> H >> A;
    if(H%A == 0){
        cout << H/A << endl;
    }else{
        cout << H/A + 1 << endl;
    }
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	bool yes=true;
	for(int i=0;i<n;++i){
		int t,x,y; cin>>t>>x>>y;
		if(t<x+y||t%2!=(x+y)%2)yes=false;
	}
	cout<<(yes?"Yes"s:"No"s)<<"\n"s;
}

Measured memory_bytes: 256
import collections

n = int(input())
s = []
for i in range(n):
    s.append(input())

c = collections.Counter(s)
c_s = c.most_common()
m = c.most_common()[0][1]
ans = []
for j in range(len(c_s)):
    if c_s[j][1] != m:
        break
    else:
        ans.append(c_s[j][0])
ans.sort()
for t in ans:
    print(t)

Measured memory_bytes: 59376
import numpy as np
tmp = list(map(int, input().split(' ')))
A = tmp[0]
B = tmp[1]
m = tmp[2]
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
xyc = [ list(map(int,input().split(" "))) for i in range(m)]
ans = min(a)+min(b)
for i in range(m):
    ans = min(a[xyc[i][0]-1]+b[xyc[i][1]-1]-xyc[i][2],ans)
print(ans)


Measured memory_bytes: 47512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

int g[3][3];
int N;
int b[20];
bool f[3][3];

void solve()
{
	for(int i=0;i<N;++i){
		for(int j=0;j<3;++j)for(int k=0;k<3;++k){
			if(b[i]==g[j][k]) f[j][k]=true;
		}
	}
	for(int i=0;i<3;++i){
		bool fl = true;
		for(int j=0;j<3;++j){
			fl &= f[i][j];
		}
		if(fl){
			cout << "Yes\n";
			return;
		}
	}
	for(int j=0;j<3;++j){
		bool fl = true;
		for(int i=0;i<3;++i){
			fl &= f[i][j];
		}
		if(fl){
			cout << "Yes\n";
			return;
		}
	}
	if(f[0][0]&&f[1][1]&&f[2][2]) cout << "Yes\n";
	else if(f[0][2]&&f[1][1]&&f[2][0]) cout << "Yes\n";
	else cout << "No\n";
}

int main()
{
	ios::sync_with_stdio(false);
	for(int i=0;i<3;++i)for(int j=0;j<3;++j)cin >> g[i][j];
	cin >> N;
	for(int i=0;i<N;++i)cin >> b[i];
	solve();
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <string.h>

using namespace std;
#define ll long long int

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

	ll n,m;
	cin>>n>>m;
	cout<<((n*(n-1))+(m*(m-1)))/2;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();

		int h = S/3600;
		int m = (S%3600)/60;
		int s = S%60;

		System.out.println(h+":"+m+":"+s);
	}
}

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

const int maxn = 2e3 + 5;
LL a[maxn];
LL b[maxn][maxn];//b[i][k] : 当整个过程使用了【k】次魔法，获得【color i】时的最少花费的时间。(不包括【k * x】).

int main(){
    int n;
    LL x,sum = 1LL << 60LL;
    cin >> n >> x;
    for(int i = 1;i <= n;i++) cin >> a[i];
    for(int i = 1;i <= n;i++){
        b[i][0] = a[i];
        for(int k = 1;k <= n - 1;k++){
            int pos = i - k;
            if(pos <= 0) pos = n - abs(pos);
            b[i][k] = min(b[i][k - 1],a[pos]);//【b[i][k]】的转移方程.
        }
    }
    for(int k = 0;k <= n - 1;k++){
        LL ans = 0;
        for(int i = 1;i <= n;i++){
            ans += b[i][k];
        }
        sum = min(sum,ans + x * k);//取最小值.
    }
    cout << sum << endl;
}


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

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

int gcd(int a, int b){return (a % b)? gcd(b, a % b) : b;}
int lcm(int a, int b){return a * b / gcd(a, b);}

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

    int n = s.size();
    string s_left, s_right;

    s_left = s.substr(0,n/2); //真ん中から左
    s_right = s.substr(n/2); //真ん中から右

    reverse(s_left.begin(), s_left.end()); //左を反転

    int q;
    cin >> q;

    int ctr = 0;

    REP(i,q){
        int t;
        cin >> t;
        if(t == 1){
            ctr ++;
        } else{
            int f;
            char c;
            cin >> f >> c;

            if((f + ctr) % 2 == 1){
                s_left += c;
            } else{
                s_right += c;
            }
        }
    }
    reverse(s_left.begin(), s_left.end()); //元に戻した
    string ans;
    ans = s_left + s_right;
    if(ctr % 2 == 1) reverse(ans.begin(), ans.end());

    cout << ans;
}

int main(void){
    solve_158D();
    
    return 0;
}

Measured memory_bytes: 1500
#include <bits/stdc++.h>
#define  pb push_back
#define nl "\n"
#define fastScan ios_base::sync_with_stdio(0); cin.tie(NULL);
#define int long long int
using namespace std;
int dp[3234][3234];
int s[3324];
signed main()
{
	fastScan;
	int n,sum=0;cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
		sum+=s[i];
	}
	for(int l=1;l<=n;l++)
	{
		for(int i=0;i<n-l+1;i++)
		{
			int j=i+l-1;
			int x=0,y=0,z=0;
			if(i+2<=j)
				x=dp[i+2][j];
			if(i+1<=j-1)
				y=dp[i+1][j-1];
			if(i<=j-2)
				z=dp[i][j-2];
			dp[i][j]=max(min(x,y)+s[i],min(y,z)+s[j]);
		}
	}
	cout<<2*dp[0][n-1]-sum<<nl;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    int ans = 0;
    for (int i = 0; i < n-2; i++) {
        if (p[i]<p[i+1]&&p[i+1]<=p[i+2]||p[i+2]<p[i+1]&&p[i+1]<=p[i]) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
counter = Counter()
for i in range(N):
    s = input()
    counter[s] += 1
most_common = counter.most_common(1)
most_count = most_common[0][1]
for k, v in sorted(counter.items(), key=lambda x: x[0]):
    if v == most_count:
        print(k)



Measured memory_bytes: 105816
n, m = map(int, input().split())
b1 = [False for i in range(n)]
bn = [False for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if a > b:
        a, b = b, a
    if a == 0:
        b1[b] = True
    if b == n - 1:
        bn[a] = True
for i in range(n):
    if b1[i] and bn[i]:
        print("POSSIBLE")
        import sys
        sys.exit()
print("IMPOSSIBLE")

Measured memory_bytes: 6320
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
#define itn int
#define all(c) c.begin(),c.end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define ll long long
#define ull unsigned long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std; 

const double PI = 3.1415926536;
int days[13] = {0, 31, 28, 31, 30, 31,30, 31, 31, 30, 31, 30, 31};

template<typename T>
ostream& operator <<(ostream& out, const vector<T>& mas) {
    for (const auto& x : mas) {
        out << x << ' ';
    }
    return out;
}

void ok() {
    cout << "YES" << '\n';
}

void no() {
    cout << "NO" << '\n';
}

inline ll nxt() {
    ll x;
    cin >> x;
    return x;
}
 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int l = nxt();
    double x = 1.0 * l / 3;
    cout << setprecision(20) << pow(x, 3);
    return 0;
}


Measured memory_bytes: 384
N=int(input())
S=[]
table=[2**i for i in range(7)]

for i in range(N):
    s=int(input())
    S.append(s)
S.sort()
a=sum(S)

if a%10 !=0:
    print(a)
else:
    for i in range(N):
        if S[i]%10 !=0:
            a=a-int(S[i])
            print(a)
            break
    else:
        print(0)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
class DisjointSet{
  public:
    vector<int> rank,p;
    DisjointSet(){}
    DisjointSet(int size){
        rank.resize(size,0);
        p.resize(size,0);
        for(int i=0;i<size;i++) makeSet(i);
    }
    void makeSet(int x){//????´????x??????????????§????????°???????????????
        p[x] = x;
        rank[x] = 0;//??¨?????????
    }
    bool same(int x,int y){//????´???????????????????
        return findSet(x) == findSet(y);
    }
    void unite(int x,int y){//???????????±???
        link(findSet(x),findSet(y));
    }
    void link(int x,int y){
        if(rank[x]>rank[y]){
            p[y]=x;
        }
        else{
            p[y] = x;
            if(rank[x] == rank[y]){
                rank[y]++;
            }
        }
    }
    int findSet(int x){//x???????????????????±?????????????????????????Union Find???
        if(x!=p[x]){
            p[x] = findSet(p[x]);
        }
        return p[x];
    }
};

int main(){
    int n,a,b,q;
    int t;
    cin >> n >> q;
    DisjointSet ds = DisjointSet(n);
    for(int i=0;i<q;i++){
        cin >> t >> a >> b;
        if(t==0)    ds.unite(a,b);
        else if(t==1){
            if(ds.same(a,b))    cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3172
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#define ll  long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define main() int main()
#define ff1(i,n) for(int i=1;i<=n;++i)
#define ff0(i,n) for(int i=0;i<n;++i)
#define pi acos(-1.0)
#define ms(a, x) memset(a, x, sizeof(a))
#define lowbit(x) ((x)&(-(x)))
#define pb push_back
#define binarycount __builtin_popcount(x)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define fir first
#define sec second
#define debug(x) cout<<x<<'\n'
#define sa(a) scanf("%d", &a)
#define sab(a, b) scanf("%d%d", &a, &b)
#define pa(a) printf("%d",a)
#define pab(a,b) printf("%d%d",a,b)
#define pii pair<int,int>
using namespace std;

#define maxn 205
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
const double eps = 1e-8;
ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}
ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}
ll powmod(ll a,ll b){
    ll ans = 1, pow = a%mod;
    while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; }
    return ans%mod;
}
int a[maxn];

main(){
    int n,k,d;
    cin>>n>>k;
    ms(a,0);
    for(int i=1;i<=k;i++){
    	cin>>d;
    	for(int j=1;j<=d;j++){
    		int x;
    		cin>>x;
    		a[x]++;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==0) ans+=1;
	}
	cout<<ans<<endl;
} 

Measured memory_bytes: 3636
function main(input){
    input = input.split(' ');
    inputA=parseInt(input[0]);
    inputB=parseInt(input[1]);
    count=1;
    inputIa=0;
    for(i=0;i<inputB;i++){
        inputIa = inputIa+inputA*count;
        count=count*10;
    }
    count=1;
    inputIb=0;
    for(i=0;i<inputA;i++){
        inputIb = inputIb+inputB*count;
        count=count*10;
    }

    if(inputIa<=inputIb){
        out = inputIb;
    }
    else if(inputIa>inputIb){
        out = inputIa;
    }

    console.log(out);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define Nitroboost  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int 
const int mod=1e9+7;
const int N=1e5+5;

ll sum1[N],sum2[N];

int main()
    {
        Nitroboost;
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif

        string s,t;
        cin>>s>>t;
        int ans=s.length();
        for(int i=0;i<=s.length()-t.length();i++)
        {
            int cnt=0;
            int r=i;
            for(int j=0;j<t.length();j++)
            {
                if(s[r++]!=t[j])
                    cnt++;
            }
            ans=min(ans,cnt);
        }

        cout<<ans;
    }

Measured memory_bytes: 3644
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
long long pluss[1000] = {};
int main() {
	long long l;
	cin >> l;
	vector<tuple<int,int, int>> edges;
	pluss[20] = 1;
	for (int i = 19; i >= 2; --i) {
		pluss[i] = pluss[i + 1] * 3;
		if (pluss[i + 1]*2 <= l) {
			edges.push_back(make_tuple(i, i + 1, pluss[i] / 3));
			edges.push_back(make_tuple(i, i + 1, (pluss[i] / 3) * 2));
			edges.push_back(make_tuple(i, i + 1, 0));
		}
	}
	long long now = 0;
	for (int i = 2; i <= 20; ++i) {
		if (now + pluss[i] <= l) {
			edges.push_back(make_tuple(1, i, now));
			now += pluss[i];
		}
		if (now + pluss[i] <= l) {
			edges.push_back(make_tuple(1, i, now));
			now += pluss[i];
		}
	}
	cout << "20 " << edges.size() << endl;
	for (int i = 0; i < edges.size(); ++i) {
		cout << get<0>(edges[i]) << " " << get<1>(edges[i]) << " " << get<2>(edges[i]) << endl;
	}
	return 0;
}

Measured memory_bytes: 888
S=input()

if S=="SUN":
    print(7)
elif S=="MON":
    print(6)
elif S=="TUE":
    print(5)
elif S=="WED":
    print(4)
elif S=="THU":
    print(3)
elif S=="FRI":
    print(2)
else:
    print(1)

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

using namespace std;
typedef long long ll;

int a[100001];
ll dp[100001];

int main(void) {
    int i, n;
    cin >> n;
    for(i=0; i<n; i++) scanf("%d", a+i);

    ll ans1 = 0, sum = 0;
    for(i=0; i<n; i++) {
        sum += a[i];
        if(i % 2 == 0 && sum <= 0) {
            ans1 += -sum + 1;
            sum = 1;
        }
        else if(i % 2 == 1 && sum >= 0) {
            ans1 += sum + 1;
            sum = -1;
        }
    }

    ll ans2 = 0; sum = 0;
    for(i=0; i<n; i++) {
        sum += a[i];
        if(i % 2 == 0 && sum >= 0) {
            ans2 += sum + 1;
            sum = -1;
        }
        else if(i % 2 == 1 && sum <= 0) {
            ans2 += -sum + 1;
            sum = 1;
        }
    }

    printf("%lld\n", min(ans1, ans2));

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

typedef long long int ll;
const ll MOD=1000000007;

ll n,k;
ll dp[1001][1001]={};

int main(){
	scanf("%lld %lld",&n,&k);
	if(n<k) printf("0\n");
	else{
		dp[0][0]=1;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=k;j++){
				dp[i][j]+=dp[i-1][j]*j;
				dp[i][j]+=dp[i-1][j-1];
				dp[i][j]%=MOD;
			}
		}
		printf("%lld\n",dp[n][k]);
	}
}


Measured memory_bytes: 10992
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int n,t;
    cin >> n >> t;
    vector<P> ab(n);
    rep(i,0,n-1)cin >> ab[i].first >> ab[i].second;
    SORT(ab);
    // REV(ab);
    int dp[n][t];
    int ans = 0;
    rep(i,0,t-1){
        if(i-ab[0].first >= 0)dp[0][i] = ab[0].second;
        else dp[0][i] = 0;
    }
    ans = ab[0].second;
    rep(i,1,n-1){
        rep(j,0,t-1){
            if(j-ab[i].first >= 0)dp[i][j] = max(dp[i-1][j], dp[i-1][j-ab[i].first] + ab[i].second);
            else dp[i][j] = dp[i-1][j];
        }
        ans = max(ans, dp[i-1][t-1] + ab[i].second);
    }
    // matprint(dp,n-1,t);
    // int ans = dp[n-2][t-1] + ab[n-1].first;

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

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

int main(){
    long long N,a,b,c,d,e;
    cin >> N;
    cin >> a >> b >> c >> d >> e;
    long long mine = min({a,b,c,d,e});
    cout << (N+mine-1)/ mine + 4 << endl;
}

//D


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define PII pair<int, int>
#define MP make_pair
#define PB push_back
#define REP(i,a,b) for(int i = a; i < b; ++i)
#define F for(int i = 0; i < n; ++i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

int main() 
{
    int n; cin>>n;
    int arr[n]; F cin>>arr[i];
    int dp[n+1]; dp[0]=0; dp[1] = 0; dp[2] = abs(arr[0]-arr[1]);
    for (int i = 3; i <= n; ++i)
    {
        dp[i] = min(dp[i-1] + abs(arr[i-1]-arr[i-2]), dp[i-2] + abs(arr[i-1]-arr[i-3]));
    }

    cout<<dp[n];

    return 0;
}

Measured memory_bytes: 4360
import java.util.*;
 
class Main {
    public static void main(String[] args){
        List<String> list = new ArrayList<String>();
 
        String[] mark = {"S", "H", "C", "D"};
 
        for(int i = 0; i < 4; i++){
            for(int j = 0; j < 13; j++){
                list.add(mark[i] + " " + (j + 1));
            }
        }
 
        Scanner sc = new Scanner(System.in);
 
        int n = Integer.parseInt(sc.nextLine());
         
        for(int i = 0; i < n; i++){
            list.remove(sc.nextLine());
        }
 
        for(String str : list){
            System.out.println(str);
        }
         
    }
}

Measured memory_bytes: 26184
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    if (s[0] == s[n - 1]) cout << (n & 1 ? "Second" : "First") << endl;
    else cout << (n & 1 ? "First" : "Second") << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define pb push_back
#define f first
#define s second
#define pi 3.141592653589793238
using namespace std;

ll gcd( ll a, ll b )
{
	if(b==0)
	{
		return a;
	}
	else
	{
		return gcd( b, a%b );
	}
}
ll lcm (ll a, ll b)
{
	return (a*b)/gcd(a,b);
}

ll power(ll a, ll b)	//a is base, b is exponent
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	if(b%2 == 1)
		return (power(a,b-1)*a)%mod;
	ll q = power(a,b/2);
	return (q*q)%mod;
}
ll n;
vll adj[200000];
bool vis[200000];
ll ans =1;
ll dp[5][200000];
void dfs(ll cur,ll m)
{
	vis[cur] = true;
	dp[0][cur] = 1;
	dp[1][cur] = 1;
	for(int i = 0;i<adj[cur].size();i++)
	{
		ll v =adj[cur][i];
		if(v!=m)
		{
			dfs(v,cur);
			dp[0][cur] = (dp[0][cur] * dp[1][v])%mod;
			dp[1][cur] = (dp[1][cur] * (dp[0][v]+dp[1][v]))%mod; 
		}
	}
}

int main()
{
	std::ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 1;i<=n-1;i++)
	{
		ll x,y;
		cin >> x >> y;
		adj[x].pb(y);
		adj[y].pb(x);
	}	
	dfs(1,-1);
	cout << (dp[0][1]+dp[1][1])%mod << endl;
	return 0;
}


//Hello, this is a snippet.


Measured memory_bytes: 20224
package main

import "fmt"

func main() {
	var x, a, b int
	fmt.Scan(&x, &a, &b)
	if b <= a {
		fmt.Println("delicious")
	} else if b - a <= x {
		fmt.Println("safe")
	} else {
		fmt.Println("dangerous")
	}
}


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

using namespace std;
using ull = unsigned long long;
using ll = long long;

int main()
{
	const double pi = acos(-1);
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	double m2 = ((double)m)/60;
	double da = a;
	double db = b;
	double t1 = pi * 2 * ((double) h + m2) / 12;
	double t2 = pi * 2 * m2;
	cout << std::fixed;
	cout << std::setprecision(10);
	cout << sqrt((double)(a * a + b * b) - da * db*cos(t2 - t1)*2) << endl;
}

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

int main(){
    int D,G;cin>>D>>G;
    G/=100;
    vector<int> P(D);
    vector<int> C(D);
    for (int i = 0; i < D; i++)
    {
        int p,c;cin>>p>>c;
        c/=100;
        P[i] = p;
        C[i] = c;
    }
    int L = G+1;
    // L = 1000000;
    vector<vector<int>> dp(D, vector<int>(L,10000));
    for(int i = 0;i < L;i++){
        if(i < P[0]){
            dp[0][i] = i;
        }else if(i <= P[0]+C[0]){
            dp[0][i] = P[0];
        }
    }
    for(int i = 1;i < D;i++){
        for(int g = 0;g < L;g++){
            for(int p = 1;p <= P[i];p++){
                int sc = (i+1)*p+ (p==P[i] ? C[i] : 0);
                if(sc >= g){
                    dp[i][g] = min(p, min(dp[i-1][g], dp[i][g]));
                }else{
                    dp[i][g] = min(dp[i-1][g], min(dp[i-1][g-sc] + p, dp[i][g]));
                }
            }
        }
    }
    // for(int i = 0;i < D;i++){
    //     for(int j = 0;j < L;j++){
    //         cout<<dp[i][j]<<" ";
    //     }cout<<endl;
    // }
    cout<<dp[D-1][G]<<endl;
    
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define debug(x) cerr<<"\tDEBUG: "<<#x<<" = "<<(x)<<endl
#define debug2(a,b) cerr<<#a<<"\t"<<#b<<" = "<<(b)<<endl
using namespace std;
const int maxn=105;
bool cur1;
int n,m;

bool cur2;
int main(){
//	double sz=&cur1-&cur2;
//	cout<<sz/1024/1024<<endl;
	int T=1;
	while(T--){
		long long a;
		cin>>a;
		cout<<3LL*a*a<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N;
std::vector<LL>A(212);
LL ans;

int main()
{
	in >> N;
	rep(i, N) { in >> A[i]; }

	ans = 1123456789;
	rep(i, N)
	{
		LL cou = 0;
		while (A[i] % 2 == 0)
		{
			A[i] /= 2;
			++cou;
		}
		ans = std::min(ans, cou);
	}

	out << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

bool check(char c) {
    return (c == 'A' || c == 'T'|| c == 'C' || c == 'G');
}

int main() {
    string s;   cin >> s;
    int l = s.length(), ans = 0;

    for (int i = 0; i < l; i++) {
        int j = i, tmp = 0;
        while (j < l && s[j] && check(s[j])) {
            tmp++;
            j++;
        }

        ans = max(tmp, ans);
    }

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

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

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

    int cost = 0, mx = 0;

    for(int i=0;i<5;++i){
        int A;
        std::cin >> A;

        cost += (A + 9) / 10 * 10;

        int t = A % 10 > 0 ? 10 - A % 10 : 0;
        mx = std::max(mx, t);
    }

    cost -= mx;

    std::cout << cost << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

set<int> se;

bool check(int n){
  while(n){
    if(se.find(n%10)!=se.end())return false;
    n/=10;
  }
  return true;
}

int main(){
  int n,k;
  cin>>n>>k;
  rep(i,k){
    int d;
    cin>>d;
    se.insert(d);
  }

  while(!check(n)){
    n++;
  }
  
  cout<<n<<endl;
  return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

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


int counter = 0;
int gcd(int a, int b) {
    if (b == 0) return a;
    counter++;
    return gcd(b, a%b);
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  map<ll,ll> mp;
  rep(i,m){
    ll a,b; cin>>a>>b;
    mp[a]++;
    mp[b]++;
  }
  for(auto e: mp){
    if(e.second%2){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
}

Measured memory_bytes: 5632
import math
from functools import reduce
K = int(input())
s = []
def gcd(*numbers):
    return reduce(math.gcd, numbers)
for i in range(K):
    for j in range(K):
        for k in range(K):
            s.append(gcd(i+1,j+1,k+1))
print(sum(s))


Measured memory_bytes: 189076
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> Pr;
typedef tuple<int, int, int> Tp;
typedef vector<int> Vec;
typedef vector<Vec> Mat;
const int INF = 1 << 28;

int n;
Mat a;
Mat d;

int main()
{
	while (scanf("%d", &n), n){
		a = Mat(2, Vec(n));
		d = Mat(2, Vec(n, INF));
		for (int i = 0; i < 2; i++){
			for (int j = 0; j < n; j++){
				scanf("%d", &a[i][j]);
			}
		}
		
		queue<Tp> que;
		int sp = 0;
		while (a[0][sp] == 1 && sp + 1 < n && a[0][sp + 1] == 1) sp++;
		que.push(Tp(0, sp, 0));
		d[0][sp] = 0;
		sp = 0;
		while (a[1][sp] == 1 && sp + 1 < n && a[1][sp + 1] == 1) sp++;
		que.push(Tp(1, sp, 0));
		d[1][sp] = 0;
		while (que.size()){
			Tp tp = que.front(); que.pop();
			int p1 = get<0>(tp);
			int p2 = get<1>(tp);
			int sum = get<2>(tp);
			if (d[p1][p2] < sum) continue;
			for (int i = 0; i <= 2; i++){
				int np1 = p1 ^ 1;
				int np2 = p2 + i;
				if (np2 >= n) continue;
				while (np2 + 1 < n && a[np1][np2] == 1 && a[np1][np2 + 1] == 1) np2++;
				while (a[np1][np2] == 2) np2--;
				if (d[np1][np2] <= sum + 1) continue;
				d[np1][np2] = sum + 1;
				que.push(Tp(np1, np2, sum + 1));
			}
		}
		
		int res = min(d[0][n - 1], d[1][n - 1]);
		if (res == INF) puts("NA");
		else printf("%d\n", res);
	}
}

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

int main()
{
	int N, x;

	cin >> N >> x;

	int a[100];

	for (int i = 0; i < N; i++) {

		cin >> a[i];
	}
	sort(a, a + N);

	
	
	int count = 0;

	for (int i = 0; i < N; i++) {
		if (x >= a[i]) {
			x -= a[i];
			count++;
		}
	}

	if (count == N && x > 0)
		count--;

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt() + 1;
        int b = sc.nextInt() + 1;
        int[][] array1 = new int [a][b];
        int[] array2 = new int [b];

        for(int i =0; i < a; i++) {
            int total1 = 0;
            if(i == a -1) {
                break;
            }
            for(int j=0;j<b;j++) {
                if(j == b -1) {
                    array1[i][j] = total1;
                    array2[j] += total1;
                    break;
                } else {
                    int c = sc.nextInt();
                    total1 += c;
                    array1[i][j] = c;
                    array2[j] += c;
                }
            }
        }
        for(int i=0; i < a; i++) {
            if(i != a-1) {
                for(int j = 0; j < b; j++) {
                    if (j == b -1) {
                        System.out.println(array1[i][j]);
                    }else {
                        System.out.print(array1[i][j] + " ");
                    }
                }
            } else {
                for(int j = 0; j < b; j++) {
                    if (j == b -1) {
                        System.out.println(array2[j]);
                    }else {
                        System.out.print(array2[j] + " ");
                    }
                }
            }
        }
    }
}


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

int main(){

  int nmin,nmax,m;
  vector<int> point(0);
  int gap,ans;

  while(cin>>m>>nmin>>nmax , nmin&&nmax&&m){
    point.resize(m);
    gap = 0;
    
    for(int i=0; i<m; i++)cin >> point[i];

    sort(point.begin(),point.end());
    reverse(point.begin(),point.end());

    //for(int i=0;i<point.size();i++)cout << point[i]<<' ';
    
    for(int i=nmin-1; i<nmax; i++){
      if(point[i]-point[i+1] >= gap){
	gap = point[i]-point[i+1];
	ans = i+1;
      }
    }

    cout << ans << endl;

  }


  return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  ll n,p;
  cin >> n >> p;
  string s;
  cin >> s;
  ll ans = 0;
  if(p==5 || p==2){
    ll cnt = 0;    
    rep(i,n){
      cnt++;
      ll c = s[i]-'0';
      if(c%p==0) ans += cnt;
    }
  }
  else{
    ll c = 0;
    map<ll,ll> smap;
    smap[c]++;
    ll digit = 1;
    for(int i=n-1;i>=0;i--){
      ll cn = s[i]-'0';
      c += digit * cn;
      c %= p;
      //      cout << c << endl;
      //      cout << ans << endl;
      ans += smap[c];
      smap[c]++;
      digit  = digit * 10 % p;
    }
  }
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 1044