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

using namespace std;

typedef long long ll;

int n;
string s;

vector<int> alp[26];

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


	cin >> n;
	cin >> s;

	rep(i, n){
		alp[s[i] - 'a'].push_back(i);
	}

	bool chk = false;
	rep(i, 26){
		if(alp[i].size() >= 2) chk = true;
	}

	if(!chk){
		cout << 0 << endl;
		return 0;
	}

	int ans = 1;
	rep(i, 26){
		int sz = alp[i].size();
		if(sz <= 1) continue;
		rep(j, sz){
			int t1 = alp[i][j];
			if(t1 + 2 * (ans+1) > n) continue;
			for(int k = j + 1; k < sz; k++){
				int t2 = alp[i][k];
				if(t2 + (ans+1) > n || t2 < t1 + (ans+1)) continue;

				int x = ans + 1;
				if(s.substr(t1, x) != s.substr(t2, x)) continue;
				while(t2 + (x + 1) <= n && (t1 + x + 1 < t2) && s.substr(t1, x + 1) == s.substr(t2, x + 1)) x++;
				ans = max(ans, x);
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#define REP(i,N) for(auto i = 0; i<N; i++)
#include <climits>

#include <cmath>
using namespace std;
typedef long long ll;

ll llin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}




void ins(multiset<pair<ll,ll>> &masu, pair<ll,ll>p,long long H,long long W){
    
    if (p.first >= 1 && p.first <=H-2 && p.second >=1 && p.second <=W-2){
        masu.insert(p);
    }
    
}

void add_count(multiset<pair<ll,ll>> &masu, pair<long long, ll >p,long long H,long long W){
    
    ins(masu,p,H,W);
    p.first--;
    ins(masu,p,H,W);
    p.first--;
    ins(masu,p,H,W);

    p.second--;
    ins(masu,p,H,W);
    p.first++;
    ins(masu,p,H,W);
    p.first++;
    ins(masu,p,H,W);

    p.second--;
    ins(masu,p,H,W);
    p.first--;
    ins(masu,p,H,W);
    p.first--;
    ins(masu,p,H,W);
    
}

int main() {

    ll H = llin(); ll W = llin(); ll N = llin();
    
    typedef pair<ll, ll> P;
    
    multiset<P> masu;
    
    P p;
    for(auto i = 0; i < N; i++){
        cin >> p.first >> p.second;
        
        add_count(masu,p,H,W);
        
    }
    
    long long j[10] = {0};
    long long total = (H-2)*(W-2);
    
    for(auto a = masu.begin(); a!= masu.end(); a++){
        
        if ((*a).first >= 1 && (*a).first<=H-2 && (*a).second >=1 && (*a).second <= W-2){

            
            j[masu.count(*a)] +=1;
            total--;
            
            ll cou = masu.count(*a)-1;
            
            for (auto j = 0; j<cou; j++){
                a++;
            }
            
        }
        
        
    }
    
    j[0] = total;
    for(auto i : j){
        cout << i << endl;
    }
    
    return 0;
    
}




Measured memory_bytes: 56448
#include<stdio.h>
int cmp[100010],r=0,f[10010];
void sdfs(int e,int s,int k,int *ta,int *to,int *nt,int *id){
  int i;
  f[s]++;
  for(i=ta[s];i+1;i=nt[i]){
    if(i<e&&k<0&&f[to[i]]<0||i>=e&&k>=0&&!f[to[i]])sdfs(e,to[i],k,ta,to,nt,id);
  }
  k<0?(id[r++]=s):(cmp[s]=k);
}
void scc(int v,int e,int *a,int *b){
  int ta[10010],to[60010],nt[60010],id[10010],i,k;
  for(i=0;i<v;i++)f[i]=ta[i]=-1;
  for(i=0;i<e;i++){
    nt[i  ]=ta[to[i+e]=a[i]];
    nt[i+e]=ta[to[i  ]=b[i]];
    ta[a[i]]=i;
    ta[b[i]]=i+e;
  }
  for(i=k=0;i<v;i++){
    if(f[i]==-1)sdfs(e,i,-1,ta,to,nt,id);
  }
  for(i=r;i;i--){
    if(f[id[i-1]]==0)sdfs(e,id[i-1],id[i-1],ta,to,nt,id);
  }
}
int main(){
  int n,i,j,l,e,a[100010],b[100010];
  double d[100010],ans;
  while(scanf("%d",&n),n){
    for(i=e=0;i<n;i++){
      scanf("%lf %d",&d[i],&l);
      while(l--){
	scanf("%d",&j);
	a[e]=i;
	b[e++]=j-1;
      }
    }
    //for(i=0;i<e;i++)printf("%d %d\n",a[i],b[i]);
    scc(n,e,a,b);
    for(i=0;i<n;i++){
      if(cmp[i]-i)d[cmp[i]]*=d[i];
    }
    //for(i=0;i<n;i++)printf("%d %d %lf\n",i,cmp[i],d[i]);
    for(i=0;i<e;i++){
      if(cmp[a[i]]==cmp[b[i]])continue;
      d[b[i]]=0;
    }
    //for(i=0;i<n;i++)printf("%lf\n",d[i]);
    ans=1;
    for(i=0;i<n;i++){
      if(cmp[i]==i)ans*=(1-d[i]);
    }
    printf("%.9lf\n",ans);
  }
  return 0;
}



Measured memory_bytes: 2052
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int A = N / 100;
	int B = N % 100;
	bool yymm = false;
	bool mmyy = false;


	if (1 <= B && B <= 12) {
		yymm = true;
	}

	if (1 <= A && A <= 12) {
		mmyy = true;
	}

	if (yymm && mmyy) {
		cout << "AMBIGUOUS" << endl;
	}
	else if (yymm) {
		cout << "YYMM" << endl;
	}
	else if(mmyy) {
		cout << "MMYY" << endl;
	}
	else {
		cout << "NA" << endl;
	}
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
vi adj[(int)1e5 + 5];
int leaf[(int)1e5 + 5];
int ans[(int)1e5 + 5];
int root = 0;
void dfs(int cur, int P){
    int cnt = 0;
    bool found =false;
    ans[cur] = leaf[cur] = 0;
    for(int child :adj[cur]){
        if(child == P)continue;
        dfs(child, cur);
        ans[cur] += ans[child];
        leaf[cur] += leaf[child];
        if(leaf[child] == 1)found = true;
        cnt++;
    }
    if(cnt>=2 && found){
        ans[cur]--;
        cnt--;
    }
    if(cnt == 0){
        ans[cur] = 1;
        leaf[cur] =1;
    }
}


signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
//    freopen("1_13.txt", "r", stdin);
    int n;cin >> n;
    int x,y;
    FOR(i, n - 1)cin >> x >> y, adj[x].pb(y), adj[y].pb(x);
    FOR(i, n){
        if(adj[i].size() > 2){
            root =i;
            dfs(i, -1);
            cout << ans[i];
            return 0;
        }
    }
    cout << 1;
}




Measured memory_bytes: 11648
#include <iostream>
#include<vector>
//imit
using namespace std;
int main(void){
    int n,m,k;
    cin >> n >> m >> k;
    
    vector<int> a(n);
    vector<int> b(m);
    
    for(int i = 0;i < n;i++){
          cin >> a[i];
    }
    for(int i = 0;i < m;i++){
          cin >> b[i];
    }
    long long t = 0;
    for(int i = 0;i < m;i++){
          t += b[i];
    }
    
    int j = m;
    int ans = 0;
    
    for(int i = 0;i < n + 1;i++){
          while(j > 0 && t > k){
                j--;
                t -= b[j];
          }
          if(t > k)break;
          ans = max(ans,i + j);
          if(i == n)break;
          t += a[i];
    }
    cout << ans << endl;
}


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

int main(){

   int a,b;
   cin >> a >> b;

   int res = a+b;
   if(res>=24) cout << res -24 << endl;
   else cout << res << endl;


//   if(b-a == c-b) cout << "YES" << endl;
//  else cout << "NO" << endl;



   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

ll lcm(ll a, ll b) {
	return a*b/__gcd(a,b);
}

ll power(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n&1) {
			res = (res*a)%mod;
		}
		a = (a*a)%mod;
		n = n/2;
	}
	return res;
}

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--){
		int n;
		cin>>n;
		int arr[n+1] = {0};
		for(int i=1; i<=sqrt(n); i++) {
			for(int j=1; j<=sqrt(n); j++) {
				for(int k=1; k<=sqrt(n); k++) {
					ll temp = i*i + j*j + k*k + i*j + j*k + k*i;
					if(temp <= n) arr[temp]++;
				}
			}
		}
		for(int i=1; i<=n; i++) {
			cout<<arr[i]<<"\n";
		}
 	}
 	return 0;
}


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

using namespace std;




int main(){

	int n, k; cin >> n >> k;


	string s; cin >> s;


	int cnt = 0;

	for(int i = 1; i < s.size(); i++){
		if(s[i] != s[i - 1]){
			cnt++;
		}
	}


	cout << n - 1 - max(0, cnt - k * 2) << endl;


	// vector <int> a, b;

	// if(s[0] == 'L'){
	// 	a.push_back(1);
	// }else{
	// 	b.push_back(1);
	// }

	// for(int i = 1; i < n; i++){
	// 	if(s[i] != s[i - 1]){
	// 		if(s[i] == 'L'){
	// 			a.push_back(1);
	// 		}else{
	// 			b.push_back(1);
	// 		}
	// 	}else{
	// 		if(s[i] == 'L'){
	// 			a[a.size() - 1]++;
	// 		}else{
	// 			b[b.size() - 1]++;
	// 		}
	// 	}
	// }






	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int v[1000006],n,sol;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<n;++i) cin>>v[i];
    sol=v[n-1]+v[1];
    for(int i=1;i<n-1;++i)
    {
        sol+=min(v[i],v[i+1]);
    }
    cout<<sol;
    return 0;
}


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

void digit_down(int *A, int N, int K){
	int i;
	for(i = N - 1; A[i] == 0; i--){}
	if(A[i] == 1){
		A[i] = 0;
	}
	else{
		A[i]--;
		for(i++; i < N; i++){
			A[i] = K;
		}
	}
}

int main(){
	int N, K, i;
	scanf("%d%d", &K, &N);
	if(K == 1){
		for(i = 0; i < (N + 1) / 2; i++){
			printf("1 ");
		}
	}
	else if(K % 2 == 0){
		printf("%d ", K / 2);
		for(i = 1; i < N; i++){
			printf("%d ", K);
		}
	}
	else{
		int *ans = (int *)malloc(sizeof(int) * N);
		for(i = 0; i < N; i++){
			ans[i] = (K + 1) / 2;
		}
		int l = N / 2;
		for(i = 0; i < l; i++){
			digit_down(ans, N, K);
		}
		for(i = 0; i < N; i++){
			if(ans[i] != 0){
				printf("%d ", ans[i]);
			}
		}
	}
	printf("\n");
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String strArr[] = br.readLine().split(" ");
            int n = Integer.parseInt(strArr[0]);
            int k = Integer.parseInt(strArr[1]);
            long result = k;
            for (int i = 1; i < n; i++) {
                result = result * (k - 1);
            }
            System.out.println(result);
       } catch (IOException e) {
            e.printStackTrace();
       }
    }
}


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

int main(){

    string s;
    cin >> s;
    int cnt = 0;
    rep(i,3) {
        if(s[i] == 'o') ++cnt; 
    }

    int res;
    res = 700 + 100*cnt;

    cout << res << endl;


    return 0;
}

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

namespace ConsoleTest
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            var arr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var shirogane = new int[10001];

            for (var i = 0; i < arr.Length; ++i)
                shirogane[arr[i]]++;

            var ap = shirogane.Select((e, i) => Enumerable.Repeat(i, e)).SelectMany(e => e);
            Console.WriteLine(string.Join(" ", ap));
        }
    }
}


Measured memory_bytes: 166896
up = list(input().split())
mid = list(input().split())
down = list(input().split())

table = [up, mid, down]

nums = []
while True:
    try:
        nums.append(input())
    except EOFError:
        break

for i in range(3):
  for j in range(3):
    if table[i][j] in nums:
      table[i][j] = 'T'

flag = False

for i in range(3):
  if table[i].count('T') == 3:
    print('Yes')
    flag = True
    if flag == True:
      break

if flag == False:
  if table[0][0]=='T' and table[1][0]=='T' and table[2][0]=='T':
    print('Yes')
    flag = True
    
if flag == False:
  if table[0][1]=='T' and table[1][1]=='T' and table[2][1]=='T':
    print('Yes')
    flag = True
    
if flag == False:
  if table[0][2]=='T' and table[1][2]=='T' and table[2][2]=='T':
    print('Yes')
    flag = True

if flag == False:
  if table[0][0]=='T' and table[1][1]=='T' and table[2][2]=='T':
    print('Yes')
    flag = True
    
if flag == False:
  if table[0][2]=='T' and table[1][1]=='T' and table[2][0]=='T':
    print('Yes')
    flag = True
    
if flag == False:
  print('No')

Measured memory_bytes: 3064
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
#define SIZE 200010
class unionfind
{
public:
	int par[SIZE];
	int ran[SIZE];
	int ren[SIZE];
	int cnt[SIZE];
	void init()
	{
		for (int i = 0; i<SIZE; i++)
		{
			par[i] = i;
			ran[i] = 0;
			ren[i] = 1;
			cnt[i] = 0;
		}
	}
	int find(int a)
	{
		if (a == par[a])return a;
		else return par[a] = find(par[a]);
	}
	void unite(int a, int b)
	{
		a = find(a);
		b = find(b);
		if (a == b)return;
		if (ran[a]>ran[b])
		{
			par[b] = a;
			ren[a] += ren[b];
			cnt[a] += cnt[b];
		}
		else
		{
			par[a] = b;
			ren[b] += ren[a];
			cnt[b] += cnt[a];
		}
		if (ran[a] == ran[b])ran[b]++;
	}
};
unionfind uf;
int main()
{
	int num;
	scanf("%d", &num);
	vector<int>va, vb;
	int a = 0, b = 0;
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		va.push_back(z);
		a ^= z;
	}
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		vb.push_back(z);
		b ^= z;
	}
	va.push_back(a);
	vb.push_back(b);
	vector<int>zta = va, ztb = vb;
	sort(zta.begin(), zta.end());
	sort(ztb.begin(), ztb.end());
	if (zta != ztb)
	{
		printf("-1\n");
		return 0;
	}
	for (int i = 0; i < va.size(); i++)
	{
		va[i] = lower_bound(zta.begin(), zta.end(), va[i]) - zta.begin();
		vb[i] = lower_bound(ztb.begin(), ztb.end(), vb[i]) - ztb.begin();
	}
	uf.init();
	for (int i = 0; i < va.size(); i++)if (va[i] != vb[i])uf.cnt[va[i]]++;
	for (int i = 0; i < va.size(); i++)uf.unite(va[i], vb[i]);
	int ans = 0;
	for (int i = 0; i < va.size(); i++)
	{
		if (uf.find(i) == i)
		{
			if (uf.cnt[i] > 1)
			{
				if (uf.find(va[num]) == i)
				{
					if (va[num] != vb[num])ans += uf.cnt[i] - 1;
					else ans += uf.cnt[i];
				}
				else ans += uf.cnt[i] + 1;
			}
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 5112
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
	int N, cnt=0,Min=1987654321;
	long long sum=0;
	scanf("%d",&N);
	while(N--){
		int tmp;
		scanf("%d",&tmp);
		sum+=abs(tmp);
		Min=min(Min,abs(tmp));
		cnt+=tmp<0;
	}
	printf("%lld",sum-(cnt%2?Min*2:0));
}


Measured memory_bytes: 128
from collections import defaultdict
import math
N = int(input())
A = [int(x) for x in input().split()]
D = defaultdict(int)
for a in A:
  D[a] += 1
cnt = 0
for a in sorted(D.keys(), reverse=True):
  p = 2 ** math.ceil(math.log(a + 1, 2))
  d = p - a
  if a == d:
    cnt += D[a] // 2
    D[a] %= 2
  else:
    m = min(D[a], D[d])
    cnt += m
    D[a] -= m
    D[d] -= m
print(cnt)

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

int main(){
  int K;
  int i, j, l;
  int ans = 0;
  
  cin >> K;

  for(i=1; i <=K; i++){
    for(j=1; j <=K; j++){
      for(l=1; l <=K; l++){
        ans += gcd(gcd(i, j), l);
      }
    }
  }

  cout << ans;

}


Measured memory_bytes: 3624
#include<iostream>
#include<sstream>
#include<string>

using namespace std;

int string_to_int(const string& str){
  int n;
  istringstream iss(str);
  iss >> n;
  return n;
}

bool solve(const string& s, const string& t){
  if(t[0] == '0') return false;
  int x = s.empty() ? 0 : string_to_int(s);
  int y = string_to_int(t);
  if(x > y) return false;
  return (y-x)%2 == 0;
}

int main(){
  int ans=0;
  string str, s, t;
  cin >> str;
  for(int i=0; i<str.size(); ++i){
    s = str.substr(0, i);
    t = str.substr(i);
    if(s.size() > t.size()) break;
    if(solve(s, t)) ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1224
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

char S[32];

int main() {
  scanf("%s", S);
  int res = 0;
  for (int i = 0; i < 16; ++i) {
    if (S[i] != "CODEFESTIVAL2016"[i]) {
      ++res;
    }
  }
  printf("%d\n", res);
  return 0;
}


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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = long.Parse(Console.ReadLine());

			var tList = new List<long>();
			var aList = new List<long>();

			for (int i = 0; i < n; i++)
			{
				var line = Console.ReadLine().Split(' ').Select(value => long.Parse(value)).ToList();
				tList.Add(line[0]);
				aList.Add(line[1]);
			}

			var t = tList[0];
			var a = aList[0];

			for(int i = 1; i < n; i++)
			{
				var tRatio = tList[i];
				var aRatio = aList[i];

				if(tRatio == aRatio)
				{
					t = Math.Max(t, a);
					a = t;

					continue;
				}

				var tQuotient = GetRoundedUpQuotient(t, tRatio);
				var aQuotient = GetRoundedUpQuotient(a, aRatio);

				if(tQuotient > aQuotient)
				{
					t = tQuotient * tRatio;
					a = tQuotient * aRatio;
				}
				else
				{
					t = aQuotient * tRatio;
					a = aQuotient * aRatio;
				}
			}
			
			Console.WriteLine(t + a);
		}

		private static long GetRoundedUpQuotient(long target, long source)
		{
			var quotient = target / source;
			var remainder = target % source;

			return remainder == 0 ? quotient : quotient + 1;
		}
	}
}


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

N = int(input())
H = list(map(int, input().split()))

ans = True
tmp = 0
for i in range(N):
    if H[i] - 1 >= tmp:
        H[i] -= 1
    if H[i] < tmp:
        ans = False
        break
    tmp = H[i]

print('Yes' if ans else 'No')


Measured memory_bytes: 14396
S = input()
if S[0] == "A" and S[2:-1].count("C") == 1 and S.count("A") == 1 and S.count("C") == 1:
  S=S.replace("A","a")
  S=S.replace("C","c")
  if S.islower():
    print("AC")
  else:
    print("WA")
else:
  print("WA")

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int N;
  cin>>N;
  while(N--){
    int dx,dy;
    int x = 0;
    int y = 0;
    int maxdb = 0;
    PII maxp;
    while(cin>>dx>>dy){
      if(dx==0&&dy==0)break;
      x += dx;
      y += dy;
      if((maxdb==x*x+y*y&&maxp.first<x)||maxdb<x*x+y*y){
        maxp = PII(x,y);
        maxdb = x*x+y*y;
      }
    }
    printf("%d %d\n",maxp.first,maxp.second);
  }
      

  return 0;
}

Measured memory_bytes: 0
import math
n, d = map(int, input().split())
x = []
for i in range(n):
  x_ = list(map(int, input().split()))
  x.append(x_)
#print(x)
ans = 0  
for i in range(n-1):
  for j in range(i+1, n):
    id = 0
    for k in range(d):
      id += (x[i][k]-x[j][k])**2
    if math.sqrt(id) == int(math.sqrt(id)):
      ans += 1
print(ans)

Measured memory_bytes: 9064
#include <iostream>
using namespace std;
int main(){
    string v="aeiou";
    char c;
    cin>>c;
    for(int i=0;i<5;i++){
        if(c==v[i]){
            cout<<"vowel"<<endl;
            return 0;
        }
    }
    cout<<"consonant"<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var abhm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var a = abhm[0];
        var b = abhm[1];
        var h = abhm[2];
        var m = abhm[3];

        var hoge = ((h * 60.0 + m) / (12 * 60) * 11) % 1;
        var deg = hoge * 2 * PI;
        var cos = Cos(deg) * a;
        var sin = Sin(deg) * a;
        Console.WriteLine(Sqrt(Pow(b - cos, 2) + Pow(Abs(sin), 2)));
    }
}


Measured memory_bytes: 28752
H, W = map(int, input().split())
X = [[1 if a == "#" else 0 for a in input()] for _ in range(H)]

Q = [0]
D = [[0] * W for _ in range(H)]
D[0][0] = 1
while Q:
    x = Q.pop()
    i, j = x//W, x%W
    for di, dj in ((1, 0), (0, 1)):
        ni, nj = i+di, j+dj
        if ni < H and nj < W and X[ni][nj]:
            if D[ni][nj] == 0:
                D[ni][nj] = 1
                Q.append(ni*W + nj)
if D[-1][-1] and sum([sum(x) for x in X]) == H + W - 1:
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 3064
#include <stdio.h>

const int sup = 1 << 30;

typedef struct {
	int id;
	long long key;
} data;

typedef struct {
	data obj[100001];
	int size;
} max_heap;

void push(data x, max_heap* h)
{
	int i = h->size;
	data tmp;
	h->obj[(h->size)++] = x;
	while (1) {
		if (i == 0) break;
		else if (h->obj[i].key > h->obj[(i-1)/2].key) {
			tmp = h->obj[(i-1)/2];
			h->obj[(i-1)/2] = h->obj[i];
			h->obj[i] = tmp;
			i = (i - 1) / 2;
		} else break;
	}
}

data pop(max_heap* h)
{
	int i = 0, j;
	data output = h->obj[0], tmp;
	h->obj[0] = h->obj[--(h->size)];
	while (1) {
		if (i * 2 + 1 >= h->size) break;
		else if (i * 2 + 2 >= h->size) j = i * 2 + 1;
		else if (h->obj[i*2+1].key > h->obj[i*2+2].key) j = i * 2 + 1;
		else j = i * 2 + 2;
		if (h->obj[j].key > h->obj[i].key) {
			tmp = h->obj[j];
			h->obj[j] = h->obj[i];
			h->obj[i] = tmp;
			i = j;
		} else break;
	}
	return output;
}

int main()
{
	int i, N, L[100001], R[100001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d %d", &(L[i]), &(R[i]));

	int min = R[1], argmin = 1;
	for (i = 2; i <= N; i++) {
		if (R[i] < min) {
			min = R[i];
			argmin = i;
		}
	}

	data d;
	max_heap h;
	h.size = 0;
	for (i = 1; i <= N; i++) {
		if (i == argmin) continue;
		d.key = (long long)L[i] * sup + R[i];
		push(d, &h);
	}
	
	long long ans = 0, l[2] = {L[argmin], h.obj[0].key / sup}, r[2] = {R[argmin], h.obj[0].key % sup};
	while (h.size > 0 && h.obj[0].key / sup > r[0]) {
		d = pop(&h);
		l[1] = (l[1] < d.key / sup)? d.key / sup: l[1];
		r[1] = (r[1] > d.key % sup)? d.key % sup: r[1];
	}
	while (h.size > 0) {
		l[0] = h.obj[0].key / sup;
		if (r[0] - l[0] + 1 + ((r[1] >= l[1])? r[1] - l[1] + 1: 0) > ans) ans = r[0] - l[0] + 1 + ((r[1] >= l[1])? r[1] - l[1] + 1: 0);
		while (h.size > 0 && h.obj[0].key / sup == l[0]) {
			d = pop(&h);
			r[1] = (r[1] > d.key % sup)? d.key % sup: r[1];
		}
	}
	l[0] = L[argmin];
	if (r[0] - l[0] + 1 + ((r[1] >= l[1])? r[1] - l[1] + 1: 0) > ans) ans = r[0] - l[0] + 1 + ((r[1] >= l[1])? r[1] - l[1] + 1: 0);
	
	int max = R[argmin] - L[argmin], argmax = argmin;
	for (i = 1; i <= N; i++) {
		if (R[i] - L[i] > max) {
			max = R[i] - L[i];
			argmax = i;
		}
	}
	if (argmax != argmin) {
		for (i = 1, max = 0; i <= N; i++) {
			if (i == argmax) continue;
			if (L[i] > max) max = L[i];
		}
		if (R[argmax] - L[argmax] + 1 + ((max <= min)? min - max + 1: 0) > ans) ans = R[argmax] - L[argmax] + 1 + ((max <= min)? min - max + 1: 0);
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

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

using namespace std;

const int maxn = 100010;
int n,l,a[maxn],pos,ans[maxn],cnt;

int main()
{
    scanf("%d%d",&n,&l);
    for (int i = 1; i <= n; i++)
        scanf("%d",&a[i]);
    pos = -1;
    for (int i = 1; i < n; i++)
        if (a[i] + a[i + 1] >= l)
        {
            pos = i;
            break;
        }
    if (pos == -1)
        puts("Impossible");
    else
    {
        puts("Possible");
        ans[++cnt] = pos;
        for (int i = pos + 1; i < n; i++)
            ans[++cnt] = i;
        for (int i = pos - 1; i >= 1; i--)
            ans[++cnt] = i;
        for (int i = cnt; i >= 1; i--)
            printf("%d\n",ans[i]);
    }

    return 0;
}


Measured memory_bytes: 1536
import math
A,B,H,M = map(int,input().split())

theta_b = M*6
theta_a = (H*60+M)*0.5
theta = theta_b - theta_a
if theta > 180:
    theta = 360 - theta

C = math.radians(theta)
cc = A*A+B*B-2*A*B*math.cos(C)
c = math.sqrt(cc)
print(c)

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

using namespace std;

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

	int n, c, k;
	cin >> n >> c >> k;
	vector<int>t(n);
	for (auto &x : t)
		cin >> x;

	sort(t.begin(), t.end());
	int least = 0, start = 0, count = 0;
	for (int i = 0; i < n; i++) {
		if (start == 0) start = t[i] + k;
		//start!=0
		if (count != c) {
			if (t[i] <= start) count++;
			else {
				least++;
				count = 1;
				start = t[i] + k;
			}
		}
		if (count == c) {
			least++;
			count = 0;
			start = 0;
		}
		//cout << "\nt[" << i << "]=" << t[i] << "\nstart=" << start << "\ncount=" << count << "\nleast=" << least << "\n\n";
	}


	if (count > 0)least++;
	cout << least << "\n";
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int a,b,k;
	cin>>a>>b>>k;
	for(int i=a;i<min(a+k,b+1);i++)cout<<i<<endl;
	for(int i=max(a+k,b-k+1);i<=b;i++)cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
using namespace std;
char str[200010];
string s;
int ans;
int main(){
  scanf("%s\n",&str );
  s=str;
  ans=-s.find('A')+s.rfind('Z')+1;
  printf("%d\n",ans );
}


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

using namespace std;

int main()
{
    string input;
    cin >> input;
    int n = input.length();

    int cnt = 0;
    for (int i = n - 2; i >= 0; i--)
    {
        if (i == input.length() - 1)
            continue;
        if (input[i + 1] != input[i])
        {
            if (i < n - 2 && i > 0)
                input = input.substr(0, i) + input.substr(i + 2, n - i - 2);
            else if (i < n - 2)
                input = input.substr(i + 2, n - i - 2);
            else
                input = input.substr(0, i);
            cnt++;
        }
    }

    printf("%d\n", cnt * 2);

    return 0;
}


Measured memory_bytes: 788
N = int(input())
S = []
C = []
for i in range(N):
    S.append(input())

results = ['AC', 'WA', 'TLE', 'RE']
for result in results:
    C.append(S.count(result))
print(f"AC x ",C[0],
"\nWA x ",C[1],
"\nTLE x ",C[2],
"\nRE x ",C[3]
)   

Measured memory_bytes: 16320
#include <stdio.h>
#define inf 1000000
#define NIL -1
#define WHITE 0
#define BLACK 1
#define MAX 100

void prim();
int n,w[MAX][MAX];

int main(){
  int i,j;

  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&w[i][j]);
      if(w[i][j]==-1) w[i][j]=inf;
    }
  }

  prim();

  return 0;
}

void prim(){
  int d[MAX], pi[MAX], color[MAX];
  int u,mincost,i,v,sum=0,j;

  for(u=0;u<n;u++){
    d[u]=inf;
    pi[u]=NIL;
    color[u]=WHITE;
  }

  d[0]=0;

  while(1){
    mincost=inf;

    for(i=0;i<n;i++){
      if(color[i]!=BLACK && d[i]<mincost){
        mincost=d[i];
        u=i;
      }

    }

    if(mincost==inf) break;

    color[u]=BLACK;

    for(v=0;v<n;v++){
      if(color[v]!=BLACK && w[u][v]<d[v]){
        pi[v]=u;
        d[v]=w[u][v];
      }
    }
    
  }

  for(i=0;i<n;i++){
    if(pi[i]!=NIL) sum+=w[i][pi[i]];
  }

  printf("%d\n",sum);
}


Measured memory_bytes: 2112
#include <iostream>
using namespace std;
int cards[520];
char mark[1000];
bool trump[40][520];

int main(){
    int n;
    int i = 0;
    cin >> n;
    
    for(int j=1;j<=n;j++){
        cin >> mark[i] >> cards[j];
        if(mark[i] == 'S'){
            i = 0;
        }
        else if(mark[i] == 'H'){
            i = 1;
        }
        else if(mark[i] == 'C'){
            i = 2;
        }
        else if(mark[i] == 'D'){
            i = 3;
        }
        trump[i][cards[j]] = true;
    }
    
    for(int i=0;i<4;i++){
        for(int j=1;j<=13;j++){
            if(trump[i][j] == false){
                if(i == 0){
                    mark[i] = 'S';
                }
                else if(i == 1){
                    mark[i] = 'H';
                }
                else if(i == 2){
                    mark[i] = 'C';
                }
                else if(i == 3){
                    mark[i] = 'D';
                }
                cout << mark[i] << " " << j << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3012
// AOJ ALDS1_8_A Binary Search Tree I
// 2018.5.1 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in()
{
	int n = 0, c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void skip(int k) { while (k--) gc(); }

void out(int n)
{
	int i;
	char ob[20];

	if (!n) { pc('0'); return; }
	if (n < 0) pc('-'), n = -n;
	i = 0; while (n) ob[i++] = n%10 + '0', n/=10;
	while (i--) pc(ob[i]); 
}

typedef struct { int key; int parent; int left, right; } BT;
BT bt[500005]; int sz;
int root;

void preorder(int node)
{
	pc(' '), out(bt[node].key);
	if (bt[node].left  > 0) preorder(bt[node].left);
	if (bt[node].right > 0) preorder(bt[node].right);
}

void inorder(int node)
{
	if (bt[node].left  > 0) inorder(bt[node].left);
	pc(' '), out(bt[node].key);
	if (bt[node].right > 0) inorder(bt[node].right);
}

void insert(int z)
{
	int x, y;

	y = 0, x = root;
	while (x) {
		y = x;
		if (bt[z].key < bt[x].key) x = bt[x].left;
		else                       x = bt[x].right;
	}
	bt[z].parent = y;

	if (!y) root = z;
	else if (bt[z].key < bt[y].key) bt[y].left  = z;
	else                            bt[y].right = z;
}

int main()
{
	int n, i;

	n = in(), root = 0, sz = 1;
	for (i = 0; i < n; i++) {
		if (gc() == 'p') {
			skip(5);
			inorder(root), pc('\n');
			preorder(root), pc('\n');
		} else {
			skip(6);
			bt[sz].key = in();
			insert(sz++);
		}
	}
	return 0;
}


Measured memory_bytes: 9248
n, k = map(int, input().split())
n_list = []
for _ in range(n):
    tmp = list(map(int, input().split()))
    n_list.append(tmp)
n_list.sort()
cnt = 0
for arr in n_list:
    cnt += arr[1]
    if k <= cnt:
        print(arr[0])
        break


Measured memory_bytes: 27872
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <queue>
#include <utility>
using namespace std;
int main() {
	int N;
	int C[]={500,100,50,10,5,1};
	while(scanf("%d",&N),N) {
		N=1000-N;
		int sum=0;
		for(int i=0;i<6;i++) {
			sum+=N/C[i];
			N%=C[i];
		}
		printf("%d\n",sum);
	}
}

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

void bubbleSort(int A[], int N);

int main() {
	int N;
	cin >> N;
	int A[N];
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	
	bubbleSort(A, N);
	return 0;
}

void bubbleSort(int A[], int N) {
	int flag = 1;
	int j = 0;
	int cnt = 0;
	while (flag) {
		flag = 0;
		for (int i = N-1; i > j; i--) {
			if (A[i] < A[i-1]) {
				int v = A[i];
				A[i] = A[i-1];
				A[i-1] = v;
				flag = 1;
				cnt++;
			}
		}
		j++;
	}
	for (int i = 0; i <N-1; i++) {
		cout << A[i] << " ";
	}
	cout << A[N-1] << endl;
	cout << cnt << endl;
}

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

int N;
int a[110];

int main(){
    cin>>N;

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

    sort(a, a+N, greater<int>());

    int asum = 0;
    int bsum = 0;

    for (int i = 0; i < N; i++)
    {
        if(i%2 == 0) asum += a[i];
        else  bsum += a[i];
    }
    
    cout << asum - bsum << endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion


int gcd(int a, int b){
    while(b != 0){
        int t = a % b;
        a = b;
        b = t;
    }
    return a;
}

int32_t main() {
    make(int, n);
    int sm = 0;
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= n; ++j){
            for(int k = 1; k <= n; ++k){
                sm += gcd(gcd(i, j), k);
            }
        }
    }
    cout << sm;
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	while(true){
	string c[11];
	int n,k;
	vector<string> num;
	int sum=0;
	cin >> n >> k;
	if(n==0 && k==0)
	break;
	for(int i=1;i<=n;i++)
	cin >> c[i];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			for(int l=(k>=3 ? 1 : 0);l<=(k>=3 ? n : 0);l++)
				for(int ii=(k>=4 ? 1 : 0);ii<=(k>=4 ? n : 0);ii++)
					if(((ii!=i && ii!=j && ii!=l )|| ii==0)&&((l!=i && l!=j) || l==0) && (j!=i))num.push_back(c[i]+c[j]+c[l]+c[ii]);
	sort(num.begin(),num.end());
	for(int i=0;i<num.size();i++){

		if(i+1==num.size() || num[i]!=num[i+1]){
			sum++;
		}
	}
	cout << sum << endl;
}
	return 0;
}

Measured memory_bytes: 1360
#include<stdio.h>

int main(void)
{
	long a,b;
	scanf("%ld %ld",&a, &b);
	long d = a / b;
	long r = a % b;
	double f = 1.0 * a / b;
	printf("%ld %ld %f\n",d, r, f);
        return 0;
}

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

int main()
{
	int n;
	int withouttax;
	cin >> n;
	withouttax = n;
	while (withouttax * 27 / 25 >= n)
	{
		if (withouttax * 27 / 25 == n)
		{
			cout << withouttax << '\n';
			return (0);
		}
		withouttax--;
	}
	cout << ":(" << '\n';
	return (0);
}


Measured memory_bytes: 3572
# Fusing Slimes
N = int(input())
X = list(map(int, input().split()))
mod = 10 ** 9 + 7
rev_sum=[0 for i in range(N+1)]
#rev_sum[x]= 1/1+   1/x
for i in range(1,N+1):
    rev_sum[i]+=rev_sum[i-1]+pow(i,mod-2,mod)
ans=0
for i in range(N-1):
    ans+=(X[i+1]-X[i])*rev_sum[i+1]
    ans%=mod
for i in range(1,N):
    ans=ans*i
    ans%=mod
print(ans)

Measured memory_bytes: 20064
import java.util.Scanner;

public interface Main {
	static int a = 1;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a < b && b < c)
			System.out.printf("Yes\n");
		else
			System.out.printf("No\n");
	}
}



Measured memory_bytes: 26360
n = int(input())
s = list(input())

S = [0] * n
countW = 0
for i in range(n):
    if s[i] == "W":
        S[i] = 1
        countW += 1

ans = []
countE = n - countW
left = 0
right = 0

for i in range(n):
    if i == 0:
        if S[0] == 0:
            ans.append(countE - 1)
        else:
            ans.append(countE)
    elif 0 < i < n-1:
        left += S[i-1]
        right = n - i - 1 - countW + left + S[i]
        ans.append(left + right)
    elif i == n-1:
        ans.append(countW - S[-1])
print(min(ans))

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

#define MAX 2000001
#define VMAX 10000

int n,i,j;

void CountingSort(short A[],short B[],int k)
{
  int C[VMAX+1];
  for(i=0;i<=k;i++) C[i]=0;

  for(j=0;j<n;j++) C[A[j]]++;

  for(i=1;i<=k;i++) C[i]=C[i]+C[i-1];

  for(j=n-1;j>=0;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
      }
}

int main(){
  unsigned short *A, *B;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=0;i<n;i++) scanf("%d",&A[i]);
  CountingSort(A,B,VMAX);

  for(i=1;i<=n;i++){
    printf("%d",B[i]);
    if(i==n){
      printf("\n");
    }else printf(" ");
  }
  return 0;
}



Measured memory_bytes: 9620
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
bool erato[(int)1e6 + 20];
// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
ll gcd(ll a, ll b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}
map<ll, ll> prime_factorization(long long n) {
  // map<ll,ll> first=素因数 second=first素因数の数
  map<ll, ll> res;
  for (int i = 2; i <= n / i; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
int main() {
  /*REP(i, (int)1e6 + 20) erato[i] = true;
  erato[0] = false;
  for (int i = 2; i <= (int)(1e6 + 2) / i; i++) {
    if (erato[i] != true) {
      continue;
    }
    for (int j = 2; j * i <= (int)(1e6 + 2); j++) {
      erato[i * j] = false;
    }
  }*/
  ll N;
  cin >> N;
  bool pairwise_coprime = true;
  unordered_map<int, int> uo{};
  vector<int> A(N);
  ll num;
  map<ll, ll> mp;
  REP(i, N) {
    cin >> A[i];
    if (pairwise_coprime) {
      mp = prime_factorization(A[i]);
      for (auto s : mp) {
        if (uo[s.first] != 0) {
          pairwise_coprime = false;
          break;
        }
        uo[s.first] = 1;
      }
    }
    if (i == 1) {
      num = gcd(A[0], A[1]);
    } else if (1 < i) {
      num = gcd(num, A[i]);
    }
  }
  if (pairwise_coprime) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  if (num == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }
  cout << "not coprime" << endl;
}

Measured memory_bytes: 7140
N, M = map(int, input().split())
A = sorted([int(a) for a in input().split()], reverse=True)

joken = sum(A)/(4*M)
can_choose = True
for i in range(M):
    if A[i] < joken:
        can_choose = False
        break

if can_choose:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;
//あとでやる https://atcoder.jp/contests/abc114/tasks/abc114_d
int main(){
    int N;
    cin>>N;
    for(int i=111;i<=999;i+=111){
        if(N<=i){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X,Y;
  cin >> X >> Y;
  
  if (4*X-Y < 0) {
    cout << "No" << endl;
  }
  
  else if (4*X-Y >= 0 && (4*X-Y)%2 == 0 && (4*X-Y)/2 <= X) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3632
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))

ans = [[0] * W for _ in range(H)]
k = 0
for i in range(H):
    for j in range(W):
        if i % 2 == 0:
            ans[i][j] = k+1
        else:
            ans[i][W-1-j] = k+1
        a[k] -= 1
        if a[k] == 0:
            k += 1
for i in range(H):
    print(' '.join(map(str, ans[i])))


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
// ==================================================
using i64 = int64_t; using u64 = uint64_t;
#define rep(i,a,b) for(i64 i=(i64)(a);i<(i64)(b);i++)
#define repn(i,n) rep(i,0,n)
#define din(t, ...) t __VA_ARGS__;_din(__VA_ARGS__)
#define stlv(t,n) vector<t> n
#define stls(t,n) set<t> n
void _din() {} void dout() { cout << endl; }
template <typename T, typename ... Args> inline void _din(T& head, Args& ... rest) { cin >> head; _din(rest...); }
template <typename T, typename ... Args> inline void dout(T head, Args ... rest) { cout << head; if (sizeof...(rest)) cout << ' '; dout(rest...); }
template <typename T>inline void vsortg(vector<T>& v) { sort(v.begin(), v.end(), greater<T>()); }
template <typename T>inline void vsortl(vector<T>& v) { sort(v.begin(), v.end(), less<T>()); }
template <typename T> inline T nmax(T f1, T f2) { return max(f1, f2); }
template <typename T, typename ... Args> inline T nmax(T first, Args ... rest) { return nmax(first, nmax(rest...)); }
template <typename T> inline T nmin(T f1, T f2) { return min(f1, f2); }
template <typename T, typename ... Args> inline T nmin(T first, Args ... rest) { return nmin(first, nmin(rest...)); }

int main()
{
	din(i64, p, m, c);
	dout(p + m + c);
	return 0;
}


Measured memory_bytes: 3088
#include<iostream>
using namespace std;
int main(){
	int n,sum,box[]={500,100,50,10,5,1};
	while(cin>>n,n){
		n=1000-n;
		sum=0;
		for(int i=0;i<6;i++){
			sum+=n/box[i];
			n=n-n/box[i]*box[i];
		}
		cout<<sum<<endl;
	}
	return 0;
}

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

namespace ABC57_C
{
    class Program
    {
        static void Main(string[] args)
        {

            var n = long.Parse(Console.ReadLine());
            long ma = 1;
            for (int i = 1; i <= Math.Sqrt(n); i++)
            {
                if(n % i == 0) ma = Math.Max(ma, i);
            }
            long b = n / ma;

            Console.WriteLine(Math.Max(ma.ToString().Length, b.ToString().Length));
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

int n, m, k, mn, x, y, c, mna = 1e9, mnb = 1e9, a[N], b[N];
int main()
{
	int i;
	cin >> n >> m >> k;
	for (i = 1; i <= n; i++) scanf("%d", &a[i]), mna = min(mna, a[i]);
	for (i = 1; i <= m; i++) scanf("%d", &b[i]), mnb = min(mnb, b[i]);
	mn = mna + mnb;
	while (k--) {
		scanf("%d %d %d", &x, &y, &c);
		mn = min(mn, a[x] + b[y] - c);
	}
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 1024
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.List (unfoldr)
import qualified Data.ByteString.Char8 as BS

main = do
  [n,m] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  xs <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let a = n - sum xs
  if a < 0 then
    putStrLn "-1"
  else
    print a


Measured memory_bytes: 5260
a=[(1<<29)*-1]*3
for i in range(10):
	h = int(input())
	if h > a[0]:
		a[2]=a[1]
		a[1]=a[0]
		a[0]=h
	elif h > a[1]:
		a[2]=a[1]
		a[1]=h
	elif h > a[2]:
		a[2]=h

for i in range(3):
	print(a[i])



Measured memory_bytes: 5596
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::cmp::max;
use std::cmp::min;


fn main() {
    input! {
        N: usize,
    }

    let mut arr: Vec<i64> = vec![0i64; 1000];
    arr[0] = 2;
    arr[1] = 1;

    for i in 2..86 + 1 {
        arr[i] = arr[i - 2] + arr[i - 1];
    }

    let ans = arr[N];
    println!("{}", ans);
}


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

int main(){
    ll n, k;
    cin >> n >> k;
    vector<int> nx(n);
    for(int i = 0; i < n; i++){
        cin >> nx[i];
        nx[i]--;
    }
    vector<int> visited(n);
    int u = 0, cnt = 0;
    int v = -1, loop = 0;
    while(!visited[u] || u != 0){
        if(visited[u] == 1 && u != 0){
            v = u;
            while(visited[v] < 2){
                visited[v]++;
                v = nx[v];
                loop++;
            }
            break;
        }
        visited[u]++;
        u = nx[u];
        cnt++;
    }
    if(v == -1){
        v = 0;
        loop = cnt;
    }
    //cout << cnt << " " << loop << endl;
    if(k < cnt - loop){
        u = 0;
        for(int i = 0; i < k % cnt; i++){
            u = nx[u];
        }
        cout << u+1 << endl;
    } else {
        int t = (k - cnt + loop) % loop;
        for(int i = 0; i < t; i++){
            v = nx[v];
        }
        cout << v+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 4840
import java.util.*

fun main(args: Array<String>) {
    val stack1 = Stack<Int>()
    val stack2 = Stack<Pair<Int, Int>>()
    var sum = 0
    readLine()?.forEachIndexed { i, c ->
        if (c == '\\') {
            stack1.push(i)
        } else if (c == '/' && stack1.isNotEmpty()) {
            val j = stack1.pop()
            var a = i - j
            sum += a
            while (stack2.isNotEmpty() && stack2.peek().first > j) {
               a += stack2.pop().second
            }
            stack2.push(Pair(j, a))
        }
    }
    println(sum)
    println(stack2.map { it.second }.fold("${stack2.size}") { s, i ->
        "$s $i"
    })
}


Measured memory_bytes: 60172