akhauriyash/Code-Regression huggingface dataset:
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;

int main(void){
	scanf("%d",&n);
	cev=n/500*1000;
	n%=500;
	cev+=n/5*5;
	printf("%d\n",cev);
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,x,y;
	int i,min,min1,z;
	min=0; min1=-1;
	scanf("%d %d %d",&a,&b,&c);
	scanf("%d %d",&x,&y);
	if(a+b>c*2){
		if(x<y){
			min1=y*c*2;
			z=x; y-=x; x=0;
		}
		else{
			min1=x*c*2;
			z=y; x-=y; y=0;
		}
		min=z*2*c;
	}	
	min+=x*a;
	min+=y*b;
	if(min1<min&&min1!=-1) min=min1;
	printf("%d\n",min);
}	


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

int main(){
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    vector<int> lx(n),ly(m);
    for (int i=0;i<n;i++){
        cin>>lx[i];
    }
    for (int i;i<m;i++){
        cin>>ly[i];
    }
    if (max(x,*max_element(lx.begin(),lx.end()))<min(y,*min_element(ly.begin(),ly.end()))){
        cout<<"No War"<<endl;
    }
    else {
        cout<<"War"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, s, n) for (ll i = s; i < (n); i++)
using namespace std;

int main(){
  ll n, k;
  cin >> n >> k;
  
  ll min = 0;
  ll max = 0;
  ll ans = 0;
  ll num = 0;
  rep(i, k-1){
    min += num;
    max += n-num;
    num++;
  }
  rep2(i, k, n+2){
    min += num;
    max += n-num;
    ans += max - min + 1;
    ans %= (1000000000+7);
    num++;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    m = {0: 2, 1: 1}
    def f(i):
        if i in m:
            return m[i]
        a = f(i-1)
        b = f(i-2)
        m[i] = a+b
        return m[i]


    return f(n)



print(main())




Measured memory_bytes: 6612
import numpy as np
from numba import njit


@njit
def solve():
    dp = np.zeros((R + 1, C + 1, 4), dtype=np.int64)
    for i in range(1, R + 1):
        for j in range(1, C + 1):
            for k in range(4):
                dp[i][j][k] = max(dp[i][j - 1][k], dp[i - 1][j][3])
            if items[i][j] == 0:
                continue
            for k in range(3, 0, -1):
                dp[i][j][k] = max(dp[i][j][k], dp[i][j][k - 1] + items[i][j])
    return dp[R][C][-1]


R, C, K, *rcv = map(int, open(0).read().split())

items = np.zeros((R + 1, C + 1), dtype=np.int32)
for r, c, v in zip(*[iter(rcv)] * 3):
    items[r][c] = v

print(solve())


Measured memory_bytes: 453116
Q,H,S,D = map(int,input().split())
N = int(input())
M = min(8*Q,4*H,2*S,D)
if (N % 2 == 0):
  print((N//2)*M)
else:
  print(((N-1)//2)*M + min(4*Q,2*H,S))

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



int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N; i++){
    cin >> A[i];
    }
    
    int diff=INT_MIN;
    
    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N; j++){
            if(abs(A[i]-A[j])>diff){
                diff=abs(A[i]-A[j]);
            }
        }
    }
    cout << diff << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using std::min;

#define MAXN 100003

int abs(int z)
{
    if (z<0)
        return -z;
    else
        return z;
}

int main(void)
{
    int N,i,j;
    int h[MAXN], p[MAXN];
    scanf("%d",&N);
    for (i=0;i<N;i++)
    {
        scanf("%d",h+i);
    }
    p[N-1]=0;
    p[N-2]=abs(h[N-2]-h[N-1]);
    for(i=N-3;i>=0;i--)
    {
        p[i]=min(p[i+1]+abs(h[i]-h[i+1]),p[i+2]+abs(h[i]-h[i+2]));
    }
    printf("%d\n",p[0]);

    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <deque>
#include <string>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <map>
#include <unordered_map>
#include <bitset>

#define _crt_secure_no_warnings
#define FREEELO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define INF 0x3F3F3F3F3F3F3F3F
#define MAX 300001
#define ALPHABET 128
#define loop(i, n) for (int i = 1; i <= (n); i++)
#define loop0(i, n) for (int i = 0; i < (n); i++)
#define sz(x) (int)x.size()
#define all(v) v.begin(), v.end()
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll, ll> llll;
typedef pair<int, int> ii;
typedef unordered_map<int, int> umii;
typedef unordered_map<ll, ll> umll;


int main(){
    int n, k; cin >> n >> k;
    vector<int> p(n + 1), c(n + 1);
    loop(i, n) cin >> p[i];
    loop(i, n) cin >> c[i];
    ll res = -INF;
    loop(i, n){
        int a = i;
        ll c_s = 0, c_c = 0;
        while(1) { c_c++, c_s += c[a], a = p[a]; if (a == i) break; }
        ll cur = 0, cnt = 0;
        while(1) {
            cnt++, cur += c[a];
            if (cnt > k) break;
            ll ans = cur + ((k - cnt) / c_c) * max(0LL, c_s);
            res = max(res, ans); a = p[a];
            if (a == i) break;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3220
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>

#define el endl
#define fd fixed
#define INF INT_MAX/2-1
#define pb push_back

using namespace std;

int main() {
  int e;
  while (cin >> e, e) {
    int x = 0, y = 0, z = 0, min = INF;
    for (z = 0; z*z*z <= e; z++) {
      for (y = 0; y*y <= e - z*z*z; y++) {
        x = e-y*y-z*z*z;
        if (x+y+z < min) min = x+y+z;
      }
    }
    cout << min << el;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
int N, x, ok;

int main(int argc, char ** argv) {
	scanf("%d", &N);
	REP(i, 1, N) {
		scanf("%d", &x);
		ok += (x != i);
	}
	printf("%s\n", ok <= 2 ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int[] a = new int[]{sc.nextInt(), sc.nextInt()};
            if (a[0] == 0 && a[1] == 0) {
                break;
            }
            Arrays.sort(a);
            System.out.println(a[0] + " " + a[1]);
        }
    }
}

Measured memory_bytes: 34532
/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define take(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define takes(a,n,st) for(ll i=st;i<n+st;i++)cin>>a[i]
ll sum(ll a[],ll n,ll s){ for(ll i=0;i<n;i++)s+=a[i]; return s;}
#define mod 1000000009
ll power(ll x, ll y, ll p)  {  
    ll res = 1;  
    x = x % p;   
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll a[200017];
void solve(){
	ll n,i,x,tot;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
//		cout<<a[i]<<" ";
		a[i]-=(i+1);
//		cout<<i+1<<" "<<a[i]<<endl;
	}
	sort(a,a+n);
	if(n%2 ==1)
		x=a[n/2];
	else{
		x=(a[n/2]+a[(n/2)-1])/2;
	}
	tot=0;
	for(i=0;i<n;i++){
//		cout<<a[i]<<" "<<tot<<endl;
		tot+=abs(a[i]-x);
	}
	cout<<tot;
	return;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ll t,T;
//	cin>>T;
	T=1;
	for(t=1;t<=T;t++){
//		cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 5148
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int sum=0;
    for(int i=0; i<s.size(); i++)
    {
        sum=sum+s[i]-'0';
    }
    if(sum%9==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3708
#include<iostream>
#include<algorithm>
using namespace std;
#include<vector>
#include<algorithm>
template<typename T>
pair<T,int>diameter_dfs(const vector<vector<pair<int,T> > >&G,int u,int p)
{
	pair<T,int>ans(0,u);
	for(const pair<int,T>&e:G[u])
	{
		if(e.first!=p)
		{
			pair<T,int>q=diameter_dfs(G,e.first,u);
			q.first+=e.second;
			ans=max(ans,q);
		}
	}
	return ans;
}
template<typename T>
T diameter(const vector<vector<pair<int,T> > >&G)
{
	pair<T,int>p=diameter_dfs(G,0,-1);
	pair<T,int>q=diameter_dfs(G,p.second,-1);
	return q.first;
}
int diameter(const vector<vector<int> >&G)
{
	vector<vector<pair<int,int> > >H(G.size());
	for(int i=0;i<G.size();i++)for(const int&e:G[i])H[i].push_back(make_pair(e,1));
	return diameter(H);
}
int N;
bool dp[2<<17];
main()
{
	cin>>N;
	vector<vector<int> >G(N);
	for(int i=1;i<N;i++)
	{
		int a,b;cin>>a>>b;
		a--,b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int d=diameter(G);
	dp[0]=true;
	dp[1]=false;
	for(int i=2;i<2<<17;i++)
	{
		dp[i]=!dp[i-1]||!dp[i-2];
	}
	cout<<(dp[d]?"First":"Second")<<endl;
}


Measured memory_bytes: 37760
#include<bits/stdc++.h>
#define rep(i, a, b) for (ll i = a; i < b; ++i)
#define ll long long
#define M 100000007
#define fr first
#define sc second
#define endl "\n"
#define vc vector
#define pb push_back
#define pii pair<ll, ll>
#define psi pair<string, ll>
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define PI 3.14159265
#define r0 return 0
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;

ll highestPowerof2(ll n) 
{ 
   ll p = (ll)log2(n); 
   return (ll)pow(2, p);  
} 

int main() {
  fast
  ll h,move=0;
  cin>>h;
  if(h==1) cout<<"1";
  else {
      ll count=0;
      ll p=highestPowerof2(h);
      while(p>0){
          count++;
          p/=2;
      }
      move=pow(2,count)-1;
      //cout<<p<<endl;
      //cout<<count<<endl;
      cout<<move;
  }
}



Measured memory_bytes: 256
s = input()
nums = [int(v) for v in s]

l = len(s)

ans = 0
for i in range(1 << (l-1)):
    tmp = s[0]
    for j in range(l-1):
        if i & 1 << j:
            tmp += '+'+s[j+1]
        else:
            tmp += s[j+1]
    ans += eval(tmp)
print(ans)


Measured memory_bytes: 39024
#include<cstdio>
	#include<cstring>
	#include<iostream>
	#include<algorithm>		
	using namespace std;
	typedef long long ll;
	
	int main()
	{ll c;int a[200005];
		int x;
		scanf("%d", &x);
		for (int i = 1; i <= x; i++) {
			scanf("%lld", &a[i]);
			
		}
		sort(a+1, a + 1 + x); c = a[x];
		int d = 0;
		for (int i = 1; i<=x-2; i++) {
			if(i&1)d++;
			c += a[x-d];
		}
		printf("%lld\n", c);
		return 0;
	}

Measured memory_bytes: 4612
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
int main()	{
    string s;
    cin>>s;
    if(s[0]==s[1] && s[1]==s[2] && s[0]==s[2])
    cout<<"No"<<endl;
    else
    {
        cout<<"Yes"<<endl;
    }
    

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n, a[maxn];
int cnt[maxn];
int ans = 0;
int main() {
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		if(a[i] > n)
			ans++;
		else
			cnt[a[i]]++;
	}
	for(int i = 1; i <= n; i++) {
		if(cnt[i] >= i)
			ans += cnt[i] - i;
		else
			ans += cnt[i];
	}
	cout << ans;
}

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

int main() {
  int N;
  cin >> N;
  int result = 0;
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    result += r - l + 1;
  }
  cout << result << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define umii            unordered_map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define rep(i,st,end)   for(int i=st;i<end;i++)
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void s_g_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	s_g_c();
	int n;
	cin >> n;
	int a[n + 1];
	int prod = 1;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		if (a[i] == 0)
		{
			cout << "0";
			return 0;
		}
	}
	for (int i = 0; i < n; i++)
	{
		if (a[i] <= 1000000000000000000 / prod )
		{
			prod *= a[i];
		}
		else
		{
			cout << "-1\n";
			return 0;
		}

	}
	cout << prod << endl;
	return 0;
}

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

int main(){
    int h, w, n, a, m[100][100];
    cin >> h >> w >> n;
    int sum = 0;
    rep(i, n){
        scanf("%d", &a);
        rep(_, a){
            m[sum / w][sum % w] = i+1;
            sum++;
        }
    }
    rep(i, h){
        if(i % 2 == 0){
            rep(j, w){
                if(j) printf(" ");
                printf("%d", m[i][j]);
            }
        } else {
            rep(j, w){
                if(j) printf(" ");
                printf("%d", m[i][w-1-j]);
            }
        }
        printf("\n");
    }
    return 0;
}

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

namespace abc060_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            string strA = input[0];
            string strB = input[1];
            string strC = input[2];

            if (strA.EndsWith(Convert.ToString(strB[0])))
            {
                if (strB.EndsWith(Convert.ToString(strC[0])))
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
            else
            {
                Console.WriteLine("NO");
            }
            

        }
    }
}


Measured memory_bytes: 11360
class UnionFind():
    """
    https://note.nkmk.me/python-union-find/
    DFSの上位互換と考えて良い
    ２要素x, yがpath-connectedかどうかをlogオーダーで判定する（螺旋本の14.1節参照）
    さらに連結成分の要素数がO(1)で取得可能なように改造してある
    """
    def __init__(self, n):
        """
        要素数をnとして、各ノードを0,1,...,(n-1)の番号で管理する
        parentsは各ノードの属する木の根を表す
        ただし根ノードのparentには(その木のノード数)*(-1)を格納する
        """
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        """
        xの属する木の根を返す
        このとき同時に経路圧縮して、探索途中のノードを全て根に繋ぎ直す
        """
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        """
        x, yのそれぞれ属する木Tx, Tyの根同士を繋ぐ
        このとき木の要素数が小さい方を大きい方に繋ぐ（rankではなくsizeを用いる）
        """
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        """
        xの属する木の要素数を返す
        根の親を要素数の(-1)倍で定めておいたおかげでO(1)で取得可能
        """
        return -self.parents[self.find(x)]

    def same(self, x, y):
        """
        xとyがpath-connectedかを判定する
        """
        return self.find(x) == self.find(y)

    def members(self, x):
        """
        xの属する木の要素を列挙する
        """
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        """
        連結成分の代表元のリストを返す
        """
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        """
        連結成分の個数を返す
        """
        return len(self.roots())

    def all_group_members(self):
         """
         連結成分およびそれぞれの代表元をまとめた辞書を返す
         代表元がキーになってる
         """
         return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        """
        連結成分およびその代表元を出力
        """
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


"""
ここから本問の解答
"""

N, M, K = map(int, input().split())
uf = UnionFind(N)
friend_num = [0] * N
for _ in range(M):
    a, b = map(int, input().split())
    uf.union(a-1, b-1)
    friend_num[a-1] += 1
    friend_num[b-1] += 1
block = [[] for _ in range(N)]
for _ in range(K):
    c, d = map(int, input().split())
    block[c-1].append(d-1)
    block[d-1].append(c-1)

ans = []
for i in range(N):
    num = uf.size(i) - friend_num[i] - 1
    for j in block[i]:
        if uf.same(i, j):
            num -= 1
    ans.append(num)
print(" ".join(map(str, ans)))


Measured memory_bytes: 119512
import java.util.*;

public class Main{
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int m = sc.nextInt();
    int number_digit;
    int number;

    Map<Integer,Integer> map = new HashMap<>();

    if(n==1&&m==0){
      System.out.println(0);
      return;
    }


    for(int i=0; i<m; i++){
      number_digit = sc.nextInt()-1;
      number = sc.nextInt();
      if(map.containsKey(number_digit)&&number!=map.get(number_digit)){//値の上書き禁止
        System.out.println(-1);
        return;
      }
      map.put(number_digit,number);
    }


    if(map.containsKey(0)){
      if(map.get(0)==0&&n>1){
        System.out.println(-1);
        return;
      }
    }
    int ans;
    int[] c = new int[n];
    Arrays.fill(c,-1);
    for(int key : map.keySet()){
      c[key]=map.get(key);
    }
    if(c[0]==-1){
      c[0]=1;
    }
    for(int i=1; i<n; i++){
      if(c[i]==-1){
        c[i]=0;
      }
    }

    StringBuilder val = new StringBuilder();
    for(int i=0; i<n; i++){
      val.append(String.valueOf(c[i]));
    }
    System.out.println(val);


  }
}

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

ll GCD(ll a, ll b) {
    ll v0 = a, v1 = b, v2 = a % b;
    while(v2 != 0) {
        v0 = v1;
        v1 = v2;
        v2 = v0 % v1;
    };
    return v1;
}

ll LCM(ll a, ll b) { return a * b / GCD(a, b); }

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

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

int main(){
  while(true){
    ll n,m;
    cin>>n>>m;
    if(n==0&&m==0){
      break;
    }
    vector<ll> p(n);
    rep(i,n)cin>>p[i];
    vector<ll> ps;
    rep(i,n){
      ps.push_back(p[i]);
      for(ll j=i;j<n;j++){
        ps.push_back(p[i]+p[j]);
      }
    }
    sort(ps.begin(),ps.end());
    ll maxi=0;
    for(ll i=0;i<ps.size();i++){
      auto itr=upper_bound(ps.begin(),ps.end(),m-ps[i]);
      if(itr!=ps.begin()){
        itr--;
        maxi=max(maxi,ps[i]+*itr);
      }
    }
    cout<<maxi<<endl;
  }
}



Measured memory_bytes: 10684
#include <bits/stdc++.h>
using namespace std;
#define int long long

int N, K;
vector<int> V;

signed main() {
  cin >> N >> K;
  V.resize(N);
  for (int i = 0; i < N; i++) cin >> V[i];

  int ans = -1e18;
  for (int i = -1; i < N; i++) {
    for (int j = i + 1; j <= N; j++) {
      if (i + 1 + N - j > K) continue;

      vector<int> v;
      int tmp = 0;
      for (int a = 0; a <= i; a++) {
        if (a == -1) break;
        v.push_back(V[a]);
        tmp += V[a];
      }

      for (int b = j; b < N; b++) {
        if (b == N) break;
        v.push_back(V[b]);
        tmp += V[b];
      }

      sort(v.begin(), v.end());

      int res = K - i - 1 - N + j;
      for (int c = 0; c < v.size() && c < res; c++) {
        if (v[c] < 0) {
          tmp -= v[c];
        }
      }

      ans = max(ans, tmp);
    }
  }

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


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

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
#define fcout cout<<fixed<<setprecision(10)
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
//template<typename T>void pp(T x){cout<<x<<endl;}

using namespace std;

int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>> v(h,vector<char>(w));
    vector<vector<int>> ans(h,vector<int>(w));
    rep(i,0,h)rep(j,0,w)cin>>v[i][j];

    rep(i,0,h){
        rep(j,0,w){
            if(v[i][j]=='c'){
                ans[i][j]=0;
                continue;
            }
            int num=-1;
            for(int k=j;k>=0;k--){
                if(v[i][k]=='c'){
                    num=j-k;
                    break;
                }
            }
            ans[i][j]=num;
        }
    }

    rep(i,0,h){
        rep(j,0,w){
            if(j)cout<<" ";
            cout<<ans[i][j];
        }
        cout<<endl;
    }
    





    
    return 0;
}


Measured memory_bytes: 3188
#include <stdio.h>

#define MAXN 3000

long S[MAXN][MAXN];
int T[MAXN][MAXN];
int A[MAXN];

long deque(int i, int j, int cnt )
{
  if ( T[i][j] ==  1 ) return S[i][j];
  T[i][j] = 1;
  if ( i == j ) {
    if ( cnt == 1 ) return S[i][j] = A[i];
    else return S[i][j] = -A[i];
  }

  long tmp1, tmp2;
  if ( cnt == 1 ) {
    tmp1 = deque(i+1, j, (cnt+1)%2 ) + A[i];
    tmp2 = deque(i, j-1, (cnt+1)%2 ) + A[j];
    return S[i][j] = (tmp1 > tmp2 ) ? tmp1:tmp2;
  } else {
    tmp1 = deque(i+1, j, (cnt+1)%2 ) - A[i];
    tmp2 = deque(i, j-1, (cnt+1)%2 ) - A[j];
    return S[i][j] = (tmp1 < tmp2 ) ? tmp1:tmp2;
  }
}

int main(void)
{
  int i,n,j;

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

  for ( i = 0; i < n; i++ ) for ( j = 0; j < n; j++ ) T[i][j] = 0;

  printf("%ld\n", deque(0,n-1,1));

  return 0;

}


Measured memory_bytes: 104960
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=200005;
char ss[N];
int pre[N],suf[N];
int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s",ss+1);
	for (int u=1;u<=n;u++) pre[u]=pre[u-1]+(ss[u]=='#');
	for (int u=n;u>=1;u--) suf[u]=suf[u+1]+(ss[u]=='.');
	int ans=n;
	for (int u=0;u<=n;u++)  ans=min(ans,pre[u]+suf[u+1]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2048
open System

let primeFactors (n: int64)=
    let add (x: int64) (m: Map<int64, int>): Map<int64, int> =
        match Map.tryFind x m with 
        | Some(cnt) -> Map.add x (cnt+1) m
        | None -> Map.add x 1 m 
    let rec f (n: int64) (i: int64) (acc: Map<int64, int>) =
        if n % i = 0L then
            g n i acc 
        elif n < i * i && n <> 1L then 
            add n acc 
        elif n < i * i then 
            acc 
        else 
            f n (i + 1L) acc 
             
    and g (n: int64) (i: int64) (acc: Map<int64, int>): Map<int64, int> = 
        if n % i = 0L then 
            f (n / i) i (add i acc)
        else 
            f n (i + 1L) acc 
    f n 2L Map.empty

let getN (n: int): int =
    let rec f n proposed acc =
        if n >= proposed then 
            f (n - proposed) (proposed + 1) (acc + 1)
        else 
            acc 
    f n 1 0 

Console.ReadLine()
|> int64
|> primeFactors
|> Map.map(fun _ v -> getN v)
|> Map.toList 
|> List.map snd 
|> List.sum 
|> printfn "%i" 

Measured memory_bytes: 30240
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    string s; cin >> s;
    int n = s.size();
    int min_diff = INF;
    rep(i,n-2)
    {
        int tmp_diff = abs(stoi(s.substr(i,3)) - 753);
        if(tmp_diff < min_diff)
            min_diff = tmp_diff;
    }
    
    cout << min_diff << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=1000000007;
int main(){
  ll x,y;cin >> x >> y;
  if((4*x-y)%2==0&&4*x-y>=0&&(4*x-y)/2<=x)cout <<"Yes"<< endl;
  else cout <<"No"<< endl;
}

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

typedef long long ll;
typedef long double ld;

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

const int INF = 2000000000; //2e9
const long long INF2 = 1000000000000000000; //1e18
const long double pi = acos(-1);

const int MOD = 1000000007; //1e9 + 7
//const int MOD = 1000000009; //1e9 + 9
//const int MOD = 998244353;




//繰り返し2乗法
//N^aの、Mで割った余りを求める。
ll my_pow(ll N, ll a, ll M) {
	ll tempo;
	if (a == 0) {
		return 1;
	}
	else {
		if (a % 2 == 0) {
			tempo = my_pow(N, a / 2, M);
			return (tempo * tempo) % M;
		}
		else {
			tempo = my_pow(N, a - 1, M);
			return (tempo * N) % M;
		}
	}
}

ll my_pow(ll N, ll a) {
	ll tempo;
	if (a == 0) {
		return 1;
	}
	else {
		if (a % 2 == 0) {
			tempo = my_pow(N, a / 2);
			return (tempo * tempo);
		}
		else {
			tempo = my_pow(N, a - 1);
			return (tempo * N);
		}
	}
}


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

	vector<int> X(N), Y(N), P(N);
	rep(i, N) cin >> X[i] >> Y[i] >> P[i];

	vector<ll> res(N + 1, INF2);
	res[N] = 0;

	int M = my_pow(2, N);
	vector<vector<int>> memox(M, vector<int>(N, -1));
	vector<vector<int>> memoy(M, vector<int>(N, -1));


	//前計算
	rep(j, M) {
		vector<int> Ys, Xs;
		Xs.push_back(0); Ys.push_back(0);
		rep(k, N) {
			if (j & (1LL << k)) Xs.push_back(X[k]);
			if (j & (1LL << k)) Ys.push_back(Y[k]);
		}
		
		rep(k, N) {
			int tempo1 = INF2;
			rep(l, (int)Xs.size()) {
				tempo1 = min(tempo1, abs(X[k] - Xs[l]));
			}
			memox[j][k] = tempo1;

			tempo1 = INF2;
			rep(l, (int)Ys.size()) {
				tempo1 = min(tempo1, abs(Y[k] - Ys[l]));
			}
			memoy[j][k] = tempo1;
		}
	}
	//前計算終わり

	rep(j, M) {
		rep(j2, M) {
			if (j & j2) continue;
			int i = __builtin_popcountll(j) + __builtin_popcountll(j2);
			ll tempo0 = 0;
			rep(k, N) tempo0 += (ll)min(memox[j][k], memoy[j2][k]) * (ll)P[k];
			res[i] = min(res[i], tempo0);
		}
	}

	rep(i, N + 1) {
		cout << res[i] << endl;
	}


}

Measured memory_bytes: 13044
chomp($a=<>);
chomp($b=<>);
chomp($c=<>);
@a=split//,$a;
@b=split//,$b;
@c=split//,$c;

$flg=0;
$target="a";
while($flg==0){
	if($target eq "a"){
    	$target=shift(@a);
        $val=1;
    }elsif($target eq "b"){
    	$target=shift(@b);
        $val=2;
    }else{
    	$target=shift(@c);
        $val=3;
    }
	if($target  eq ""){
		$flg=1;
    }
}

if($val==1){
	print "A";
}elsif($val==2){
	print "B";
}else{
	print "C";
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
  
int main()
{
  int N, M;
  cin >> N >> M;

  vector<P> A(M);
  REP(i,M) cin >> A[i].first >> A[i].second;
  unordered_map<int, int> mp;
  REP(i,M){
    if(A[i].first == 1){
      mp[A[i].second]++;
    }
  }
  int flag = 0;
  REP(i,M){
    if(A[i].second==N&&mp[A[i].first]!=0){
      flag = 1;
    }
  }

  if(flag == 0){
    cout << "IMPOSSIBLE" << endl;
  }else{
    cout << "POSSIBLE" << endl;
  }

}

Measured memory_bytes: 10056
import math
h, w = map(int, input().split())

a = 0
b = 0
c = 0
ans = 1e+9

for ha in range(1, max(2, h-1)):  # bとcを横に分割するパターン
    a = ha * w
    b = (h-ha) * (w//2)
    c = (h-ha) * math.ceil(w/2)
    smax = max(a, max(b, c))
    smin = min(a, min(b, c))
    ans = min(ans, smax-smin)

for ha in range(1, max(2, h-1)):  # bとcを縦に分割するパターン
    a = ha * w
    b = (h-ha)//2 * w
    c = math.ceil((h-ha)/2) * w
    smax = max(a, max(b, c))
    smin = min(a, min(b, c))
    ans = min(ans, smax-smin)

h, w = w, h

for ha in range(1, max(2, h-1)):  # bとcを横に分割するパターン
    a = ha * w
    b = (h-ha) * (w//2)
    c = (h-ha) * math.ceil(w/2)
    smax = max(a, max(b, c))
    smin = min(a, min(b, c))
    ans = min(ans, smax-smin)

for ha in range(1, max(2, h-1)):  # bとcを横に分割するパターン
    a = ha * w
    b = (h-ha)//2 * w
    c = math.ceil((h-ha)/2) * w
    smax = max(a, max(b, c))
    smin = min(a, min(b, c))
    ans = min(ans, smax-smin)

print(int(ans))


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int a[1000]= {0};
int main()
{
    long long int i,j,n,m;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
   long  int num=0;
    for(i=1; i<n; i++)
    {
        if(a[i]-a[i-1]>0)
            num++;
    }
    cout<<num+1;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define REP(i,n) for(int i=0;i<n;i++)
#define pb push_back


// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

int main(void) {
	// cin, coutの結びつきを解除し、速くする
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int k; cin >> k;
	if (k % 2 == 0) cout << pow((k/2), 2) << endl;
	else cout << (k/2) * (k/2 + 1) << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  int a;
  cin>>n;
  set<int> s;
  rep(i,n){
    cin>>a;
    if(s.find(a)!=s.end()){
      s.erase(a);
    }
    else{
      s.insert(a);
    }
  }
  cout<<s.size()<<'\n';
  return(0);
}


Measured memory_bytes: 4992
#include <stdio.h>

int main(void){

	int a[10000], min, max, n, i;
	long long sum = 0;

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

	max = min = a[0];

	for(i = 1; i < n; i++){
		if(a[i] > max)max = a[i];
		if(a[i] < min)min = a[i];
	}

printf("%d %d %lld\n", min, max, sum);

return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstring>

int main()
{
    bool *table = new bool[1000000];
    while (true) {
        int n;
        std::cin >> n;
        if (std::cin.eof()) break;

        memset(table, 1, sizeof(bool) * (n + 1));
        for (int i = 2; i * i <= n; ++i)
            for (int j = 2; i * j <= n; ++j)
                table[i * j] = false;

        int cnt = 0;
        for (int i = 2; i <= n; ++i) cnt += table[i];
        std::cout << cnt << std::endl;
    }
    delete[] table;
}

Measured memory_bytes: 2064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    String s = sc.next();
    Deque<Character> stack = new ArrayDeque<>();
    for (char c : s.toCharArray()) {
      if (!stack.isEmpty() && stack.peek() != c) {
        stack.pop();
      } else {
        stack.push(c);
      }
    }
    System.out.println(s.length() - stack.size());
  }
}

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

int main() {
  string s;
  cin>>s;
  int n = s.length();
  int cnt = 0;
  for (int i=0; i<n/2; i++) {
    if (s[i] != s[n-1-i]) {
      ++cnt;
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		String str = scan.nextLine();
		char[] c=str.toCharArray();
		
		for(int i=0;i<c.length;i++){
			if(c[i] >='a' && c[i]<='z')
				c[i]-='a'-'A';
			else if(c[i] >= 'A' && c[i] <= 'Z')
				c[i]+='a'-'A';
		}
		
		str=String.valueOf(c);
		
		System.out.println(str);
		
	}
}


Measured memory_bytes: 26092
s = input().replace('BC', 'o').replace('B', 'x').replace('C', 'x')

ans = cnt = 0
for c in s[::-1]:
    if c == 'x':
        cnt = 0
        continue
    elif c == 'o':
        cnt += 1
    else:
        ans += cnt
print(ans)


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

using namespace std;

typedef unsigned long long ull;

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

int main(){
    int n;
    while(cin >> n, n){
        vector<pair<int, int> > v(n);
        rep(i, n)cin >> v[i].second >> v[i].first;
        sort(all(v));
        int m = 0;
        bool is = true;
        rep(i, n){
            m += v[i].second;
            if(v[i].first < m){is = false; break;}
        }
        cout << (is?"Yes":"No") << endl;
    }
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rrep(i,1,n+1){
        if(i%2==0)continue;
        cnt=0;
        rrep(j,1,n+1){
            if(i%j==0)cnt++;
        }
        if(cnt==8)ans++;
    }
    Cout(ans);
    return 0;
}


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

int main(){
  float N, D, a;
  cin >> N >> D;
  a = N / (D * 2 + 1);
  cout << ceil(a) << endl;
}

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

int main() {
  int N;
  cin >> N;
  map<char, vector<int> > m;
  m['S'] = vector<int>(13, 0);
  m['H'] = vector<int>(13, 0);
  m['C'] = vector<int>(13, 0);
  m['D'] = vector<int>(13, 0);

  for (int i = 0; i < N; i++) {
    char S;
    int rank;
    cin >> S >> rank;
    m[S].at(rank - 1) = 1;
  }

  string s = "SHCD";
  for (int j = 0; j < s.size(); j++) {
    for (int i = 0; i < 13; i++)
      if (!m[s.at(j)].at(i)) {
        cout << s.at(j) << " " << i+1 << endl;
      }
  }
}



Measured memory_bytes: 3160
import java.util.*;
public class Main {
	public static void main(String[] args) {
        // 文字をキーボードから入力し、配列に記憶
        // Scannerクラスのインスタンスの生成
        Scanner scan = new Scanner(System.in);
        String str = scan.next();
        
        long n = 0;
        int a = 0;
        int flag = 0;
        
        for (int i = 0; i < str.length(); i++) {
        	if(str.charAt(i) == 'B' && flag == 0) {
        		flag = 1;
        	}
        	if(flag == 1) {
        		if(str.charAt(i) == 'W') {
        			n += a;
        		}
        		if(str.charAt(i) == 'B') {
        			a++;
        		}
        	}
        }
        System.out.println(n);
	}
}


Measured memory_bytes: 26644
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = x / 500;
        int b = x % 500;
        int c = b / 5;
        System.out.println(a * 1000+ c * 5);
    }

}


Measured memory_bytes: 23252
#include <stdio.h>
#define MAX 100

int main(void) {
    int i, j, k, n, m, l;
    int a[MAX][MAX], b[MAX][MAX];
    long long v;
    scanf("%d %d %d", &n, &m, &l);
    for(i = 0; i < n; i++) {
        for(j = 0; j < m; j++) {
            scanf("%d", &a[i][j]);
        }
    }
    for(i = 0; i < m; i++) {
        for(j = 0; j < l; j++) {
            scanf("%d", &b[i][j]);
        }
    }
    for(i = 0; i < n; i++) {
        for(j = 0; j < l; j++) {
            for(k = v = 0; k < m; k++) {
                v += a[i][k] * b[k][j];
            }
            printf("%s%lld", j ? " " : "", v);
        }
        printf("\n");
    }
    return 0;
}

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

ll GCD(ll a, ll b)
{
	if (b == 0) return a;
	else return GCD(b,a%b);
}

ll x, n;
vector<ll> v(10000000);

int main(int argc, char **argv)
{
	cin >> n >> x;
	for (int i = 0; i < n; ++i)
		cin >> v[i];

	ll ans = 0;
	for (int i = 0; i < n; ++i)
	{
		ans = GCD(ans ,abs(v[i] - x));
	}

	std::cout << ans << std::endl;
}


Measured memory_bytes: 78336
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int H, W;
void move(int& x, int& y, char c){
  if(c == '8' && y - 1 >= 0) y--;
  if(c == '6' && x + 1 < W) x++;
  if(c == '4' && x - 1 >= 0) x--;
  if(c == '2' && y + 1 < H) y++;
}

int main(){
  while(cin>>H>>W && H){
    vector<string> grid(H);
    string pattern;
    REP(y, H) cin>>grid[y];
    cin>>pattern;
    int N = pattern.size();
    int sx, sy, gx, gy;
    REP(y, H)REP(x, W){
      if(grid[y][x] == 'A') sx = x, sy = y;
      if(grid[y][x] == 'B') gx = x, gy = y;
    }
    queue<int> qx, qy;
    int min_arrive[20][20];
    REP(y, H)REP(x, W) min_arrive[y][x] = INF;
    qx.push(sx), qy.push(sy);
    min_arrive[sy][sx] = 0;
    int max_arrive = -INF;
    while(!qx.empty()){
      int x = qx.front(), y = qy.front();
      qx.pop(); qy.pop();
      REP(r, 4){
        int nx = x + dx[r];
        int ny = y + dy[r];
        if(nx >= 0 && ny >= 0 && nx < W && ny < H && min_arrive[ny][nx] == INF && grid[ny][nx] != '#'){
          min_arrive[ny][nx] = min_arrive[y][x] + 1;
          max_arrive = max(max_arrive, min_arrive[ny][nx]);
          qx.push(nx), qy.push(ny);
        }
      }
    }
    /*
    REP(y, H){
      REP(x, W){
        cout<<min_arrive[y][x]<< " ";
      }
      cout<<endl;
    }
    */
    int ans_t = INF, ans_x = INF, ans_y = INF;
    bool used[10][20][20] = {};
    for(int t = 0; ; t++){
      if(used[t % N][gy][gx] && max_arrive < t) break;
      used[t % N][gy][gx] = true;
      if(min_arrive[gy][gx] <= t){
        ans_t = t, ans_x = gx, ans_y = gy;
        break;
      }
      move(gx, gy, pattern[t % N]);
    }
    if(ans_t != INF) printf("%d %d %d\n", ans_t, ans_y, ans_x);
    else printf("impossible\n");
  }
  return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	vector<int> d(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	sort(d.begin(), d.end());

	int ans = d[n/2] - d[n/2 - 1];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.*
import java.math.*
import java.lang.Math.*

val readString: ()->String = {readLine()!!}
val readInt: ()->Int = {readLine()!!.toInt()}
val readLong: ()->Long = {readLine()!!.toLong()}
val readIntArray: ()->IntArray = {readLine()!!.split(' ').map{it.toInt()}.toIntArray()}
val readLongArray: ()->LongArray = {readLine()!!.split(' ').map{it.toLong()}.toLongArray()}
val errPrintln: (String)->Unit = {msg -> System.err.println(msg)}
val MOD = 1_000_000_007L
val INF = Int.MAX_VALUE/2
val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)


fun solve() {
}


fun main(args: Array<String>) {
    val C = readString().toCharArray()[0]

    val ans = if ('A' <= C && C <= 'Z') 'A' else 'a'
    println(ans)
}


Measured memory_bytes: 34608
n = int(input())
for i in [2,4,5,7,9]:
  if n % 10 == i:
    print('hon')

for i in [0,1,6,8]:
  if n % 10 == i:
    print('pon')

for i in [3]:
  if n % 10 == i:
    print('bon')

Measured memory_bytes: 9116
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

class union_find {
public:
vector<int> par,rank,lsize;
union_find(int n): par(n),rank(n),lsize(n){
   for (int i=0;i < n;i++){
      par[i]=i;
      rank[i]=0;
      lsize[i]=1;
   }
}

int find(int x){
   if (par[x]==x){
      return x;
   }
   else{
      return par[x] = find(par[x]); 
   }
}

void unite(int x ,int y){
   x=find(x);
   y=find(y);
   if (x==y) return;
   if (rank[x] < rank[y]){
      lsize[y] += lsize[x];
      lsize[x] = -1;
      par[x] = y;
   }else{
      lsize[x] += lsize[y];
      lsize[y] = -1;
      par[y]=x;
      if (rank[x]==rank[y]) rank[x]++;
   }   
}

bool same(int x, int y){
   return find(x) == find(y);
}

int size(int x){
   if (lsize[x] == -1){
      x=find(x);
   }
   return lsize[x];
}
};

int main(){
   int n,m;
   cin >> n >> m;
   vector<pair<int,int>> v(m);
   rep(i,m){
      int x,y;
      cin >> x >> y;
      x--;y--;
      v[i] = {x,y};
   }
   int ans = 0;
   rep(i,m){
      union_find tree(n);
      rep(j,m){
         if (i == j) continue;
         tree.unite(v[j].first,v[j].second);
      }
      bool can = true;
      rep(h,n){
         if (tree.size(h) != n){
            can = false;
            break;
         }
      }
      if (!can) ans++;
   }
   cout << ans << endl;

   
   
   
  
   
   
   return 0;
   
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int num=1;
  rep(i,n){
    num*=(i+1);
  }
  vector<int> b(n),c(n),a(n);
  rep(i,n) a[i]=i+1;
  rep(i,n) cin>>b[i];
  rep(i,n) cin>>c[i];
  int l,r;
  rep(i,num){
    if(a==b) l=i;
    if(a==c) r=i;
    next_permutation(a.begin(),a.end() );
  }
  cout<<abs(r-l)<<endl;
      

  return 0;
}


Measured memory_bytes: 256