akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int n,a; cin >> n>>a;
	int t = n % 500;
	if (t > a)cout << "No";
	else cout << "Yes";


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int a[26];
  string s, ans="None";
    for(int i=0; i<26; i++) a[i] = -1;
    cin >> s;
    for(int i=0; i<s.size(); i++) a[s[i]-'a'] = 0;
    for(int i=0; i<26; i++){
      if(a[i]==-1){
        ans = 'a'+i;
        break;
      }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)


int Len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}


int Sint(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int GCD(int a,int b)
{
  int r, tmp;
   /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}


long long int Factorial(long long int n){
  long long int m=1;
  while(n>=1) m*=n,m%=mod,n--;
  return m;
}


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  long long int n,m,ans;
  cin>>n>>m;
  if(abs(n-m)>=2){
    cout<<0<<endl;
    return 0;
  }
  ans=(Factorial(n)*Factorial(m))%mod;
  if(n%2==m%2){
    ans*=2;
  }
  cout<<ans%mod<<endl;
}
///////////////////////////

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> AB(N, vector<int>(2));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> AB.at(i).at(j);
    }
  }
  vector<vector<int>> CD(M, vector<int>(2));
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> CD.at(i).at(j);
    }
  }

  for (int i = 0; i < N; i++) {
    int ans, dist = 1e9;
    for (int j = 0; j < M; j++) {
      int tmp = abs(AB.at(i).at(0) - CD.at(j).at(0)) + abs(AB.at(i).at(1) - CD.at(j).at(1));
      if (tmp < dist) dist = tmp, ans = j + 1;
    }
    cout << ans << "\n";
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			String s = sc.next(), t = sc.next();
			int[][] dp = new int[s.length() + 1][t.length() + 1];
			dp[0][0] = (s.charAt(0) == t.charAt(0)) ? 1 : 0;
			for (int i = 0; i < s.length(); i++) {
				for (int j = 0; j < t.length(); j++) {
					if (s.charAt(i) == t.charAt(j)) {
						dp[i + 1][j + 1] = Math.max(Math.max(dp[i + 1][j], dp[i][j + 1]), dp[i][j] + 1);
					} else {
						dp[i + 1][j + 1] = Math.max(dp[i][j + 1], dp[i + 1][j]);
					}
				}
			}
			StringBuilder sb = new StringBuilder();
			int i = s.length(), j = t.length();
			while(i > 0 && j > 0) {
				if(dp[i][j] == dp[i - 1][j]) i--;
				else if(dp[i][j] == dp[i][j - 1]) j--;
				else {
					sb.append(s.charAt(i - 1));
					i--; j--;
				}
			}
			System.out.println(sb.reverse().toString());
		}
	}
}

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

using namespace std;

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

	int tmp = N;
	int sum = 0;
	while (tmp > 0) {
		sum += tmp % 10;
		tmp /= 10;
	}

	if (N % sum == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


}






Measured memory_bytes: 3608
N = int(input())
A = [int(e) for e in input().split()]
ans = 1
if(0 in A):
    print(0)
else:
    for i in range(N):
        ans *= A[i]
        if(ans > 10**18):
            print(-1)
            break
    else:
        print(ans)
  



Measured memory_bytes: 84596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int x,y;
  cin >> x>>y;
  for(int i=0;i<=50;i++){
    for(int j=0;j<=25;j++){
      if(i+j==x && 2*i+4*j==y){
        cout << "Yes";
        return 0;
      }
    }
  }
  cout << "No";
}

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

typedef long long ll;
 
int main(){
  int n;
  cin >> n;
  int px=0, py=0, pt=0;
  for(int i=0; i<n; i++){
    int x, y, t;
    cin >> t >> x >> y;
    int dx = abs(px - x);
    int dy = abs(py - y);
    int dt = t - pt;
    if((dx+dy>dt)||((dx+dy)%2!=dt%2)){
      cout << "No" << endl;
      return 0;
    }
    px = x;
    py = y;
    pt = t;
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
#define INF 1000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;

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

  int n, m;
  string s;
  cin >> n >> m >> s;
  reverse(s.begin(), s.end());

  vector<int> rec;

  int p = 0, pbefore = 0;
  while (p != n) {
    pbefore = p;
    for (int i = min(n-p, m); i > 0; i--) {
      if ((char)s[p + i] == '0') {
        p += i;
        rec.emplace_back(i);
        //cout << i << endl;
        break;
      }
    }
    if (pbefore == p) {
      cout << -1 << endl;
      return 0;
    }
  }

  for (int i = rec.size()-1; i >= 0; i--) cout << rec[i] << " ";
  cout << endl;
}

Measured memory_bytes: 1096
N,M=map(int,input().split())
A=[]
for i in range(M):
    a=int(input())
    A.append(a)
DP=[0]*(1+N)
DP[0]=1
DP[1]=1
damage=[0]*(N+1)
kotae=0
for m in A:
    damage[m]=-1
if N==1:
    print(1)
elif N==2:
    if M==1:
        print(1)
    else:
        print(2)
else:
    for a in range(2,N+1):
        if damage[a-1]==-1 and damage[a-2]==-1:
            print(0)
            kotae+=1
            break
        if damage[a]==-1:
            continue
        elif damage[a-1]==-1:
            DP[a]=DP[a-2]
        elif damage[a-2]==-1:
            DP[a]=DP[a-1]
        else:
            DP[a]=DP[a-2]+DP[a-1]
    if kotae==0:
        print(DP[-1]%(pow(10,9)+7))



Measured memory_bytes: 470520
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define pb push_back
#define all(x) x.begin(), x.end()
#define pi pair<int, int>
#define l first
#define r second
#define int long long

using namespace std;

const int maxn = 2e5 + 1;

bool v[101][101];
int dp[101][101];

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, m; cin >> n >> m;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
            char ch; cin >> ch;
            v[i][j] = (ch == '#');
        }
    dp[0][0] = v[0][0];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (i == 0 && j == 0) continue;
            if (i == 0) {dp[i][j] = dp[i][j - 1] + !(v[i][j - 1] || !v[i][j]);}
            if (j == 0) {dp[i][j] = dp[i - 1][j] + !(v[i - 1][j] || !v[i][j]);}
            if (i * j == 0) continue;
            dp[i][j] = min(dp[i][j - 1] + !(v[i][j - 1] || !v[i][j]),
                           dp[i - 1][j] + !(v[i - 1][j] || !v[i][j]));
        }
    }
    cout << dp[n - 1][m - 1];
    return 0;
}


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

using namespace std;

int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    while(k --)
    {
        if(a >= b)
        {
            b *= 2;
            continue;
        }
        if(b >= c)
        {
            c *= 2;
        }
    }
    if(a < b && b < c)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3616
n, l = map(int, input().split())

if l < 0 and n+l <= 0:
    kei = sum(list(x for x in range(l,l+n-1)))
    # print(list(x for x in range(l,l+n-1)))
if l < 0 and n+l > 0:
    kei = sum(list(x for x in range(l,l+n)))
    # print(list(x for x in range(l,l+n)))
if l >= 0:
    kei = sum(list(x for x in range(l+1,l+n)))
    # print(list(x for x in range(l+1,l+n)))
print(kei)


Measured memory_bytes: 38384
N = int(input())
hp = list(map(int, input().split()))
hp.sort()

def gcd(a, b):
    if b < a:
        tmp = a
        a = b
        b = tmp
    p = b // a
    r = b % a
    while r != 0:
        b = a
        a = r
        p = b // a
        r = b % a
    return a

ans = hp[0]
for i in range(len(hp) - 1):
    ans = gcd(ans, hp[i+1])

print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string s;
    string t;
    
    cin>>s;
    cin>>t;
    
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
          cout<<"No"<<endl;
          return 0;
        } 
    }
    
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1e9+1;

/*

*/

void solve(){
    int n;
    cin >> n;
    double t,a;
    cin >> t >> a;
    double h[n+10];
    rep(i,n){
        cin >> h[i];
    }
    double err = 1000000000;
    int point = 0;
    rep(i,n){
        double tmp = t - h[i]*0.006;
        //cout << tmp << endl;
        if(err>abs(tmp-a)) {
            point = i;
            err = abs(tmp-a);
        }
    }
    cout << point + 1 << endl;

}

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


Measured memory_bytes: 384
x=[]
y=[]
n,m,l=map(int,input().split())
r=[[0]*l for n in range(n)]
for i in range(n):
    x.append(list(map(int,input().split())))
for i in range(m):
    y.append(list(map(int,input().split())))
for i in range(n):
    for j in range(l):
        s=0
        for k in range(m):
            s+=x[i][k]*y[k][j]
        r[i][j]=s
for n in range(n):
    print(' '.join(map(str,r[n])))


Measured memory_bytes: 6904
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
 
int N,K;

char S[100001];


int main()
{
  int i,j1,k,U,score;

  scanf("%d %d %s",&N,&K,S);
  
  U=0;
  for(i=0;i<N-1;i++)
  {
    if(S[i]!=S[i+1])
    {
      U++;
    }
  }
  
  score=N-1-U;
  score=fmin(N-1,score+2*K);
  
  

  printf("%d",score);

  return 0;
}

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

namespace abc168_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());

            string S = Console.ReadLine();

            if(S.Length <= K)
            {
                Console.Write(S);
            }
            else if(S.Length>K)
            {
                Console.Write(S.Substring(0, K) + "...");
            }
            Console.Read();
        }
    }
}


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

#define MAX 90
#define rep(i,n) for(int i = 0 ; i < n ; i++)

int W,H;
int field[MAX][MAX];
const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};
 
int rec(int x,int y){
    int res = 0;
 
    rep(i,4){
	int nx = x + dx[i];
	int ny = y + dy[i];
    
	if(0 <= nx && nx < H && 0 <= ny && ny < W){
	    if(field[nx][ny]){
		field[nx][ny] = 0;
		res = max(res,rec(nx,ny)+1);
		field[nx][ny] = 1;
	    }
	}
    }
    return res;
}
 
int main(){
    while(cin >> W >> H , W | H){
	rep(i,H){
	    rep(j,W){
		cin >> field[i][j];
	    }
	}
 
	int ans = -1;
	rep(i,H){
	    rep(j,W){
		ans = max(ans,rec(i,j));
	    }
	}  
	cout << ans << endl;
    }
    return 0;
}

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

const int mod = 1e9 + 7;

int main() {
    ll n;
    cin >> n;
    vector<ll> c(1);
    cin >> c[0];
    for (ll i = 1;i < n;++i) {
        ll ci;
        cin >> ci;
        if (c.back() != ci)c.push_back(ci);
    }
    n = c.size();
    map<ll, ll> m;
    m.insert({ c[0],1 });
    vector<ll> dp(n, 0);
    dp[0] = 1;
    for (ll i = 1;i < n;++i) {
        dp[i] = (dp[i - 1] + m[c[i]]) % mod;
        m[c[i]] = dp[i];
    }
    cout << dp.back() << endl;
}

Measured memory_bytes: 18688
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  int m,nmin,nmax;
  int i,j;

  while(true){
    cin>>m>>nmin>>nmax;
    if(m==0 && nmin==0 && nmax==0)break;
    int score[200]={};
    rep(i,m)
      cin>>score[i];
    rep(i,m-1)
      score[i]-=score[i+1];

    pii p[200]={};
    int n=0;
    for(i=nmin-1;i<=nmax-1;i++){
      p[n].first=score[i];
      p[n].second=i+1;
      n++;
    }
    int num=nmax-nmin+1;
    sort(p,p+num);

    cout<<p[num-1].second<<endl;

  }

}

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

#define int long long
#define INF 9223372036854775807
#define M_PI 3.14159265358979323846
#define double long double

int mod = INF;

int fastPow(int b, int e){int r = 1;while(e){if(e%2 == 1){r*=b;r%=mod;}b*=b;b%=mod;e/=2;}return r;}
int pgcd(int a, int b){ if(a%b == 0) return b; else return pgcd(b, a%b);}
int sign(int a){if(a < 0){ return -1;}if(a == 0) {return 0;}if(a > 0) {return 1;}}
bool isPrime(int a){if(a == 1) {return false;}int f = sqrt(a);for(int i = 2; i<=f; i++){if(a%i == 0){return false;}}return true;}
int toInt(string s){int tot = 0;for(int i = s.size()-1; i >= 0; i--){tot+=((s[i]-'0')%mod)*fastPow(10,i);tot%=mod;}return tot;}
string toString(int a){string s = "";while(a){s = (char)('0'+a%10) + s;a/=10;}return s;}

vector<int> we(109);
vector<int> v(109);

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, w;
    cin >> n >> w;
    for(int i = 1; i <= n; i++){
        cin >> we[i] >> v[i];
    }
    int memo[n+1][w+1];
    for(int i = 0; i <= w; i++) memo[0][i] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= w; j++){
            if(j-we[i] >= 0)memo[i][j] = max(memo[i-1][j], memo[i-1][j-we[i]]+v[i]);
            else memo[i][j] = memo[i-1][j];
        }
    }
    cout << memo[n][w] << endl;
}


Measured memory_bytes: 79232
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  string ans;
  ll X;

  cin >> X;

  while (X) {
    X--;
    ans = (char)('a' + (X % 26)) + ans;
    X /= 26;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3596
#include <cstdio>

unsigned long long fn_f(unsigned long long );

unsigned long long a[1000000];

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

    bool E = false;
    int m;

    for(int i = 0; i < 1000000; i++){
        if(i == 0){
            a[0] = s;
        }else{
            a[i] = fn_f(a[i - 1]);
            for(int j = i - 1; j >= 0; j--){
                if(a[i] == a[j]){
                    E = true;
                    m = i + 1;
                    break;
                }
            }
        }

        if(E){
            break;
        }
    }

    printf("%d\n",m);

    return 0;
}


unsigned long long fn_f(unsigned long long n){
    if(n % 2 == 0){
        return n / 2;
    }else{
        return 3 * n + 1;
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<string> ans(N);
  for(int i=0;i<N;i++){
    cin>>ans.at(i);
  }
  sort(ans.begin(),ans.end());
  vector<pair<int,string>> A;
  int count = 1;
  for(int i=1;i<N;i++){
    if(ans.at(i)!=ans.at(i-1)){
      A.push_back(make_pair(count,ans.at(i-1)));
      count=1;
    }else{
      count++;
    }
    if(i==N-1)A.push_back(make_pair(count,ans.at(i)));
  }

  sort(A.begin(),A.end());
  int t=300000;
  vector<string> B;
  for(int i=A.size()-1;i>=0;i--){
    if(i==A.size()-1){
        B.push_back(A.at(i).second);
        t=A.at(i).first;
    }else if(t==A.at(i).first){
        B.push_back(A.at(i).second);
          }
  }
  for(int i=B.size()-1;i>=0;i--){
    cout<<B.at(i)<<endl;
  }


}


Measured memory_bytes: 21744
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let s: String = scan(tokens);
    let bytes = s.as_bytes();
    let n = bytes.len();
    let mut count = 0;
    for i in 0..n / 2 {
        if bytes[i] != bytes[n - 1 - i] {
            count += 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
use std::io;

fn counting_sort(src: &Vec<u32>, dst: &mut Vec<u32>, k: u32) {
    let l = (k+1) as usize;
    let mut cnt: Vec<u32> = vec![0; l];

    for e in src.iter() {
        cnt[*e as usize] += 1;
    }

    // 累積和に変更
    for i in 1..l {
        cnt[i] = cnt[i] + cnt[i-1];
    }

    for v in src.iter().rev() {
        // 後ろから行うことで安定になる
        let i = cnt[*v as usize] - 1;
        dst[i as usize] = *v;
        cnt[*v as usize] -= 1;
    }
}

fn main() {
    let sin = io::stdin();
    let mut buf = String::new();
    sin.read_line(&mut buf).ok();
    let n: usize = buf.trim().parse().unwrap();

    let mut buf = String::new();
    sin.read_line(&mut buf).ok();
    let src: Vec<u32> = buf.split_whitespace()
        .map(|v| v.parse::<u32>().unwrap())
        .collect::<Vec<u32>>();

    let mut dst = vec![0; n];
    let k = src.iter().max().unwrap();

    counting_sort(&src, &mut dst, *k);

    let out = dst.iter().map(|v| v.to_string())
        .collect::<Vec<String>>()
        .join(" ");
    println!("{}", out);
}



Measured memory_bytes: 103320
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;
use std::io::Write;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readvec<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readlines<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
    }
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
            fn parse(s: &str) -> ($($t),*) {
                let mut tokens = s.split_whitespace();
                ($($t::parse(tokens.next().unwrap())),*)
            }
        }
    }
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let n: usize = read();
    let mut a: Vec<i32> = readvec();
    a.sort();
    let mut sum = 0;
    let mut idx = 1;
    for i in (0..n).rev() {
        sum += a[i] * idx;
        idx *= -1;
    }
    println!("{}", sum);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<cmath>
#define ll long long
using namespace std;
int main()
{
    ll n,d,m,cont=0;
    cin>>n>>d;
    while(n--)
    {
        ll p,q;
        cin>>p>>q;
         m=(p*p+q*q);
         if(m<=d*d)
         {
             cont++;
         }
         //cout<<m;
    }
        cout<<cont;
}


Measured memory_bytes: 3612
# ABC169 D Div Game

n = int(input())

def factorization(n):
    arr = []
    if n == 1:
        return arr
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

f_list = factorization(n)
ans = 0

for i in range(len(f_list)):
    _tmp = f_list[i][1]
    j = 1
    while _tmp >= 0:
        _tmp -= j
        j += 1
    ans += j-2

print(ans)

Measured memory_bytes: 63412
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,s,n) for(int i=s; i<n; i++)
#define ALL(x) x.begin(), x.end()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;

bool expr(string str) {
	vector<string> cls;
	string s="";
	rep(i, str.length()) {
		if(str[i] == '|') {
			cls.push_back(s);
			s = "";
		}
		else {
			s += str[i];
		}
	}
	cls.push_back(s);
	rep(i, cls.size()) {
		vector<string> lit;
		string s="";
		for(int j=1; cls[i][j]!=')'; j++) {
			if( cls[i][j] == '&' ) {
				lit.push_back(s);
				s = "";
			} else {
				s += cls[i][j];
			}
		}
		lit.push_back(s);
		bool ok = true;
		rep(j, lit.size()) {
			for(int k=j+1; k<lit.size(); k++) {
				if(lit[j][lit[j].length()-1] == lit[k][lit[k].length()-1] &&
					lit[j].length() != lit[k].length() ) {
					ok = false;
				}
			}
		}
		if(ok) return true;
	}
	return false;
}

int main() {
	string in;
	while(cin >> in, in!="#") {
		if( expr(in) ) {
			cout << "yes" << endl;
		} else {
			cout << "no" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1196
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();
        for (int i = 1; i <= 10100; i++) {
            if (i * 8 / 100 == a && i * 10 / 100 == b) {
                System.out.println(i);
                return;
            }
        }
        System.out.println(-1);
    }
}


Measured memory_bytes: 23636
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[5]; 
    rep(i, 5) cin >> a[i];
    int ans = INF;
    int order[5] = {0, 1, 2, 3, 4};
    do{
        int sum = 0;
        rep(i, 5) {
            sum += (10 - sum % 10) % 10;
            sum += a[order[i]];
        }
        ans = min(ans, sum);
    }while(next_permutation(order, order + 5));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
    //入力
        Scanner sc = new Scanner(System.in);
        char[] c = sc.next().toCharArray();
        long K = sc.nextLong();
        ArrayList<Integer> a = new ArrayList<>();
        ArrayList<Integer> pre = new ArrayList<>();
        ArrayList<Integer> repeat = new ArrayList<>();
        ArrayList<Integer> suf = new ArrayList<>();
		int posi = 0;
        int count = 1;
        while(posi <= c.length-1){
          if(posi != c.length-1){
            if(c[posi]==c[posi+1]){
              count++;
            }
            else{
              a.add(count);
              count = 1;
            }
          }
          else{
            a.add(count);
          }
          posi++;
        }
      	if(a.size() == 1){
          System.out.println((long)(a.get(0)* K/2));
        }
        if(a.size() == 2){
          System.out.println((long)(a.get(0)/2) * K +(long)(a.get(1)/2) * K);
        }
        if(a.size() >= 3){
          long ans = 0;
          pre.add(a.get(0));
          for(int i=1;i<=a.size()-1;i++){
			suf.add(a.get(i));
          }
          if(c[0]==c[c.length-1]){
            for(int i=1;i<=a.size()-2;i++){
			  repeat.add(a.get(i));
            }
			repeat.add(a.get(0)+a.get(a.size()-1));
          }
          else{
            for(int i=1;i<=a.size()-2;i++){
			  repeat.add(a.get(i));
            }
			repeat.add(a.get(a.size()-1));
            repeat.add(a.get(0));
          }
          ans += (long)pre.get(0)/2;
          for(int i=0;i<repeat.size();i++){
            ans += (long)(repeat.get(i)/2)*(K-1);
          }
          for(int i=0;i<suf.size();i++){
            ans += (long)suf.get(i)/2;
          }
          System.out.println(ans);
        }
    }
}

Measured memory_bytes: 22740
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    global X,Y,now_X,now_Y
    K=I()
    X,Y=MI()
    ans = []
    now_X=0
    now_Y=0
    
    def move_greedy():
        global X,Y,now_X,now_Y
        move = min(K,abs(now_X-X))
        if(X-now_X<0):
            now_X -= move
        else:
            now_X += move
        if(Y-now_Y<0):
            now_Y -= K-move
        else:
            now_Y += K-move
        ans.append((now_X,now_Y))
    
    def move_last():
        global X,Y,now_X,now_Y
        distance = abs(X-now_X) + abs(Y-now_Y)
        move = (2*K-distance)//2 #あまりの半分
        if(abs(X-now_X) < abs(Y-now_Y)):
            if(X-now_X<0):
                now_X += move
            else:
                now_X -= move
            if(Y-now_Y<0):
                now_Y -= K - move
            else:
                now_Y += K - move
        else:
            if(Y-now_Y<0):
                now_Y += move
            else:
                now_Y -= move
            if(X-now_X<0):
                now_X -= K - move
            else:
                now_X += K - move
        ans.append((now_X,now_Y))
        ans.append((X,Y))
    
    
    if (abs(X) + abs(Y)) % 2 == 1 and K %2 == 0:
        print(-1)
        return
    while abs(now_X-X) + abs(now_Y-Y) > 2*K:
        move_greedy()

    if(K%2==0):
        move_last()
    else:
        if(abs(X-now_X) + abs(Y-now_Y) == K):
            ans.append((X,Y))
        else:
            distance = abs(X-now_X) + abs(Y-now_Y)
            if(distance&1):
                move_greedy()
            move_last()
            
    print(len(ans))
    for a in ans:
        print(*a)


    
if __name__ == '__main__':
    main()

Measured memory_bytes: 59772
use proconio::fastout;
use whiteread::parse_line;

#[fastout]
fn main() {
    let (n, m): (usize, usize) = parse_line().unwrap();
    let ret = match (n, m) {
        (1, 1) => 1,
        (1, l) | (l, 1) => l - 2,
        (n, m) => (n - 2) * (m - 2),
    };
    println!("{}", ret);
}


Measured memory_bytes: 2152
#include <iostream>
#include <vector>

int main()
{
    const long long infty = 1e+18;

    int N;
    long long x;
    scanf("%d %lld", &N, &x);
    std::vector<long long> a(N);
    for(int i=0; i<N; i++) scanf(" %lld", &a[i]);

    long long min_t = infty;
    std::vector<long long> m(N, infty);

    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            if(a[(j+i)%N] < m[j]) m[j] = a[(j+i)%N];
        }

        long long tmp = i * x;
        for(int j=0; j<N; j++) tmp += m[j];
        if(tmp < min_t) min_t = tmp;
    }

    std::cout << min_t << std::endl;
}

Measured memory_bytes: 384
n,m,l = gets.split(" ").map(&:to_i)
a = []
b = []
n.times do
  a<<gets.split(" ").map(&:to_i)
end
m.times do
  b<<gets.split(" ").map(&:to_i)
end
bt = b.transpose
n.times do |i|
  c = []
  l.times do |j|
    c<<[a[i],bt[j]].transpose.map{|t| t.inject(:*)}.inject(:+)
  end
  puts c.join(" ")
end

Measured memory_bytes: 9132
# -*- coding: utf-8 -*-

import sys
import os



def insertion_sort(A):
    n = len(A)
    for i in range(1, n):
        v = A[i]
        j = i - 1

        # i-1????????§???sort??????
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(*A)

input()
lst = list(map(int, input().split()))
print(*lst)
insertion_sort(lst)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
const ld pi = 4.0 * atanl(1.0);
const int iinf = 1e9 + 10;
const int inf = 1e18 + iinf + 10;
const int mod = 1000000007;
const ld prec = .000001;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()

ll n, m, t, a[mxN];
vi v;

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

int main() {
  fast();
  cin >> n >> m;
  bool ok = true;
  if (n % m == 0) cout << 0, ok = false;
  if (ok) {
    if (abs(n - m) > n)
      cout << n;
    else {
      cout << abs((n % m) - m);
    }
  }

  return 0;
}



Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
	T f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 200003, M = N << 1;

int d[5];

int main()
{
	//File("");
	for (int i = 1; i <= 3; i+=1) ++d[gi <int> ()], ++d[gi <int> ()];
	int c1 = 0, c2 = 0;
	for (int i = 1; i <= 4; i+=1) if (d[i] == 2) ++c2; else if (d[i] == 1) ++c1;
	if (c1 == 2 && c2 == 2) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 3600
def binary_search(arr, val):
    left = 0
    right = len(arr)

    while left < right:
        mid = (left + right)//2
        if arr[mid] == val:
            return mid
        elif arr[mid] < val:
            left = mid + 1
        else:
            right = mid
    return -1

if __name__ == '__main__':
    n = int(input())
    S = list(map(int, input().split()))
    q = int(input())
    T = list(map(int, input().split()))

    cnt = 0
    for i in T:
        if binary_search(S, i) != -1:
            cnt += 1
    print(cnt)
        


Measured memory_bytes: 16712
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int color[10010];

int main() {
	int a,b,i,n,res;
	while(n=in()){
		res=n;
		for(i=0;i<n;i++){
			color[i]=in();
		}
		for(i=0;i<n;i++){
			int j,c,r;
			for(j=1;j<=3;j++){
				a=b=i;
				r=n;
				c=j;
				while(a-1>=0&&color[a-1]==c)a--;
				while(b+1<n&&color[b+1]==c)b++;
				if(b-a<3)continue;
				r-=b-a+1;
				while(1){
					if(a==0||b==n-1)break;
					a--;b++;
					if(color[a]!=color[b])break;
					c=color[a];
					while(a-1>=0&&color[a-1]==c)a--;
					while(b+1<n&&color[b+1]==c)b++;
					if(b-a-(n-r)<3)break;
					r-=b-a-(n-r)+1;
				}
//cout<<i<<" "<<j<<" "<<r<<endl;
				chmin(res,r);
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
#define MAX 100010
ll mod = 1000000007;
ll inv[MAX], fact[MAX], factInv[MAX];

int main(void) {
    int i, N, M;
    inv[1] = 1;
    for(i=2; i<=MAX; i++) inv[i] = mod - inv[mod%i] * (mod / i) % mod;
    fact[0] = factInv[0] = 1;
    for(i=1; i<=MAX; i++) {
        fact[i] = fact[i-1] * i % mod;
        factInv[i] = (factInv[i-1] * inv[i]) % mod;
    }

    cin >> N >> M;
    if(abs(N - M) > 1) return (!printf("0\n"));
    ll ans = fact[N] * fact[M] % mod;
    if(N == M) ans = 2 * ans % mod;
    return (!printf("%lld\n", ans));
}

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

int main() {
	string str;
	cin >> str;
	if (str[5] == '1') {
		goto T;
	}
	if (str[6] >= '5') {
		goto T;
	}
	cout << "Heisei" << endl;
	return 0;
	T:
	cout << "TBD" << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int z,o,i;string s;
  cin >> s;z = o = 0;
  for(i=0;i<s.size();i++){
    if (s[i]=='0') z += 1;
    else o += 1;
  }
  cout << min(z,o)*2 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)

int main() {
  int h,w;
  cin>>h>>w;
  int a[h][w];
  rep(i,0,h){
    rep(j,0,w){
      cin>>a[i][j];
    }
  }
  int b[h][w];
  rep(i,0,h){
    rep(j,0,w){
      cin>>b[i][j];
    }
  }
  bool dp[h+1][w+1][200*80+1];
  rep(i,0,h+1){
    rep(j,0,w+1){
      rep(k,0,200*80+1){
        dp[i][j][k]=false;
      }
    }
  }
  dp[1][0][0]=true;
  dp[0][1][0]=true;
  rep(i,0,h){
    rep(j,0,w){
      rep(k,0,200*80+1){
        if(dp[i+1][j][k]){
          dp[i+1][j+1][abs(k+a[i][j]-b[i][j])]=true;
          dp[i+1][j+1][abs(k-a[i][j]+b[i][j])]=true;
        }
        if(dp[i][j+1][k]){
          dp[i+1][j+1][abs(k+a[i][j]-b[i][j])]=true;
          dp[i+1][j+1][abs(k-a[i][j]+b[i][j])]=true;
        }
      }
    }
  }
  int ans=0;
  while(true){
    if(dp[h][w][ans]){
      cout<<ans<<endl;
      break;
    }
    ans++;
  }
}


Measured memory_bytes: 102784
/**********************************************************************
File    .cpp
Author  Takahiro Yamazaki
**********************************************************************/
/**********************************************************************
Include Libraries
**********************************************************************/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
/**********************************************************************
Declare variables
**********************************************************************/
/**********************************************************************
Declare instance
**********************************************************************/
/**********************************************************************
Proto_type_Declare functions
**********************************************************************/

/**********************************************************************
Main
**********************************************************************/
int main() {
  int s,w;
  cin >> s>> w;

  if (s <= w) {
    printf("unsafe\n");
  }
  else printf("safe\n");
}
/**********************************************************************
Functions
**********************************************************************/


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  ll n; cin >> n;
  string ans = "";
  while(n){
    n--;
    char c = (n % 26) + 'a';
    n = (n - (n % 26)) / 26;
    ans = c + ans;
  }
  cout << ans << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


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

typedef long long ll;
#define pb push_back
#define ii pair<int ,int >
#define vi vector<int >
#define vii vector < pair<int ,int > >
#define IO ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define IOfiles freopen("input.txt","r+",stdin) ; freopen("output.txt","w+",stdout)
#define PI 3.14159265
const double eps = 1e-9;

int main()
{
	IO;
	int n,x,y;
	cin>>n>>x>>y;
	int ans[n];
	memset(ans,0,sizeof ans);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++){
			int d=j-i;
			d=min(d,abs(i-x)+abs(y-j)+1);
			//cout<<i<<" "<<j<<" "<<d<<" "<<abs(i-x)+abs(y-i)+1<<endl;
			ans[d]++;
		}

	for(int i=1;i<n;i++)
		cout<<ans[i]<<endl;

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC109D
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            int[] ints = ConsoleInput.IntArray();
            int H = ints[0];
            int W = ints[1];
            int[][] Map = new int[H][];
            for (int i = 0; i < H; i++)
            {
                Map[i] = ConsoleInput.IntArray();
            }

            List<string> cmd = new List<string>();
            int Cmds = 0;
            for (int i = 0; i < H; i++)
            {
                for (int j = 0; j < W - 1; j++)
                {
                    if (Map[i][j] % 2 != 0)
                    {
                        cmd.Add("" + (i + 1) + " " + (j + 1) + " " + (i + 1) + " " + (j + 2) + "\n");
                        Cmds++;
                        Map[i][j]--;
                        Map[i][j + 1]++;
                    }
                }
            }

            for (int i = 0; i < H - 1; i++)
            {
                if (Map[i][W - 1] % 2 != 0)
                {
                    cmd.Add("" + (i + 1) + " " + W + " " + (i + 2) + " " + W + "\n");
                    Cmds++;
                    Map[i][W - 1]--;
                    Map[i + 1][W - 1]++;
                }
            }

            string Ans = String.Join("", cmd.ToArray());
            Console.WriteLine("" + Cmds + "\n" + Ans);
        }
    }

    internal static class ConsoleInput
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 39184
h,w = map(int,input().split())
if h == 1 or w == 1:
  print(1)
  exit()
if h%2 == w%2 == 0:
    print(h*w//2)
elif h%2 == 0:
    print((h//2) * w)
elif w%2 == 0:
    print((w//2) *h)
else:
    print(2*(w//2)*(h//2) +w//2 + h//2 +1)


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

int main(){
  int A, B;
  cin >> A >> B;
  if(A < 6){
    cout << 0 << endl;
  }
  else if(A < 13){
    cout << B/2 << endl;
  }
  else{
    cout << B << endl;
  }
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int sum;

int main()
{
    for (int i = 0; i < 3; i++)
    {
        int A; scanf("%d", &A);
        sum += A;
    }
    if (sum >= 22) printf("bust\n");
    else printf("win\n");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int d1[n],d2[n];
    for(int i=0;i<n;i++)cin>>d1[i]>>d2[i];
    int flag=0,c=0;
    for(int i=0;i<n;i++){
        if(d1[i]==d2[i])c++;
        else c=0;
        if(c==3){flag=1;break;}
    }
    if(flag==0)cout<<"No";
    else cout<<"Yes";
    
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


int main(){
  int i;
  char s[100];
  int x[100];
  for(i=0;i<100;i++){
    x[i]=0;
  }
  i=0;
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      x[i-2]=x[i-1]+x[i-2];
      i--;
    }else if(s[0]=='-'){
      x[i-2]=x[i-2]-x[i-1];
      i--;
    }else if(s[0]=='*'){
      x[i-2]=x[i-1]*x[i-2];
      i--;
    }else{
      x[i]=atoi(s);
      i++;
    }
  }
  printf("%d\n",x[i-1]);

  return 0;
}

Measured memory_bytes: 1804
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        root = x
        while self.parents[root] != root:
            root = self.parents[root]
        while self.parents[x] != root:
            parent = self.parents[x]
            self.parents[x] = root
            x = parent
        return root

    def unite(self, x, y):
        xroot = self.find(x)
        yroot = self.find(y)
        if xroot == yroot:
            return
        xrank = self.rank[xroot]
        yrank = self.rank[yroot]
        if xrank < yrank:
            self.parents[xroot] = yroot
            self.size[yroot] += self.size[xroot]
        elif xrank == yrank:
            self.parents[yroot] = xroot
            self.rank[yroot] += 1
            self.size[xroot] += self.size[yroot]
        else:
            self.parents[yroot] = xroot
            self.size[xroot] += self.size[yroot]

    def len(self, x):
        return self.size[self.find(x)]

N, M = map(int, input().split())

uf = UnionFind(N)

for _ in range(M):
    x, y, z = map(int, input().split())
    uf.unite(x - 1, y - 1)

print(len([i for i in range(N) if uf.rank[i] == 0]))

Measured memory_bytes: 59168
#!/usr/bin/env python
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

N, X = map(int, input().split())
l = [abs(int(i) - X) for i in input().split()]

G = l[0]
for x in l[1:]:
    G = gcd(G, x)
print(G)

Measured memory_bytes: 14252
#include<iostream>
#include<vector>

int main(){
    using namespace std;
    // input
    size_t n;
    cin >> n;
    vector<unsigned int> a(n);
    for(auto& i : a)cin >> i;
    
    auto output = [&a, &n](){for(size_t i = 0; i < n; ++i)cout << a[i] << " \n"[i + 1 == n];};
    
    // process
    for(size_t i = 1; i < n; ++i){
        output();
        auto v = a[i];
        auto j = i;
        for(; j-- > 0 && a[j] > v;)a[j + 1] = a[j];
        a[j + 1] = v;
    }
    output();
}


Measured memory_bytes: 3088
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<map>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1000000000 + 7, INF = 1e18;

lint N, A;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	lint cnt = 0, curr_line = 0;
	cin >> A;
	cnt += (A - 1);
	curr_line++;
	REP(i, N - 1) {
		cin >> A;
		cnt += (A - 1) / (curr_line + 1);
		if (curr_line + 1 == A) curr_line++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3640