akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;
ll dp[1<<16][20];
ll dp2[1<<16];
ll N;
ll X[2][20], P[20];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    assert(N <= 15);
    for(int i = 0; i < N; i++) {
        cin >> X[0][i] >> X[1][i] >> P[i];
    }
    for(int bits = 0; bits < (1 << N); bits++) {
        ll val = INF;
        for(int x = 0; x < 2; x++) {
            ll sum = 0;
            ll num = 0;
            for(int i = 0; i < N; i++) {
                if(!((1 << i) & bits)) continue;
                sum += P[i] * X[x][i];
                num += P[i];
            }
            //ll ave = 0;
            //if(num > 0) ave = sum / num;
            //cerr << bits << " " << x << " " << ave << " " << sum << " " << num << endl;
            for(int j = 0; j < N; j++) {
                ll pos = X[x][j];
                ll now = 0;
                for(int i = 0; i < N; i++) {
                    if(!((1 << i) & bits)) continue;
                    now += P[i] * abs(X[x][i] - pos);
                }
                chmin(val, now);
            }
        }
        dp2[bits] = val;
        //cerr << bits << " " << dp2[bits] << endl;
    }
    for(int bits = 0; bits < (1 << N); bits++) {
        for(int k = 0; k <= N; k++) {
            dp[bits][k] = INF;
        }
    }
    for(int bits = 0; bits < (1 << N); bits++) {
        dp[bits][0] = 0;
        for(int i = 0; i < N; i++) {
            if(bits & (1 << i)) {
                dp[bits][0] += min(abs(X[0][i]), abs(X[1][i])) * P[i];
            }
        }
    }
    for(int i = 0; i <= N; i++) {
        dp[0][i] = 0;
    }
    for(int bits = 1; bits < (1 << N); bits++) {
        for(int k = 1; k <= N; k++) {
            chmin(dp[bits][k], dp[bits][k-1]);
            for(int sub = bits+1; ; ) {
                sub = (sub - 1) & bits;
                assert((sub & bits) == sub);
                chmin(dp[bits][k], dp[bits ^ sub][k-1] + dp2[sub]);
                if(sub == 0) break;
            }
        }
    }
    for(int i = 0; i <= N; i++) {
        cout << dp[(1 << N) - 1][i] << endl;
    }
    return 0;
}


Measured memory_bytes: 8988
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[n-1-i];
    }
    for(int j = 0; j < n-1; j++){
        cout << a[j] << " ";
    }
    cout << a[n-1] << endl;
    
    return 0;
    
}


Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <string>
using namespace std;

struct CARD {
	int number;
	char mark;
};

int partition(vector<CARD>& A, int p, int r) {
	int i,j,x=A[r].number;
	i=p-1;
	for(j=p; j<r; ++j) {
		if(A[j].number<=x) {
			++i;
			swap(A[i],A[j]);
		}
	}
	swap(A[i+1],A[r]);
	return i+1;
}

void quickSort(vector<CARD>& A, int p, int r) {
	if(p<r) {
		int q;
		q=partition(A,p,r);
		quickSort(A,p,q-1);
		quickSort(A,q+1,r);
	}
	return;
}

int main() {
	int n;
	int i;
	bool stability=true;
	vector<CARD> A;
	map<int,queue<char> > M;

	cin >> n;
	A.resize(n);

	for(i=0; i<n; ++i) {
		cin >> A[i].mark >> A[i].number;
		M[A[i].number].push(A[i].mark);
	}
	quickSort(A,0,n-1);
	for(i=0; i<n; ++i) {
		stability=stability && (A[i].mark==M[A[i].number].front());
		M[A[i].number].pop();
	}
	printf((stability?"Stable\n":"Not stable\n"));
	for(i=0; i<n; ++i) {
		printf("%c %d\n",A[i].mark,A[i].number);
	}
	return 0;
}

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

using namespace std;

int main() {
  int n, a;
  cin >> n >> a;
  int w = n % 500;
  if ((n < a) || (w < a) || ((w == 0) && (a == 0))) {
      cout << "Yes" << endl;
  }
  else {
      cout << "No" << endl;
  }
}

Measured memory_bytes: 3040
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#define ll long long

using namespace std; 

ll a[100001];
ll sum = 0;
int n;

int main(){
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	sum += a[0] - 1;
	ll limit = 2;
	for (int i = 1; i < n; ++i)
	{
		ll tmp_limit = limit;
		if(a[i] == limit){
			limit++;
		}

		sum += a[i]/tmp_limit;
		if(a[i] % tmp_limit == 0){
			sum--;
		} 
	}
	cout << sum << endl;
}

Measured memory_bytes: 1152
import re
import copy

def accept_input():
    a,b,c = map(int,input().split())
    return a,b,c

a,b,c = accept_input()
aamari = a%b
amaridict = {}
curamari = a%b
for i in range(b):
    curamari = (curamari+aamari)%b
    amaridict[curamari] = 1
if c in amaridict:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 9956
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H,K;
	string s;
	while(cin>>s) {
		VI h(26);
		REP(i, s.size()) h[s[i]-'a']++;
		string ans="None";
		REP(i, 26) if(h[i]==0) {ans=string(1, i+'a');break;}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>

int main(){
	int d, n, ans;
	scanf("%d %d", &d, &n);

	if (n != 100) {
		 ans = n*pow(100, d);
	}
	else
	{
		 ans = 101 * pow(100, d);
	}

	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c[256]={};
  cin>>a>>b;
  c[0]=a+b;
  c[1]=a*b;
  c[2]=a-b;
  sort(c,c+3);
  cout<<c[2]<<'\n';
  return 0;
}
  


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

constexpr int MAX = 2010;

using ll = long long int;

constexpr ll mod = 1e9 + 7;

ll ct[MAX][MAX];

int s[MAX], t[MAX];

int main()
{

    int n, m;
    std::cin >> n >> m;

    for (int i = 1; i <= n; ++i)
        std::cin >> s[i];

    for (int i = 1; i <= m; ++i)
        std::cin >> t[i];

    for (int i = 0; i <= n; ++i)
        ct[i][0] = 1;

    for (int i = 0; i <= m; ++i)
        ct[0][i] = 1;

    for (int x = 1; x <= n; ++x)
    {
        for (int y = 1; y <= m; ++y)
        {
            ct[x][y] = (ct[x - 1][y] + ct[x][y - 1] - ct[x - 1][y - 1]+mod) % mod;

            if (s[x] == t[y])
                ct[x][y] = (ct[x][y] + ct[x - 1][y - 1]) % mod;
        }
    }

    std::cout << ct[n][m] << std::endl;

    return 0;
}


Measured memory_bytes: 31744
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        long mod = (long)Math.pow(10,9)+7;
        Scanner sc = new Scanner(System.in);
        ArrayList<Count> li = new ArrayList<Count>();
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] al = new int[n];
        for(int i = 0; i < n; i++){
            al[i] = sc.nextInt();
        }
        combination comb = new combination(n);
        Arrays.sort(al);
        long ans = 0;
        for(int i = k-1; i < n; i++){
            ans += al[i] * comb.comb(i,k-1)%mod;
            ans %= mod;
        }
        for(int i = n-k; i >= 0; i--){
            ans -= al[i] * comb.comb(n-i-1,k-1) % mod;
            ans += mod;
            ans %= mod;
        }
        System.out.println(ans);
    }
    
    public static long nCk(long n,long k,long M) {
        long ret = 1;
        long min = Math.min(k, n-k);
        for(long i=1;i<=min;i++) {
            ret = (ret * pow(i,M-2,M)) % M;
        }
        for(long i=n-min+1;i<=n;i++) {
            ret = (ret * i) % M;
        }
        return ret;
    }

    public static long pow(long a,long b,long M) {
        long ret = 1;
        long tmp = a;
        while(b>0) {
            if((b&1)==1){
                ret = (ret * tmp) % M;
            }
            tmp = (tmp * tmp) % M;
            b = b>>1;
        }
        return ret;
    }
    
}

class combination {
    final static long mod = (long)Math.pow(10,9)+ 7;
    private static long[] fact, ifact;
    public combination(int n){
        fact = new long[n+1];
        ifact = new long[n+1];
        fact[0] = 1;
        long ln = n;
        for (long i = 1; i <= ln; ++i){
            int ii = (int)i;
            fact[ii] = fact[ii-1]%mod * i % mod;
        }
        ifact[n] = pow(fact[n],this.mod-2);
        for (int i = n; i >= 1; --i){
            int ii = (int)i;
            ifact[ii-1] = ifact[ii]%mod*i%mod;
        }
    }
    public static long comb(int n, int k){
        if (k < 0 || k > n) return 0;
        return fact[n] % mod * ifact[k] % mod * ifact[n-k] % mod;
    }
    public static long pow(long a,long b) {
        long ret = 1;
        long tmp = a;
        while(b>0) {
            if((b&1)==1){
                ret = (ret * tmp) % mod;
            }
            tmp = (tmp * tmp) % mod;
            b = b>>1;
        }
        return ret;
    }
}

class Count{
    int p,cnt;
    public Count(int p, int c){
        this.p = p;
        this.cnt = c;
    }
}



Measured memory_bytes: 49744
#include<iostream>
#include<cmath>
using namespace std;
bool isprime(int t){
	double sqtt=sqrt(t);
	for(int i=2;(i<=sqtt);i++)
		if(t%i==0)
			return false;
	return true;
}
int main(){
	int N,t,count=0;
	cin >> N;
	for(int i=0;i<N;i++){
	cin >> t;
	if(isprime(t)) count++;
	}
	cout<< count << endl;
	return 0;
}

Measured memory_bytes: 1160
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
using namespace std;
typedef pair<ll, ll> P;



int main(void) {
	ll n, m, ans = 0, t = 0;
	cin >> n >> m;
	vector<ll>x(n), y(n), z(n),sum(n);
	for (ll i = 0;i < n;i++) {
		cin >> x[i] >> y[i] >> z[i];
	}
	for (ll i = 0;i < 2;i++){
		for (ll j = 0;j < 2;j++) {
			for (ll k = 0;k < 2;k++) {
				for (ll l = 0;l < n;l++) {
					ll s = 0;
					if (i & 1)s += x[l];
					else s -= x[l];
					if (j & 1)s += y[l];
					else s -= y[l];
					if (k & 1)s += z[l];
					else s -= z[l];
					sum[l] = s;
				}
				t = 0;
				sort(sum.begin(), sum.end(), greater<ll>());
				for (ll l = 0;l < m;l++)t += sum[l];
				ans = max(ans, t);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    Random rnd = new Random();
    Stopwatch sw = new Stopwatch();
    readonly int[] dd = { 0, 1, 0, -1, 0 };
    readonly int mod = 1000000007;
    readonly string alfa = "abcdefghijklmnopqrstuvwxyz";

    //浅いのと先に戦う。
    void Solve()
    {
       
        int N = cin.Nextint;
        var G = Enumerable.Range(0, N).Select(i => new List<int>()).ToArray();
        for (int i = 1; i < N; i++)
        {
            G[cin.Nextint - 1].Add(i);
        }
        var B = new bool[N];
        var dp = new int[N];
        var S = new Stack<int>();
        S.Push(0);
        while (S.Any())
        {
            int u = S.Pop();
            if (B[u])
            {
                if (G[u].Count == 0)
                {
                    dp[u] = 0;
                    continue;
                }
                var L = new List<int>();
                foreach (var v in G[u])
                {
                    L.Add(dp[v]);
                }
                dp[u] = L.OrderByDescending(k => k).Select((v, i) => new { v, i }).Max(k => k.v + k.i) + 1;
            }
            else
            {
                B[u] = true;
                S.Push(u);
                foreach (var v in G[u])
                {
                    S.Push(v);
                }
            }
        }

        WriteLine(dp[0]);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}

Measured memory_bytes: 31592
import java.util.*
import java.math.*;
fun main(args: Array<String>) {

    //val N = readLine()!!.split("").map{it.toInt()}
    val S = readLine()!!
    //val K = readLine()!!.split(" ").map{it.toInt()}[0]
    var ans = 0
    var min = 1000;
    for (i in 0 until S.length-2) {
        var tmp = S.substring(i..i+2).toInt()
        var t = Math.abs(tmp-753)
        if (min < t) continue
        min = t
    }

    println(min)
}


Measured memory_bytes: 33928
#include <stdio.h>
 
int main()
{
    int S,h,m,s,a;
    scanf("%d",&S);
    a=S%3600;
    s=a%60;
    m=(a-s)/60;
    h=(S-m-s)/3600;
 
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}



Measured memory_bytes: 2136
#include <stdio.h>
#include <map>
using namespace std;
typedef long long int ll;
const int N=1e3+10;
int main(){
    int n;
    ll v,a[N],temp,ans=0;
    map<ll,ll> m;
    scanf("%d%lld",&n,&v);
    for(int i=0;i<n;i++)scanf("%lld",&a[i]);
    for(int i=0;i<n;i++){
        scanf("%lld",&temp);
        for(int j=0;j<n;j++){
            if(m.find(v-temp-a[j])!=m.end())m[v-temp-a[j]]++;
            else m.insert({v-temp-a[j],1});
        }
    }
    for(int i=0;i<n;i++)scanf("%lld",&a[i]);
    for(int i=0;i<n;i++){
        scanf("%lld",&temp);
        for(int j=0;j<n;j++)if(m.find(temp+a[j])!=m.end())ans+=m[temp+a[j]];
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 65196
#include <stdio.h>
#include <stdlib.h>

int main () {
    int N, K, Q;
    scanf("%d", &N);
    scanf("%d", &K);
    scanf("%d", &Q);

    int *A = malloc((1 + Q) * sizeof(int));
    int *ans_count = calloc(1+N, sizeof(int));
    for (int i = 1; i <= Q; i++) {
        scanf("%d", &A[i]);
        ans_count[A[i]]++;
    }

    for (int i = 1; i <= N; i++) {
        if ((K - Q + ans_count[i]) > 0)
            printf("Yes\n");
        else
            printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

int N, M, K, Q, W, H, R, C;
string S;

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

    cin >> N;
    cout << (N + 1) / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	int diff = 0;
	for (int i = 1; i <= n; i++) {
		cin >> p;
		if (p != i) {
			diff++;
		}
	}

	cout << (diff <= 2 ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	a := nextInt()
	b := nextInt() //target
	nownum := 1
	tap := 0

	for i := 0; i < b; i++ {
		if nownum >= b {
			break
		}
		nownum = nownum - 1 + a
		tap++
	}

	fmt.Println(tap)

}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1776
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CompetitiveProgCsLib
{
	class MainProg
	{
		static string R => Console.ReadLine();
		static int RI => int.Parse(R);
		static double RD => double.Parse(R);
		static int[] RIs => R.Split(' ').Select(int.Parse).ToArray();
		static double[] RDs => R.Split(' ').Select(double.Parse).ToArray();
		static void Out(object obj) => Console.WriteLine(obj);
		static void Outb(bool b) => Out(b ? "Yes" : "No");
		static void OutB(bool b) => Out(b ? "YES": "NO");

		static void Main(string[] args)
		{
			var input = RIs;
			int ans = 0;
			for(;!same(input);ans++)
			{
				var a = input.Min();
				var b = input.Max();
				var c = input.Count(x => x == a);
				for(int j = 0;j < input.Length;j++ )
				{
					if(a == input[j])
					{
						if (b - a == 1 && c == 2) input[j]++;
						else
						{
							input[j] += 2;
							goto NEXT;
						}
					}
				}
				NEXT:;
			}
			Out(ans);
		}

		static bool same(int[] arg)
		{
			return arg[0] == arg[1] && arg[1] == arg[2];
		}
	}
}


Measured memory_bytes: 13396
#include <stdio.h>
#include <string.h>

int main()
{
    char s[100001];
    scanf("%s",s);

    int len = strlen(s),count = 0;
    for (int i = 0; i < len; i++)
    {
        if(s[i] == '0')count++;
    }

    if(count > len - count)
    {
        printf("%d",(len - count) * 2);
    }
    else
    {
        printf("%d",count * 2);
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
//typedef LL int;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    int h,w,n;
    cin >> h >> w >> n;

    int a[10000];
    REP(i, n){
        cin >> a[i];
    }
    
    deque<int> dq;
    REP(i, n){
        REP(j, a[i]){
            dq.pb(i+1);
        }
    }

    deque<int> ans[100];

    REP(i, h){
        REP(j, w){
            if(i % 2 == 0){
                int x;
                x = dq.front(); dq.pop_front();
                ans[i].push_back(x);
            }else{
                int x;
                x = dq.front(); dq.pop_front();
                ans[i].push_front(x);
            }
        }
    }

    REP(i, h){
        REP(j, w){
            int x;
            x = ans[i].front(); ans[i].pop_front();
            cout << x << " "; 
        }
        cout << endl;
    }
}


Measured memory_bytes: 384
N, Q = map(int, input().split())
S = input().rstrip()

cs = [0]
cnt = 0

for i in range(N-1):
    if S[i:i+2] == 'AC':
        cnt += 1
    cs.append(cnt)

for i in range(Q):
    l, r = map(int, input().split())
    print(cs[r-1]-cs[l-1])


Measured memory_bytes: 6100
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String sl[];

    sl = r.readLine().split(" ");
    int n = Integer.parseInt(sl[0]);
    System.out.println(n * n);



  }

}


class RemRing
{
 long module;
 public RemRing(long module)
 {
   this.module = module;
 }

 public long sum(long a, long b)
 {
   return (a + b + module) % module;
 }

 public long sub(long a, long b)
 {
   return (a - b + module) % module;
 }

 public long prod(long a, long b)
 {
   return (a * b) % module;
 }

 public long div(long a, long b)
 {
   return (a * inv(b)) % module;
 }

 public long inv(long a)
 {
   long b = this.module;
   long u = 1;
   long v = 0;
   while(b > 0)
   {
     long t = a / b;
     a -= t * b;
     u -= t * v;
     long z = a;
     a = b;
     b = z;
     z = u;
     u = v;
     v = z;
   }
   u %= this.module;
   if(u < 0) u += this.module;
   return u;
 }
}


Measured memory_bytes: 21332
N = int(input())
li = []

for i in range(N):
    li.append(list(map(str, input().split())))
    li[i][1]  = int (li[i][1])


copyli = li.copy()
ans = []
##copyli.sort()
a = sorted(copyli, key = lambda copyli: copyli[1],  reverse=True)
c = sorted(a, key = lambda a: a[0])


##copyli.sort(key=attrgetter(1), reverse=True)

for i in range(N):
    for j in range(N):
        if (li[j][0] == c[i][0]) and (li[j][1] == c[i][1]):
            ans.append(j+1)

for i in range(N):
    print(ans[i])


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
 
int main() {
  string S, T;
  cin >> S;
  cin >>T;
  for(int i = 0; i < S.length(); i++ ) {
    S = S.back() + S;
    S.pop_back();
    if(S == T) {
      cout << "Yes" << endl;
      return 0;
    }
  }
 
  cout << "No" << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include<queue> 
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
priority_queue <int> q;
int a[101010],c[2020];
int main()
{
	int ans,cnt,i,k,p,mx,mn,tmp,n,j,sum=0;
	ans=1000000007;
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d%d%d",&n,&k,&p);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=1;i<=n;i++)
	{
		cnt=0;
		sum=0;
		for(j=1;j<=n;j++)
		{
			if(a[j]>=a[i])
			{
				q.push(-a[j]);
				sum++;
				if(sum>=k)
				{
					tmp=q.top();
					tmp=-tmp;
					c[++cnt]=tmp;
					q.pop();
				}
			}
			else
			{
				while(!q.empty())
					q.pop(); 
				sum=0;	
			}
		}
		if(cnt>=p)
		{
			sort(c+1,c+cnt+1);
			ans=min(ans,c[p]-a[i]);
		}
//		printf("%d %d\n",i,ans);
		while(!q.empty())
			q.pop();
		memset(c,0,sizeof(c));
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    intmax_t N, M, A[(int)1e4];
    intmax_t ans = 0;

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

    ans = N;

    for (size_t i = 0; i < M; i++) {
        ans -= A[i];
    }

    if (ans < 0) {
        puts("-1");
    } else {
        printf("%jd\n", ans);
    }

    return 0;
}


Measured memory_bytes: 2152
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
using namespace std;

int main()
{
    int a;
    cin>>a;
    a = a + a*a + a*a*a;
    cout<<a<<endl;
}


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

using ll=long long;
using namespace std;

#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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

const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

char BigAlphaToSmall(char a){
    if (a >= 65 && a <= 90){
        return a + 32;
    }
    return a;
}

char SmallAlphaToBig(char a){
    if (a >= 97 && a <= 122){
        return a - 32;
    }
    return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n;cin >> n;
    vector<int> hoge(n);
    rep_i(i, n)cin >> hoge[i];
    int sum = 0;
    int m = IINF;
    for (int i = *min_element(hoge.begin(), hoge.end()); i <= *max_element(hoge.begin(), hoge.end()); i++){
        rep_i(a, n){
            sum += (i - hoge[a])*(i - hoge[a]);
        }
        if(sum <= m){
            m = sum;
        }
        sum = 0;
    }
    say(m)
}

Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_Training
{
    public class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var x = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var xmax = x.Max();
            var xmin = x.Min();
            var RequiredMinHP = x.Sum(tmp => tmp * tmp);
            for(int p = xmin; p <= xmax; p++)
            {
                var RequiredHP = x.Sum(tmp => (tmp - p) * (tmp - p));
                RequiredMinHP = Math.Min(RequiredMinHP, RequiredHP);
            }
            Console.WriteLine(RequiredMinHP);
        }
    }
}


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

int main() {
	ll N; cin >> N;

	ll T = 1, A = 1;
	for (int i = 0; i < N; i++) {
		ll t, a;
		cin >> t >> a;

		ll M = max((T - 1) / t + 1, (A - 1) / a + 1);
		T = t*M;
		A = a*M;
	}

	cout << A + T << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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 long long INF = 1LL << 60;

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

  cout << s[0];
  cout << s[1];
  cout << s[2];
  cout << endl;

  return 0;
}


Measured memory_bytes: 3624
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	stdin.Split(bufio.ScanWords)
	var X, N uint64
	X = nextInt64()
	N = 100
	y := 0
	for N < X {
		y++
		N = uint64(float64(N) * 1.01)
	}
	fmt.Println(y)
}

func nextInt() int {
	stdin.Scan()
	i, err := strconv.Atoi(stdin.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextInt64() uint64 {
	stdin.Scan()
	i, err := strconv.ParseUint(stdin.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextStr() string {
	stdin.Scan()
	i := stdin.Text()
	return i
}


Measured memory_bytes: 1756
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String line;
		while(true){
			/* input from here */
			line = r.readLine();
			//s: num of hot springs, d: num of districts
			int s, d, min=100, minindex=0;
			s = Integer.parseInt(line.split("[ \t]")[0]);
			d = Integer.parseInt(line.split("[ \t]")[1]);
			if(s==0&&d==0){
				break;
			}
			//shortest direct distance from hot springs to each district
			int[] stod = new int[d];
			Arrays.fill(stod, 101);
			for(int i=0;i<s;i++){
				line = r.readLine();
				String[] t = line.split("[ \t]");
				for(int j=0;j<d;j++){
					int distj = Integer.parseInt(t[j]);
					if(distj>0&&distj<stod[j]){
						stod[j] = distj;
						if(distj<min){
							min = distj;
							minindex = j;
						}
					}
				}
			}
			//distance between districts
			int[][] dtod = new int[d][d];
			for(int i=0;i<d-1;i++){
				line = r.readLine();
				String[] t = line.split("[ \t]");
				for(int j=i+1;j<d;j++){
					dtod[i][j] = Integer.parseInt(t[j-i-1]);
				}
				for(int j=0;j<i;j++){
					dtod[i][j] = dtod[j][i];
				}
			}
			for(int j=0;j<d-1;j++){
				dtod[d-1][j] = dtod[j][d-1];
			}
			/* input till here */
			//test output
			/*
			for(int i=0;i<d;i++){
				for(int j=0;j<d;j++){
					System.out.print(dtod[i][j] + " ");
				}
				System.out.println();
			}*/
			/* processing from here */
			//shortest distance from a hot spring to the district 
			int[] dist = new int[d];
			ArrayList<Integer> doneindex = new ArrayList<Integer>();
			dist[minindex] = min;
			doneindex.add(minindex);
			int restcount = d-1, sum = min;
			//System.out.println(minindex + " FIRST:" + min); 
			while(restcount>0){
				int nextmin = 101, nextminindex = -1;
				for(int i=0;i<d;i++){
					if(doneindex.contains(i)){
						//System.out.println("already:" + i);
						continue;
					}
					if(stod[i]>0&&stod[i]<nextmin&&!doneindex.contains(i)){
						//System.out.println("d from s: " + stod[i]);
						nextmin = Math.min(stod[i],nextmin);
						nextminindex = i;
					}

					for(Integer j : doneindex){
						if(dtod[j][i]>0&&dtod[j][i]<nextmin){
							nextmin = Math.min(dtod[j][i], nextmin);
							nextminindex = i;
						}
					}
				}
				sum += nextmin;
				//System.out.println(nextminindex + " next: " + nextmin + " sum: " + sum);
				doneindex.add(nextminindex);
				restcount--;
			}

			/* processing till here */
			/* output */
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 19688
#include "bits/stdc++.h"
using namespace std;

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

int main(void) {
	int K;
	int sum = 0;
	cin >> K;
	for (int k = 1; k <= K; k++)
		for (int j = 1; j <= K; j++)
			for (int i = 1; i <= K; i++)
				sum += gcd(gcd(i, j), k);
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3624
n = int(input())
#a, b = map(int,input().split())
a = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(1,n):
    if a[i-1]<=a[i]:
        pass
    else:
        dif=a[i-1]-a[i]
        ans+=dif
        a[i]=a[i]+dif

print(ans)



Measured memory_bytes: 32064
open Batteries

let calc x li =
  let rec aux c sum = function
    | [] when sum = x -> c
    | [] -> c - 1
    | a :: al when a + sum > x -> c
    | a :: al -> aux (1 + c) (a + sum) al
  in
  aux 0 0 li

let () =
  Scanf.scanf " %d %d " (fun n x ->
      List.init n (fun _ -> Scanf.scanf " %d" (fun x -> x))
      |> List.sort (fun x y -> x - y)
      |> calc x |> Printf.printf "%d\n" )


Measured memory_bytes: 1152
var lines = [];

var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var c = lines.map(i => i.split(" ").map(i => Number(i)));
    
    // Aiを表す
    for (var a1 = 0; a1 <= 100; a1++) {
        var b1 = c[0][0] - a1
        var b2 = c[1][0] - a1
        var b3 = c[2][0] - a1

        // Biを表す
        for (var a2 = 0; a2 <= 100; a2++) {
            if (a2 + b1 !== c[0][1]) { continue }
            if (a2 + b2 !== c[1][1]) { continue }
            if (a2 + b3 !== c[2][1]) { continue }

            // Ciを表す
            for (var a3 = 0; a3 <= 100; a3++) {
                if (a3 + b1 !== c[0][2]) { continue }
                if (a3 + b2 !== c[1][2]) { continue }
                if (a3 + b3 !== c[2][2]) { continue }

                console.log("Yes");
                return (0)
            }
        }
    }
    console.log("No")

});


Measured memory_bytes: 7628
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,m; cin >> n >> m;
  vector<string> a,b;
  int cnt = 0;
  for(int i = 0; i < n; i++){
    string s; cin >> s;
    a.push_back(s);
  }
  for(int i = 0; i < m; i++){
    string s; cin >> s;
    b.push_back(s);
  }
  for(int x = 0; x < n; x++){
    for(int y = 0; y < n; y++){
      if(x + m - 1 >= n or y + m - 1 >= n) continue;
      
      bool match = true;
      for(int i = 0; i < m; i++){
        for(int j = 0; j < m; j++){
          if(a.at(x+i).at(y+j) != b.at(i).at(j)) match =false;
        }
      }
      if(match){
        cout << "Yes";
        return 0;
      }
      
    }
  }
  cout << "No";
}

Measured memory_bytes: 3608
/*
	*	Created By: 'Present_Sir'
	*	Created On: Sunday 02 August 2020 05:28:16 PM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
using namespace std;


void solve(){
    int a;
    cin>>a;
    if(a<30){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}

int32_t main(){
    IOS;
    //int t; cin>>t; while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

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

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n;
    cin >> n;
    /*
    400 以上 599 以下：8
級
600
以上 799 以下：7
級
800
以上 999 以下：6
級
1000
以上 1199 以下：5
級
1200
以上 1399 以下：4
級
1400
以上 1599 以下：3
級
1600
以上 1799 以下：2
級
1800
以上 1999 以下：1 級
    */
   int ans = 8 - (n - 400) / 200;
   cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstring>
#include <cstdio>
#define maxn 1005

using namespace std;

char s[maxn],p[maxn];
int n;

int main()
{
    scanf("%d",&n);
    scanf("%s",s);
    scanf("%s",p);
    for (int i=0;i<n;i++) printf("%c%c",s[i],p[i]);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int num[100010], primes[100010], special[100010];

void pri(){
    primes[0] = 0;
    primes[1] = 0;
    num[0] = 0;
    num[1] = 0;
    int idx=0, idx2=0;
    for(int i=2; i<=100000; i++){
        if(num[i] == 0){
            num[i] = 2;
            for(int j=i+i; j<=100000; j+=i){
                num[j] = 1;
            }
            idx+=1;
            if(num[(i+1)/2] == 2){
                idx2 +=1;
                //printf("%d %d \n", i, (i+1)/2);
            }
        }
        primes[i]=idx;
        special[i] = idx2;
    }
}

int main(){
    //printf("-----");
    pri();
    //printf("-----");
    int a, b, q, cont;

    scanf("%d", &q);
    for(int i=0; i<q; i++){
        scanf("%d %d", &a, &b);
        //if(special[b] == )
        cont = special[b] - special[a-1];
        //printf("->%d %d<-\n", special[b], special[a]);
        printf("%d\n", cont);
    }
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <limits>
#include <map>

using namespace std;

int main(){
    long n;
    cin >> n;
    map<int,int> pr;
    for(int i=1;i<n+1;i++){
        int a;cin>>a;
        pr[a]=i;
    }
    for(int i=1;i<n+1;i++){
        cout << pr[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 6912
import itertools

N, M = map(int, input().split())
G = [[0] * N for i in range(N)]
cnt = 0

for i in range(M):
    a, b = map(int, input().split())
    G[a-1][b-1] = 1
    G[b-1][a-1] = 1

if N == 1:
    print(1)
    exit()

for x in itertools.permutations(range(1, N), N-1):
    prev = 0
    for i in range(N-1):
        if G[prev][x[i]] == 0:
            break

        prev = x[i]

        if i == N-2:
            cnt += 1

print(cnt)


Measured memory_bytes: 3064
/// 0000: List of Top 3 Hills

use std::io;

fn main() {
    let mut hs: Vec<i32> = vec![];

    loop {
        let mut line = String::new();
        let _ = io::stdin().read_line(&mut line);
        let h: i32 = match line.trim().parse() {
            Ok(n) => n,
            Err(_) => break,
        };
        hs.push(h);
    }

    hs.sort_by(|a, b| b.cmp(a));

    for i in 0..3 {
        println!("{}", hs[i]);
    }
}

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

int main() {
    int N; cin >> N;
    vector<int> t(100010), x(100010), y(100010);
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    for (int i=0; i<N; ++i) cin >> t[i+1] >> x[i+1] >> y[i+1];
    
    bool flag = true;
    for (int i=0; i<N; ++i) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) {
            flag = false;
            break;
        }
        if (dist % 2 != dt % 2) {
            flag = false;
            break;
        }
    }

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
pair<int,int> z[100010];
int h,w,n;
int main(){
	cin>>w>>h>>n;
	lol(i,n)cin>>z[i].first>>z[i].second;
	sort(z,z+n,greater<pair<int,int> >());
	int ans=mod,maxi=0;
	lol(i,n){
		ans=min(ans,maxi+z[i].first);
		maxi=max(maxi,z[i].second);
	}
	ans=min(ans,maxi);
	cout<<ans<<endl;
	return 0;
}



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

#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))

using namespace std;

using ll = long long; using ull = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;

const ll MOD = 1e9+7;

int main(){
string number;
ll sum;
while(1){
cin>>number;
sum=0;
if(number[0]=='0')break;
REP(i,number.size()){
sum+=(number[i]-'0');
}
cout<<sum<<endl;
}
}


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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int q;
  cin >> q;
  while ( q-- ) {
    vector<int> h(9);    
    for ( int i = 0; i < 9; i++ ) {
      cin >> hex >> h[i];      
    }
    int k = 0;
    for ( int i = 0; i < 32; i++ ) {
      int sum = 0;
      for ( int j = 0; j < 8; j++ ) {
	sum += h[j];	
      }
      if ( (sum&(1LL<<i)) != (h[8]&(1LL<<i)) ) {
	k |= (1LL<<i);
	for ( int j = 0; j < 9; j++ ) {
	  h[j] ^= (1LL<<i);	  
	}
      }
    }

    cout << hex << k << endl;
  }
  
  return 0;
}



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

#define ll long long

using namespace std;

int main(){

    int n,x;
    vector<int> l;

    cin >> n >> x;

    int count = 0;

    l.push_back(0);

    for(int i = 1; i <= n; i++){
        int tmpl;
        cin >> tmpl;
        l.push_back(l[i - 1] + tmpl);
    }

    for(int i = 0; i < l.size(); i++){
        if(l[i] <= x){
            count++;
        }else{
            break;
        }
    }

    cout << count << endl;


    return 0;
}   

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,a;

int d_count(int x){
  int res=0;
  while(x>0){
    res++;
    x/=10;
  }
  return res;
}

vector<int> compute(int x){
  vector<int>res;
  x=x*x;
  int cnt = d_count(x);
  while(x>0){
    res.push_back(x%10);
    x/=10;
  }
  for(int i=0;i<(8-cnt);i++)res.push_back(0);
  reverse(res.begin(),res.end());
  return res;
}

int main(){
  vector<int>t;
  cin>>n;
  for(int I=1;I<=n;I++){
    t.clear();
    cin>>a;
    cout<<"Case "<<I<<':'<<endl;
    for(int i=0;i<10;i++){
      t=compute(a);

      //for(int i=0;i<t.size();i++)cout<<t[i]<<' ';cout<<endl;
      a=t[2]*1000+t[3]*100+t[4]*10+t[5];
      cout<<a<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long  n, k, q, i, x, cnt[100010]={0};
    vector<long long > a;
    cin >> n >> k >> q;
    for(i=0;i<q;i++){
        cin >> x;
        cnt[x]++;
        a.push_back(x);
    }
    for(i=1;i<=n;i++){
        if(cnt[i]>=q-k+1) cout << "Yes" <<endl;
        else cout << "No" <<endl;
    }

    return 0;
}

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

const int INF = 1e9;

pair<vector<int>, bool> bellmanFord(int start,int V,const vector<tuple<int, int, int>> edges) {
    vector<int> dist(V, INF);
    bool negativeLoop = false;
    dist[start] = 0;
    for (int i = 0; i < V; i++) {
        for (const auto& e: edges){
            int from, to, cost;
            tie(from, to, cost) = e;
            if (dist[from] < INF && dist[to] > dist[from] + cost) {
                dist[to] = dist[from] + cost;
                if (i == V - 1) {
                    return {dist, true};
                }
            }
        }
    }
    return {dist, false};
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int V, E, r;
    cin >> V >> E >> r;
    vector<tuple<int, int, int>> edges;
    for (int i = 0; i < E; i ++) {
        int from, to, cost;
        cin >> from >> to >> cost;
        edges.push_back(tuple<int, int, int>(from, to, cost));
    }
    vector<int> d; bool negLoop;
    tie(d, negLoop) = bellmanFord(r, V, edges);
    if (negLoop) {
        cout << "NEGATIVE CYCLE" << endl;
    } else {
        for (auto v: d) {
            if (v >= INF/2) cout << "INF" << endl;
            else cout << v << endl;
        }
    }
    return 0;
}


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

const int INF = 1e9;

int V, E;
vector<vector<int> > dist;
vector<vector<int> > dp;

int rec(int S = (1 << V) - 1, int to = 0) {
    if (S == 0) {
        return (to) ? INF : 0;
    }
    if (!(S & (1 << to))) {
        return INF;
    }
    int &ret = dp.at(S).at(to);
    if (ret != -1) {
        return ret;
    }
    ret = INF;
    for (int from = 0; from < V; ++from) {
        ret = min(ret, rec(S ^ (1 << to), from) + dist.at(from).at(to));
    }
    return ret;
}

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

    cin >> V >> E;
    dist.assign(V, vector<int>(V, INF));
    for (int i = 0; i < E; ++i) {
        int s, t, d;
        cin >> s >> t >> d;
        dist.at(s).at(t) = d;
    }

    dp.resize(1 << V, vector<int>(V, -1));
    int ans = rec();

    cout << ((ans == INF) ? -1 : ans) << endl;

    return 0;
}


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

int main() {
  int x, y, tmp;
  while(true) {
    cin >> x >> y;
    if(x == 0 && y == 0) { break; }
    if(x > y) { tmp = x; x = y; y = tmp; }
    cout << x << " " << y << endl;
  }
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int K;
    cin >> K;

    cout << (K / 2) * (K - K / 2) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

int main(void) {
    int N;
    cin >> N;
    set<int> st;
    for(int i=0; i<N; i++) {
        int A;
        cin >> A;
        st.insert(A);
    }

    if(st.size() == N) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


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

int binpow(int n, int k) {
    if (k == 0) return 1;
    if (k == 1) return n;
    if (k % 2 == 0) {
        int nn = binpow(n, k / 2);
        return nn*nn;
    }
    if (k % 2 == 1) {
        return n * binpow(n, k - 1);
    }
}

void solve() {
    int n;
    cin >> n;
    cout << (n / 500) * 1000 + ((n % 500) / 5) * 5;
    
}

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


Measured memory_bytes: 256