akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
  int N, i, box;
  float T, A, Box = 500;
  scanf("%d %f %f", &N, &T, &A);
  float H[N], h;

  for(i = 0; i < N; i ++){
    scanf("%f", &H[i]);
    H[i] = T - H[i] * 0.006;
    h = A - H[i];
    if(A - H[i] < 0){
      h = h * -1;
    }
    if(h < Box){
      Box = h;
      box = i+1;
    }
  }
  printf("%d\n", box);
  return 0;
}
/*
入力を受け取る
Aと比べる
近かったら入れ替える…？
*/


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 100005
#define INF 1000000005LL

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

int N;
ll M;
ll B[SIZE];

int main()
{
	scanf("%d%lld",&N,&M);
	ll a;
	ll ans=0;
	for(int i=0;i<N;i++){
		scanf("%lld",&a);
		B[i] = (i==0?a:(B[i-1]+a))%M;
		if(B[i]==0)ans++;
	}
	//return 0;
	if(N==1){
		printf("%d\n",ans);
		return 0;
	}
	sort(B,B+N);
	ll c=1;
	for(int i=1;i<N;i++){
		if(B[i] == B[i-1])c++;
		else{
			ans += c*(c-1)/2;
			c=1;
		}
	}
	ans += c*(c-1)/2;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 896
#include<iostream> 
using namespace std; 
int main()
{
	int R; 
	cin >> R; 
	if (R<1200)
	{
		cout << "ABC" << "\n";
	} 
	else if (R<2800)
	{
		cout << "ARC" << "\n"; 
	} 
	else
	{
		cout << "AGC" << "\n";
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n,q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<pair<char,char>> a(q);
  rep(i,q){
    cin >> a[i].F >> a[i].S;
  }
  int ok=-1,ng=n+1,mid=(ok+ng)/2;
  int pos=mid;
  while(ng-ok>1){
    mid=(ok+ng)/2;
    pos=mid;
    rep(i,q){
      if(0<=pos && pos<n && s[pos]==a[i].F){
        if(a[i].S=='R'){ pos++; } else { pos--; }
      }
    }
    if(pos<n){ ok=mid; }else{ ng=mid; }
  }
  pos = ok;

  ok=n,ng=-1,mid=(ok+ng)/2;
  int pos2=mid;
  while(ok-ng>1){
    mid=(ok+ng)/2;
    pos2=mid;
    rep(i,q){
      if(0<=pos2 && pos2<n && s[pos2]==a[i].F){
        if(a[i].S=='R'){ pos2++; } else { pos2--; }
      }
    }
    if(0<=pos2){ ok=mid; }else{ ng=mid; }
  }
  pos2 = ok;

  int ans = max(pos-pos2+1,0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 900
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
int main(){
    string s;
    cin>>s;
    if(s=="ABC"){
        cout<<"ARC"<<endl;
    }
    else{
        cout<<"ABC"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, l;
    string s[102] = {};
    cin >> n >> l;
    for (int i = 0; i < n; i++) cin >> s[i];
    sort(s, s + n);
    for (int i = 0; i < n; i++) cout << s[i];
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (){
    int r, c;
    int sum_row , sum_line;
    cin >> r >> c;
    int table[r + 1][c + 1];
    for (int i = 0; i < r ; i++){
        for (int k = 0; k < c; k ++){
            cin >> table[i][k];
        } 
    }
    
    for (int i = 0; i < r ; i++){
        sum_row = 0;
        for (int k = 0; k < c; k++){
            sum_row += table[i][k];
        }
        table[i][c] = sum_row ;
    }
    
    for (int k = 0; k < c + 1 ; k ++){
        sum_line = 0;
        for (int i = 0; i < r; i ++){
            sum_line += table[i][k];
        }
        table[r][k] = sum_line ;
    }

    for (int i = 0; i < r + 1; i ++){
        for (int k = 0; k < c + 1; k ++){
            if (k != 0) cout << " ";
            cout << table[i][k] ;
        }
         cout << endl;
    }
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define MAX 100005
using namespace std;

typedef long long ll;

bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int lg(int n)
{
	int cnt = 0;
	while(n != 1){
		n /= 2;
		cnt++;
	}
	return cnt;
}

int main()
{
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	#ifdef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int L;

	cin>>L;
	int n = lg(L) + 1;		//total number of vertices
	int m = (n * 2 - 2);

	for(int i = 0; i < n - 1; i++){
		if(check(L, i)){
			m++;
		}
	}

	cout<<n<<" "<<m<<endl;
	int k = 0;
	for(int i = n - 1; i >= 1; i--){
		cout<<i<<" "<<i+1<<" "<<0<<endl;
		cout<<i<<" "<<i+1<<" "<<(1<<k)<<endl;
		k++;
	}

	int sum = 0;
	k = n;
	for(int i = 0; i < n - 1; i++){
		if(check(L, i)){
			sum += (1<<i);
			cout<<1<<" "<<k<<" "<<(L - sum)<<endl;
		}
		k--;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>


std::string condition(int a, int b) {
  std::string cond;
  if (a > b) {
    cond = ">";
  } else if (a < b) {
    cond = "<";
  } else {
    cond = "==";
  }
  return cond;
}


int main() {
  int a, b;
  char delimiter = ' ';

  std::cin >> a >> b;
  std::cout <<
    'a' << delimiter << condition(a, b) << delimiter << 'b' << std::endl;

  return 0;
}



Measured memory_bytes: 3140
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <cctype>
#include <queue>
using namespace std;
long long b[100002];
int main()
{
	long long n, c, d, a, sum = 0;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		cin >> a;
		b[a]++;
		sum += a;
	}
	int q;
	long long t;
	cin >> q;
	for (int i = 1; i <= q; i++)
	{
		cin >> c >> d;
		t = d - c;
		sum += t * b[c];
		b[d] += b[c];
		b[c] = 0;
		cout << sum << endl;
	}
}


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

using ll = long long;
using namespace std;
constexpr ll inf = 1e15;
constexpr ll mod = 1e9+7;

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

    int N;
    cin>>N;
    vector<int> ans(N);
    int cur = N/2;
    for (int n = 0; n < N; n++) {
        cin>>ans[cur];
        if (N % 2 == 0) {
            if (n % 2 == 0) cur = N - 1 - cur;
            else cur = N - cur;
        } else {
            if (n % 2 == 0) cur = N - 2 - cur;
            else cur = N - 1 - cur;
        }
    }
    if (N % 2 == 1) reverse(begin(ans), end(ans));
    for (int a : ans) cout<<a<<" ";
    return 0;
}

Measured memory_bytes: 2944
#include<cstdio>
typedef long long ll;
int main(){
	ll a,b;
	char s;
	while(~scanf("%lld %c %lld",&a,&s,&b)){
		if(s=='+'){
			printf("%lld\n",a+b);
		}
		if(s=='-'){
			printf("%lld\n",a-b);
		}
	}
	return 0;
}

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

int main(void){
    int n;
    cin >> n;
    vector<vector<int>> red(n), blue(n);
    int x,y;
    for(int i=0; i<n; i++){
        vector<int> v(2);
        cin >> v.at(0) >> v.at(1);
        red.at(i) = v;
    }
    for(int i=0; i<n; i++){
        vector<int> v(2);
        cin >> v.at(0) >> v.at(1);
        blue.at(i) = v;
    }
    
    sort(blue.begin(), blue.end());
    int ans = 0;

    for(int i=0; i<n; i++){
        int j = 0, max = -1, place = -1;
        while(j<red.size()){
            if(red.at(j).at(0) < blue.at(i).at(0) && red.at(j).at(1) < blue.at(i).at(1) && red.at(j).at(1) > max){
                place = j;
                max = red.at(j).at(1);
            }
            j++;
        }
        if(place >= 0){
            red.erase(red.begin() + place);
            ans++;
        }
    }

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
Cs = list(map(int, input().split()))

cnt = 0
pre = -1
for a in As:
  cnt += Bs[a-1]
  if pre == a - 1:
    cnt += Cs[pre-1]
  pre = a
  
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eb emplace_back
#define eps 1e-10
#define F first
#define S second

int main() { //cast caution
    int w, h, x, y; cin >> w >> h >> x >> y;
    cout << fixed << setprecision(10);
    cout << 1.0000000000 * w * h / 2 << " ";
    cout << (w == 2 * x && h == 2 * y) << endl;
}




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

int main(){

	int i,len,cnt=0;
	char s[110];
	
	scanf("%s",&s);
	len = strlen(s);
	
	if(len%2==0){
		for(i=0;i<len/2;i++){
			if(s[i]!=s[len-1-i]) {
				cnt++;}
			//printf("%c, %c, %d\n",s[i],s[len-1-i],i);
			
		}
	}
	else {
		for(i=0;i<len/2;i++){
			if(s[i]!=s[len-1-i]) {
				cnt++;}
			//printf("%c, %c, %d\n",s[i],s[len-1-i],i);
			
		}
		
	}
	
	 printf("%d\n",cnt);
 return 0;
 }

Measured memory_bytes: 128
def conv(s):
    if s.find('.') == -1:
        s += '.'
    s = s.rstrip('0')
    t = len(s) - s.find('.') - 1
    a = int(s.replace('.', ''))
    if a == 0:
        return (0, 0)
    x, y = -t, -t
    while a % 5 == 0:
        x += 1
        a //= 5
    while a % 2 == 0:
        y += 1
        a //= 2
    return (x, y)


N, *A = open(0).read().split()
N = int(N)

d = {}
for a in A:
    t = conv(a)
    d.setdefault(t, 0)
    d[t] += 1

result = 0
xs = list(d.keys())
for i in range(len(xs)):
    x, y = xs[i]
    t = d[xs[i]]
    if x >= 0 and y >= 0:
        result += t * (t - 1) // 2
    for j in range(i + 1, len(xs)):
        m, n = xs[j]
        if x + m >= 0 and y + n >= 0:
            result += t * d[xs[j]]
print(result)


Measured memory_bytes: 25560
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int INF=10000000;
const int mod=1e9+7;
ll cnt;
int l;
int a[1000005];
int n;
vector<int> g;
void ins(int a[],int n,int g)
{
    for(int i=g;i<n;i++)
    {
        int v=a[i];
        int j=i-g;
        while(j>=0&&a[j]>v)
        {
            a[j+g]=a[j];
            j-=g;
            cnt++;
        }
        a[j+g]=v;
    }
}
void shell(int a[],int n)
{
    for(int i=1;;)
    {
        if(i>n)
            break;
        g.push_back(i);
        i=i*3+1;
    }
    for(int i=g.size()-1;i>=0;i--)
    {
        ins(a,n,g[i]);
    }
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    shell(a,n);
    cout<<g.size()<<endl;
    for(int i=g.size()-1;i>=0;i--)
    {
        printf("%d",g[i]);
        if(i)
            printf(" ");
    }
    printf("\n");
    printf("%d\n",cnt);
    for(int i=0;i<n;i++)
    {
        printf("%d\n",a[i]);
    }
    return 0;
}



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

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();

            // 整数の入力
            //long n = long.Parse(Console.ReadLine());

            // 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            //var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            string result;

            if (s == "ABC")
            {
                result = "ARC";
            }

            else
            {
                result = "ABC";
            }


            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


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

int main(){
  int N,i,t=0,total=0,x=0;

  cin>>N;

  for(i=1;i<=8;i++){
    t = N/pow(10,i);
    t = N-t*pow(10,i)-total;
    total += t;
    x += t/pow(10,i-1);
  }
  if(N%x==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

}


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

int main(void){
	int a,b;
	string op;
	cin >> a >> op >> b;
	while(op != "?"){
		if(op == "+")cout << a+b << "\n";
		else if(op == "-")cout << a-b << "\n";
		else if(op == "*")cout << a*b << "\n";
		else cout << a/b << "\n";
		cin >> a >> op >> b;
	}
	return 0;

}


Measured memory_bytes: 3124
def gcd(x, y):
    if x < y:
        x, y = y, x
    while y > 0:
        x, y = y, x % y
    return x


def main():
    A, B, C, D = map(int, input().split())
    R = int(C * D / gcd(C, D))

    tmp = B // C - (A-1) // C + B // D - (A-1) // D - B // R + (A-1) // R
    print(B-A+1-tmp)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ls p<<1
#define rs p<<1|1 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define mm make_pair
#define pi 2*acos(0.0)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout.precision(i);cout<<fixed<<ans<<endl;
#define lowbit(x) (x)&(-x)
#define out(x) {cout<<x<<endl;return 0;} 
#define all(v) v.begin(),v.end() 
#define mem(x,i) memset(x,i,sizeof(x)) 
#define mec(x,y) memcpy(x,y,sizeof(y))
#define eps 1e-8 
#define ull unsigned long long
#define cps CLOCKS_PER_SEC
using namespace std;
typedef long long ll;
const ll mod=4E18;
const int inf=0x3f3f3f3f;
ll gcd(ll x,ll y){if(y==0) return x;else return gcd(y,x%y);} 
ll ksm(ll a,ll b){ll r=1;while(b){if(b&1) r=(r*a)%mod;a=a*a%mod;b>>=1;}return r;} 
void exgcd(ll a, ll b, ll &x, ll &y, ll &d){if(!b) d=a,x=1,y=0;else exgcd(b,a%b,y,x,d),y-=a/b*x;}
ll inv(ll a, ll p){ll x,y,d;exgcd(a,p,x,y,d);x=(x%p+p)%p;return x;}
inline int read()
{
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
const int maxn=1e5+100;
int n,m,k,t;
ll x;
int main()
{
	cin>>x;
	for(ll a=-500;a<=500;a++)
	for(ll b=-500;b<a;b++)
	{
		ll sum=ksm(a,5)-ksm(b,5);
		if(sum!=x) continue;
		cout<<a<<" "<<b<<endl;
		return 0;
	}
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;


//http://drken1215.hatenablog.com/entry/2018/08/13/123600
int main(){
    ll N;cin>>N;
    string str = "";
    while(N!=0){
        int r = N%2;
        if(r<0) r+=2;
        N = (N-r)/(-2);
        str += char('0'+r);
    }
    reverse(str.begin(), str.end());
    if (str == "") str = "0"; // N = 0 のときは空文字列になってしまうので例外処理
    cout << str << endl;
}

Measured memory_bytes: 256
#abc123d
 
x,y,z,k=map(int,raw_input().split())
a=sorted(map(int,raw_input().split()),reverse=True)
b=sorted(map(int,raw_input().split()),reverse=True)
c=sorted(map(int,raw_input().split()),reverse=True)
 
ab=sorted([i+j for i in a for j in b],reverse=True)
res=sorted([ij+l for ij in ab[:k] for l in c],reverse=True)
for i in res[:k]:
	print i

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

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(n), b(n);
    vector<int> when[m] = {};
    priority_queue<int> q;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < n; i++) {
        if (m - a[i] < 0) continue;
        when[m - a[i]].push_back(b[i]);
    }
    long long res = 0;
    for (int i = m - 1; i >= 0; i--) {
        for (int j = 0; j < when[i].size(); j++) {
            q.push(when[i][j]);
        }
        if (!q.empty()) {
            res += q.top();
            q.pop();
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 6400
#include <iostream>
#include <vector>
using namespace std;
#pragma warning (disable: 4996)

int N, A[1 << 18], B[1 << 18];
int col[1 << 18];
vector<int> X[1 << 18];
vector<int> L0, L1;

int P[1 << 18];
bool used[1 << 18];

void dfs(int pos, int dep) {
	col[pos] = dep;
	if (dep == 0) L0.push_back(pos);
	else L1.push_back(pos);
	for (int i : X[pos]) {
		if (col[i] >= 0) continue;
		dfs(i, 1 ^ dep);
	}
}

int main() {
	cin >> N;
	for (int i = 1; i <= N - 1; i++) {
		cin >> A[i] >> B[i];
		X[A[i]].push_back(B[i]);
		X[B[i]].push_back(A[i]);
	}
	for (int i = 1; i <= N; i++) col[i] = -1;
	dfs(1, 0);
	if (L0.size() > L1.size()) swap(L0, L1);

	int num = N / 3;
	if (L0.size() <= num) {
		for (int i = 0; i < L0.size(); i++) {
			P[L0[i]] = 3 * (i + 1);
			used[3 * (i + 1)] = true;
		}
		int cnts = 1;
		for (int i = 0; i < L1.size(); i++) {
			while (used[cnts] == true) cnts++;
			used[cnts] = true;
			P[L1[i]] = cnts;
		}
	}
	else {
		for (int i = 0; i < L0.size(); i++) {
			if (3 * i + 1 > N) break;
			P[L0[i]] = 3 * i + 1;
			used[3 * i + 1] = true;
		}
		for (int i = 0; i < L1.size(); i++) {
			if (3 * i + 2 > N) break;
			P[L1[i]] = 3 * i + 2;
			used[3 * i + 2] = true;
		}
		int cnts = 1;
		for (int i = 1; i <= N; i++) {
			if (P[i] >= 1) continue;
			while (used[cnts] == true) cnts++;
			used[cnts] = true;
			P[i] = cnts;
		}
	}

	for (int i = 1; i <= N; i++) {
		if (i >= 2) cout << " ";
		cout << P[i];
	}
	cout << endl;
	return 0;
}

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

int main() {
    int A, B, K; cin >> A >> B >> K;
    int i = 1;
    int count = 0;
    vector<int> v;
    while(true) {
        if (A % i == 0 && B % i == 0) {
            v.push_back(i);
            count++;
        }
        if (i >= A || i >= B) {
            break;
        }
        i++;
    }
    cout << v[(int)v.size()-K] << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<time.h>

using namespace std;

int main() {
	int a, b;
	cin >> a>> b;
	if (a < 10 && b < 10) {
		cout << a * b;
		return 0;
	}
	cout << -1;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;


int main(){

   int n,k;
   int l[100];

   cin >> n >> k;
   rep(i,n) cin >> l[i];

   sort(l,l+n,greater<int>());

   int sum = 0;
   rep(i,k){
      sum += l[i];
   }

   cout << sum <<endl;


   return 0;
}

Measured memory_bytes: 256
//	created : 16/04/26
// 	author   : Rp7rf
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define vi vector<int>
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define INF 1e9

bool comp(pair<int,int> a,pair<int,int> b){
  if(a.second == b.second){
    return a.first < b.first;
  }
  return a.second > b.second;
}

int main(void){
  int n,m,in;
  while(cin>>n>>m,n+m){
    vector<pair<int,int> > ary(m);
    rep(i,m)ary[i] = mp(i+1,0);
  //  rep(i,m)cout<<ary[i].first<<endl;
  //  cout<<endl;
    rep(i,n){
      rep(j,m){
        cin>>in;
        ary[j].second += in;
      }
    }
    sort(ary.begin(),ary.end(),comp);
    rep(i,m-1)cout<<ary[i].first<<" ";
    cout<<ary[m-1].first<<endl;
  }
}

Measured memory_bytes: 1200
# ?????????O(n)????????£?????????
class union_find(object):
 	"""union-find tree"""
 	def __init__(self, length):
 		self.length = length
 		self.unionnumber=0
 		self.unionlist=[[]]
 		self.num=list(-1 for i in range(length))

 	def unite(self,i,j):
 		if self.num[i]==-1:
 			if self.num[j]==-1:
 				self.unionlist[self.unionnumber].extend([i,j])
 				self.num[i]=self.unionnumber
 				self.num[j]=self.unionnumber
 				self.unionnumber+=1
 				self.unionlist.append([])
 			else:
 				tmp=i 
 				i=j 
 				j=tmp 
 		if self.num[i]!=-1:
 			if self.num[j]!=-1:
 				if self.num[i]==self.num[j]:
 					pass
 				else:
 					self.unionlist[self.num[i]].extend(self.unionlist[self.num[j]])
 					tmp=self.num[j]
 					for k in self.unionlist[self.num[j]]:
 						self.num[k]=self.num[i]
 					self.unionlist[tmp]="del"
 			else:
 				self.num[j]=self.num[i]
 				self.unionlist[self.num[i]].append(j)

 	def same(self,i,j):
 		if self.num[i]==-1 or self.num[j]==-1:
 			return(False)
 		else:
 			return(self.num[i]==self.num[j])


n,m=input().split()
n=int(n)
m=int(m)

l=[]
union=union_find(n)
for i in range(m):
	com,a,b=input().split()
	a=int(a)
	b=int(b)
	if com=="0":
		union.unite(a,b)
	else:
		if union.same(a,b):
			print(1)
		else:
			print(0)

Measured memory_bytes: 8476
#include <bits/stdc++.h>
using namespace std;
int main ( )
{
	char a[6];
	for(int i=0;i<6;i++)
	{
		cin>>a[i];
	}
	if(a[2]==a[3]&&a[4]==a[5])
	{
		cout<<"Yes"; 
	}
	else
	{
		cout<<"No";
	}
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
 
int H, W, M;
set<i_i> st;
 
void input() {
    cin >> H >> W >> M;
    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        st.insert({a, b});
    }
}
 
void solve() {
    map<int, int> mph, mpw;
    int hmaxval = 0;
    int wmaxval = 0;
    vector<int> hmax, wmax;
    for(auto tmp : st) {
        chmax(hmaxval, ++mph[tmp.first]);
        chmax(wmaxval, ++mpw[tmp.second]);
    }
    for(auto tmp : mph) {
        if(hmaxval == tmp.second) hmax.push_back(tmp.first);
    }
    for(auto tmp : mpw) {
        if(wmaxval == tmp.second) wmax.push_back(tmp.first);
    }
    int ANS = hmaxval + wmaxval - 1;
    for(auto h : hmax) {
        for(auto w : wmax) {
            if(st.find({h, w}) == st.end()) {
                ANS++;
                cout << ANS << endl;
                return;
            }
        }
    }
    cout << ANS << endl;
}
 
int main() {
    input();
    solve();
    return 0;
}


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

int main(){
  int a, b;
  std::cin >> a >> b;
  int c = a+b;
  int d = a-b;
  int e = a*b;
  int f = max(c, d);
  int g = max(f, e);
  std::cout << g << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int N, G[10];
    int a[3][3], ck[3][3];
 
    for(int i = 0 ; i < 3 ; i++ ) {
        scanf("%d %d %d",&a[i][0],&a[i][1],&a[i][2]);
    }

    scanf("%d",&N);

    for(int j = 0 ; j < N ; j++ ){
        scanf("%d",&G[j]);
 
        for(int  x = 0 ; x < 3 ; x++ ) {
            for(int z = 0 ; z < 3 ; z++ ){
                if( G[j] == a[x][z] ) {
                    ck[x][z] = 1;
                }
            }
        }
    }

    if( (ck[1][1] == 1 && ck[2][2] == 1 && ck[0][0] == 1  )
    ||(ck[2][0] == 1 && ck[1][1] == 1 && ck[0][2] == 1  )
    ||(ck[0][0] == 1 && ck[0][1] == 1 && ck[0][2] == 1  )
    ||(ck[1][0] == 1 && ck[1][1] == 1 && ck[1][2] == 1  )
    ||(ck[2][0] == 1 && ck[2][1] == 1 && ck[2][2] == 1  )
    ||(ck[0][0] == 1 && ck[1][0] == 1 && ck[2][0] == 1  )
    ||(ck[0][1] == 1 && ck[1][1] == 1 && ck[2][1] == 1  )
    || (ck[0][2] == 1 && ck[1][2] == 1 && ck[2][2] == 1  )
    ) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }


    return 0;
}

Measured memory_bytes: 1644
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>
#include<string>
#include<numeric>
#include<set>
#include<deque>
using namespace std;

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

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

    deque<int> col;
    col.push_front(a[0]);
    int left, right, mid;

    for(int i = 1; i < n; i++){
        if(a[i] <= col[0]) col.push_front(a[i]);
        else{
            left = -1;
            right = col.size();
            while(right - left > 1){
                mid = left + (right - left) / 2;
                if(a[i] > col[mid]) left = mid;
                else right = mid;
            }
          	col[left] = a[i];
        }
    }

    cout << col.size() << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string o, e;
    cin >> o >> e;
      int n = min(o.size(), e.size());
      for(int i=0; i<n; i++){
        cout << o[i] << e[i];
      }
      if(n < o.size()) cout << o[o.size()-1];
      cout << endl;
}


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

using namespace std;

int main(){

  int n;

  while(cin>>n,n){

	vector<int> k(n);
	string s;

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

	cin>>s;

	int key=0;
	
	for(int i=0;i!=s.size();++i){
	  for(int j=0;j<k[key];++j){
		if(s[i]=='a')
		  s[i]='Z';
		else  if(s[i]=='A')
		  s[i]='z';
		else
		  s[i]--;
	  }
	  if(key==n-1)
		key=0;
	  else
		key++;
	}

	cout<<s<<endl;
	
  }

}



Measured memory_bytes: 3152
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
    int n, x, i;
    cin>>n>>x;
    int pan[n];
    int min = 1000;
    for(i=0; i<n; i++){
        cin>>pan[i];
        x -= pan[i];
        if(min>pan[i]){
            min = pan[i];
        }
    }

    cout<<n+x/min<<endl;

    
    return 0;
}


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

int main()
{
    int n;
    int c;
    int cnt[10];

    while (scanf("%d", &n), n != 0) {
        memset(cnt, 0, sizeof(cnt));

        for (int i = 0; i < n; i++) {
            scanf("%d", &c);
            cnt[c]++;
        }

        for (int i = 0; i < 10; i++) {
            if (cnt[i] == 0) {
                printf("-\n");
            }
            else {
                for (int j = 0; j < cnt[i]; j++) {
                    putchar('*');
                }
                putchar('\n');
            }
        }
    }
    
    return 0;
}



Measured memory_bytes: 2032
K,A,B = map(int,input().split())

#(方針) ビスケットの増やし方(B>A) 
#1:1回の操作で手持ちを1枚増やす(1回の操作で+1枚）
#2:2回の操作で手持ちのA枚をB枚にする(2回の操作で+3以上なら上よりお得）

ans = 0
if((B<=A+2)or(K<=A)): ans += K+1
else:
  count = A-1
  ans += A  #手持ちをA枚に
  #A枚をB枚にをできるだけ繰り返す
  if((K-count)%2 == 0):
   ans += (B-A)*((K-count)//2)
  else:
   ans += (B-A)*((K-count)//2) + 1
ans = max(K+1,ans)
print(ans)

Measured memory_bytes: 3064
package main

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

func main() {
	s := wordScanner()

	var n, d int
	scanInts(s, &n, &d)

	l := make([][]int, n)
	for i := 0; i < n; i++ {
		l[i] = make([]int, d)
		for j := 0; j < d; j++ {
			scanInts(s, &l[i][j])
		}
	}

	c := 0
	for i, a := range l[:len(l)] {
		for _, b := range l[i+1:] {
			if dist(a, b) {
				c++
			}
		}
	}

	fmt.Println(c)
}

func dist(x, y []int) bool {
	d2 := 0.0
	for i := range x {
		c := x[i] - y[i]
		d2 += float64(c) * float64(c)
	}

	tmp := int(math.Sqrt(d2))
	if d2 == float64(tmp)*float64(tmp) {
		return true
	}
	return false
}

func wordScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func scanInts(s *bufio.Scanner, vals ...*int) {
	for i := range vals {
		s.Scan()
		n, _ := strconv.Atoi(s.Text())
		*vals[i] = n
	}
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int N, Q;
  cin >> N >> Q;
  string s;
  cin >> s;

  vector<int> cnt(N, 0);
  REP (i, 1, N) {
    cnt[i] = cnt[i - 1];
    if (s[i] == 'C' && s[i - 1] == 'A') cnt[i]++;
  }

  rep (i, Q) {
    int l, r;
    cin >> l >> r;
    l--; r--;
    int ans = cnt[r];
    if (l - 1 >= 0) {
      ans -= cnt[l - 1];
      if (s[l - 1] == 'A' && s[l] == 'C') ans--;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, X;
  cin >> K >> X;
  int i = X-K+1;
  cout << i << ' ';
  while(i<X+K-1) {
    i++;
    cout << i << ' ';
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
using namespace std;
long long a[100050];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    long long k=0,c=0,d;
    for(int i=(n-1); i>=0; i--)
    {
        if(a[i]==a[i-1])
        {
            i--;
            if(c==0)
            {
                c++;
                c=a[i];
            }
            k++;
            if(k==2)
            {
                d=a[i];
                break;
            }
        }
    }
    if(k==0)
        printf("0");
    else
        printf("%lld\n",c*d);
    return 0;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
def print_ans(N, M, arr):
    """Test Case
    >>> print_ans(2, 5, [[4, 9], [2, 4]])
    12
    >>> print_ans(4, 30, [[6, 18], [2, 5], [3, 10], [7, 9]])
    130
    >>> print_ans(1, 100000,[[1000000000, 100000]])
    100000000000000
    """
    ans = 0
    tmp = M
    arr = sorted(arr)
    for ar in arr:
        if tmp > ar[1]:
            ans += ar[0] * ar[1]
        else:
            ans += ar[0] * tmp
            break
        tmp -= ar[1]
    print(ans)


if __name__ == '__main__':
    N, M = map(int, input().rstrip().split())
    arr = [list(map(int, input().rstrip().split())) for _ in range(N)]
    print_ans(N, M, arr)


Measured memory_bytes: 28612
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 998244353
#define INF 93193111451418101
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<string, string> PS;

int main() {
  string s;
  int k;
  cin >> s >> k;
  ll cnt = 0;
  char ans;
  for (auto &a : s) {
    if (a == '1') {
      cnt++;
    } else {
      ans = a;
      break;
    }
  }
  if (cnt >= k) {
    cout << 1 << endl;
  } else {
    cout << ans << endl;
  }
}

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

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

    double r;
    cin >> r;
    printf("%.19f\n", 2*r*M_PI);

    return 0;
}

Measured memory_bytes: 3836
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N;

int main(){
    cin>>N;

    int ans=0;
    for(int i=1;i<=N;i+=2){
        int x=i;
        int cnt=1;
        for(int j=2;j<=100;j++){
            int a=1;
            while(x%j==0){
                a++;
                x/=j;
            }
            if(a>0) cnt*=a;
        }
        if(cnt==8){
            ans++;
        }
    }

    cout<<ans<<endl;
}

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

template<class T> struct MinCircle {
    using point = complex<T>;
    using circle = pair<point, T>;
private : 
    const T eps = 1e-10;
    const int seed;
    int n;
    vector<point> dat;

public : 
    MinCircle (const vector<point> &dat, int seed = 1333) : 
        dat(dat), n(dat.size()), seed(seed) { }

    pair<point, T> build () {
        if (n == 1) { return {dat[0], 0}; }
        shuffle (dat.begin(), dat.end(), mt19937(seed));
        circle ret = make_circle_2p(dat[0], dat[1]);
        for (int i = 2; i < n; i++) {
            if (not inner(dat[i], ret)) {
                // MinDiskWithPoint
                ret = make_circle_2p(dat[0], dat[i]);
                for (int j = 1; j < i; j++) {
                    if (not inner(dat[j], ret)) {
                        // MinDiskWith2Point
                        ret = make_circle_2p(dat[i], dat[j]);
                        for (int k = 0; k < j; k++) {
                            if (not inner(dat[k], ret)) {
                                ret = make_circle_3p(dat[k], dat[j], dat[i]);
                            }
                        }
                    }
                }
            }
        }
        return ret;
    }

    inline bool inner (const point &a, const circle &c) {
        return norm(a - c.first) <= c.second + eps;
    }

    inline circle make_circle_2p (const point &a, const point &b) {
        point c = (a + b) / 2.0; double r = norm(a - c);
        return {c, r};
    }

    inline circle make_circle_3p (point &a, point &b, point &c) {
        double A = norm(b - c), B = norm(c - a), C = norm(a - b);
        double S = norm((a - c) * conj(b - c) - conj(a - c) * (b - c));
        point p = (A * (B + C - A) * a + B * (C + A - B) * b + C * (A + B - C) * c) / S;
        double r = norm(p - a);
        return {p, r};
    }

};

int main() {
    using point = complex<double>;
    int n;
    cin >> n;
    vector<complex<double>> dat(n);
    for (int i = 0; i < n; i++) {
        double a, b;
        cin >> a >> b;
        dat[i] = point(a, b);
    }
    
    MinCircle<double> disk(dat);
    
    double ans = disk.build().second;
    
    cout << fixed << setprecision(20) << sqrt(ans) << '\n';
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
char s[200005];
int main(){
	scanf("%s",s);
	for(int i=0;s[i]!='\0';i++){
		if(s[i]=='?'){
			if(i==0){
				if(s[i+1]=='\0'||s[i+1]=='P'||s[i+1]=='?') s[i]='D';
				else s[i]='P'; 
			}
			if(s[i-1]=='P') s[i]='D';
			if(s[i-1]=='D'&&(s[i+1]=='D'||s[i+1]=='?')) s[i]='P';
			else s[i]='D';
		}
	}
	printf("%s",s);
	return 0;
}


Measured memory_bytes: 1924
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define OO 2e18
#define oo 1e9
#define yalla ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define FILES freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define sz  100005
#define re return
#define mod  1000000007
#define pi acos(-1)
using namespace std;
///
int n;///length,numofheads
ld ans[3005][3005],prop[3005],sum;
int main()
{yalla;
 cin>>n;
 for(int i=1;i<=n;i++)
    cin>>prop[i];
 ///
 ///number of coins, number of ups
 ans[1][0]=1-prop[1];
 ans[1][1]=prop[1];
 ///
 for(int i=2;i<=n;i++)
 {
  for(int y=0;y<=n;y++)
  {
    ans[i][y]+=ans[i-1][y]*(1-prop[i]);
    if(y)
    ans[i][y]+=(prop[i]*ans[i-1][y-1]);

  }
 }
 for(int i=(n/2)+1;i<=n;i++)///last row
    sum+=ans[n][i];

 cout<<fixed<<setprecision(10)<<sum<<endl;

 re 0;
}

Measured memory_bytes: 141056
/*
    NO 
        TIME 
            TO 
                DIE
                    --007
                            */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli mod=1e9+7ll;
lli INF=1e17;
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcountll(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctzll(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clzll(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffsll(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
int fmx(int x, int y) { return (((y-x)>>(31))&(x^y))^y; }
int fmi(int x, int y) { return (((y-x)>>(31))&(x^y))^x; }
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,q,z,y,k,m;
const double pi1=3.14159265358979323846;
//matrix exponentiation is associative and distributive
lli me(lli a,lli b)
{
    lli res=1;
    while(b)
    {
        if(b&1)
        res=(res%mod*a%mod)%mod;
        a=a*a;
        a%=mod;
        b=b>>1;
    }
    return res;
}
lli mI(lli a)
{
    return (me(a,mod-2)%mod+mod)%mod;
}
bool cmp(ll a,ll b)
{
    if(a.first==b.first)
    return a.second<b.second;
    return a.first<b.first;
}
lli fact[200005];
void compb()
{
    fact[0]=1;
    for(int i=1;i<=200004;i++)
    {
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    compb();
    cin>>n>>m;
    lli temp=m;
    vector<lli> vv;
    for(int i=2;i*i<=m;i++)
    {
        lli cc=0;
        while(temp%i==0)
        {
            temp/=i;
            cc++;
        }
        if(cc)
        vv.push_back(cc);
    }
    if(temp>1)
    vv.push_back(1);
    lli ans=1;
    for(int j=0;j<vv.size();j++)
    {
        // cout<<vv[j]<<"\n";
        lli tem=(fact[vv[j]+n-1]%mod*(mI(fact[n-1])%mod*mI(fact[vv[j]])%mod)%mod)%mod;
        ans=(ans%mod*tem%mod)%mod;
    }
    cout<<ans;
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var n int
	con.Scan(&n)
	r := make([]bool, 8)
	s := 0
	for i := 0; i < n; i++ {
		var a int
		con.Scan(&a)
		if a < 3200 {
			r[a/400] = true
		} else {
			s++
		}
	}
	t := 0
	for _, a := range r {
		if a {
			t++
		}
	}
	s += t
	if t < 1 {
		t = 1
	}
	con.Println(t, s)
	return nil
}


Measured memory_bytes: 640
S=input()
H=input()

slen=len(S)
hlen=len(H)

jisho=[]
ans=False
for i in range(slen-hlen+1):
  jud=True
  for j in range(hlen):
    if S[i+j]!='?' and S[i+j]!=H[j]:
      jud=False
      break
  if jud:
    ansS=S[:i]+H+S[i+hlen:]
    ans=True
    ansS=ansS.replace('?','a')
    jisho.append(ansS)

if ans:
  jisho.sort()
  print(jisho[0])
else:
  print("UNRESTORABLE")

Measured memory_bytes: 3064
#include<stdio.h>
#define A 100
int main(){
  int n,a[A],i,count=0,change,min,j,jud = 0;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%d",&a[i]);
  }

  for(i = 0;i < n;i++){
    min = i;
    change = a[i];
    for(j = i;j < n;j++){
      if(a[j] < a[min]){
	min =j;
	
      }
    }
    if(change != a[min]){
    change = a[i];
    a[i] = a[min];
    a[min] = change;
    count++;
    }
  }

  for(i = 0;i < n-1;i++){
    printf("%d ",a[i]);
  }
  printf("%d\n%d\n",a[n-1],count);

  return 0;

}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int((x).size()))
#define fi first
#define se second
#define pb push_back
#define VI vector<int>
typedef long long ll;
typedef pair<int,int> pii;
const int maxN=200005;
const ll inf=(ll)1e15;
int n,a[maxN];
ll b[maxN];
pair<ll,ll>pre[maxN],suf[maxN];
ll Abs(ll x){return x>0?x:-x;}
ll sum(int l,int r){
  return b[r]-b[l-1];
}
int main(){
  //freopen("aa.in","r",stdin);
  int i,j;
  scanf("%d",&n);
  for(i=1;i<=n;++i){
    scanf("%d",a+i);
    b[i]=b[i-1]+a[i];
  }
  for(j=1,i=2;i<=n;++i){
    for(;j<i-1&&Abs(sum(j+2,i)-sum(1,j+1))<Abs(sum(j+1,i)-sum(1,j));++j);
    pre[i]=make_pair(sum(1,j),sum(j+1,i));
    //printf("pre %d %lld %lld\n",i,pre[i].fi,pre[i].se);
  }
  for(j=n,i=n-1;i;--i){
    for(;i<j-1&&Abs(sum(i,j-2)-sum(j-1,n))<Abs(sum(i,j-1)-sum(j,n));--j);
    suf[i]=make_pair(sum(j,n),sum(i,j-1));
    //printf("suf %d %lld %lld\n",i,suf[i].fi,suf[i].se);
  }
  ll ans=inf;
  for(i=2;i<=n-2;++i){
    ll x=max(max(pre[i].fi,pre[i].se),max(suf[i+1].fi,suf[i+1].se));
    ll y=min(min(pre[i].fi,pre[i].se),min(suf[i+1].fi,suf[i+1].se));
    ans=min(ans,x-y);
  }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

string s;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> s;
	vector<char> v;
	FOR(i, s.size()) {
		if (s[i] == 'B') {
			if (!v.empty()) v.pop_back();
		}
		else v.push_back(s[i]);
	}
	FOR(i, v.size()) cout << v[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int n,c[510],s[510],f[510],*d=c,*t=s,*g=f,i;main(){scanf("%d",&n);for(;d<c+n-1;++d,++t,++g)scanf("%d%d%d",d,t,g);*g=1;while(i<n)for(int a=0,j=i++;j<n||!printf("%d\n",a);)a=(a<s[j]?s[j]:(a/f[j]+(a%f[j]!=0))*f[j])+c[j++];}

Measured memory_bytes: 128
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = [S() for i in range(N)]
s = {}

tmp = 0
for i in range(N):
  if a[i] in s:
    s[a[i]] += 1
  else:
    s[a[i]] = 0
  tmp = max(tmp, s[a[i]])

ans = []
for i in range(N):
  if s[a[i]] == tmp:
    ans.append(a[i])
ans = list(set(ans))
ans.sort()
for i in ans:
  print(i)

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

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


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int N, M, A, B;
    cin >> N >> M;
    int H[N] = {}, res[N] = {};
    for(int i=0; i<N; i++) cin >> H[i];
    for(int i=0; i<M; i++) {
        cin >> A >> B;
        if(H[A-1]>=H[B-1]) res[B-1] = 1;
        if(H[A-1]<=H[B-1]) res[A-1] = 1;
    }
    int ans = 0;
    for(int i=0; i<N; i++) ans += (res[i] == 0 ? 1 : 0);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4400
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  vector<string>lis={"dream","dreamer","erase","eraser"};
  int l=s.length();
  vector<vector<int>>edge(l);
  rep(i,l){
    rep(j,4){
      int ll=lis[j].length();
      int f=1;
      if(i+ll>l)continue;
      rep(k,ll){
        if(s[i+k]!=lis[j][k])f=0;
      }
      if(f){edge[i].push_back(i+ll);}
    }
  }
  vector<int>used(l+1);
  function<bool(int)>dfs=[&](int now){
    if(now==l)return true;
    //used[now]=1;
    bool res=0;
    for(auto nn:edge[now]){
      if(used[nn])continue;
      res|=dfs(nn);
    }
    return res;
  };
  if(dfs(0))cout<<"YES"<<endl;
  else cout<<"NO"<<endl;




  return 0;

}


Measured memory_bytes: 4688
fn main(){
    let v: Vec<isize> = read_vec();

    let vm: Vec<isize> = vec![v[0] * v[2], v[0] * v[3], v[1] * v[2], v[1] * v[3]];

    let ans = vm.iter().max().unwrap();

    println!("{}", ans)
}

#[allow(dead_code)]
fn read<T>() -> T
where T: std::str::FromStr,
      T::Err: std::fmt::Debug
{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).expect("failed to read");
    buf.trim().parse().unwrap()
}

#[allow(dead_code)]
fn read_vec<T>() -> Vec<T>
where T: std::str::FromStr,
      T::Err: std::fmt::Debug
{
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).expect("failed to read");
    buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}


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

#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define nl "\n"
#define sp " "
#define int long long

int32_t main()
{
	FastIO ;
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	int sum=0;
	for(int i=0;i<k;i++)
	{
		sum+=a[i];
	}
	cout<<sum;
	return 0 ;
}


Measured memory_bytes: 3580
// codeforces.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <bits/stdc++.h>
using namespace std;
using ll =long long int;
constexpr ll mod = 1e12;
int main()
{
	ll n, k; cin >> n >> k;
	if (n % k == 0)cout << n / k;
	else cout << n / k + 1;
	return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 256
#85C
import sys
n , y = map(int,input().split())
a , b , c = -1,-1,-1

for i in range(n+1):
    for j in range(n-i+1):
        if i * 10000 + j * 5000 + (n-i-j) * 1000 == y:
            a,b,c = i , j , n-i-j
            print("{} {} {}".format(a,b,c))
            sys.exit()
            
print("{} {} {}".format(a,b,c))

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int a, b;
	vector<int> bo(110);
	cin>> a >> b;

	rep(i, 101) bo[i]=i;
	bo[100]=101;

	cout<< bo[b]*(int)pow(10, 2*a) << endl;
 
	return 0;
}

Measured memory_bytes: 4112