akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; (i) < ((int)(n)); ++(i))

int main() {
    ll ans = 0;
    int N;
    cin >> N;
    vector<ll> A(N + 1), B(N);
    rep(i, N + 1) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) {
        ans += min(A[i], B[i]);
        B[i] = max(0LL, B[i] - A[i]);
        ans += min(A[i + 1], B[i]);
        A[i + 1] = max(0LL, A[i + 1] - B[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 4848
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val s = readLine() ?: return
    var c = 0
    var max = 0
    s.forEach {
        if (it == 'D') {
            c--
        } else {
            c++
        }
        max = Math.max(max, c)
    }
    println(max.toString())
}


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

int N, M, Q;
vector<int> a(50), b(50), c(50), d(50);
int ans = 0;

void dfs(int n, vector<int> A, int tail) {
  if (n == N) {
    int tmp = 0;
    for (int i = 0; i < Q; i++) {
      if (A.at(b.at(i)) - A.at(a.at(i)) == c.at(i)) {
        tmp += d.at(i);
      }
    }
    ans = max(ans, tmp);
    return;
  }
  for (int i = tail; i <= M; i++) {
    A.at(n) = i;
    dfs(n+1, A, i);
  }
}

int main() {
  cin >> N >> M >> Q;
  for (int i = 0; i < Q; i++) {
    cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
    a.at(i)--; b.at(i)--;
  }
  vector<int> A(N);
  dfs(0, A, 1);
  cout << ans << endl;
}

Measured memory_bytes: 3596
import java.util.Scanner;

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

    int N = scanner.nextInt();
    double m = 0.d;
    for (int i = 0; i < N; i++) {
      int a = scanner.nextInt();
      m += 1.d / a;
    }

    System.out.println(1.d / m);
  }
}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    string s;
    cin >> s;
    int ans = 0, l = 0, r = s.size() - 1;
    while(l < r){
        if(s[l] != s[r]) ans++;
        l++;
        r--;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int n,k,x,y;
    cin >> n >> k >> x >> y;
    int ret = 0;
    if (n <= k) {
        ret = x * n;
    } else {
        ret += x * k + y * (n - k);
    }
    cout << ret << endl;
}


Measured memory_bytes: 256
#include <iostream>
//#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL a;
    LL b;
    LL c;
    LL d;
    cin >> a >> b >> c >> d;
    LL tmp0=a*c;
    LL tmp1=a*d;
    LL tmp2=b*c;
    LL tmp3=b*d;
    LL ans=max(max(tmp0,tmp1),max(tmp2,tmp3));
    cout << ans << endl;

    return 0;
}


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

int pnjg, pnjgedit;
string input, a, b;

int main (){
	cin>>input;
	pnjg=input.length();
	for (int i=pnjg-1; i>=0; i--) {
		input.erase(i, 1);
		pnjgedit=input.length();
		if (pnjgedit%2==0){
			a=input.substr(0, pnjgedit/2);
			b=input.substr(pnjgedit/2, pnjgedit-1);
			if (a==b){
				i=-1;
				cout<<pnjgedit<<endl;
			}
		}
	}
}
	

Measured memory_bytes: 3556
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"

string st;

int getnum( int l) {
	int num = 0;
	while (isdigit(st[l])) {
		num = num * 10 + st[l] - '0';
		l++;
	}
	return num;

}
int calc(const int a,const int b,const char type) {
	if (type == '+')return a + b;
	else if (type == '-')return a - b;
	else if (type == '*')return a*b;
	else {
		if (b)return a / b;
		else {
			throw(false);
		}
	}
}

set<int> getexpr(const int l,const int r) {
	set <int>aset;
	if (l > r)assert(false);
	if (st[l] == '('&&st[r] == ')') {
		int depth = 0;
		bool kakko = true;
		for (int x = l; x <= r; ++x) {
			if (st[x] == '(') {
				depth++;
			}
			else if (st[x] == ')') {
				depth--;
			}
			if (!depth&&x != r)kakko = false;
		}
		if (kakko) {

			return getexpr(l + 1, r - 1);
		}
	}
	int depth = 0;
	bool flag = false;
	for (int x = l; x <= r; ++x) {
		if (st[x] == '(') {
			depth++;
		}
		else if (st[x] == ')') {
			depth--;
		}
		else if (st[x] == '+' || st[x] == '-' || st[x] == '*' || st[x] == '/') {
			flag = true;
			if (!depth) {
				const set<int> lset = getexpr(l, x - 1);
				const set<int> rset = getexpr(x + 1, r);
				for (auto a : lset) {
					for (auto b : rset) {
						if (st[x] == '/'&&!b)continue;
						else {
							aset.emplace(calc(a, b, st[x]));
						}
					}
				}
			}
		}
	}
	if (!flag) {
		aset.emplace(getnum(l));
	}
	return aset;
}

int main() {
	while (1) {
		cin >> st;
		if (st == "#")break;
		set<int>aset;
		bool ok = true;
		try {
			aset=getexpr(0,st.size()-1);
		}
		catch (...) {
			assert(false);
			ok = false;
		}
		
		cout << aset.size() << endl;
	}

	return 0;
}

Measured memory_bytes: 3208
def expct(x):
  return (x+1)/2

n, k = map(int, input().split())
p = list(map(int, input().split()))

expt=list(map(expct,p))

maxval=sum(expt[0:k])
curval = maxval

for i in range(1,n-k+1):
  curval -= expt[i-1]
  curval += expt[k+i-1]
#  print(maxval,curval)
  if curval>maxval:
    maxval=curval

print(maxval)




Measured memory_bytes: 24548
#include<bits/stdc++.h>
using namespace std;
char t;
int main()
{
    string a,b;
    cin>>a>>b;
    for(int i=0;i<a.size() || i<b.size() ;i++)
    {
        if(i>=a.size())
        {
            cout<<b[i];
            continue;
        }
        if(i>=b.size())
        {
            cout<<a[i];
            continue;
        }
        cout<<a[i]<<b[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

int main()
{
    int x,y;
    cin>>x;
    cin>>y;
    if(x==1){
        if(y==2 || y==4)
        cout<<"Yes";
        else cout<<"No";
    }
    else{
    string ans="No";
    int a=0,b=x;
    for(int i=0;i<=x;i++){
        if(a*2+b*4==y)
        {
            ans="Yes";
            break;
        }
        a++;
        b--;
        
        
        
    }
    cout<<ans;
    

}
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
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 MOD = 1000000007;
const long long INF = (1LL << 29);
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, q; string s; cin >> n >> q >> s;
	vector<int>a(q), b(q);
	rep(i, q)cin >> a[i] >> b[i];
	vector<int>sum(n + 1, 0);
	for (int i = 1; i < n; i++) {
		sum[i + 1] = sum[i];
		if (s[i - 1] == 'A'&&s[i] == 'C') {
			sum[i + 1]++;
		}
	}
	rep(i, q) {
		int ans = sum[b[i]] - sum[a[i]];
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3408
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int h,w,n;
  cin >> h >> w >> n;
  
  int point = max(h,w);
  int select = min(h,w);
  
  for(int i=1;i<=select;i++){
    if(i*point >= n){ cout << i << endl; return 0;}
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char s[4];
  char t[]="abc";
  int count=0,i,j;
  scanf("%s",s);
  
 for(j=0;j<3;j++){
  for(i=0;i<3;i++){
  if(s[i]==t[j]){
    count++;
  t[j]='0';
  }
  }
 }
   if(count==3)
     printf("Yes");
   else
     printf("No");
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H,W;
        while(sc.hasNextLine()){
            String[] str = sc.nextLine().split(" ");
            H = Integer.parseInt(str[0]);
            W = Integer.parseInt(str[1]);
            if(H == 0 && W == 0) break;
            for(int y = 0; y < H; y++){
                for(int x = 0;x < W; x++){
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }

}

Measured memory_bytes: 34180
#include<iostream>
#include<algorithm>
using namespace std;
//construct SA by SA-IS O(N)
#include<string>
#include<vector>
struct SA{
	string s;
	vector<int>sa;
	SA(const string&s_):s(s_)
	{
		sa=build(vector<int>(s.begin(),s.end()),256);
	}
	vector<int>induced_sort(const vector<int>&S,const vector<int>&id,const vector<bool>&SL,vector<int>last)
	{
		vector<int>first(last);
		vector<int>ret(id.size());
		ret[0]=id[0];
		for(int i=0;i<id.size();i++)
		{
			if(id[i]>=1&&!SL[id[i]-1])
			{
				ret[first[S[id[i]-1]-1]++]=id[i]-1;
			}
			else if(ret[i]>=1&&!SL[ret[i]-1])
			{
				ret[first[S[ret[i]-1]-1]++]=ret[i]-1;
			}
		}
		for(int i=id.size();i--;)
		{
			if(ret[i]>=1&&SL[ret[i]-1])
			{
				ret[--last[S[ret[i]-1]]]=ret[i]-1;
			}
		}
		return ret;
	}
	vector<int>build(vector<int>S,int maxval)
	{
		if(S.size()==1)
		{
			return(vector<int>){1,0};
		}
		S.push_back(0);
		vector<int>cnt(maxval,0);
		vector<bool>SL(S.size());//S=>true,L=>false
		for(int i=S.size();i--;)
		{
			cnt[S[i]]+=1;
			SL[i]=i+1==S.size()||S[i]<S[i+1]||S[i]==S[i+1]&&SL[i+1];
		}
		for(int i=1;i<maxval;i++)cnt[i]+=cnt[i-1];
		vector<int>last(cnt);
		vector<int>id(S.size());
		vector<int>is_LMS(S.size());
		int LMScnt=0;
		for(int i=1;i<S.size();i++)
		{
			if(!SL[i-1]&&SL[i])
			{
				is_LMS[i]=1;
				id[--cnt[S[i]]]=i;
				LMScnt+=1;
			}
		}
		id=induced_sort(S,id,SL,last);
		int LMSsub=1;
		int pre=-1;
		is_LMS[id[0]]=LMSsub++;
		for(int i=1;i<id.size();i++)
		{
			if(is_LMS[id[i]])
			{
				if(pre>=0&&S[pre]==S[id[i]])
				{
					int k;
					for(k=1;S[pre+k]==S[id[i]+k]&&!is_LMS[pre+k]&&!is_LMS[id[i]+k];k++);
					LMSsub-=S[pre+k]==S[id[i]+k]&&is_LMS[pre+k]&&is_LMS[id[i]+k];
				}
				pre=id[i];
				is_LMS[id[i]]=LMSsub++;
			}
		}
		vector<int>newstr(LMScnt);
		vector<int>rev(LMScnt);
		int counter=0;
		for(int i=0;i<S.size();i++)
		{
			if(is_LMS[i])
			{
				newstr[counter]=is_LMS[i];
				rev[counter]=i;
				counter+=1;
			}
		}
		vector<int>sortedLMS=build(newstr,LMSsub);
		id.assign(S.size(),0);
		for(int i=1;i<sortedLMS.size();i++)
		{
			int I=rev[sortedLMS[i]];
			id[cnt[S[I]]++]=I;
		}
		return induced_sort(S,id,SL,last);
	}
	int operator[](int i){return sa[i];}
	int lower_bound(const string&t)
	{
		int L=-1,R=sa.size();
		while(R-L>1)
		{
			int M=L+R>>1;
			if(s.compare(sa[M],t.size(),t)>=0)R=M;
			else L=M;
		}
		return R;
	}
	int upper_bound(const string&t)
	{
		int L=-1,R=sa.size();
		while(R-L>1)
		{
			int M=L+R>>1;
			if(s.compare(sa[M],t.size(),t)<=0)L=M;
			else R=M;
		}
		return R;
	}
	bool contain(const string&t)
	{
		int id=lower_bound(t);
		return id<sa.size()&&s.compare(sa[id],t.size(),t)==0;
	}
	int size(){return sa.size();}
};
main()
{
	string T,P;
	cin>>T>>P;
	SA X(T);
	int L=X.lower_bound(P);
	int R=X.upper_bound(P);
	vector<int>A;
	for(int i=L;i<R;i++)
	{
		A.push_back(X[i]);
	}
	sort(A.begin(),A.end());
	for(int a:A)cout<<a<<endl;
}




Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    n=n%10;
    if(n==2 || n==4 || n==5 || n==7 || n==9){cout<<"hon\n";}
    else if(n==0 || n==1 || n==6 || n==8){cout<<"pon\n";}
    else cout<<"bon\n";
    return 0;
}


Measured memory_bytes: 3640
let () = Scanf.scanf "%d" @@ fun n ->
  let aa = Array.init n @@ fun _ -> Scanf.scanf " %d" Fun.id in
  let ans = ref 0.0 in
  for i = 0 to n - 1 do
    ans := !ans +. 1.0 /. float_of_int aa.(i)
  done;
  Printf.printf "%f\n" (1.0 /. !ans)

Measured memory_bytes: 3916
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
using llong = long long;

llong A, B, Q;
llong s[100005];
llong t[100005];
llong x[100005];

int main() {
    cin >> A >> B >> Q;
    for (int i = 0; i < A; i++) cin >> s[i];
    for (int i = 0; i < B; i++) cin >> t[i];
    for (int i = 0; i < Q; i++) cin >> x[i];

    s[A] = t[B] = 1ll << 50ll;
    sort(s, s + A);
    sort(t, t + B);

    for (int i = 0; i < Q; i++) {
        llong si = lower_bound(s, s + A, x[i]) - s;
        llong sm = si - 1;
        llong ti = lower_bound(t, t + B, x[i]) - t;
        llong tm = ti - 1;

        llong v1, v2, v3, v4;
        v1 = v2 = v3 = v4 = 1ll << 60ll;

        if (sm >= 0) 
            v1 = labs(x[i] - s[sm]) + labs(t[ti] - x[i]) + min(labs(x[i] - s[sm]), labs(t[ti] - x[i]));

        if (tm >= 0) 
            v2 = labs(x[i] - t[tm]) + labs(s[si] - x[i]) + min(labs(x[i] - t[tm]), labs(s[si] - x[i]));

        if (sm >= 0 && tm >= 0)
            v3 = max(labs(x[i] - s[sm]), labs(x[i] - t[tm]));
        
        v4 = max(labs(s[si] - x[i]), labs(t[ti] - x[i]));

        //cout << v1 << ' ' << v2 << ' ' << v3 << ' ' << v4 << endl;
        cout << min({v1, v2, v3, v4}) << endl;
    }

    return 0;
}


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

#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())
#define pii pair<int, int>
#define mp make_pair
#define f first
#define ll long long
#define ld long double
#define s second
#define vec vector<int>

using namespace std;

const int N = (int) 1e5 + 10;
const int M = (int) 2018 * 2018;
const int K = (int) 500 + 10;
const int INF = (int) 1e9 + 7;
const int mod = (int) 1e9 + 7;
const ld EPS = (ld) 1e-9;
const ll LINF = (ll) 1e18;

int n;
bitset<M> dp;

int main() {
	#ifdef sony
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	srand(time(0));
	cin >> n;
	dp[0] = 1;
	int sum = 0;
	for (int i = 1, x; i <= n; i++) {
		cin >> x;
		sum += x;
		dp |= dp << x;
	}
	for (int i = (sum + 1) / 2; ; i++) {
		if (dp[i]) {
			cout << i;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1792
import re

A,B = map(int, input().split())
S = str(input())
ma = '^[0-9]{'+str(A)+'}-[0-9]{'+str(B)+'}$'
pattern = re.compile(ma)
m=pattern.match(S)
#print(m)
if m is not None:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion


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

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int main(){
    int N;
    bool count = false;
    cin >> N;
    
    for(int i = 1; i <= N; i++){
        string S;
        cin >> S;
        
        if(S != "Y"){
            continue;
        }
        else if(S == "Y"){
            count = true;
            break;
        }
    }
    if(count){
        cout << "Four" << endl;
    }
    else{
        cout << "Three" << endl;
    }
}

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

int main ()
{
    string s;
    cin >> s;
	char c = s[s.size()-1];
    if(c == '2' || c == '4' || c == '5' || c == '7' || c == '9'){
      cout << "hon" << '\n';
    }
  	else if(c == '0' || c == '1' || c == '6' || c == '8'){
      cout << "pon"  << '\n';
    }
  	else{
      cout << "bon"  << '\n';
    }
  	return 0;
}


Measured memory_bytes: 3580
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define mod 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll a, b, c, d, max=-1*INF;
    
    cin >> a >> b >> c >> d;

    chmax(max,a*c);
    chmax(max,a*d);
    chmax(max,b*c);
    chmax(max,b*d);

    cout << max << endl;

    return 0;
}

Measured memory_bytes: 3600
/*
                " اللهم صلي و سلم علي سيدنا محمد و علي اله وصحبه اجمعين "
*/

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define f for
#define ll long long
#define ull unsigned long long
#define endl "\n"
#define intial(s1, s2, x, dp) f(int i = 0; i < s1; i++) f(int j = 0; j < s2; j++) dp[i][j] = x;
using namespace std;
#define BI acos(-1)
#define all(a) a.begin(), a.end()
#define loop1(n) f(int i = 0; i < n; i++)
#define loop2(n) f(int j = 0; j < n; j++)
#define mem(dp) memset(dp, -1, sizeof dp);
#define oo 1e9;
void Open()
{
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
}
ll gcd(ll a, ll b)
{
    return b == 0 ? a : gcd(b, a % b);
}
void madesetprobblem()
{
    //$ $
    //less than or equal => $ 1 \leq 100 $
    //  $(1 \le A,B \le 10^5 )$
    // a[i] => $a_i$
    // a[i][j] => $a_{i,j}$
    // double qoutes ''yext''
    /*
        image
        \begine{center}
        \includegraphics{image.jpg}
        \end{center}
    */
    /*
        list
        \begin{itemize}
            \item first one
            \item second one
        \end{itemize}
    */
}
int n,m;
string s,t;
int dp[3001][3001];
int ans(int i,int j)
{
    if(i==n||j==m)
    {
        return 0;
    }
    int& ret=dp[i][j];
    if(~ret)return ret;
    if(s[i]==t[j])
    {
        ret=ans(i+1,j+1)+1;
    }
    else
    {
        ret=max(ans(i+1,j),ans(i,j+1));
    }
    return ret;

}
void ans1(int i,int j)
{
    if(i==n||j==m)
    {
        return ;
    }

    if(s[i]==t[j])
    {
        cout<<s[i];
        ans1(i+1,j+1);
    }
    else
    {
        int c1=dp[i+1][j],c2=dp[i][j+1];
        if(dp[i][j]==c1)
           ans1(i+1,j);
        else
            ans1(i,j+1);
    }

}
int main()
{
    //Open();
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>s>>t;
    mem(dp);
    n=s.size(),m=t.size();
    ans(0,0);
    ans1(0,0);
}


Measured memory_bytes: 39080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i,a,b) for(i=a;i<b;i++)
#define rloop(i,a,b) for(i=a;i>=b;i--)
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf=1000000001;
const ll INF=1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
	int n,i;
	cin>>n;
	vi a(n);
	vi color(9,0);
	loop(i,0,n){
		cin>>a[i];
	}
	loop(i,0,n){
		color[min(a[i]/400,8)]++;
	}
	int m=0,M=0;
	loop(i,0,8){
		if(color[i]>0){
			m++;
			M++;
		}
	}
	if(color[8]>0){
		M=M+color[8];
	}
	if(m==0){
		m++;
	}
	cout<<m<<" "<<M<<endl;
}

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


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

    string N;
    cin >> N;

    int sum = 0;
    for(int i = 0; i < N.length(); i++)
    	sum += (N[i]-'0');

   	if(sum % 9 == 0)
   		std::cout << "Yes\n";
   	else
   		std::cout << "No\n";

	return 0;
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<long long> vll;

int main()
{
     string N;
     cin>>N;
     if(N[0]=='7' || N[1]=='7'||N[2]=='7')
     {
         cout<<"Yes"<<endl;
     }
     else
     {
         cout<<"No"<<endl;
     }

     return 0;

}





Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

int main(){
    int A,B, a, b, ans=1000000;
    cin >> A>> B;
    for(int i=0; i < 110000; i++){
        if(int(i*0.1) == B && int(i*0.08) == A){
            ans = min(ans,i);
        } 
    }
    if(ans != 1000000) cout << ans << endl;
    else cout << -1 << endl;
}

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

int main(){

  int n;

  while(cin >> n, n){

    int a[1000],tmp,count = 0;

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

    for(int i=0;i<n-1;i++){
      for(int j=n-1;j>i;j--){
	if(a[j] < a[j-1]){

	  tmp = a[j];
	  a[j] = a[j-1];
	  a[j-1] = tmp;

	  count++;

	}
      }
    }

    cout << count << endl;

  }
}

Measured memory_bytes: 1160
program main

  implicit none
  integer :: h, n
  integer, allocatable :: a(:)
  integer :: i, j, k

  read(*,*) h, n
  allocate(a(n))
  read(*,*) a
  
  if ( sum(a) >= h )then 
    print*, "Yes"
  else
    print*, "No"
  endif
end program main


Measured memory_bytes: 1152
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define Mx 2000000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
inline int pt(int a[],int l,int r){
	int p,i,j;
	p=a[l];
	i=l;
	j=r+1;
	for(;;){
		while(a[++i]<p) if(i>=r) break;
		while(a[--j]>p) if(j<=l) break;
		if(i>=j) break;
		else swap(a[i],a[j]);
	}
	if(j==l) return j;
	swap(a[l],a[j]);
	return j;
}
inline void q_sort(int a[],int l,int r){
	int q;
	if(r>l){
		q=pt(a,l,r);
		q_sort(a,l,q-1);
		q_sort(a,q+1,r);
	}
}
map<int,int> gs;
int n,x;
int main(){
	ios_base::sync_with_stdio(false);
	int i,j;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x;
		gs[x]++;
		gs[x-1]++;
		gs[x+1]++;
	}
	int mx=0;
	for(auto it=gs.begin();it!=gs.end();it++) mx=max(mx,it->second);
	cout<<mx<<endl;
	return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <cmath>

#define MOD 1000000007

using namespace std;

typedef long long ll;

typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;

typedef pair<ll, ll> pll;
typedef pair<int, int> pi;

typedef vector<pll> vpl;
typedef vector<pi> vpi;

typedef queue<ll> ql;
typedef queue<int> qi;

template <class T>
void printv(vector<T> vc) {
    for (auto e: vc) cout << e << " ";
    cout << endl;
}

template <class T>
void printvv(vector<T> vvc) { 
    for (auto vc: vvc) {
        for (auto e: vc) cout << e << " ";
        cout << endl;
    }
}

template <class T>
void printvp(vector<pair<T, T> > vp) {
    for (auto pT: vp) cout << pT.first << " " << pT.second << endl;
}

int main() {
    int d; cin >> d;
    cout << "Christmas";
    for (int i = 0; i < 25-d; ++i) {
        cout << " Eve";
    }

    cout << "\n";

    return 0;
}

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

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

    sort(a, a+n);

    for(int i = 0;i < n;i++){
        if(b[i] == a[n-1]){
            cout << a[n-2] << endl;
        }else{
            cout << a[n-1] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int ans = A + B + C - max(A,max(B,C));
  int k = max(A,max(B,C));
  for (int i = 0; i < K; i++) {
    k *= 2;
  }
  cout << ans + k << endl;
}

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())

M = 10**9+7 # 出力の制限
N = n+3 # 必要なテーブルサイズ

g1 = [None] * (N+1) # 元テーブル
g2 = [None] * (N+1) #逆元テーブル
inverse = [None] * (N+1) #逆元テーブル計算用テーブル
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1] 

for i in range( 2, N + 1 ):
    g1[i] = ( g1[i-1] * i ) % M 
    inverse[i] = ( -inverse[M % i] * (M//i) ) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
    g2[i] = (g2[i-1] * inverse[i]) % M 

def cmb(n, r, M):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return (g1[n] * g2[r] * g2[n-r]) % M
ans = 0
prev = 0
# s = 0
for i in range((n+1)//2, n):
    tmp = (cmb(i-1, n-i-1, M) * g1[i] * g1[n-1-i])
    ans += tmp
#     ans += i*(tmp-prev)
    prev = tmp
#     print(i, tmp, g1[i], g1[n-1-i])
    ans %= M
i = n-1
ans = (i+1) * (cmb(i-1, n-i-1, M) * g1[i] * g1[n-1-i]) - ans
ans %= M
print(ans)

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

int main(){
  int K;
  cin >> K;
  if(K % 2 == 1){
    cout << (K/2)*((K/2)+1) << endl;
  }
  else{
    cout << (K/2)*(K/2) << endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 1001001001;

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

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint modPow(mint a, int n){
  //cout << a << endl;
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * modPow(a, n-1);
  else return modPow(a*a, n/2);
}

const int MAX = 200200;


int main(){
	vector<mint> fact(2000005);
	fact[0] = 1;
	for (int i = 1; i < fact.size(); i++){
		fact[i] = fact[i-1] * i;
	}		
	const auto comb = [&fact](int n, int r) {
		return fact[n] / fact[r] / fact[n-r];
	};
	ll n, m, k; cin >> n >> m >> k;
	mint t = 0, tt = 0;
	for (int i = 1; i < m; i ++) t += (mint) n * n * (m-i) * 2 * i;
	for (int i = 1; i < n; i ++) tt += (mint) m * m * (n-i) * 2 * i;
	t *= comb(k, 2) * fact[m*n-2] / fact[k] / fact[m*n-2 - (k-2)];
	tt *= comb(k, 2) * fact[m*n-2] / fact[k] / fact[m*n-2 - (k-2)];
	cout << (t+tt) << endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
	double a,b,x;
    cin>>a>>b>>x;
    x/=a;
    double S=a*b/2;
    double theta;
    if(x>S) theta=atan2(2*(a*b-x),a*a);
    else theta=atan2(b*b,2*x);
    double ans=theta*180/pi;
    printf("%.10lf\n",ans);
	return 0;
}

Measured memory_bytes: 4068
#include <stdio.h>
#include <string.h>
int main() {
    long N;
    long ans = 0;
    long A[200001];
    scanf("%ld", &N);
    for (int i = 0; i < N; i++) scanf("%ld", &A[i]);

    for (int i = 0; i < N-1; i++) {
        if (A[i]>A[i+1])  {
            ans += A[i] - A[i+1];
            A[i + 1] = A[i];
        }
    }

    printf("%ld", ans);
}

Measured memory_bytes: 3260
n = int(input())
a = list(map(int, input().split()))
MAX_A = max(a)
divide_minimam_prime = [i for i in range(MAX_A + 1)]
is_prime = [True for i in range(MAX_A + 1)]
is_prime[0] = False
is_prime[1] = False
for div in range(2,int(MAX_A**0.5) + 1):
    if is_prime[div]:
        # divが素数だった場合
        k = div
        divide_minimam_prime[k] = k
        k += div
        while k <= MAX_A:
            is_prime[k] = False
            if divide_minimam_prime[k] == k:
                divide_minimam_prime[k] = div
            k += div
# pairwise coprimeであるかどうか？
pairwise_coprime = True
use_divnum = set()
for i in range(n):
    k = a[i]
    while k != 1:
        if divide_minimam_prime[k] in use_divnum:
            pairwise_coprime = False
            break
        else:
            use_divnum.add(divide_minimam_prime[k])
        div = divide_minimam_prime[k]
        while k % div == 0 and k > 1:
            k = k // div
if pairwise_coprime: 
    print("pairwise coprime")
    exit()
from math import gcd
gcd_of_a = a[0]
for i in range(n):
    gcd_of_a = gcd(gcd_of_a, a[i])
if gcd_of_a == 1:
    print("setwise coprime")
else:
    print("not coprime")

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

void swap(int *a, int *b) {
	int x = *a;
	*a = *b;
	*b = x;
}
int main() {
	int w, n, a, b, amida[31];
	char c;
	cin >> w;
	for (int i = 1;i <= w;i++) { amida[i] = i; }
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> a >>c>> b;
		swap(&amida[a], &amida[b]);
	}
	for (int i = 1;i <= w;i++)
		cout << amida[i] << endl;
}

Measured memory_bytes: 1160
def main():
    n,k = map(int,input().split())
    p = list(map(int,input().split()))

    for i in range(n):
        p[i]=(p[i]+1)/2
    s = [0]
    for i in range(n):
        s.append(s[i]+p[i])
    m = 0
    for i in range(n-k+1):
        if m<s[i+k]-s[i]:
            m = s[i+k]-s[i]
    print(m)

if __name__ == "__main__":
    main()

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;

int main(){
    cin >> n;
    vector<ll> v(n),c(n);
    rep(i,n)cin >> v[i];
    rep(i,n)cin >> c[i];
    ll ans = 0;
    rep(i, (1 << n)){
        ll x = 0,y = 0;
        rep(j,n){
            if(i & (1 << j)){
                x += v[j];
                y += c[j];
            }
        }
        ans = max(ans,x-y);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n;
	while(cin>>n,n){
		string s,t;
		cin>>s>>t;
		if(s==t){
			cout<<0<<endl;
			continue;
		}
		map<string,int>m;
		m[s]=0;
		queue<string>q;
		q.push(s);
		while(!s.empty()){
			string a=q.front();
			q.pop();
			int g=0;
			while(a[g]==t[g])g++;
			int r=(10+t[g]-a[g])%10;
			string b=a;
			loop(i,g,n){
				b[i]=(b[i]+r-'0')%10+'0';
//				cout<<b<<" "<<r<<endl;
				if(m[b]==0||m[a]+1<m[b]){
					m[b]=m[a]+1;
					q.push(b);
					if(b==t){
						cout<<m[b]<<endl;
						goto end;
					}
				}
			}
		}
		end:;
	}
}

Measured memory_bytes: 1980
#include<stdio.h>

typedef struct{
	char name[30];
	int ten;
}team;

int main(){
	int n,i,j,k,m,h,f;
	team soccer[10],t;
	f=1;
	while(~scanf("%d",&m)){
		if(m==0)break;
		if(f!=1)printf("\n");
		f=2;
		for(i=0;i<m;i++){
			scanf(" %s %d %d %d ",soccer[i].name,&k,&n,&h);
			soccer[i].ten=3*k+h;
		}
		
		for(i=0;i<m;i++){
			for(j=0;j<m-1;j++){
				if(soccer[j].ten<soccer[j+1].ten){
					t=soccer[j];
					soccer[j]=soccer[j+1];
					soccer[j+1]=t;
				}
			}
		}
		for(i=0;i<m;i++){
			printf("%s,%d\n",soccer[i].name,soccer[i].ten);
		}
	}
	return 0;
}

Measured memory_bytes: 0
import collections
n = int(input())
v = list(map(int,input().split()))
od = [0]
ev = [0]
for i in range(n):
    if i % 2 == 0:
        od.append(v[i])
    else:
        ev.append(v[i])
        
o1, o2 = collections.Counter(od).most_common(2)
e1, e2 = collections.Counter(ev).most_common(2)
if o1[0] == e1[0]:
    if o1[1] + e1[1] == n:
        print(n//2)
        exit()
    print(n - max(o1[1] + e2[1], o2[1] + e1[1]))
else:
    print(n - (o1[1] + e1[1]))


Measured memory_bytes: 15972
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize
    }
    match n % 10 {
        2|4|5|7|9 => println!("hon"),
        0|1|6|8 => println!("pon"),
        _ => println!("bon"),
    }
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  string S;
  cin >> N >> S;
  int right = 0, left = 0;
  for(int i = 0; i < N; i++){
    if('(' == S.at(i))right++;
    else if(')' == S.at(i) && right >= 1)right--;
  }
  for(int i = N - 1; i >= 0; i--){
    if(')' == S.at(i))left++;
    else if('(' == S.at(i) && left >= 1)left--;
  }
  for(int i = 0; i < left; i++)cout << '(';
  cout << S;
  for(int i = 0; i < right; i++)cout << ')';
  return 0;
}

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

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

    int ans = 700;
    for(int i = 0; i < 3; i++){
        if(s[i] == 'o'){
            ans += 100;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	int a,b,res;
	
	for (int i = 0; i < 7; ++i) {
		cin >> a >> b;
		res = a - b > 0 ? a -b : b -a;
		cout << res << endl;

	}

	return 0;
}

Measured memory_bytes: 1164
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;

void main(){

    int[] ch = [0,6000,4000,3000,2000];
    for(int i=0;i<4;i++){
	auto s = split(readln()).to!(int[]);
	writeln(ch[s[0]]*s[1]);
    }

}

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

bool compare(tuple<string, int, int> a, tuple<string, int, int> b){
  string s1, s2; int p1, p2, i1, i2;
  tie(s1,p1,i1)=a;tie(s2,p2,i2)=b;
  if(s1!=s2) return s1<s2;
  else return p1>p2;
}
 
int main() {
  int N; cin >> N;
  vector<tuple<string, int, int>> P(N);
  for (int i=0; i<N; i++) {
    string s; int p;
    cin >> s >> p;
    P[i]=make_tuple(s,p,i+1);
  }
  if(N==1) {cout << 1 << "\n"; return 0;}
  sort(P.begin(), P.end(), compare);
  for (int i=0; i<N; i++) {
    string s; int p,ans;
    tie(s, p, ans)=P[i];
    cout << ans << "\n";
  }
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	if a == b && b == c {
		fmt.Println(1)
	} else if a == b || b == c || c == a {
		fmt.Println(2)
	} else {
		fmt.Println(3)
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define double long double
const int INF = (int)1e18 + 18;
const int maxn = (int) 1e6 + 6; 
using namespace std;
 
int a;
string s;
 
signed main(){
  cin >> a >> s;
  if(a >= 3200) cout << s << endl;
  else cout << "red" << endl;
  
    return 0;
}

Measured memory_bytes: 256
import math
a,b = map(int,input().split())
 
count = 0
for i in range(1,1001):
  if math.floor(i*0.08) == a and math.floor(i*0.1) == b:
    print(i)
    exit()
  else:
    count += 1
if count > 99:
  print(-1)

Measured memory_bytes: 3060
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(13);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

#define debug(x) cout << __LINE__ << " " << #x <<"..." << x << endl

const double PI = 3.141592653589793;

int pref[100001] ;

void solve()
{
	int n,q;
	string s;
	cin >> n >> q >> s;
	for(int i=0;i<n;i++)
	{
		if(s[i]== 'C' && s[i-1]=='A')
		{
			pref[i] = pref[i-1]+1;
		}
		else pref[i] = pref[i-1];
	}
	while(q--)
	{
		int l,r;
		cin >> l >> r;
		cout << pref[r-1] - pref[l-1] << nl;
	}
}

int32_t main()
{
	FastIO;
	Fast_D;
	int T;
	T=1;
	while(T--) solve();
	return 0;
}



Measured memory_bytes: 4560
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int[] v = new int[5005];
        for(int i = 0;i < 5005;i++){
            v[i] = 1;
        }
        int p = 3;
        while(true){
            if(p*p > 10010){
                break;
            }else{
                if(v[(p-1)/2] == 0){
                    p += 2;
                }else{
                    int t = p*p;
                    while(t < 10010){
                        v[(t-1)/2] = 0;
                        t += 2*p;
                    }
                    p += 2;
                }
            }
        }
        while(scan.hasNext()){
        	int n = scan.nextInt();
        	if(n == 0){
        		break;
        	}else if(n%2 == 0){
        		n--;
        	}
        	for(int i = n/2;i > 1;i--){
        		if(v[i] == 1 && v[i-1] == 1){
        			System.out.println(2*(i-1)+1 + " " + (2*i+1));
        			break;
        		}
        	}
        }
	}
}

Measured memory_bytes: 33508
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;
use std::collections::BTreeSet;

fn main() {
    let s = input_line_str();
    let k: usize;
    input!(k);

    let mut heap = BTreeSet::new();

    for i in 0..s.len() {
        for j in i + 1..s.len() + 1 {
            if j - i > k {
                continue;
            }
            heap.insert(&s[i..j]);
        }
    }
    println!("{}", heap.iter().nth(k - 1).unwrap());
}

Measured memory_bytes: 4476
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

ll n, m;
ll a[2001], b[2001], c[2001];

ll d[1001];

void solve(){
	for(int i = 0;i < 1001;i++){
		d[i] = INFLL;
	}

	d[0] = 0;

	for(int i = 0;i < n-1;i++){
		for(int j = 0;j < m;j++){
			if(d[a[j]] != INFLL && d[b[j]] > d[a[j]] + c[j]){
				d[b[j]] = d[a[j]] + c[j];
			}
		}
	}

	ll ans = d[n-1];

	for(int i = 0;i < n-1;i++){
		for(int j = 0;j < m;j++){
			if(d[a[j]] != INFLL && d[b[j]] > d[a[j]] + c[j]){
				d[b[j]] = d[a[j]] + c[j];
			}
		}
	}

	if(ans != d[n-1]){
		cout << "inf" << endl;
	}else{
		cout << -ans << endl;
	}

}

int main() {
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		cin >> a[i] >> b[i] >> c[i];
		a[i]--;
		b[i]--;
		c[i] = -c[i];
	}

	solve();

	return 0;
}

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

using namespace std;

const int M = 1000000007;

vector<int> buildFail(vector<int> &p) {
  int m = p.size();
  vector<int> fail(m+1);
  int j = fail[0] = -1;
  for (int i = 1; i <= m; ++i) {
    while (j >= 0 && p[j] != p[i-1]) j = fail[j];
    fail[i] = ++j;
  }
  return fail;
}

vector<int> match(vector<int> &t, vector<int> &p, vector<int> &fail) {
  int n = t.size(), m = p.size();
  int count = 0;
  vector<int> res;
  for (int i = 0, k = 0; i < n; ++i) {
    while (k >= 0 && p[k] != t[i]) k = fail[k];
    if (++k >= m) {
      ++count; // match at t[i-m+1 .. i]
      res.push_back(i - m + 1);
      k = fail[k];
    }
  }
  return res;
}

int main () {
  int N;
  cin >> N;
  int a[N], b[N];
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

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

  int modn = 1;

  for (int i = 0; i < N-1; i++) {
    modn <<= 1;
    modn %= M;
  }

  bool ok[N + 1];
  memset(ok, true, sizeof(ok));
  for (int i = 0; i < 30; i++) {
    bool ok2[N + 1];
    memset(ok2, false, sizeof(ok2));
    for (int rev = 0; rev < 2; rev++) {
      vector<int> a2(N * 2);
      vector<int> b2(N);

      for (int j = 0; j < N * 2; j++) {
        a2[j] = (a[j % N] >> i) & 1;
      }
      for (int j = 0; j < N; j++) {
        b2[j] = ((b[j] >> i) ^ rev) & 1;
      }
      auto fail = buildFail(b2);
      auto res = match(a2, b2, fail);

      for (auto x: res) {
        ok2[x] = true;
      }
    }
    for (int j = 0; j < N; j++) {
      ok[j] = ok[j] && ok2[j];
    }
  }

  for (int i = 0; i < N; i++) {
    if (ok[i]) {
      int x = a[i] ^ b[0];
      cout << i << ' ' << x << endl;
    }
  }
}


Measured memory_bytes: 7188
#include<stdio.h>

int main(){
    int  Num[100]={0};
    char Dir[100]={0};
    int i=0, imax=0, Upper, tmp=0;
    
    for(i=1; i<=6; i++){
        scanf("%d",&Num[i]);
    }
    scanf("%s",Dir);
    //printf("%c\n", Dir[2]);
    
    //Upper = Num[1];
    for(i=0; i<sizeof(Dir)/sizeof(Dir[0]); i++){
        if(Dir[i] == 'S'){
            //Upper = Num[5];
            tmp = Num[1];
            Num[1] = Num[5];
            Num[5] = Num[6];
            Num[6] = Num[2];
            Num[2] = tmp;
        }else if(Dir[i] == 'N'){
            tmp = Num[1];
            Num[1] = Num[2];
            Num[2] = Num[6];
            Num[6] = Num[5];
            Num[5] = tmp;
        }else if(Dir[i] == 'E'){
            tmp = Num[1];
            Num[1] = Num[4];
            Num[4] = Num[6];
            Num[6] = Num[3];
            Num[3] = tmp;
        }else if(Dir[i] == 'W'){
            tmp = Num[1];
            Num[1] = Num[3];
            Num[3] = Num[6];
            Num[6] = Num[4];
            Num[4] = tmp;
        }
    }
    
    printf("%d\n", Num[1]);
    
return 0;
}


Measured memory_bytes: 2092
import bisect
def f(x,a):
  global M
  b = bisect.bisect_left(a,x)
  if x==a[min(b,M)]:
    return True
  else:
    return False
MOD = 10**9+7
N,M = map(int,input().split())
a = [-1]+[int(input()) for _ in range(M)]
a.sort()
x = 0
y = 1
for i in range(N):
  if f(i,a) and f(i+1,a):
    print(0)
    exit()
  elif f(i+1,a):
    z = 0
  else:
    z = x + y
  x = y
  y = z
print(z%MOD)


Measured memory_bytes: 7848