akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

    vector<bool> alpha_list(26, true);

    string s;
    cin >> s;
    for (char ch : s)
    {
        int ind = (int)(ch - 'a');
        alpha_list[ind] = false;
    }

    for (int i = 0; i < 26; i++)
    {
        if (alpha_list[i])
        {
            char ch = 'a' + i;
            cout << ch << endl;
            return 0;
        }
    }
    cout << "None" << endl;

    return 0;
}

Measured memory_bytes: 512
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	long long int N, res=0, min, max;
	vector<long long int> A;

	cin >> N;

	rep(i, N){
		long long int tmp;
		cin >> tmp;
		A.push_back(tmp);
	}

	sort(A.begin(), A.end(), greater<long long int>());

	if(A.size()%2 == 1){
		for(int i=1; i<=A.size()/2; i++){
			res+=A[i-1];
		}
		for(int i=A.size()/2+1; i<A.size(); i++){
			res += A[i-A.size()/2];
		}
	}else{
		for(int i=1; i<=A.size()/2; i++){
			res+=A[i-1];
		}
		for(int i=A.size()/2+1; i<A.size(); i++){
			res += A[i-A.size()/2];
		}
	}

	cout << res;

	return 0;
}

Measured memory_bytes: 5356
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

struct Data{
    int x, y, s;
    Data(int x, int y, int s) : x(x), y(y), s(s) {}
    Data() {}
};

int main () {
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<char>> A(H, vector<char>(W, '#'));
    int sx, sy;
    int dx[] = {0, 1, 0, -1};
    int dy[] = {1, 0, -1, 0};
    REP (i, 0, H) REP (j, 0, W) {
        cin >> A[i][j];
        if (A[i][j] == 'S') {
            sy = i;
            sx = j;
        }
    }
    queue<Data> q;
    vector<vector<bool>> isAccess(H, vector<bool>(W, false));
    q.emplace(sx, sy, K);
    while (q.size()) {
        auto data = q.front();
        q.pop();
//        cout << data.x << ' ' << data.y << endl;
        if (isAccess[data.y][data.x]) continue;
        isAccess[data.y][data.x] = true;
        if (data.s <= 0) continue;
        if (data.x == 0 || data.x == W - 1 || data.y == 0 || data.y == H - 1) {
            cout << 1 << endl;
            return 0;
        }
        REP (i, 0, 4) {
            int xx = data.x + dx[i];
            int yy = data.y + dy[i];
            if (yy < 0 || yy >= H || xx < 0 || xx >= W || A[yy][xx] == '#') continue;
            if (isAccess[yy][xx]) continue;
            q.emplace(xx, yy, data.s - 1);
        }
    }
    int ans = 1 << 20;
    REP (i, 0, H) {
        REP (j, 0, W) {
            if (isAccess[i][j]) {
                ans = min({ans, (H - i + K - 2) / K, (i + K - 1) / K, (W - j + K - 2) / K, (j + K - 1) / K});
            }
        }
    }
    cout << ans + 1 << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef  double ld;
#define A 1000000007ll
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n"

int main() 
{
    FAST;
    ll n;
    cin>>n;
    ll a[n+1],avp[n+1];
    for(int i=0;i<=n;i++)
    {
        cin>>a[i];
        avp[i]=0;
    }
    ll la=1;
    for(int i=0;i<=n;i++)
    {
        if(a[i]>la)
        {
            cout<<-1;
            return 0;
        }
        avp[i]=la-a[i];
        la=min(2*avp[i],D);
    }
    ll ca=a[n],ans=ca;
    for(int i=n-1;i>=0;i--)
    {
        if(2*avp[i]<ca)
        {
            cout<<-1;
            return 0;
        }
        if(ca<avp[i])
            ca=ca+a[i];
        else
            ca=avp[i]+a[i];
        ans+=ca;
    }
    cout<<ans;
    subt;
    return 0;
}

Measured memory_bytes: 5368
n=gets.to_i
m=gets.split.map(&:to_i)
ans = 0
0.upto(m.size-1) do |i|
  a = m[i] - 1
  b = m[a] - 1
  if a != i  && b != a && b == i && a < b
    ans +=1
  end
end
puts ans


Measured memory_bytes: 8068
#include <stdio.h>
int main(void){
    int a,b,c,tmp;
    scanf("%d",&a); scanf("%d",&b); scanf("%d",&c);
    if(a>b){
        tmp=a;
        a=b;
        b=tmp;
    }
    if(b>c){
        tmp=b;
        b=c;
        c=tmp;
    }
    if(a>b){
        tmp=a;
        a=b;
        b=tmp;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}



Measured memory_bytes: 2032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;

int main(){
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)cin>>a[i];
	ll cnt1 = 0;
	ll cnt0 = 0;
	bool ans = false;
	if(n%3LL==0){
		ans = true;
	}

	sort(a,a+n);
	cnt1=1;
	for(ll i=0;i<n-1;i++){
		if(a[i]!=a[i+1])cnt1++;
	}
	if(cnt1<=3){
		ans=true;
	}


	ll m=a[n-1];

	for(ll i=0;;i++){
		cnt1=0;cnt0=0;
		if((1<<i)>(m)){
			break;
		}
		for(ll j=0;j<n;j++){
			if(a[j]&(1<<i))cnt1++;
			else cnt0++;
		}
		if(cnt1!=2LL*(n/3LL)&&cnt0!=n){
			ans = false;
		}
	}
	if(ans)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


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


#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(arr) arr.begin(),arr.end()
#define INF 2000000000
#define MOD 1000000007
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define mp make_pair
#define um unordered_map
#define us unordered_set
#define ff first
#define ss second



using namespace std; 
void solve(); 
int main() 
{ 
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 

/*
#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin); 
	freopen("error.txt", "w", stderr); 
	freopen("output.txt", "w", stdout); 
#endif 
*/
	//int t = 1; 
	/*is Single Test case?*/ 
	/*
	cin >> t; 
	while (t--) { 
		solve(); 
		cout << "\n"; 
	} 
	
	*/
	char s[6];
	cin>>s;
	if ((s[2] == s[3]) && (s[4] == s[5])){
		cout<<"Yes";
		}else{cout<<"No";}

	cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
	return 0; 
} 
void solve() 
{ 
} 


Measured memory_bytes: 256
#include <stdio.h>
#define H 500000

int A[H];
int n;

void maxHeapify(int i){
  int l, r, lar, temp;

  l = 2*i;
  r = 2*i+1;
//左のほうが大きい場合
  if((l <= n)&&(A[l] > A[i])){
    lar = l;
  }
  //自分が最大の場合
  else{
    lar = i;
  }
//
  if((l <= n)&&(A[r] > A[lar])){
    lar = r;
  }

  if(lar != i){
    temp = A[i];
    A[i] = A[lar];
    A[lar] = temp;
//再帰させる
    maxHeapify(lar);
  }

}

void buildMaxHeap(int n){
  int i;
  for(i = n/2; i >=1; i--){
    maxHeapify(i);
  }
}

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

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

  A[n+1] = 0;

  buildMaxHeap(n);

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

  return 0;
}




Measured memory_bytes: 3724
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long M = sc.nextLong();
		long perone = 1900*M+100*(N-M);
		long pgaku = pow(2, M);
		System.out.println(perone*pgaku);
	}
	
	static double kakuritsu(int i, double p) {
		double ret = p;
		for(int j=1;j<i; j++)  {
			ret *= (1-p);
		}
		return ret;
	}
	
	static int binarySearch(int[] A, int x) {
		int l = 0;
		int r = A.length;
		while(l<r) {
			int mid = (l+r)/2;
			if(A[mid] == x) return mid;
			else if(x<A[mid]) r = mid;
			else l = mid+1;
		}
		return -1;
	}
	
	static long upper_bound(int[] A, int b) {
		// bよりおおきい値がはじめて出てくるindexを返す
		return lower_bound(A, b+1);
	}

	static long lower_bound(int[] A, int b) {
		// b以上の値がはじめて出てくるindexを返す
		int lb=0;
		int ub=A.length;
		while(ub>lb) {
			int mid = (lb+ub)/2;
			if(A[mid]>=b) ub = mid;
			else lb = mid+1;
		}
		return lb;
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static int max(int...ls) {
		int ans = Integer.MIN_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.max(ans, ls[i]);
		}
		return ans;
	}
	
	static int min(int...ls) {
		int ans = Integer.MAX_VALUE;
		for(int i=0; i<ls.length; i++) {
			ans = Math.min(ans, ls[i]);
		}
		return ans;
	}
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static long pow(long a, long b) {
		if(b==0) return 1;
		if(b==1) return a;
		if(b%2==0) {
			long d = pow(a, b/2);
			return d*d;
		} else {
			return a*pow(a, b-1);
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}

Measured memory_bytes: 23764
X, N = list(map(int, input().split()))
# X, N = 10, 5

def func():
    if N == 0:
        return X

    P = list(map(int, input().split()))
    # P = [4, 7, 10, 6, 5]
        
    diff = 0
    while True:
        if X - diff not in P:
            return X - diff
        if X + diff not in P:
            return X + diff
        diff += 1


print(func())




Measured memory_bytes: 9180
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int r =0;
		for(int i=0;i<a;i++) {
			double x =sc.nextInt();
			double y= sc.nextInt();
			if(Math.sqrt(x*x+y*y)<=b) {
				r++;
			}
		}
		System.out.println(r);
		

	}

}





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

ll c2(ll n){
    return n*(n-1)/2;
}
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    vector<int>b(n+1);
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        b[a[i]]++;
    }
    rep(i,n+1){
        sum+=c2(b[i]);
    }
    rep(i,n){
        ll ans=sum;
        ll x1=c2(b[a[i]]);
        ll x2=c2(b[a[i]]-1);
        ans+=x2-x1;
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 4096
N = int(input())

import collections
A_list = []
A_collections = collections.Counter()
for i in range(N):
    A_list.append(int(input()))
    A_collections[A_list[-1]] += 1
    
max_num = max(A_list)
max_count = A_collections[max_num]
if(max_count > 1):
    for i in range(N):
        print(max_num)
else:
    A_collections.pop(max_num)
    for i in range(N):
        if(A_list[i] == max_num):
            print(max(A_collections))
        else:
            print(max_num)

Measured memory_bytes: 19048
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 998244353;
const double EPS = 1e-9;

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

  if (arr[0] != 0) {
    cout << 0 << endl;
    return 0;
  }

  sort(all(arr));

  if (arr[1] == 0) {
    cout << 0 << endl;
    return 0;
  }

  int num = 1;
  vi sum = {1, 0};

  for (int i=1; i<n; ++i) {
    if (arr[i] == num) {
      ++sum[num];
    }
    else if (arr[i] == num + 1) {
      sum.push_back(1);
      ++num;
    }
    else {
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans = 1;
  for (int i=1; i<sum.size(); ++i) {
    rep(j,sum[i]) {
      (ans *= sum[i-1]) %= MOD;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1276
def digit(n):
    ans = 0
    while n > 0:
        ans += 1
        n //= 10
    return ans

N = int(input())

check = 100
for i in range(1, int(1e6)):
    if N % i != 0:
        continue
    if N // i < i:
        break
    j = N // i
    f = max(digit(i), digit(j))
    check = min(check, f)

print(check)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
int mod=1e9+7;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}


const int N=2e5+5;
int dp[1ll<<16];
signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

 int n;
 cin>>n;
 int c[n][n];
 for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
        cin>>c[i][j];
 memset(dp,0,sizeof(dp));
 for(int i=0;i<(1ll<<n);i++)
 {
    for(int j=0;j<n;j++)
    {
        if((i>>j)&1)
        {
            for(int k=j+1;k<n;k++)
            {
                if((i>>k)&1)
                {
                    dp[i]+=c[j][k];        
                }
            }          
        }
    }

    for(int mask=i;mask;mask=(mask-1)&i)
    {
        dp[i]=max(dp[mask]+dp[i^mask],dp[i]);
    }
 }

 cout<<dp[(1ll<<n)-1];


}

Measured memory_bytes: 4172
import sys
readline = sys.stdin.readline
 
N = int(readline().strip())
A = []
B = []
for i in range(N):
  ai, bi = map(int, readline().split())
  A.append(ai)
  B.append(bi)

A.sort()
B.sort()

if N%2 == 0:
  a = (A[N//2 - 1] + A[N//2])/2
  b = (B[N//2 - 1] + B[N//2])/2
  n = (b - a)*2 + 1
else:
  a = A[(N+1)//2 - 1]
  b = B[(N+1)//2 - 1]
  n = b - a + 1
print(int(n))

Measured memory_bytes: 25408
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
using namespace  std ;
typedef long l ;
typedef long long ll ;
typedef vector<int>vi ;
typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    std::cout.unsetf ( std::ios::floatfield );//this and next line for floating precision upto 6
    std::cout.precision(10);
    ll a,b,c,d,x,i,j,n,t,m,k,y;
    double p,q,r,w,u ;
    string str = "",str1 = "" ;
    ll a1,a2,b1,b2 ;
    char ch ;
    cin>>str ;
    n = str.size() ;
    c = 0 ;
    for(i=0 ; i<n; i=i+1)
    {
        if(str[i]=='A' || str[i]=='C' || str[i]=='G' || str[i]=='T')
        {
            d = 1 ;
            j = i + 1 ;
            while(j<n)
            {
            	if(str[j]=='A' || str[j]=='C' || str[j]=='G' || str[j]=='T')
            	{
            		d++ ;
            		j++ ;
				}
				else
				{
					break;
				}
			}
			i = j - 1 ;
			c = max(c,d) ;
        }
    }
    cout<<c ;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int main()
{
	char s[101];
	int i;
	int is_c = 9;
	
	std::cin >> s;
	
	int len = strlen(s);
	for(i = 0; i < len; i++)
	{
		if(s[i] == 'C')
		{
			++i;
			break;
		}
	}
	
	for(; i < len; i++)
	{
		if(s[i] == 'F')
		{
			break;
		}
	}
	
	if(i < len)
	{
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No" << std::endl;
	}

	return 0;
}


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

using namespace std;

using ll = long long;

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

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

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

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

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

ll n, w;

int main() {
    cin >> n >> w;
    V<Pll> x(n);
    REP(i, n) cin >> x[i].first >> x[i].second;

    V<V<Pll>> y(4);
    REP(i, n) y[x[i].first - x[0].first].push_back(x[i]);
    REP(i, 4) sort(ALL(y[i]), greater<Pll>());

    ll w0 = 0, v0 = 0, maxi = -1;
    REP(i0, y[0].size()+1) {
        if (i0 > 0 && w0 + y[0][i0-1].first > w) break;
        if (i0 > 0) {
            w0 += y[0][i0-1].first;
            v0 += y[0][i0-1].second;
        }
        ll w1 = 0, v1 = 0;
        REP(i1, y[1].size()+1) {
            if (i1 > 0 && w0 + w1 + y[1][i1-1].first > w) break;
            if (i1 > 0) {
                w1 += y[1][i1-1].first;
                v1 += y[1][i1-1].second;
            }
            ll w2 = 0, v2 = 0;
            REP(i2, y[2].size()+1) {
                if (i2 > 0 && w0 + w1 + w2 + y[2][i2-1].first > w) break;
                if (i2 > 0) {
                    w2 += y[2][i2-1].first;
                    v2 += y[2][i2-1].second;
                }
                ll w3 = 0, v3 = 0;
                REP(i3, y[3].size()+1) {
                    if (i3 > 0 && w0 + w1 + w2 + w3 + y[3][i3-1].first > w) break;
                    if (i3 > 0) {
                        w3 += y[3][i3-1].first;
                        v3 += y[3][i3-1].second;
                    }
                    maxi = max(maxi, v0+v1+v2+v3);
                }
            }
        }
    }
    cout << maxi << '\n';

    return 0;
}


Measured memory_bytes: 256
#
# abc095 a
#
import unittest
from io import StringIO
import sys


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


def resolve():
    S = input()
    p = 700
    for i in range(3):
        if S[i] == "o":
            p += 100
    print(p)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """oxo"""
        output = """900"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """ooo"""
        output = """1000"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """xxx"""
        output = """700"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 5616
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
input()
l = list(map(int,input().split()))
gcd_l = [i for i in l]
gcd_r = [i for i in l]
for i in range(1,len(l)):
    gcd_l[i] = gcd(gcd_l[i-1],gcd_l[i])

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

ans = max(gcd_r[1],gcd_l[-2])
for i in range(1,len(l)-1):
    ans = max(ans,gcd(gcd_l[i-1],gcd_r[i+1]))
print(ans)

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

main(){
  int m,n;
  int b[1001];
  while(cin >> n >> m,m || n){
    int total=0;
    int k=n/m;
    for(int i=0;i<n;i++) cin >> b[i];
    sort(b,b+n);

    for(int i=1;i<=n;i++){
      if(i%m) total+=b[n-i];
    }
    cout << total << endl;
  }
}

Measured memory_bytes: 1180
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC158B - Count Balls

        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();

        if (a == 0) {
            System.out.println(0);
            return;
        }
        
        long x = n / (a + b);
        long y = n % (a + b);
        y = (y > a) ? a : y;
        long ans = x * a + y;

        System.out.println(ans);
    }
}

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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

int x,a,b;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
   

    cin>>x>>a>>b;
    if(a>=b)
        cout<<"delicious";
    else if(b-a<=x)
        cout<<"safe";
    else
        cout<<"dangerous";
}




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

void printResult(std::vector<int>& arr) {
    std::cout << arr[0] << " " << arr[1] << " " << arr[2] << std::endl;
}

std::vector<int> f(int n, int y) {

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n - i; j++) {
            if (i * 10000 + j * 5000 > y) {
                break;
            }
            if (i * 10000 + j * 5000 + (n - (i + j)) * 1000 == y) {
                std::vector<int> result;
                result.push_back(i);
                result.push_back(j);
                result.push_back(n - (i + j));
                return result;                    
            }
        }
    }

    std::vector<int> result;
    result.push_back(-1);
    result.push_back(-1);
    result.push_back(-1);
    return result;
}

int main() {

    int n, y;
    std::cin >> n >> y;

    std::vector<int> result = f(n, y);
    printResult(result);

    return 0;
}


Measured memory_bytes: 256
n = list(map(int, list(input())))
k = int(input())

dp = [[0,0,0] for _ in range(len(n))]
counter = 0

for i in range(len(n)):
    dp[i][0] += dp[i-1][0] + 9*(counter > 0)
    dp[i][1] += dp[i-1][0]*9 + dp[i-1][1]
    dp[i][2] += dp[i-1][1]*9 + dp[i-1][2]
    if n[i] > 0:
        if counter >= 1 and counter <= 3:
            dp[i][counter-1] += 1
        counter += 1
        if counter <= 3:
            dp[i][counter-1] += n[i]-1

print(dp[len(n)-1][k-1]+(counter==k))

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

const int P = 1e9 + 7;

inline void upd(int &x, int y) { x = x + y - P; x += x >> 31 & P; }

inline int mpow(int a, int b) {
    int ans = 1;
    for (; b; b >>= 1, a = (ll) a * a % P)
        if (b & 1) ans = (ll) ans * a % P;
    return ans;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> fact(n + 1);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) {
        fact[i] = (ll) fact[i - 1] * i % P;
    }
    vector<int> p(n + 1);
    vector<vector<int>> g(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> p[i];
        if (p[i] != -1) g[p[i]].push_back(i);
    }
    vector<bool> vis(n + 1);
    function<void(int, int, int&)> dfs = [&](int u, int f, int &sz) {
        ++sz;
        vis[u] = 1;
        for (auto v : g[u])
            if (!vis[v]) dfs(v, u, sz);
    };
    int re = 0;
    bool found;
    vector<bool> ins(n + 1);
    function<void(int)> dfsbrt = [&](int u) {
        vis[u] = 1;
        ins[u] = 1;
        for (auto v : g[u]) {
            if (!vis[v]) dfsbrt(v);
            else if (ins[v]) found = 1;
        }
        ins[u] = 0;
    };
    int cnt = 0;
    vector<int> sz(n + 1);
    for (int i = 1; i <= n; ++i) {
        if (!vis[i] && p[i] == -1) {
            dfs(i, 0, sz[++cnt]);
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (!vis[i]) {
            found = 0; dfsbrt(i);
            re += found;
        }
    }
    vector<int> dp(cnt + 1, 0);
    dp[0] = 1;
    for (int i = 1; i <= cnt; ++i) {
        vector<int> new_dp(cnt + 1, 0);
        for (int j = 0; j <= cnt; ++j) {
            upd(new_dp[j], dp[j]);
            if (j + 1 <= cnt) upd(new_dp[j + 1], (ll) dp[j] * sz[i] % P);
        }
        swap(dp, new_dp);
    }
    // for (int i = 1; i <= cnt; ++i)
        // cerr << dp[i] << " ";
    // cerr << '\n';
    // cerr << re << '\n';
    int ans = (ll) mpow(n - 1, cnt) * n % P;
    upd(ans, P - (ll) re * mpow(n - 1, cnt) % P);
    for (int i = 1; i <= cnt; ++i) {
        int coeff = (ll) fact[i - 1] * mpow(n - 1, cnt - i) % P;
        int tmp = (ll) coeff * dp[i] % P;
        if (i == 1) upd(tmp, P - (ll) cnt * coeff % P);
        upd(ans, P - tmp);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3904
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	int n, x, t;
	cin >> n >> x >> t;
	cout << ((n + x - 1) / x) * t << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=300;
int dp1[maxn];
int dp2[maxn];
int w[maxn];
int v[maxn];
struct node{
    int w;
    int v;
}p[maxn];
bool cmp(struct node a,struct node b){
    if(a.v==b.v) return a.w<b.w;
    return a.v<b.v;
}
int main()
{
    int a,b,c,x;
    while(cin>>a>>b>>c>>x){
        int i,j,k;
        int cnt=0;
        for(i=0;i<=a;i++){
            for(j=0;j<=b;j++){
                for(k=0;k<=c;k++){
                   if(i*500+j*100+k*50==x) cnt++;
                }
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;

int main()
{
	boost;
	int n, i;
	cin >> n;
	int x = ((n + 999) / 1000);
	x *= 1000;
	cout << x - n;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int N;
int Y;


int main(){
    cin >> N >> Y;
    
    for (size_t a = 0; a <= N; a++) {
      for (size_t b = 0; b + a <= N; b++) {
        if (Y == 10000 * a + 5000 * b + 1000 * (N - a - b)) {
          cout << a << " " << b << " " << N - a - b;
          return 0;
        } 
      }
    }
    cout << "-1 -1 -1" << endl; 
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    double a, b, x;
    constexpr double pi = 3.141592653589793;
    cin >> a >> b >> x;
    double t1 = 2.0 * (a * a * b - x) / (a * a * a);
    double t2 = 2.0 * x / (a * b * b);
    double th1 = atan(t1) * 180.0 / pi;
    double th2 = (pi / 2.0 - atan(t2)) * 180.0 / pi;
    double pre = atan(b / a);

    if (!(0 <= atan(t1) && atan(t1) <= pre))
        th1 = (double)(-infl);
    if (!(pre <= (pi / 2.0 - atan(t2)) && (pi / 2.0 - atan(t2)) <= pi / 2.0))
        th2 = (double)(-infl);
    cout << setprecision(10) << max(th1, th2) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 200000000000
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()

bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    ll N,ans = 0;
    cin >> N;
    vector<ll> A(N);
    vector<ll> B(N);
    vector<ll> C(N);
    rep(i,N){
        cin >> A[i];
    }
    rep(i,N){
        cin >> B[i];
    }
    rep(i,N){
        cin >> C[i];
    }
    sort(all(A));
    sort(all(B));
    sort(all(C));
    vector<ll> AB(N);
    AB[0] = lower_bound(all(A), B[0]) - A.begin();
    rep3(i,1,N){
        AB[i] = AB[i-1] + lower_bound(all(A), B[i]) - A.begin();
        
    }
    rep(i,N){
        ll b = lower_bound(all(B), C[i]) - B.begin();
        if(b!=0)
            ans += AB[b-1];
    }
    cout << ans <<endl;


    return 0;
    

}

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

#define DEBUG 0

#if DEBUG
  #define DLOG(...) fprintf(stderr, __VA_ARGS__)
  #define DFUNC(fname, ...) fname(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DFUNC(fname, ...)
#endif

ll R, G, B, N;

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> R >> G >> B >> N;

  ll cnt = 0;
  for (ll r = 0; r <= N / R; r++) {
    ll rem = N - r * R;
    for (ll g = 0; g <= rem / G; g++) {
      ll rem2 = rem - g * G;
      if (rem2 % B == 0)  cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}



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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int h, a;
    cin >> h >> a;
    cout << Div(h, a) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<complex>
#include<vector>
#include<algorithm>
#include<functional>
#include<array>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;


int main() {
	int a, b, c, d, e;
	cin >> a >> b;
	c = a + b; d = a - b; e = a * b;
	if (c > d)if (c > e)cout << c << endl;
	else cout << e << endl;
	else if(d>e) cout << d << endl;
	else cout << e << endl;



	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int goal( char amida[ 30 ][ 10 ], int m, int d ) {
  int i, j;
  int cur = m;

  for( i = 0; i < d; i++ ) {
    if( amida[ i ][ cur-1 ] == '1' )    cur--;
    else if( amida[ i ][ cur ] == '1' ) cur++;
  }
  
  return cur;
}

int main( void ) {

  while( 1 ) {
    int i, j, k, l;
    int n, m, h, d;
    char amida[ 30 ][ 10 ], hoge;
    char pre[ 30 ][ 10 ];
    int cont;

    scanf( "%d", &n );
    if( !n ) break;
    scanf( "%d%d%d", &m, &h, &d );

    for( i = 0; i < d; i++ ) {
      scanf( "%c", &hoge ); // 改行の切り捨て
      for( j = 0; j < n-1; j++ )
        scanf( "%c", &amida[ i ][ j+1 ] ); // あみだの読み込み
      amida[ i ][ 0 ] = '0';
      amida[ i ][ n ] = '0';
    }

    if( goal( amida, m, d ) == h ) {
      printf( "0\n" );
      continue;
    }

    cont = 1;
    for( i = 0; i < d && cont; i++ )
      for( j = 1; j < n && cont; j++ )
        if( amida[ i ][ j-1 ] == '0' &&
            amida[ i ][  j  ] == '0' &&
            amida[ i ][ j+1 ] == '0' ) {
          for( k = 0; k < d; k++ )
            for( l = 0; l < n+1; l++ )
              pre[ k ][ l ] = amida[ k ][ l ]; // コピー

          pre[ i ][ j ] = '1';

          if( goal( pre, m, d ) == h ) {
            printf( "%d %d\n", i+1, j );
            cont = 0;
          }
        }

    if( cont == 0 ) continue;
    else            printf( "1\n" );
  }

  return( 0 );
}

Measured memory_bytes: 0
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        long[] p = new long[A];
        long[] q = new long[B];
        long[] r = new long[C];
        for (int i = 0; i < A; i++) {
            p[i] = sc.nextLong();
        }
        for (int i = 0; i < B; i++) {
            q[i] = sc.nextLong();
        }
        for (int i = 0; i < C; i++) {
            r[i] = sc.nextLong();
        }
        Arrays.sort(p);
        Arrays.sort(q);
        Arrays.sort(r);
        long sum = 0L;
        for (int i = 0; i < x; i++) {
            sum += p[A-1-i];
        }
        for (int i = 0; i < y; i++) {
            sum += q[B-1-i];
        }
        int idxp = A-x, idxq = B-y;
        for (int i = 0; i < C; i++) {
            long dp = A-1 < idxp ? -1 : r[C-1-i] - p[idxp];
            long dq = B-1 < idxq ? -1 : r[C-1-i] - q[idxq];
            if(dp <= 0 && dq <= 0)break;
            if(dp < dq){
                sum += dq;
                idxq++;
            }else{
                sum += dp;
                idxp++;
            }
        }
        System.out.println(sum);
        sc.close();

    }

}


Measured memory_bytes: 97588
package main

import (
	"bufio"
	"fmt"
	"os"
	"reflect"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	n := []rune(read())
	if len(n) == 1 {
		fmt.Println(int(n[0] - '0'))
		return
	}
	nStr := strings.Repeat("9", len(n[1:]))
	if reflect.DeepEqual(n[1:], []rune(nStr)) {
		sum := int(n[0]-'0') + len(n[1:])*9
		fmt.Println(sum)
	} else {
		n[0] -= 1
		sum := int(n[0]-'0') + len(n[1:])*9
		fmt.Println(sum)
	}
}


Measured memory_bytes: 640
w,h,n=map(int,input().split())
mat=[[1]*w for _ in range(h)]
#print(mat)
l=[-1]*5
l[2]=float('inf')
l[4]=float('inf')
for _ in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        l[1]=max(l[1],x)
    elif a==2:
        l[2]=min(l[2],x)
    elif a==3:
        l[3]=max(l[3],y)
    else:
        l[4]=min(l[4],y)
#print(l)
for i in range(h):
    for j in range(w):
        #j means x and i means y 
        if j<l[1]:
            mat[i][j]=0
        if l[2]<=j:
            mat[i][j]=0
        if i<l[3]:
            mat[i][j]=0
        if l[4]<=i:
            mat[i][j]=0
#print(mat)
ans=0
for i in range(h):
    for j in range(w):
        ans+=mat[i][j]
print(ans)


Measured memory_bytes: 3188
#include<cstdio>

const int mod=998244353,N=1000005;

int fexp(int a,int b)
{
	int x=1;
	for(;b;b>>=1,a=1LL*a*a%mod)
		if(b&1)x=1LL*x*a%mod;
	return x;
}

int n,m,ans,fac[N],ifac[N];

int main()
{
	scanf("%d%d",&n,&m);
	n+=m;
	fac[0]=1;
	for(int i=1; i<=n; ++i)fac[i]=1LL*i*fac[i-1]%mod;
	ifac[n]=fexp(fac[n],mod-2);
	for(int i=n-1; ~i; --i)ifac[i]=1LL*(i+1)*ifac[i+1]%mod;
	n-=m;
	if(n<m){int k=n;n=m;m=k;}
	for(int x=1; x<=m; ++x)
		ans=(ans+1LL*fac[x+x]*ifac[x]%mod*ifac[x]%mod*fac[n-x+m-x]%mod*ifac[n-x]%mod*ifac[m-x])%mod;
	ans=1LL*ans*ifac[2]%mod*ifac[n+m]%mod*fac[n]%mod*fac[m]%mod;
	printf("%d",(ans+n)%mod);
	return 0;
}


Measured memory_bytes: 7936
#include <iostream>
#include <iomanip>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/utility/string_ref.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/math/common_factor_rt.hpp>

template <class... Args>
struct tuple_input_impl;
template <std::size_t i, std::size_t... tail>
struct tuple_input_impl<std::index_sequence<i, tail...>>
{
    template <class... Args>
    static void f(std::tuple<Args...>& x)
    {
        std::cin >> std::get<i>(x);
        tuple_input_impl<std::index_sequence<tail...>>::f(x);
    }
};
template <>
struct tuple_input_impl<std::index_sequence<>>
{
    static void f(...) {}
};

template <class... Args>
std::istream& operator>>(std::istream& in, std::tuple<Args...>& x)
{
    tuple_input_impl<std::index_sequence_for<Args...>>::f(x);
    return in;
}
template <class T1, class T2>
std::istream& operator>>(std::istream& in, std::pair<T1, T2>& x) { return in >> x.first >> x.second; }

template <class T>
T read()
{
    T res;
    std::cin >> res;
    return res;
}
template <class T>
std::vector<T> read(std::size_t n)
{
    std::vector<T> res(n);
    for (std::size_t i = 0; i < n; ++i) std::cin >> res[i];
    return res;
}

template <class T>
void out_impl(T&& v) { std::cout << std::forward<T>(v); }
template <class T, class... Args>
void out_impl(T&& v, Args&&... args)
{
    std::cout << std::forward<T>(v) << ' ';
    out_impl(std::forward<Args>(args)...);
}
template <class... Args>
void out(Args&&... args)
{
    out_impl(std::forward<Args>(args)...);
    std::cout << '\n';
}
template <class... Args>
void out_noreturn(Args&&... args) { out_impl(std::forward<Args>(args)...); }

template <class T>
void print(const T& container)
{
    bool first = true;
    for (auto&& x : container) {
        if (!first) std::cout << ' ';
        std::cout << x;
        first = false;
    }
    std::cout << '\n';
}

void prog()
{
    auto f = [](char c) { return c - '0'; };
    auto s = read<std::string>();
    int n1 = f(s[0]) * 10 + f(s[1]);
    int n2 = f(s[2]) * 10 + f(s[3]);
    bool f1 = 0 < n1 && n1 <= 12;
    bool f2 = 0 < n2 && n2 <= 12;
    if (f1 && f2) {
        out("AMBIGUOUS");
    } else if (!f1 && !f2) {
        out("NA");
    } else if (f1) {
        out("MMYY");
    } else {
        out("YYMM");
    }
}

int main()
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    prog();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main()
{
    ios::sync_with_stdio(false);
    int cards[4][13] = {0};
    int i, j, n;
    int num;
    char mark[] = "SHCD", m;
    cin >> n;
     
    for(i=0; i<n; i++) {
        cin >> m >> num;
        if(m=='S') cards[0][num-1]++;
        else if(m=='H') cards[1][num-1]++;
        else if(m=='C') cards[2][num-1]++;
        else if(m=='D') cards[3][num-1]++;
    }
    for(i=0; i<4; i++) {
        for(j=0; j<13; j++) {
            if(!cards[i][j]) cout <<mark[i]<<' '<<j+1<<endl;
        }
    }
     
    return 0;
}

Measured memory_bytes: 1192
#include<iostream>
using namespace std;
int main(){
    int a[101][101],r,c;
    cin>>r>>c;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<=r;i++)a[i][c]=0;
    for(int j=0;j<=c;j++)a[r][j]=0;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            a[i][c]+=a[i][j];
            a[r][j]+=a[i][j];
            a[r][c]+=a[i][j];
        }
    }   
    for(int i=0;i<=r;i++){
        for(int j=0;j<=c;j++){
            if(j)cout<<' ';
            cout<<a[i][j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <cmath>
#include <tuple>

using namespace std;

#define rep(i,n) for(int i = 0;i < n;i++)
#define all(n)	n.begin(),n.end()
#define each(i,n) for(auto &i : n)

const int INF = 1e9;

signed main() {

	int n, m;
	while (cin >> n >> m && n) {
		int s, g;
		cin >> s >> g; s--; g--;
		typedef pair<int, int> p;
		vector<vector<p>> v(n, vector<p>(n, p(-1, -1)));
		rep(i, m) {
			int x, y, d, c;
			cin >> x >> y >> d >> c;
			x--; y--;
			v[x][y] = p(d, c);
			v[y][x] = p(d, c);
		}
		double d[31][31][31];
		rep(i, 31)rep(j, 31)rep(k, 31)d[i][j][k] = INF;

		typedef tuple<int, int, int> t;
		queue<t> q;
		q.push(t(s, s, 1));
		d[s][s][1] = 0;
		double ans = INF;

		while (q.size()) {

			int now = get<0>(q.front());
			int prev = get<1>(q.front()); 
			int speed = get<2>(q.front());
			q.pop();

			rep(i, n) {
				if (i != prev && v[now][i].first != -1 && v[now][i].second >= speed) {
					double time = double(v[now][i].first) / double(speed);

					for (int t_speed = max(1, speed - 1); t_speed <= speed + 1; t_speed++) {
						if (i == g && speed == 1) {
							ans = min(ans, d[now][prev][speed] + time);
						}
						if (d[i][now][t_speed] > d[now][prev][speed] + time) {	
							d[i][now][t_speed] = d[now][prev][speed] + time;
							q.push(t(i, now, t_speed));
						}
					}
				}
			}

		}
		if (ans == INF) {
			cout << "unreachable" << endl;
		}
		else {
			cout << fixed << setprecision(30) << ans << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3660
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n ; i++) {
      a[i] = sc.nextInt();
    }
    int c = 0;
    for(int i =0 ; i < n ; i++) {
      if(k <= a[i]) {
        c++;
      }
    }
    System.out.println(c);
  }
}


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

using namespace std;

int main(){

  int h, w;
  string s;
  cin >> h >> w;

  for ( int i = 0; i < h; i++ ){
    string x;

    cin >> x;

    s += x;
  }

  for ( int i = 0; i < h; i++ ){
    for ( int j = 0; j < w; j++ ){
      //cout << s << endl;
      int x = 0;
      
      if ( s[ i * w + j ] == '#' ) continue;
      
      if ( ( i - 1 ) > -1 ){
        if ( s[ ( i - 1 ) * w + j ] == '#' ){
          x++;
        }
      }
      
      if ( ( i + 1 ) < h ){
        if ( s[ ( i + 1 ) * w + j ] == '#' ){
          x++;
        }
      }
      
      if ( ( j - 1 ) > -1 ){
        if ( s[ i * w + j - 1 ] == '#' ){
          x++;
        }
      }

      if ( ( j + 1 ) < w ){
        if ( s[ i * w + j + 1 ] == '#' ){
          x++;
        }
      }

      if ( i - 1 > -1 && j - 1 > -1 ){
        if ( s[ ( i - 1 ) * w + j - 1 ] == '#' ){
          x++;
        }
      }
      
      if ( i - 1 > -1 && j + 1 < w ){
        if ( s[ ( i - 1 ) * w + j + 1 ] == '#' ){
          x++;
        }
      }

      if ( i + 1 < h && j - 1 > -1 ){
        if ( s[ ( i + 1 ) * w + j - 1 ] == '#' ){
          x++;
        }
      }
      
      if ( i + 1 < h && j + 1 < w ){
        if ( s[ ( i + 1 ) * w + j + 1 ] == '#' ){
          x++;
        }
      }

      char a = '0' + x;
      s[ i * w + j ] = a;
    }
  }
  for ( int i = 0; i < h; i++ ){
    cout << s.substr( i * w, w ) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <climits>
#include <cstring>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using namespace std;

const int N_MAX = 1000000;
int dp[101][N_MAX];
vector<int> v;
vector<int> w;

int main(){
  int N, W;
  cin >> N >> W;
  rep(i, 0, N){
    int n, m;
    cin >> n >> m;
    v.push_back(n);
    w.push_back(m);
  }
  
  rep(row, 0, N+1){
    dp[row][0] = 0;
  }
  rep(col, 0, W+1){
    dp[0][col] = 0;
  }

  rep(row, 1, N+1){
    rep(col, 1, W+1){
      if(col-w[row-1]>=0){
	dp[row][col] = max(dp[row-1][col], dp[row-1][col-w[row-1]] + v[row-1]);
      }
      else dp[row][col] = dp[row-1][col];
    }
  }
  cout << dp[N][W] << endl;
  return 0;
}



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

int main() {
  //初期化
  int N; cin >> N;
  
  //1～10^5のAを数える
  vector<int> count_A(100000, 0);
  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    count_A.at(a-1)++;
  }
  
  int Q; cin >> Q;
  //答え
  int64_t sum = 0;
  
  //初期配列の合計値
  for (int i = 0; i < 100000; i++) {
    sum += count_A.at(i) * (i + 1);
  }
  
  //Q回の操作
  for (int i = 0; i < Q; i++) {
    int b, c; cin >> b >> c;
    //合計値の変化を計算
    sum += (c - b) * count_A.at(b - 1);
    cout << sum << endl;

    count_A.at(c - 1) += count_A.at(b - 1);
    count_A.at(b - 1) = 0;
  }
  return 0;
}

Measured memory_bytes: 3720
import os, sys, re, math

s = int(input())
nums = [-1,s]
M = 1000001

def doit(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1

for i in range(2,M):
    tmp = doit(nums[i-1])
    if tmp in nums:
        break
    else:
        nums.append(tmp)

print(i)


Measured memory_bytes: 3188
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
using namespace std;
//最大公約数
long gcd(long a, long b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}



//最小公倍数
long lcm(long a, long b)
{
   return a * b / gcd(a, b);
}

int main(){
    long A,B;
    cin>>A>>B;
    cout<<lcm(A,B);
    return 0;
}

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

using namespace std;
#define FOR(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)

int main(){
  double l;
  double a;
  cin >> l;
  a = l / 3;
  // cout << a << endl;
  double vol;
  vol = a * a * a;
  printf("%.6lf\r\n", vol);

  return 0;
}

Measured memory_bytes: 256