akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
   ll n,x;
   cin >> x >> n;
   set <ll> arr;
   for (int z=0;z<n;z++){
      ll temp;
      cin >> temp;
      arr.insert(temp);
   }
   for (int z=0;z<=100;z++){
      if (arr.find(x-z) == arr.end()){
         cout << x-z << endl;
         return 0;
      }
      if (arr.find(x+z) == arr.end()){
         cout << x+z << endl;
         return 0;
      }
   }
} 

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;

int main(){
  string s,t;
  cin >> s;
  cin >> t;
  
  ll count=0;
  for(int i=0; i<s.size(); i++){
    if(s[i]!=t[i]) count++;
    
  }
  
  cout << count << endl;
  
}
       
        
      
  
    

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

int main(){
  string input;
  int sum = 0;

  while(true){
    sum = 0;
    cin >> input;
    if(input[0] == '0'){
      break;
    }
    for(int i = 0;i < input.size(); i++){
      sum += input[i] - '0';
    }
    cout << sum << endl;
  }
}



Measured memory_bytes: 3220
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int K = sc.nextInt();
		boolean jud = false;

//ここまではたぶんあってる
		
		for (int i = 0; i <= K; i++) {
			for (int j = 0; j <= K; j++) {
				for (int k = 0; k <= K; k++) {
					double x = a * Math.pow(2,i);
					double y = b * Math.pow(2,j);
					double z = c * Math.pow(2,k);
					if ((i + j + k <= K) && (x < y) && (y < z)) jud = true;
				}
			}
		}
		
//ここからもたぶんあってる
		if(jud == true){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
	
	public static boolean judge(double a, double b, double c){
		if((a < b)&&(b < c)){
			return true;
		}else{
			return false;
		}
	}
	
}

Measured memory_bytes: 35660
/* code by AbhiTaker  */
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define M 1000000007
#define N 1000016
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define inf 9000000000000000000


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

    cout<<24+(24-n)<<"\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string.h>
#include <iomanip>
using namespace std;
#define int long long
#define ull unsigned long long
#define F first
#define S second
#define nl "\n"
#define ld long double
#define div 1000000007
#define pi 3.14159265358979323846

void solve()
{
    int n;cin>>n;
    int a[n]={0};
    for(int i=0;i<n-1;i++)
    {
        int x;cin>>x;
        a[x-1]++;
    }
    for(int i=0;i<n;i++)
        cout<<a[i]<<nl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int t=1;
    //cin>>t;
    //int i=1;
    while(t--)
    {
        //cout<<"Case #"<<i<<": ";
        solve();
        //i++;
    }
    return 0;
}


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

int main() {
	string s;
	cin >> s;
	for (int i = 0;i < s.size() - 1;++i) {
		if (s[i] == 'C') {
			for (int j = i;j < s.size();++j) {
				if (s[j] == 'F') {
					puts("Yes");
					return 0;
				}
			}
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
bool second_greater(const pii& left, const pii& right) {
    return left.second > right.second;
}
#endif


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

    int N, K;  cin >> N >> K;
    vi A(N); 
    set<int> st;
    REP(i, N) {
        cin >> A[i];
        st.insert(A[i]);
    }

    map<int,int> mp;
    for (int k : st) mp[k] = 0;

    REP(i, N) mp[A[i]]++;

    vector<pii> h;
    for (int k : st) h.push_back(pii(k, mp[k]));

    sort(h.begin(), h.end(), second_greater);

    int ans = 0;
    FOR(i, K, h.size()){
        ans += h[i].second;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 22004
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <math.h>
#include <vector>
 
#define MOD 1000000007
typedef long long ll;
 
using namespace std;

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

	ll t, n, ans;
	cin >> n;
	if(n%1000==0) ans = 0;
	else {
		ans = ((n/1000)+1) * 1000 - n;
	}
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include<limits>
#include <cmath>
#include <string>
typedef long long ll;
typedef long l;
using namespace std;
using std::cin ;
#define f1(i,a,b) for(i=a;i<b;i++)
#define f(i,b) for(i=0;i<b;i++)

int main(){
	int test=1,z,i,j,k;
	//cin>>test;
	vector<int> a= {1,3,5,7, 8,10,12}, b ={4, 6,9,11};
	int flag = 0,flag1 = 0,flag2 =0;
	for(z=0;z<test;z++){
		int x,y;
		cin>>x>>y;
		if(x == 2 || y == 2){
			flag = 0;
			break;
		}
		f(i,a.size()){
			if(x == a[i])
				flag1 = 1;
			if(y == a[i])
				flag2 = 1;
		}
		if(flag1 == 1 && flag2 == 1){
			flag = 1;
			break;
		} else {
			flag1 = 0;
			flag2 = 0;
		}
		f(i,b.size()){
			if(x == b[i])
				flag1 = 1;
			if(y == b[i])
				flag2 = 1;
		}
		if(flag1 == 1 && flag2 == 1){
			flag = 1;
			break;
		} else {
			flag1 = 0;
			flag2 = 0;
		}



	}
	if(flag){
		cout<<"Yes";
	} else {
		cout<<"No";
	}

	return 0;
}

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

int main(){
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  int ans=0;
  int co=0;
  rep(i,n-1){
    if(s.at(i)==s.at(i+1)){
      ans++;
    }
    else{
      co++;
    }
  }
  ans=min(ans+2*k,n-1);
  cout<<ans<<endl;
}

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

int main(){
    //n...道の数
    while(true){
        int n;
        cin >> n;

        if(n==0){
            return 0;
        }

        int time[10][10];


        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                if(i==j){
                    time[i][j] = 0;
                }else{
                    time[i][j] = 10000;
                }
            }
        }

        int m = 0;

        for(int i=0;i<n;i++){
            int a,b,c;
            cin >> a >> b >> c;
            //入力から表の作成
            time[a][b] = time[b][a] = c;
            if(a+1>m){
                m = a+1;
            }
            if(b+1>m){
                m = b+1;
            }
        }

        for(int k=0;k<m;k++){
            for(int i=0;i<m;i++){
                for(int j=0;j<m;j++){
                    time[i][j] = min(time[i][j],time[i][k]+time[k][j]);
                }
            }
        }


        int mintime = 10000;
        int town = 0;

        for(int i=0;i<m;i++){
            int sumtime = 0;
            for(int j=0;j<m;j++){
                sumtime += time[i][j];
            }
            if(mintime>sumtime){
                mintime = sumtime;
                town = i;
            }
        }

        cout << town << " " << mintime << endl;
    }
    
}


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

int main()
{
    int N;
    cin >> N;
    vector<ll> H(N);
    int count = 1;

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

    for(int i = 1; i < N; i++)
    {
        bool flag = true;
        for(int j = 0; j < i; j++)
        {
            if(H[j] > H[i])
            {
                flag = false;
                break;
            }
        }
        if(flag)count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, M = map(int, input().split())
    cnt = [0 for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        cnt[a] += 1
        cnt[b] += 1

    for c in cnt:
        if c % 2 != 0:
            return print("NO")

    print("YES")


if __name__ == '__main__':
    main()


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


struct UFDS{
private:
	vector <long long> parent,rank;
	long long num;
public:
	UFDS(long long x){
		num = x;
		rank.assign(x+1,0);
		parent.assign(x+1,0);
		for (long long i = 1 ; i <= x ; i++){
			parent[i] = i;
		}
	}
	long long findSet(long long i){
		return (parent[i] == i ? i : parent[i] = findSet(parent[i]));
	}
	long long isSame(long long i, long long j){
		return(findSet(i) == findSet(j));
	}
	void unionSet(long long i, long long j){
		if (!isSame(i,j)){
			long long x = findSet(i);
			long long y = findSet(j);
			if (rank[x] > rank[y]){
				parent[y] = x;
			}
			else{
				parent[x] = y;
				if (rank[x] == rank[y]){
					rank[y]++;
				}
			}

		}
	}
};

int main(){
	long long n,m;
	cin >> n >> m;
	UFDS uf(n+m);
	for (long long i = 0 ; i < n ; i++){
		long long k;
		cin >> k;
		for (long long j = 0 ; j < k ; j++){
			long long zz;
			cin >> zz;
                        //cout << i+1<< " " << n+1+zz << endl;
 			uf.unionSet(i+1,n+zz);
                        
		}
	}
        
	for (long long i = 2 ; i <= n; i++){
		//cout << uf.isSame(i,1) << endl;
		if (!uf.isSame(i,1)){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;


}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int k = sc.nextInt();
		int s = sc.nextInt();
		
		int[] nums = new int[k+1];
		
		for(int i=0; i<nums.length; i++) {
			nums[i] = i;
		}
		int count = 0;
		for(int i=0; i<nums.length; i++) {
			int x = nums[i];
			for(int j=0; j<nums.length; j++) {
				int y = nums[j];
				int z = s - x - y;
				if(z>=0 && z<=k) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 22996
use proconio::input;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
        b: [usize; n],
        c: [usize; n-1],
    }

    solve(n, &a, &b, &c);
}

fn solve(n: usize, a: &[usize], b: &[usize], c: &[usize]) {
    let mut s = 0;
    for i in 0..n {
        s += b[i];
    }
    for i in 0..(n - 1) {
        if a[i] + 1 == a[i + 1] {
            s += c[a[i] - 1];
        }
    }
    println!("{}", s);
}


Measured memory_bytes: 2156
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define endl "\n"
using namespace std;
 
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}





void test_case() {

    
    

    string s;
    cin>>s;

    int a =0 , b = 0;

    for(auto it : s) {
        if(it ==  'A' ) {
            a++;
        } else {
            b++;
        }
    }

    if( a > 0 && b > 0) {
        yes;
    } else {
        no;
    }



    




  

    


}
 
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);
 
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
 
 
    int t = 1;
    // cin >> t;
    while (t--)
    {
        test_case();
    }
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <deque>
using namespace std;
int min(int a,int b){
    return a<b?a:b;
}
int main(void){
    int N;
    int A[3][3];
    int check[3][3] = {{0},{0}};
    bool bingo = false;
    
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> A[i][j];
        }
    }
    
    cin >> N;
    for(int i=0;i<N;i++){
        int b;
        cin >> b;
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(A[j][k] == b){
                    check[j][k]++;
                }
            }
        }
    }
    for(int i=0;i<3;i++){
        if(check[i][0] == 1 && check[i][1] == 1 && check[i][2] == 1){
            bingo = true;
            break;
        }
        if(check[0][i] == 1 && check[1][i] == 1 && check[2][i] == 1){
            bingo = true;
            break;
        }
    }
    if(check[0][0] == 1 && check[1][1] == 1 && check[2][2] == 1 || check[0][2] == 1 && check[1][1] == 1 && check[2][0] == 1){
        bingo = true;
    }
    if(bingo){
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};


//-----------------------------------------------------------------------------

int n,a,b;
int cnt=0;

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

	cin>>n>>a>>b;
	REP(i,n+1) {
		int tmp=0,j=i;
		while(j>0) tmp+=j%10,j/=10;
		if(tmp>=a&&tmp<=b) cnt+=i;
	}
	cout<<cnt<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int i = 0;
        
        for(i = 1; i <= 10000; i++){
            int x = sc.nextInt();
            if(x == 0){
                break;
            }
            System.out.printf("Case %d: %d\n", i, x);
        }
    }
}



Measured memory_bytes: 66968
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(b % a == 0){
      System.out.println(a + b);
    }else{
      System.out.println(b - a);
    }
  }
}


Measured memory_bytes: 23764
#include<stdio.h>

int main(void){
	
	int a, b;
	scanf("%d %d", &a, &b);

	if(a < b){
		printf("a < b\n");
	} else if (a > b){
		printf("a > b\n");
	} else if (a == b){
		printf("a == b\n");
	}

	return 0;

}

Measured memory_bytes: 1812
#include <iostream>

#define H 2000
#define W 2000

int h, w;
int L[H][W], R[H][W], U[H][W], D[H][W];
std::string s[H];

void preprocess() {
    // preprocessiong L
    for (int i=0; i<h; ++i) {
        for (int j=0; j<w; ++j) {
            if (s[i][j] != '#') {
                L[i][j] = (j == 0) ? 1 : L[i][j-1]+1;
            }
        }
    }

    // preprocessing R
    for (int i=0; i<h; ++i) {
        for (int j=w-1; j>=0; --j) {
            if (s[i][j] != '#') {
                R[i][j] = (j == w-1) ? 1 : R[i][j+1]+1;
            }
        }
    }
    // preprocessiong U
    for (int j=0; j<w; ++j) {
        for (int i=0; i<h; ++i) {
            if (s[i][j] != '#') {
                U[i][j] = (i == 0) ? 1 : U[i-1][j]+1;
            }
        }
    }
    // preprocessiong D
    for (int j=0; j<w; ++j) {
        for (int i=h-1; i>=0; --i) {
            if (s[i][j] != '#') {
                D[i][j] = (i == h-1) ? 1 : D[i+1][j]+1;
            }
        }
    }
}


int main() {
    int ans = 0;
    std::cin >> h >> w;
    for (int i=0; i<h; ++i) std::cin >> s[i];
    preprocess();
    for (int i=0; i<h; ++i) {
        for (int j=0; j<w; ++j) {
            int tmp = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3;
            ans = std::max(ans, tmp);
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


Measured memory_bytes: 66816
using System;
using static System.Console;

namespace TaxRate
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            for(int i = 0; i < 46300; i++){
                if(n == Math.Floor(i * 1.08)){
                    WriteLine(i);
                    return;
                }
            }
            WriteLine(":(");
        }
    }
}


Measured memory_bytes: 13140
n=int(input())
a=list(map(int, input().split()))
cnt=0
t=0
ans=0
tmp=0
for s in range(n):
    while t<n and tmp^a[t]==tmp+a[t]:
        tmp=tmp^a[t]
        t+=1
    ans+=t-s   
    tmp-=a[s]
print(ans)  

Measured memory_bytes: 23560
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n),t(n);
	for(int i = 0; i < n; i++){
		cin >> t[i] >> a[i];
	}

	ll T = 1,A=1;
	for(int i = 0; i < n; i++){
		//ll co = max(ceil((double)T/t[i]),ceil((double)A/a[i]));
		ll x = T/t[i];
		ll y = A/a[i];
		if(T%t[i] != 0) x++;
		if(A%a[i] != 0) y++;
		ll co = max(x,y);
		T = co * t[i];
		A = co * a[i];
	}

	cout << T+A << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
using namespace std;
int main (void) {
    int N;
    bool rate[8];
    int cnt = 0;
    int mi = 0;
    int ma = 0;

    for (int i = 0; i < 8; i++) rate[i] = false;

    cin >> N;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (a >= 3200) cnt++;
        else rate[a / 400] = true;
    }

    for (int i = 0; i < 8; i++) {
        if (rate[i]) mi++;
    }

    ma = mi + cnt;
    if (mi == 0) mi = 1;

    cout << mi << " " << ma << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N;
    cin >> N;
    vector<long long> a(N - 1);
    vector<long long> num(N, 0);
    for(int i =0 ;i < N - 1; i++) {
        cin >> a[i];
        a[i]--;
        num[a[i]]++;
    }
    for(int i =0; i < N; i++){
        cout << num[i] << endl;
    }
}

Measured memory_bytes: 6352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
int main() {
	ll h,n,a[10010],b[10010];
	ll dp[30000];
	cin>>h>>n;
	for(ll i=0;i<30000;i++){
		dp[i]=INF;
	}
	dp[0]=0;
	for(ll i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		a[i]=x;
		b[i]=y;
	}
	ll ans=INF;
	for(ll i=0;i<h;i++){
		for(ll j=0;j<n;j++){
			dp[i+a[j]]=min(dp[i+a[j]],dp[i]+b[j]);
		//	cout << i+a[j]<<" "<< i<< " "<<dp[i+a[j]]<<" "<<b[j]<<endl;
			if(i+a[j]>=h){
				ans=min(ans,dp[i+a[j]]);
			}
		}
	}
	cout <<ans;
	return 0;
}

Measured memory_bytes: 512
#!/usr/bin/env python3
import sys
import math
import collections


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    list_counter = collections.Counter()

    for i in range(1, math.floor(N**(1/2))+1):
        for j in range(1,  math.floor(N**(1/2))+1):
            for k in range(1,  math.floor(N**(1/2))+1):
                n = i**2 + j**2 + k**2 + i*j + j*k + k*i
                list_counter.update({n: 1})

    for n in range(1, N+1):
        print(list_counter[n])


    # oj t -c "pypy3 main.py"
    # acc s main.py -- --guess-python-interpreter pypy
main()


Measured memory_bytes: 88996
import java.io.*;
import java.util.StringTokenizer;
import java.util.Arrays;

class Main{

static final PrintWriter out=new PrintWriter(System.out);
static final int INF=Integer.MAX_VALUE/2;

public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String line="";
while((line=br.readLine())!=null&&!line.isEmpty()){
StringTokenizer st=new StringTokenizer(line);
int n=Integer.parseInt(st.nextToken());
int m=Integer.parseInt(st.nextToken());
int[][] tir=new int[m+1][n+1];
Arrays.fill(tir[m],INF);
tir[m][n]=0;
int[] d=new int[n];
int[] c=new int[m];
for(int i=0;i<n;i++) d[i]=Integer.parseInt(br.readLine());
for(int i=0;i<m;i++) c[i]=Integer.parseInt(br.readLine());
for(int i=m-1;i>=0;i--){
for(int j=n-1;j>=0;j--){
tir[i][j]=Math.min(tir[i+1][j],tir[i+1][j+1]+d[j]*c[i]);
}
}
out.println(tir[0][0]);
out.flush();
}
}
}

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

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

#define dump(x) cerr << #x << " = " <<(x)<<endl;
#define debug(x) cerr << #x << " = " <<(x) << "(L" << __LINE__ << ")" << __FILE__ << endl;

#define BIT_ON(x,b) ((x)|=(b))
#define BIT_OFF(x,b) ((x)&=~(b))
#define BIT_IS_ON(x,b) (((x)&(b))==(b))


using namespace std;

typedef long long ll;

int main(void){
  ll A,B;
  ll K;
  cin >> A >> B >> K;
  ll sub = (B- A + 1)/2;
  bool odd = (B-A) % 2;
  ll oldK = K;
  K = min(K, sub);
  //cout << "K:" << K<<endl;
  FOR(i,A,A+K) cout << i << endl;
  if(!odd && oldK != K) cout << A+K << endl;
  FOR(i,B-K+1,B+1) cout << i << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=600;
int n,m,cnt1,cnt2;
long long Ans=0,f[maxn][maxn];
struct point{
	int f,s;
}p[maxn];
inline long long read(){
	long long x=0,f=1;
	char c;
	do{c=getchar();if(c=='-') f*=-1;}while(!isdigit(c));
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
	return x*f;
}
bool cmp(const point a,const point b){return (a.f==b.f)?(a.s<b.s):(a.f<b.f);}

int main(){
	n=read();m=read();
	for(int i=0;i<n;i++){
		p[i].f=sqrt((n*n-1)-i*i);
		p[i].s=min(2*n-1,(int)sqrt((4*n*n)-i*i));
	}
	for(int i=n;i<2*n;i++){
		p[i].f=sqrt((4*n*n)-i*i);
		p[i].s=0;
	}
	sort(p,p+2*n,cmp);
	for(int k=0;k<=n;k++){
		memset(f,0,sizeof(f));
		cnt1=cnt2=0;
		f[0][0]=1;
		for(int i=1;i<=2*n;i++){
			if(p[i-1].s==0){
				for(int j=0;j<=cnt1;j++){
					(f[i][j]+=f[i-1][j]*(p[i-1].f+1-cnt2-j))%=m;
				}
				cnt2++;
			}
			else{
				for(int j=0;j<=cnt1;j++){
					(f[i][j+1]+=f[i-1][j]*(p[i-1].f+1-cnt2-j))%=m;
					(f[i][j]+=f[i-1][j]*(p[i-1].s+1-n-k-(cnt1-j)))%=m;
				}
				cnt1++;
			}
		}
		Ans=(Ans+m+(k%2==0?1:-1)*f[2*n][k])%m;
	}
	printf("%lld\n",Ans);
	return 0;
}

Measured memory_bytes: 3200
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int, int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n;
    cin >> n;
    vi v;
    int x;
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> x;
        v.pb(x);
    }
    for(int i = 0; i < v.size(); i++){
        cin >> x;
        if(v[i]>x) sum+=v[i]-x;
    }
    cout << sum;
}

Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n, i, v, max, m, mmin;

    n = sc.nextInt();
    max = -1; mmin = -1;
    for(i = 0;i < n;i++){
      m = sc.nextInt(); v = sc.nextInt();
      if(max < v || (max == v && mmin > m)){
        max = v; mmin = m;
      }
    }
    out.println(mmin + " " + max);

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 17312
#include<stdio.h>
int min(int x,int y)
{
    return x<y?x:y;
}
int max(int x,int y)
{
    return x>y?x:y;
}
int n,m,sum;
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        int x;
        scanf("%d",&x);
        m=max(m,x);
        sum+=x;
    }
    if(2*m<sum)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
    long long int x, k, d,a;
    cin >> x >> k >> d;
    x = abs(x);
    if (x / d >= k)
    {
        x = abs(x - d * k);

    }
    else
    {
        a = x / d;
        k = k - x / d;
        x = abs(x) % d;
        
       /* if(k%2==1)
        {
            x = abs(abs(x) - d);
        }*/
        if (k % 2 == 1)
        {
            x = abs(x - d);
        }
       /* else
        {
            if (abs(x - d) <= abs(x + d))
                x = abs(x - d);
            else
                x = abs(x + d);
            if (abs(x - d) <= abs(x + d))
                x = abs(x - d);
            else
                x = abs(x + d);
        }*/
    }
    cout << x << endl;
    
}

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

int main () {
    int A , B; 
    cin >> A >> B;

    if (A % 2 == 1 && B % 2 == 1){
        cout << "Yes" << endl;
    }

    else {
        cout << "No" << endl;
    }
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template<class T>

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

vvi adl_input(int N,int M){ //N頂点M辺
  vvi L(N);
  rep(i,M){
    int a,b;
    cin >> a >> b;
    //a--;b--;
    L[a].push_back(b);
    L[b].push_back(a);
  }
  return L;
}

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

vector<int> bfs(vvi L,int S){ //List,Start
  vector<int> v(L.size(),-1);
  v[S]=0;
  queue<int> q;
  q.push(S);
  while(!q.empty()){
    int a=q.front();
    q.pop();
    for(int x:L[a]){
      if (v[x]==-1){
        v[x]=v[a]+1;
        q.push(x);
      }
    }
  }
  return v;//startからの距離
}

void initialize(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << fixed << setprecision(15);
}

/////////////////////////////////////////

int main(){
  initialize();
  int N;
  cin >> N;
  int A[N];
  int M1=0;
  int M2=0;
  rep(i,N){
    cin >> A[i];
    M2=max(A[i],M2);
    if(M2>M1) swap(M1,M2);
  }
  rep(i,N){
    if(A[i]==M1) cout << M2 << endl;
    else cout << M1 << endl;
  }
  return 0;
}

Measured memory_bytes: 2432
n,m,x=map(int,input().split())
c=[]
a=[]
for i in range(n):
  tmp = list(map(int, input().split()))
  c.append(tmp[0])
  a.append(tmp[1:])


result = -1
for i in range(2**n):
  skill = [0]*m
  cost = 0
  for j in range(n):
    if (i >> j) & 1 == 0:
      continue
    cost += c[j]
    for s in range(m):
      skill[s] += a[j][s]

  if all(s >= x for s in skill):
    if result == -1:
      result = cost
    else:
      result = min(result,cost)
print(result)

Measured memory_bytes: 9060
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    map<string, int>mp;
    for (int i=0; i<N; i++){
        string S; cin >> S;
        mp[S]++;
    }
    int mx=0;
    for (auto p : mp) mx = max(mx, p.second);
    for (auto p : mp) {
        if (p.second == mx) cout << p.first << endl;
        else continue;
    }
    return 0;
}

Measured memory_bytes: 25216
N, K = map(int, input().split())

D = list(map(int, input().split()))

i = N
while i >= N:
  work = i
  while work > 0:
    if work % 10 in D:
      break
    else:
      work = work // 10

  if work > 0:
    i += 1
    continue
  else:
    break
    
print(i)

Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
using namespace std;

int main()
{
    int num=0;
    int numa=0,numb=0,numc=0,numd=0,nume=0;

    cin >> num >> numa >> numb;
    if(numa*num<numb){
        cout << numa *num;
    }else{
        cout << numb;
    }

    cout << endl;
    return 0;
}

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

typedef long long ll;

int Mod = 1000000007;
ll fact[1010],fact_inv[1010];

ll exp(ll a,ll b) {
	if (b == 0) return 1;
	else if (b == 1) return a;
	else {
		ll c = exp(a,b/2);
		if (b%2) return (((c*c)%Mod)*a)%Mod;
		else return (c*c)%Mod;
	}
}

ll combi(ll a,ll b) {
	return (((fact[a]*fact_inv[b])%Mod)*fact_inv[a-b])%Mod;
}

int main() {
	int n,a,b,c,d;
	cin >> n >> a >> b >> c >> d;
	vector<vector<ll>> dp(1010,vector<ll>(1010,0));

	fact[0] = 1;
	for (int i = 1;i < 1010;++i) fact[i] = (fact[i-1]*i)%Mod;
	for (int i = 0;i < 1010;++i) fact_inv[i] = exp(fact[i],Mod-2);

	dp[a-1][0] = 1;
	for (int i = a;i <= b;++i) {
		for (int j = 0;j <= n;++j) {
			if (dp[i-1][j] == 0) continue;
			dp[i][j] += dp[i-1][j];
			dp[i][j] %= Mod;
			for (int k = c;k <= min((n-j)/i,d);++k) {
				dp[i][j+i*k] += (((((((dp[i-1][j]*fact[n-j])%Mod)*fact_inv[n-j-i*k])%Mod)*exp(fact_inv[i],k))%Mod)*fact_inv[k])%Mod;
				dp[i][j+i*k] %= Mod;
			}
		}
	}
	
	cout << dp[b][n] << endl;

	return 0;
}

Measured memory_bytes: 8320
#include<iostream>
using namespace std;
const int maxn = 1e6+10;
int m,n;
int main()
{
	char c;
	int m=0;
	for(int i=1;i<=4;i++)
	{
		cin>>c;
		if(c=='+')m++;
		if(c=='-')m--;
	}
	cout<<m;
}

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

int dx[] = {0,1,1,0,-1,-1};
int dy[] = {1,1,0,-1,-1,0};
int t,n;
typedef pair<int,int> P;
const int C = 60;
const int MAX_N=130;
const int INF = 100000;

void solve() {
    int dist[MAX_N][MAX_N];
    bool ok[MAX_N][MAX_N];
    rep(i,MAX_N) rep(j,MAX_N) dist[i][j]=INF,ok[i][j]=true;
    int x,y;
    rep(i,n) {
        cin>>x>>y;
        x+=C;
        y+=C;
        ok[x][y]=false;
        
    }
    queue<P> que;
    cin>>x>>y;
    x+=C;
    y+=C;
    que.push(P(x,y));
    dist[x][y]=0;

    int ans = 0;
    while(que.size()) {
        P p = que.front(); que.pop();
        int x = p.first;
        int y = p.second;
        rep(i,6) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(ok[nx][ny] && dist[nx][ny] == INF) {
                dist[nx][ny] = dist[x][y]+1;
                que.push(P(nx,ny));
            }
        }
    }
    rep(i,MAX_N) rep(j,MAX_N) if(dist[i][j]<=t) ans++;
    cout<<ans<<endl;

}

int main() {
    while(cin>>t>>n) {
        if(t+n==0) return 0;
        solve();
    }
    return 0;
}

Measured memory_bytes: 1304
import java.util.Scanner;
class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int[] num = new int[5];
		int i;
		
		for(i=0;i<5;i++){
			num[i] = scan.nextInt();
		}
		
		for(i=0;i<4;i++){
			for(int j=4;j>i;j--){
				if(num[j]>num[j-1]){
					int t = num[j];
					num[j] = num[j-1];
					num[j-1] = t;
				}
			}
		}
		System.out.println(num[0] + " " + num[1] + " " + num[2] + " " + num[3] + " " + num[4]);
	}
}

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

void CountingSort(int *arr,int n)
{
    int output[n+1];
    int mn = *min_element(arr,arr+n);
    int mx = *max_element(arr,arr+n);
    int cnt[mx-mn+5];

    memset(cnt,0,sizeof cnt);

    for(int i=0; i<n; i++)
    {
        cnt[arr[i]-mn]++;
    }
    for(int i=1; i<(mx-mn+2); i++)
    {
        cnt[i]+=cnt[i-1];
    }
    for(int i=n-1; i>=0; i--)
    {
        output[cnt[arr[i]-mn]-1] = arr[i];
        cnt[arr[i]-mn]--;
    }
    for(int i=0; i<n; i++)
        arr[i] = output[i];
}

int arr[MAX];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0 ; i < n ; i++) scanf("%d", &arr[i]);
    CountingSort(arr, n);
    for(int i = 0 ; i < n; i++)
    {
        if(i) printf(" ");
        printf("%d", arr[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 18848
#include <iostream>
using namespace std;
int main(){
  long long int N;
  cin >> N;
  long long int A[N], sum = 0, mod = N*(N+1)/2, c = 0LL;
  for(int i = 0; i < N; ++i){
    cin >> A[i];
    c += A[i]/mod;
    sum += A[i]%mod;
    c += sum/mod;
    sum %= mod;
  }
  for(int i = 0; i < N; ++i){
    if(A[i] < c || A[i] > c*N){
      cout << "NO" << endl;
      return 0;
    }
  }
  if(sum){
    cout << "NO" << endl;
    return 0;
  }
  long long int B[N], M = 0LL;
  for(int i = 0; i < N; ++i){
    B[i] = A[(i+1)%N] - A[i];
    M = max(M, B[i]);
  }
  if((c%N - M%N + N)%N){
    cout << "NO" << endl;
    return 0;
  }
  long long int k = M;
  for(int i = 0; i < N; ++i){
    long long int t = M - B[i];
    if(t%N){
      cout << "NO" << endl;
      return 0;
    }
    k -= t/N;
  }

  if(k){
    cout << "NO" << endl;
    return 0;
  }

  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n, x, m;
    cin >> n >> x >> m;
    vector<int> id(m, -1);
    vector<int> a;
    int len = 0;
    ll tot = 0;
    while (id[x] == -1)
    {
        a.push_back(x);
        id[x] = len;
        len++;
        tot += x;
        x = (x * x) % m;
    }
    int c = len - id[x];
    ll s = 0;
    for (int i = id[x]; i < len; i++)
        s += a[i];

    ll ans = 0;
    if (n <= len)
    {
        for (int i = 0; i < n; i++)
            ans += a[i];
    }
    else
    {
        ans += tot;
        n -= len;
        ans += s * (n / c);
        n %= c;
        for (int i = 0; i < n; i++)
        {
            ans += a[id[x] + i]; // 周期の始まりからi個．a[id[x]]には周期の始まりとなるxの値が入っている．
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll n,m;
ll x[100100];
ll r1[100100];
ll rep[100100];
int main(){
	cin>>n>>m;
	REP(i,n)cin>>x[i];
	sort(x,x+n);
	ll co=1;
	r1[x[0]%m]++;
	FOR(i,1,n){
		r1[x[i]%m]++;
		if(x[i-1]==x[i]){
			co++;
			if(i==n-1){
				rep[x[n-1]%m]+=(co/2);
			}
		}else{
			rep[x[i-1]%m]+=(co/2);
			co=1;
		}
	}
	ll ans=0;
	ans+=(r1[0]/2);
	//cout<<0<<" "<<ans<<endl;
	for(ll i=1;i<=m/2;i++){
		if(i==m-i){
			ans+=(r1[i]/2);
		}else if(r1[i]>r1[m-i]){
			ans+=r1[m-i];
			ll t1=r1[i]-r1[m-i];
			rep[i]*=2;
			if(r1[m-i]>r1[i]-rep[i]){
				ans+=(t1)/2;
			}else{
				ans+=(rep[i])/2;
			}
		}else{
			ans+=r1[i];
			ll t1=r1[m-i]-r1[i];
			rep[m-i]*=2;
			if(r1[i]>r1[m-i]-rep[m-i]){
				ans+=(t1)/2;
			}else{
				ans+=(rep[m-i])/2;
			}
		}
		//cout<<i<<" "<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2688
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
string a;
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>a;
	if(a[1]=='B')
	{
		cout<<"ARC"<<endl;
	}
	else
	{
		cout<<"ABC"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s=scan.nextLine();
		String t=scan.nextLine();
		StringBuilder s1= new StringBuilder(t);
		s1.reverse();
		if(s.contains(s1)) System.out.println("YES");
		else System.out.println("NO");

	}

}


Measured memory_bytes: 27028
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define fi first
#define se second
#define L(i,u) for (int i=head[u]; i!=0; i=nxt[i])
#define rep(i,a,b) for (register int i=a; i<=b; i++)
#define per(i,a,b) for (register int i=a; i>=b; i--)
typedef long long ll;
using namespace std;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(ll &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
ll x; int ans;
int main() {
	read(x); while (x) {ans+=x%10;x/=10;}
	if (ans==1)ans=10;cout<<ans;
	return 0;
}


Measured memory_bytes: 768
def main(input = STDIN)
  while (n, m = input.gets.split(" ").map(&:to_i)) != [0, 0]
    arr = Array.new(m){|i|[0, i + 1]}
    n.times do
      input.gets.split(" ").map(&:to_i).each_with_index{|i, idx|arr[idx][0] += i}
    end
    puts arr.sort_by{|i|[-i[0], i[1]]}.map{|i|i[1]}.join(" ")
  end
end
main

Measured memory_bytes: 6104
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

long long gcd(long long a, long long b) {
    return b ? gcd(b, a % b) : a;
}

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

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

    std::cout << lcm(a, b) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
const int maxn = 500;
const int inf = 0x3f3f3f3f;
int ch[maxn];
int ans[maxn];
char str[100];
int n;
int main()
{
	
	scanf("%d", &n);
	memset(ans, inf, sizeof(ans));
	for (int i = 1; i <= n; i++)
	{
		memset(ch, 0, sizeof(ch));
		scanf("%s", str);
		for (int i = 0; i<strlen(str); i++)
		{
			ch[str[i]]++;
		}
		for (int i = 'a'; i <= 'z'; i++)
		{
			ans[i] = min(ans[i], ch[i]);
		}
	}
	for (int i = 'a'; i <= 'z'; i++)
	{
		for (int j = 0; j < ans[i]; j++)
			printf("%c", (char)(i));
	}
}


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

/*vector<int> p(n);
cin >> p[i]*/

int main(){

    int count = 0;
    int a[3][3] = {0};
    int n;
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> a[i][j];
        }
    }
    cin >> n;

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

    while(1){
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                if(a[i][j] == b[count]){
                    a[i][j] = 1000;
                }
            }
        }
        count++;
        if(count > 8) break;
    }

    if((a[0][0] == 1000 && a[0][1] == 1000 && a[0][2] == 1000) || (a[1][0] == 1000 && a[1][1] == 1000 && a[1][2] == 1000) || 
       (a[2][0] == 1000 && a[2][1] == 1000 && a[2][2] == 1000) || (a[0][0] == 1000 && a[1][0] == 1000 && a[2][0] == 1000) ||
       (a[0][1] == 1000 && a[1][1] == 1000 && a[2][1] == 1000) || (a[0][2] == 1000 && a[1][2] == 1000 && a[2][2] == 1000) ||
       (a[0][0] == 1000 && a[1][1] == 1000 && a[2][2] == 1000) || (a[0][2] == 1000 && a[1][1] == 1000 && a[2][0] == 1000)){
           cout << "Yes" << endl;
       }else{
           cout << "No" << endl;
       }
    return 0;
}

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

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

int main(){
    int n; cin >> n;
    int a[n]; rep(i, n) cin >> a[i];

    int maxv = a[1] - a[0];
    int minv = a[0];

    rep(i, n-1){
        maxv = max(maxv, a[i+1] - minv);
        minv = min(minv, a[i+1]);
    }

    cout << maxv << endl;
}


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

int main(){
  int n,m;
  cin>>n;
  vector<int> t(n);
  for(int i=0;i<n;i++) cin>>t[i];
  cin>>m;
  for(int i=0;i<m;i++){
    int p,x;
    cin>>p>>x;
    p--;
    int ans=0;
    for(int j=0;j<n;j++){
      if(j==p) ans+=x;
      else ans+=t[j];
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

const double EPS=(1e-10);
typedef long long ll;
typedef pair<int,int> pii;
bool EQ(double a,double b){
  return abs((a)-(b))<EPS;
}
void fast_stream(){
	std::ios_base::sync_with_stdio(0);
}

int rs[100001];
void solve(){
    int n,S;
    while(cin>>n>>S&&(n|S)){
        int cnt=0;
        for(int i=0;i<n;i++)cin>>rs[i];
        sort(rs,rs+n);
        for(int i=0;i<n;i++){
            int *a=upper_bound(rs+i+1,rs+n,S-rs[i]);
            if(a!=rs+n){
                cnt+=min(((rs+n)-a),n-i-1);
            }
        }
        cout<<cnt<<endl;
    }
}


int main(){

    solve();

    return 0;
}

Measured memory_bytes: 900
import sys
input=sys.stdin.buffer.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
S,W = map(int,input().split())
if W >= S:
    print("unsafe")
else:
    print("safe")

Measured memory_bytes: 9216
#include <iostream>
#define max_3(a, b, c) max(a, max(b, c))

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;

    int score = max_3(2*A - 1, 2*B - 1, A + B);
    cout << score;
    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)


int main() {
	
	int n;
	string s;

	cin >> n >> s;

	int ans = 0;
	int max = 0;

	REP(i, n) {
		if (s[i] == 'I') {
			ans++;
			if (ans > max) {
				max = ans;
			}
		}
		else {
			ans--;
		}
	
	}

	ANS(max);

	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<ctime>
#include<algorithm>
using namespace std;
const int MR=2000000;


int main(){
	char w[200];
	cin.getline(w,101);
	int cnt[26]={0},len=strlen(w);
	for(int i=0;i<len;i++){
		cnt[w[i]-'a']++;
	}
	bool flag=true;
	for(int i=0;i<26;i++){
		if(cnt[i]%2==1){
			flag=false;
			break;
		}
	}
	if(flag) printf("Yes\n");
	else printf("No\n");
	return 0;
}



Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math;

void main()
{
    auto N = readln.chomp.to!int;
    auto AS = readln.split.to!(int[]);

    auto cnt = int.max;
    foreach (a; AS) {
        int i;
        for (; a && a%2 == 0; ++i) a /= 2;
        cnt = min(cnt, i);
    }
    writeln(cnt);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using namespace std;


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

   long h,w,ans; cin >> h >> w;
   if(h==1 or w==1) cout << 1 << endl;
   else cout << (h*w+1)/2 << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const double pi = 3.14159265;
const ll LLINF = 1LL << 50;
using namespace std;


int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k % 2 == 0)cout << a - b << endl;
    else cout << b - a << endl;
    return 0;
}


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

using namespace std;

int main(int argc,char* argv[]){
  int N,A,B,max,min;
  cin >> N >> A >> B;
  if(N>A+B) min = 0;
  else min = A+B-N;
  if(A>B) max = B;
  else max = A;
  cout << max << " " << min << endl;
  

  return 0;
}


Measured memory_bytes: 256