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

using namespace std;

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

#define rep(i, j, k) for (int i = j; i < k; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define mt make_tuple

#define iv inline void
#define ii inline int
#define ill inline ll

template <typename S, typename T>
inline bool smin(S &l, T r) {
  return r < l ? l = r, 1 : 0;
}
template <typename S, typename T>
inline bool smax(S &l, T r) {
  return l < r ? l = r, 1 : 0;
}

constexpr int MOD = 1e9 + 7;  // 998244353;

template <typename S>
inline S mod(S &l) {
  return l = (l % MOD + MOD) % MOD;
}
template <typename S, typename T>
inline S add(S &l, T r) {
  return mod(l += r);
}
ill po(ll v, ll u) {
  return u ? po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD : 1;
}

void fileIO(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}

constexpr int N = 1e6 + 10;

int n, x;

int main() {
#ifndef LOCAL
  // fileIO("");
#endif

  cin >> n >> x;
  if (x == 1 || x == (2 * n - 1)) return cout << "No\n", 0;

  cout << "Yes\n";

  if (n == 2) return cout << "1\n2\n3\n", 0;

  if (x == 2) {
    int ptr = 5;
    rep(i, 0, n - 2) cout << ptr++ << '\n';
    cout << "4\n2\n1\n3\n";
    rep(i, 0, n - 3) cout << ptr++ << '\n';
    return 0;
  }

  int ptr = 0;
  rep(i, 0, n - 2) {
    ptr++;
    while (ptr <= x + 1 && ptr >= x - 2) ptr++;
    cout << ptr << '\n';
  }
  cout << x - 2 << '\n' << x << '\n' << x + 1 << '\n' << x - 1 << '\n';
  rep(i, 0, n - 3) {
    ptr++;
    while (ptr <= x + 1 && ptr >= x - 2) ptr++;
    cout << ptr << '\n';
  }

  return 0;
}


Measured memory_bytes: 1536
using System;

class Program
{
	static void Main(string[] args)
	{
		int a;

        a = int.Parse(Console.ReadLine());

        if (a % 10 == 9)
        {
            Console.WriteLine("Yes");

        }else if(90 <= a && a <= 99){

            Console.WriteLine("Yes");

        }else{

            Console.WriteLine("No");

        }
		



	}
}

Measured memory_bytes: 11092
import math
N,A,B = map(int,input().split())
V = list(map(int,input().split()))
V.sort()
V.reverse()
cur = 0
selectlist = []
for i in range(A,B+1):
    S = 0
    for j in range(i):
        S += V[j]
    S = S/i
    if cur < S:
        cur = S
        selectlist = [i]
    elif cur == S:
        selectlist.append(i)
ans = 0
for p in range(len(selectlist)):
    nowselect = 1
    s = 0
    K = []
    for i in range(selectlist[p]):
        K.append(V[i])
    P = list(set(K))
    P.sort()
    P.reverse()
    for j in range(len(P)):
        cnt = V.count(P[j])
        s += cnt
        if s >= selectlist[p]:
            res = K.count(P[j])
            nowselect *= math.factorial(cnt)//(math.factorial(res)*math.factorial(cnt-res))
            ans += nowselect
        else:
            nowselect *= cnt
print(cur)
print(ans)

Measured memory_bytes: 3064
import math


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

ans = 0

for n in range(1, N+1):
    # 2^(num_success) * n >= K なる num_success
    # 2^(num_success) >= K/n
    # num_success >= log_2(K/n)
    num_success = max(0, math.ceil(math.log2(K/n)))
    ans += (1/2) ** num_success

print(ans/N)


Measured memory_bytes: 3188
import sys
#import numpy as np
import math
from fractions import Fraction
import itertools

input=sys.stdin.readline
n,k=map(int,input().split())
a=list(map(int,input().split()))
p=[0]*n
q=[0]*n
ans=0
mod=10**9+7
for i in range(n):
    for j in range(n):
        if a[i]>a[j]:
            if i>j:
                p[i]+=1
            elif i<j:
                q[i]+=1
                
for i in range(n):
    ans+=(k*q[i]+((p[i]+q[i])*k*(k-1)//2)%mod)%mod
    ans=ans%mod
print(int(ans%mod))

Measured memory_bytes: 67432
#include<bits/stdc++.h>
const int N=1e6+5;
int n,a[N],i,Q,k,q[N],t,w;
char s[N];
long long ans,z;
int main(){
	scanf("%d%s%d",&n,s+1,&Q);for(i=1;i<=n;++i)a[i]=a[i-1]+(s[i]=='M');
	for(;Q--;){
		scanf("%d",&k);
		t=1;w=z=ans=0;
		for(i=1;i<=n;++i){
			for(;t<=w && i-q[t]>=k;z-=a[q[t++]]);
			if(s[i]=='C')ans+=1ll*a[i]*(w-t+1)-z;
			if(s[i]=='D')z+=a[q[++w]=i];
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 9088
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<Integer, Integer> map = new HashMap<Integer, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<Integer> cc = new ArrayList<>(N);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	static int INF=1000000007;
	

	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		
		//Ae2+Be2=Ce2
		//StringBuffer str = new StringBuffer(hoge1);
		//for(int i=0;i<N;i++) {}
		//int v[]=new int[];for(int i=0;i<;i++)v[i]=sc.nextInt();
		//int a[]=new int[N];for(int i=0;i<N;i++) {a[i]=sc.nextInt();}
		//String S=sc.next();
	
		int a[]=new int[5];
		for(int i=0;i<5;i++) {a[i]=sc.nextInt();}
		
		int t=(a[2]-a[0])*60+a[3]-a[1];
		p(t-a[4]);
		
		
		
		
		
	}
	static long bi(int i) {
		long t=1;
		for(int a=1;a<=i;a++) {
			t*=a;
			t%=mod;
		}
		return t;
	}
	public static long modPow(long g,long N) {
		long T=1;
		for(int i=0;i<N;i++) {
			T*=g;
			T%=mod;
		}
		return T;
	}
	
	public static long lcm(long a, long b) {
        return a / gcd(a, b) * b;
	}
	
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 35756
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<long int> M(N);
  long int s=0;
  long int S;
  long int answer;
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  for(int i=N; i>1; i--){
    s+=A.at(i-1);
    S=s%1000000007;
    M.at(i-2)=(S*A.at(i-2))%1000000007;
  }
  for(int i=0; i<N-1; i++){
    answer+=M.at(i);
  }
  cout << answer%1000000007 <<endl;
}

Measured memory_bytes: 5548
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define eps 1e-8
#define mp make_pair
#define np next_permutation
#define pb push_back
#define all(x) (x.begin(),x.end())
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
using namespace std; 
const int maxn=500+5;

vector <int> v[maxn]; 
bool vis[maxn];

void init(){
	rep(i,0,maxn) v[i].clear();
	memset(vis,0,sizeof(vis));
}


void addedge(int l,int r){
	int len=r-l;
	v[l].pb(len);
}

int  checkedge(int l,int len){
//	if(v[l].begin()!=v[l].end()) 
//		 cout<<*v[l].begin()<<endl; 
	int ans=upper_bound(v[l].begin(),v[l].end(),len)-v[l].begin();
//	cout<<"ans="<<ans<<endl;
	return ans;
}
int n,m,q,li,ri,pi,qi;

int main(){
//	ios::sync_with_stdio(false);
	while(~scanf("%d%d%d",&n,&m,&q)){
		init(); 
		rep(i,0,m){
			scanf("%d%d",&li,&ri);
			addedge(li,ri);
			vis[li]=1;
		}
		rep(i,0,maxn){
			if(vis[i])	sort(v[i].begin(),v[i].end()); 
		} 
		rep(i,0,q){
			scanf("%d%d",&pi,&qi);
			int cnt=0;
			for(int i=pi;i<=qi;i++){
				int plen=qi-i;
//				cout<<"plen="<<plen<<endl;
				cnt+=checkedge(i,plen);
			}
			printf("%d\n",cnt);
		}
	} 
} 


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

class Solution
{
    static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int n = 0;
        for (int i = 0; i < 3; i++)
        {
            n *= 10;
            n += vals[i];
        }

        Console.WriteLine((n % 4 == 0) ? "YES" : "NO");
    }
}

Measured memory_bytes: 13396
import sys
import math
import numpy as np
import itertools
# いくつか入力
x,y,a,b,c = (int(i) for i in input().split())  

# 空白区切りの数列をリストに代入
p = [int(i) for i in input().split()] 
q = [int(i) for i in input().split()] 
r = [int(i) for i in input().split()] 

p=sorted(p,reverse=True)
q=sorted(q,reverse=True)
r=sorted(r,reverse=True)

# print(p)
# print(q)
# print(r)
u=[]
for i in range(x):
    u.append(p[i])
for i in range(y):
    u.append(q[i])
u=sorted(u)
# print(u)
for i in range(min(len(u),len(r))):
    if u[i]<r[i]:
        u[i]= r[i]
# print(u)
answer = 0
for a in u:
    answer += a
print(answer)


Measured memory_bytes: 31344
#include <bits/stdc++.h>
using namespace std;
     
int main(){
  string w;
  cin >> w;
  
  vector<string> V(w.size());
  
  for(int i = 0; i < w.size(); i++){
    V.at(i) = w.at(i);
  }
  
  sort(V.begin(), V.end());
  
  int sum = 0;
  
  if(w.size() % 2 == 1){
    cout << "No" << endl;
  }
  
  else{
  
  for(int i = 0; i < w.size() / 2; i++){
  if(V.at(2 * i) == V.at(2 * i + 1)){
    sum += 1;
  }
  }
    
    if(sum != w.size() / 2){
      cout << "No" << endl;
    }
    
    else{
      cout << "Yes" << endl;
    }
  }
    
    
}

Measured memory_bytes: 256
n, m  = map(int, input().split())
edges = [[] for i in range(n)]

for i in range(m):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)

dp = [-1] * n
from collections import deque
q = deque([])
q.append(0)
dp[0] = 0
while len(q) > 0:
    u = q.popleft()
    for v in edges[u]:
        if dp[v] != -1:continue
        q.append(v)
        dp[v] = u
# print(dp)
for d in dp[1:]:
    if d == -1:
        print("No")
        exit()
print("Yes")
for d in dp[1:]:
    print(d+1)

Measured memory_bytes: 34800
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define MP make_pair
const int oo = 1e9;
int n,a,sum;
int main(){_
cin >> n;
for(int i=0;i<n;i++){
    cin >> a ;
    sum+=a;
}
cout << sum-n;
}


Measured memory_bytes: 256
// Nihesh Anderson - knandy

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
ll MOD=1000000007;

#define endl '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
ll INF = 2000000000000000001;
long double EPS = 1e-9;
ll power(ll a, ll n, ll md){if(n==0){return 1;}else{int res=power(a,n/2,md);res=(res*res)%md;if(n%2!=0){res=(res*a)%md;}return res;}}
random_device rndm;
mt19937 grndm(rndm());
void mix(int* a, int* b){shuffle(a,b,grndm);}

int main(){
	fast_cin();
	// freopen("input.in","r",stdin);
	// freopen("output.out","w",stdout);
	int n; cin >> n;
	if(n % 1000 == 0) {
		cout << 0 << endl;
		return 0;
	}
	cout << 1000 - n % 1000 << endl;
	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
using namespace	std;
int main(){

  int n,tmp,p[100000]={};
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>tmp;
    if(i+1==tmp) p[i]=1;
  }
  int r=0;
  for(int i=0;i<n;i++){
    if(p[i]==1){
      r++;
      p[i]=0;
      if(i+1<n) p[i+1]=0;
    }
  }
  cout<<r<<endl;

  return 0;

}






Measured memory_bytes: 640
def reverse(s):
    return ''.join(list(reversed(s)))

m = int(input())

for i in range(m):
    d = input()
    _set = set()
    for i in range(len(d)-1):
        w1 = d[:i+1]
        w2 = d[i+1:]
        _set.add(w1 + w2)
        _set.add(w2 + w1)
        _set.add(reverse(w1) + reverse(w2))
        _set.add(reverse(w2) + reverse(w1))
        _set.add(w1 + reverse(w2))
        _set.add(w2 + reverse(w1))
        _set.add(reverse(w1) + w2)
        _set.add(reverse(w2) + w1)

    print(len(_set))

Measured memory_bytes: 6804
#include <stdio.h>
#pragma warning (disable:4996)

int main() {
	//input
	int A, B, C, K;
	(void)scanf("%d%d%d%d", &C, &B, &A, &K);

	//output
	bool ab, bc;
	if (A <= B)ab = false; else ab = true;
	if (B <= C)bc = false; else bc = true;
	for (int i = 0; i < K; i++) {
		if (ab && bc)break;
		if (ab == false) {
			A *= 2;
			if (A > B)ab = true;
			continue;
		}
		if (bc == false) {
			B *= 2;
			if (A <= B)ab = false;
			if (B > C)bc = true;
			continue;
		}
	}
	/*
	bool ab = false, bc = false;
	for (int i = 0; i < K; i++) {
		if (A <= B) {
			A *= 2;
		}
		else if (B <= C) {
			ab = true;
			B *= 2;
			if (A <= B)ab = false;
		}
		else {
			ab = true;
			bc = true;
			break;
		}
	}
	*/
	if (ab && bc)printf("Yes");
	else printf("No");
}

Measured memory_bytes: 1724
object Main extends App {
  io.StdIn.readLine.split(" ").map(_.toInt) match {
    case Array(n, k) => {
      var now = n
      var ans = 0
      while(now > 0) {
        now = now / k
        ans = ans + 1
      }
      println(ans)
    }
  }
}


Measured memory_bytes: 27336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    ll ans=(n*(n+1))/2;
    ll a=(n/3),b=(n/5),c=(n/15);
    ans=(ans - (a*(a+1)/2)*3);
    ans=(ans - (b*(b+1)/2)*5);
    ans=(ans + (c*(c+1)/2)*15);
    cout<<ans;
}



Measured memory_bytes: 3592
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

S = input()
T = input()
ans = 0
for s, t in zip(S, T):
    ans += s != t
print(ans)


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

using namespace std;
typedef long long ll;
typedef pair<int,ll> pil;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int maxN = 5e5 + 5;
const ll INF = 1ll<<60;
int n,m;
ll a[maxN];
ll b[maxN];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+1+m);
	b[0] = 0;
	for(int i=2;i<=m;i++)
	{
		ll x = a[i] - a[i-1];
		b[i] = x;
	}
	sort(b+1,b+1+m);
	reverse(b+1,b+1+m);
	ll ans = 0;
	for(int i=n;i<=m;i++)
	{
		ans += b[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main() {
    int n;
  
    while(true){
        cin>>n;
        if(n==0) break;
        int a[n];
        int sum=0;
        int sum2=0;
        double m=n;
        
        for(int i=0;i<n;i++){
            cin>>a[i];
            sum+=a[i];
            sum2+=a[i]*a[i];
        }
        double ave=sum/m;
        double ave2=sum2/m;
         double s=sqrt(ave2 - ave*ave);
        cout<<setprecision(10)<<s<<endl;
    }

	return 0;
}


Measured memory_bytes: 3284
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

#define Re return
#define In inline
#define St static
#define inc(l, i, r) for(i=l;   i<r;  ++i)
#define dec(l, i, r) for(i=r-1; i>=l; --i)
typedef pair<int, int> pint;
#define fst first
#define snd second
#define mP make_pair

const int mxn=1<<20;

int n, m, v[20], a[mxn], ans[mxn],  pre[mxn][20], nxt[mxn][20], f[mxn], g[mxn];

pint pr[mxn], que[mxn];

In void mxe(int& a, int b){a<b? a=b: 0;}
In void mne(int& a, int b){a>b? a=b: 0;}

int main()
{
    int i, j, k, l;
    scanf("%d%d", &n, v);
    for(i=1; v[i-1]/2; ++i)
        v[i]=v[i-1]>>1;
    m=i+1;
    inc(1, i, n+1)
        scanf("%d", a+i);

    inc(0, j, m) pre[1][j]=1;
    inc(2, i, n+1)
        inc(0, j, m)
    {
        if(a[i]-a[i-1]>v[j])
            pre[i][j]=i;
        else
            pre[i][j]=pre[i-1][j];
//        printf("%d %d:%d\n", i, j, pre[i][j]);
    }
    

    inc(0, j, m) nxt[n][j]=n;
    dec(1, i, n)
        inc(0, j, m)
        if(a[i+1]-a[i]>v[j])
            nxt[i][j]=i;
        else
            nxt[i][j]=nxt[i+1][j];

//    inc(0, i, m) printf("%d ", nxt[1][i]);puts("");
    
    inc(0, i, 1<<m)
        inc(0, j, m)
        if(~i&1<<j)
            if(f[i]<n) mxe(f[i|1<<j], nxt[f[i]+1][j]);
            else mxe(f[i|1<<j], n);

    inc(0, i, 1<<m) g[i]=n+1;
    inc(0, i, 1<<m)
        inc(0, j, m)
        if(~i&1<<j)
            if(g[i]>1) mne(g[i|1<<j], pre[g[i]-1][j]);
            else mne(g[i|1<<j], 1);

    inc(j=0, i, 1<<m-1)
        pr[i]=mP(g[i<<1], i<<1);
    inc(1, i, n+1)
        if(pre[i][0]==i)
            que[j++]=mP(i, nxt[i][0]);

    sort(pr, pr+(1<<m-1)), sort(que, que+j);

//    inc(0, i, 1<<m) printf("%d %d\n", f[i], g[i]);
//    inc(0, i, 1<<m-1) printf("%d %d")

    inc(k=0, i, j)
    {
//        printf("%d -- %d\n", que[i].fst, que[i].snd);
        for(;k<1<<m-1 && f[(1<<m)-2-pr[k].snd]<que[i].fst-1; ++k);
        if(k==1<<m-1 || pr[k].fst>que[i].snd+1) continue;
//        printf("%d !! %d\n", f[(1<<m)-2-pr[k].snd], pr[k].fst);
        inc(que[i].fst, l, que[i].snd+1) ans[l]=1;
    }

    inc(1, i, n+1) puts(ans[i]? "Possible": "Impossible");
    
    Re 0;
}


Measured memory_bytes: 51456
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<int, vector<int>, greater<int> > PQG;
#define REP(i, a, n) for(ll i = (ll) a;i < (ll) n;i++)
#define fi first
#define se second
#define pb push_back
#define INF 1000000009
#define MOD 1000000007
#define MAXN 100005
#define MAXC 100000000000014
#define MAXV 1000000009

ll x, y, n, ans;

int main()
{
    cin >> x >> y;
    n = x;
    ans = 1;
    while(n < y){
        n *= 2;
        ans++;
    }
    if(ans != 1){
        if(n == y)cout << ans << endl;
        else cout << ans - 1 << endl;
    }
    else{
        cout << ans << endl;
    }

    return 0;
}
















Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define compress(v) sort(all(v)), v.erase(unique(all(v)), v.end())
using namespace std;

typedef long long ll;

int n, cnt;
string s;

int dp[202020];
int get(int x){
    int ret = 0;
    while(x){ if(x & 1) ret++; x >>= 1; }
    return ret;
}

int f(int x){
    int &res = dp[x];
    if(res != -1) return res;
    if(x == 0) return res = 0;
    return res = 1 + f(x % get(x));
}

int table[2][202020];
int all[2];
void init(){
    ll a = 1, b = 1;
    for(int i=n-1; ~i; i--){
        if(cnt != 1) table[0][i] = a % (cnt-1);
        table[1][i] = b % (cnt+1);
        a <<= 1; b <<= 1;
        if(cnt != 1) a %= (cnt-1);
        b %= (cnt+1);
    }
    for(int i=0; i<n; i++){
        if(s[i] == '1' && cnt != 1) all[0] = (all[0] + table[0][i]) % (cnt-1);
        if(s[i] == '1') all[1] = (all[1] + table[1][i]) % (cnt+1);
    }
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    cin >> n >> s;
    memset(dp, -1, sizeof dp);
    for(auto i : s) cnt += (i == '1');
    init();

    for(int i=0; i<n; i++){
        if(cnt == 1 && s[i] == '1'){ cout << "0\n"; continue; }
        if(s[i] == '0'){
            int t = all[1]; t = (t + table[1][i]) % (cnt+1);
            cout << f(t) +1 << "\n";
        }else{
            int t = all[0]; t = (t - table[0][i]) % (cnt-1);
            t += cnt-1; t %= (cnt-1);
            cout << f(t) + 1 << "\n";
        }
    }
}

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

int main(){
    int N;
    cin >> N;
    int i = N;
    int sum = 0;
    while(i>0){
        sum += i % 10;
        i /= 10;
    }
    if(N %sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

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

int main() {
  string s;
  cin >> s;

  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }

  return 0;
}


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

#define debug(n) cerr << #n << ':' << n << endl;

using namespace std;

using  ll = long long;

template<class T,class U>
using umap = unordered_map<T,U>;

template<class T>
using uset = unordered_set<T>;

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

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


int main(){
  int n;cin >> n;
  vector<int> a(n), b(n), c(n-1);
  for(int&x:a)cin >> x;
  for(int&x:b)cin >> x;
  for(int&x:c)cin >> x;

  int ans = 0;
  for(int&x:b)ans += x;
  for(int i = 0; i < n - 1; ++ i){
    if(a[i] + 1 == a[i + 1])ans += c[a[i]-1];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	private static Scanner sc=new Scanner(System.in);
	
	void ans(){
		int n=sc.nextInt();
		int a[]=new int[8];
		for(int i=0;i<n;i++){
			String  pp=sc.next();
			char ps[]=pp.toCharArray();
			
			for(int j=0;j<8;j++){
				a[j]=ps[j];
			}
			
			
			
			Arrays.sort(a);
			int count=1;
			int temp=0;
			int ans=0;
			for(int j=0;j<8;j++){
				 temp+=a[j]*count;
				count*=10;
				//System.err.println(temp);
			}
			
			
			
			count=1;
			for(int j=7;j>=0;j--){
				ans+=a[j]*count;
				count*=10;
				//System.err.println(ans);
			}
			
			
			
			temp-=ans;
			System.out.println(temp);
		}
	    
	}
	public static void main(String[] args) {
	
		Main app=new Main();
		app.ans();
	}

}

Measured memory_bytes: 17172
import Control.Applicative
import Data.List.Split (splitOn)

main :: IO ()
main = solve <$> f >>= putStrLn
  where
    f = map read <$> splitOn "/" <$> getLine

solve :: [Int] -> String
solve [_, m, _]
  | m <= 4 = "Heisei"
  | otherwise = "TBD"


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

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

int main() {
  // 入力
  int N;
  cin >> N;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];

  int ans = 0;
  int idx = 0;
  bool flag;
  while (idx < N - 1) {
    if (a[idx] == a[idx+1]) {
      idx++;
    } else if (a[idx] < a[idx+1]) {
      flag = true;
      ans++;
      while (idx < N - 1 && a[idx] <= a[idx+1]) idx++;
      idx++;
    } else {
      flag = false;
      ans++;
      while (idx < N - 1 && a[idx] >= a[idx+1]) idx++;
      idx++;
    }
  }
  if (flag) {
    if (a[N-2] > a[N-1]) ans++;
  } else {
    if (a[N-2] < a[N-1]) ans++;
  }

  // 解答
  cout << ans << endl;

  return 0;
}


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

class DisjSet
{
    vector<int> parent;
    vector<int> rank;
public:
    DisjSet(size_t sz)
        : parent(sz, -1), 
        rank(sz, -1) {}

    void make_set(int v)
    {
        parent[v] = v;
        rank[v] = 0;
    }

    int find_set(int x)
    {
        if (parent[x] != x)
            return parent[x] = find_set(parent[x]);
        return x;
    }

    void union_sets(int l, int r)
    {
        int pl = find_set(l);
        int pr = find_set(r);
        if (pl != pr) {
            if (rank[pl] < rank[pr])
                swap(pl, pr);
            parent[pr] = pl;
            if (rank[pr] == rank[pl])
                rank[pl] += 1;
        }
    }
};

int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    int N, M;
    cin >> N >> M;
    DisjSet ds(N);
    for (int i = 0; i < N; ++i)
        ds.make_set(i);
    int res = 0;
    for (int i = 0; i < M; ++i) {
        int u, v, w;
        cin >> u >> v >> w;
        --u; --v;
        if (u == v) continue; 
        if (ds.find_set(u) != ds.find_set(v))
            ++res;
        ds.union_sets(u, v);
    }

    cout << N - res << endl;

    return 0;
}


Measured memory_bytes: 1024
from itertools import accumulate
import bisect
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

aa = list(accumulate(a))
aa.insert(0,0)
bb = list(accumulate(b))
bb.insert(0,0)

ans = 0

for i in range(n+1):
    if aa[i] > k:
        break
    nokori = k-aa[i]
    kazu = bisect.bisect_right(bb, nokori)
    ans = max(ans,i+kazu-1)



print(ans)

Measured memory_bytes: 47672
#include <iostream>
#include <cmath>

using namespace std;

#undef INFINITY
#define INFINITY	100000000000

typedef unsigned long long ull;

ull cost[100001] = { 0 };
ull height[100001] =  { 0 };

ull getMinCost(int n, int k) {
	for (int i = n-2; i >= 0; --i) {
		ull minCost = INFINITY;
		for (int j = 1; j <= k && (i+j) < n; ++j) {
			ull currentCost = abs((long long)height[i] - (long long)height[i+j]) + cost[i+j];
			if (currentCost < minCost) {
				minCost = currentCost;
			}
		}
		cost[i] = minCost;
	}
	return cost[0];
}

int main() {
	int n, k;

	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> height[i];
	}

	cout << getMinCost(n, k) << endl;

	return 0;
}


Measured memory_bytes: 5160
#include <stdio.h>
    int main(){
        int i=0,x=0,k;
        int data[10000];
        while(1){
            x++;
            scanf("%d",&data[x]);
            i=i+1;
            if(data[x] == 0)break;
        }
        for(k=1;k<i;k++){
            printf("Case %d: %d\n",k,data[k]);
    }
    return 0;
}

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

int main(){
  int H, W;
  cin >> H >> W;
  
  vector<char> frame(W+2, '#');
  vector<string> str(H);
  
  for(int i=0; i<H; i++){
    cin >> str.at(i) ;
  }
  
  for(int i=0; i<H+2; i++){
    if(i == 0 || i == H+1){
      for(int j=0; j<W+2; j++){
         cout << frame.at(j);
      }
      cout << endl;
    }
    else{
      cout << '#' << str.at(i-1) << '#' << endl;
    }
  }
}

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

int main() {
  string s;
  cin >> s;
  string t = "aaa";
  
  for(int i=0; i<3; i++){
    t[i] = s[i];
  }
  
  cout << t << endl;
	return 0;
}


Measured memory_bytes: 3624
// template {{{

#include <bits/stdc++.h>
using namespace std;

#define loop(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) loop(i, 0, n)
#define rloop(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define rrep(i, n) rloop(i, 0, n)
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define mp std::make_pair
#define mt std::make_tuple
#define fi first
#define se second

using ll = long long;
using ull = unsigned long long;

template<typename T, size_t H, size_t W>
using matrix = std::array<std::array<T, W>, H>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 10;
const ll LLINF = 1e18 + 10;

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

template<typename T>
inline T sq(T x){ return x * x; }

template<typename T, typename U>
inline void chmax(T &x, U y){ x = std::max<T>(x, y); }

template<typename T, typename U>
inline void chmin(T &x, U y){ x = std::min<T>(x, y); }

template<typename T>
inline void sort(T &c){ std::sort(std::begin(c), std::end(c)); }

template<typename T>
inline void reverse(T &c){ std::reverse(std::begin(c), std::end(c)); }

template<typename T>
inline void unique(T &c){ std::sort(c); c.erase(std::unique(std::begin(c), std::end(c))); }

// }}}

using pr = pair<int, int>;

int n;
int x[20000], y[20000];
map<pr, pr> c;
map<pr, int> g;

bool dfs(int x, int y, int col)
{
	g[pr(x, y)] = col;
	rep(dir, 4){
		int nx = x + dx[dir];
		int ny = y + dy[dir];
		if (!g.count(pr(nx, ny))) continue;
		if (pr(nx, ny) == c[pr(x, y)]){
			if (g[pr(nx, ny)] == col) return false;
			if (g[pr(nx, ny)] == 0){
				if (!dfs(nx, ny, -col)) return false;
			}
		}
		else {
			if (g[pr(nx, ny)] == -col) return false;
			if (g[pr(nx, ny)] == 0){
				if (!dfs(nx, ny, col)) return false;
			}
		}
	}
	return true;
}

int main()
{
	int n;
	while (cin >> n, n){
		c.clear();
		g.clear();
		rep(i, n){
			string dir;
			cin >> x[i] >> y[i] >> dir;
			if (dir == "x"){
				c[pr(x[i], y[i])] = pr(x[i] + 1, y[i]);
				c[pr(x[i] + 1, y[i])] = pr(x[i], y[i]);
				g[pr(x[i], y[i])] = 0;
				g[pr(x[i] + 1, y[i])] = 0;
			}
			else {
				c[pr(x[i], y[i])] = pr(x[i], y[i] + 1);
				c[pr(x[i], y[i] + 1)] = pr(x[i], y[i]);
				g[pr(x[i], y[i])] = 0;
				g[pr(x[i], y[i] + 1)] = 0;
			}
		}
		bool res = true;
		rep(i, n){
			if (!g[pr(x[i], y[i])]){
				if (!dfs(x[i], y[i], 1)){
					res = false;
					break;
				}
			}
		}
		cout << (res ? "Yes" : "No") << endl;
	}
}

Measured memory_bytes: 13292
// AOJ 1225: e-market
// 2017.10.25 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define HASHSIZ 2003
typedef struct { char *s; int id; } HASH;
HASH hash[HASHSIZ+2], *hashend = hash + HASHSIZ;			// Hash table

int lookup(char *s, int id)
{
	int w = strlen(s);
	int i = (101 * *s + 103 * *(s+w-1) + 107 * w) % HASHSIZ;
	HASH *tp = hash + i;

	while (tp->s != NULL) {
		if (!strcmp(tp->s, s)) return tp->id;
		if (++tp == hashend) tp = hash;
	}
	tp->s = s, tp->id = id;
	return -1;
}

typedef struct { int id, buy, m, p, fin; } T;
T tbl[1002]; int n;
typedef struct { int min, max, sum, n; } M;
M mono[26];
typedef struct { char *nm; int paid, got; } D;
D dealer[1002];
char dealerName[1002][12]; int sz;

int cmp(D *a, D *b) { return strcmp(a->nm, b->nm); }
int main()
{
	int i, j, id;
	char b1[10], b2[5];
	T *tp;

	while (scanf("%d", &n) && n > 0) {
		memset(hash, 0, sizeof(hash)); memset(mono, 0, sizeof(mono));
		for (sz = 0, tp = tbl, i = 0; i < n; i++, tp++) {
			scanf("%s%s%s%d", dealerName[sz], b1, b2, &tp->p);
			if ((id = lookup(dealerName[sz], sz)) < 0) {
				dealer[sz].nm = dealerName[sz], dealer[sz].paid = dealer[sz].got = 0;
				id = sz++;
			}
			tp->id = id, tp->buy = (*b1=='B'), tp->m = (*b2-'A'), tp->fin = 0;
		}

		for (i = 1; i < n; i++) {
			int buy, p, best, m, jj;
			if (tbl[i].fin) continue;
			buy = tbl[i].buy, m = tbl[i].m, p = tbl[i].p, best = -1;
			for (j = 0; j < i; j++) {
				if (tbl[j].id != tbl[i].id && tbl[j].buy != buy && tbl[j].m == m && !tbl[j].fin) {
					if (buy && tbl[j].p <= p) {
						if (best < 0 || tbl[j].p < best) best = tbl[j].p, jj = j;
					} else if (!buy && p <= tbl[j].p) {
						if (best < 0 || best < tbl[j].p) best = tbl[j].p, jj = j;
					}
				}
			}

			if (best >= 0) {
				tbl[i].fin = tbl[jj].fin = 1;
				best = (p + tbl[jj].p)/2;
				if (mono[m].n == 0) mono[m].min = mono[m].max = best;
				else {
					if      (best < mono[m].min) mono[m].min = best;
					else if (best > mono[m].max) mono[m].max = best;
				}
				mono[m].sum += best, mono[m].n++;
				id = tbl[jj].id;
				if (buy) dealer[id].got += best; else dealer[id].paid += best;
				id = tbl[i].id;
				if (buy) dealer[id].paid += best; else dealer[id].got += best;
			}
		}

		for (i = 0; i < 26; i++) if (mono[i].n > 0) {
			printf("%c %d %d %d\n", i+'A', mono[i].min, mono[i].sum/mono[i].n, mono[i].max);
		}
		puts("--");
		qsort(dealer, sz, sizeof(D), cmp);
		for (i = 0; i < sz; i++) {
			printf("%s %d %d\n", dealer[i].nm, dealer[i].paid, dealer[i].got);
		}
		puts("----------");
	}
	return 0;
}

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

int main(){
  int i;
  string s,t;
  cin>>s;
  cin>>t;
  for(i=0;i<s.size()+1;i++){
    if(s==t){
      cout<<"Yes";
      return 0;
    }
    s=s[s.size()-1]+s.substr(0,s.size()-1);
  }
  cout<<"No";
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		ArrayList<Integer> A = new ArrayList<Integer>();
		ArrayList<Integer> B = new ArrayList<Integer>();
		for(int i = 0; i < N; i++) {
			A.add(Integer.parseInt(sc.next()));
			B.add(A.get(i));
		}
		sc.close();
		Collections.sort(B);
		int max = B.get(N - 1);
		int count = 0;
		for(int i = 0; i < N; i++) {
			if(max == A.get(i)) {
				count++;
			}
		}
		for(int i = 0; i < N; i++) {
			if(count < 2) {
				if(max == A.get(i)) {
					System.out.println(B.get(N - 1 - count));
				}else {
					System.out.println(max);
				}
			}else {
				System.out.println(max);
			}
		}
	}

}

Measured memory_bytes: 77300
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int n;
set<int> s;
char c;
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++){
    	cin>>c;
    	s.insert(c-'0');
	}
	if(s.size()==3)
	cout<<"Three";
	else
	cout<<"Four";
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define RI register int
const int mod=998244353,N=4005;
int n,K;
int fac[N],inv[N],ifac[N],bin[N];
 
int qm(int x) {return x>=mod?x-mod:x;}
int qpow(int x,int y) {
	int re=1;
	for(;y;y>>=1,x=1LL*x*x%mod) if(y&1) re=1LL*re*x%mod;
	return re;
}
int C(int d,int u) {
	if(d<0||u<0||d<u) return 0;
	return 1LL*fac[d]*ifac[u]%mod*ifac[d-u]%mod;
}
int getans(int x,int y,int z) {
	int re=0;
	for(RI i=0;i<=x;++i)
		re=qm(re+1LL*bin[i]*C(x,i)%mod*C(z+y-1,z-i)%mod);
	return re;
}
int main()
{
	scanf("%d%d",&K,&n);
	fac[0]=1;for(RI i=1;i<=4000;++i) fac[i]=1LL*fac[i-1]*i%mod;
	inv[0]=inv[1]=1,ifac[0]=1;
	for(RI i=2;i<=4000;++i) inv[i]=1LL*(mod-mod/i)*inv[mod%i]%mod;
	for(RI i=1;i<=4000;++i) ifac[i]=1LL*ifac[i-1]*inv[i]%mod;
	bin[0]=1;for(RI i=1;i<=4000;++i) bin[i]=qm(bin[i-1]+bin[i-1]);
	for(RI i=2;i<=2*K;++i) {
		int x=(min(K,i-1)-max(1,i-K)+1)/2,ans=0;
		if(i&1) ans=getans(x,K-x*2,n);
		else ans=qm(getans(x,K-x*2-1,n)+getans(x,K-x*2-1,n-1));
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

int main(){
	char a[32],b[32];
	while(~scanf("%s %s",a,b)){
		if(a[0]==b[0] && b[0] == '0') break;
		int hit=0;
		int brow=0;

		for(int i=0;i<4;i++){
			if(a[i]==b[i]){
				hit++;
				continue;
			}
			for(int j=0;j<4;j++){
				if(i==j) continue;
				if(b[i] == a[j]){
					brow++;
					break;
				}
			}

		}

		printf("%d %d\n",hit,brow);
	}
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int h, w, k;
  while (cin >> h >> w >> k) {

    vector<int> v;
    for (int bit = 0; bit < (1 << (w - 1)); ++bit) {
      bool f = true;
      for (int i = 0; i < w - 1; ++i) {
        int a = 1 << i;
        int b = 1 << (i + 1);
        if ((bit & a) && (bit & b)) f = false;
      }
      if (f) v.push_back(bit);
    }

    const int mod = 1000000007;
    const int H = 100 + 5;
    const int K = 8 + 5;
    lli dp[H][K];
    fill(&dp[0][0], &dp[H - 1][K - 1] + 1, 0);
    dp[0][0] = 1;
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        each (b, v) {
          if (b & (1 << j)) {
            (dp[i + 1][j + 1] += dp[i][j]) %= mod;
          } else if (j && (b & (1 << (j - 1)))) {
            (dp[i + 1][j - 1] += dp[i][j]) %= mod;
          } else {
            (dp[i + 1][j] += dp[i][j]) %= mod;
          }
        }
      }
    }

    cout << dp[h][k - 1] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

int main() {
    long long x;
    cin >> x;
    cout << (x / 11) * 2 + ((x % 11) + 5) / 6 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
const int INF=998244353;
const int N=1005;
const int M=2005;
struct Node{
	int v;
	int next;
}a[M];
int last[N],tot,du[N],b[N],pre[N],ans[N],sum;
bool vis[N],visk[N];
void add(int u, int v)
{
	tot++;
	a[tot].v=v;
	a[tot].next=last[u];
	last[u]=tot;
}
queue<int> q;
queue<int> k;
void bfs(int s)
{
	while(!k.empty())k.pop();
	memset(pre,0,sizeof(pre));
	memset(visk,0,sizeof(visk));
	k.push(s);
	visk[s]=1;
	int p=0;
	while(!k.empty())
	{
		if(p>0)break;
		int u=k.front();
		k.pop();
		for(int c=last[u];c>0;c=a[c].next)
		{
			int v=a[c].v;
			if(v==s)
			{
				p=u;
				break;
			}
			if(visk[v])continue;
			k.push(v);
			pre[v]=u;
			visk[v]=1;
		}
	}
	if(p==0)return;
	int h=p,cnt=1;
	while(h!=s){
        cnt++;
		h=pre[h];	
	}
	if(cnt<sum)
	{
		cnt=1;
		ans[cnt]=s;
		while(p!=s)
		{
			cnt++;
			ans[cnt]=p;
			p=pre[p];
		}
		sum=cnt;
	}
}
int main()
{
	int n,m,u,v;
	scanf("%d%d",&n,&m);
	tot=0;
	memset(du,0,sizeof(du));
	memset(last,0,sizeof(last));
	for(int i=1;i<=m;i++){
		scanf("%d%d",&u,&v);
		add(u,v);
		du[v]++;
	}
	while(!q.empty())q.pop();
	for(int i=1;i<=n;i++){
		if(du[i]==0){
			q.push(i);
		}
	}
	memset(vis,0,sizeof(vis));
	while(!q.empty()){
		int u=q.front();
		vis[u]=-1;
		q.pop();
		for(int c=last[u];c>0;c=a[c].next)
		{
			int v=a[c].v;
			du[v]--;
			if(du[v]==0)q.push(v); 
		}
	}
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(vis[i]==0){
			cnt++;
			b[cnt]=i;
		}
	}
	if(cnt==0){
		printf("-1");
		return 0;
	}
	sum=INF;
	for(int i=1;i<=cnt;i++){
//		printf("%d ",b[i]);
		bfs(b[i]);
//		printf("%d ",b[i]);
	}
	printf("%d\n",sum);
	for(int i=1;i<=sum;i++){
		printf("%d\n",ans[i]);
	}
	return 0;
}

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

int main(){
  int n;
  string s;
  cin>>n>>s;
  int cnt=0;
  for(int i=0;i<n-2;i++){
    if(s.at(i)=='A'&&s.at(i+1)=='B'&&s.at(i+2)=='C'){
      cnt++;
    }
  }
  cout<<cnt; 
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

ll A, B, N; 

ll f(ll x) {
    return A * x / B - A * (x / B);
}

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

    ll ans = -1;
    if (N >= B - 1) {
        ans = f(B - 1);
    } else {
        ans = f(N);
    }

    // for (ll i = 1; i <= N; i++) {
    //     cout << i << ":" << f(i) << endl;
    // }

    cout << ans << endl;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
 		Scanner scanner = new Scanner(System.in);
 		int A = scanner.nextInt();
 		int B = scanner.nextInt();
 		int H = scanner.nextInt();
 		int M = scanner.nextInt();
 		double cos = 0;
 		double result = 0;

 		double h = H * 30 + M * 0.5;
 		double m = M * 6;
 		if (h >= m) {
 			cos = Math.cos(Math.toRadians(h-m));
 		} else {
 			cos = Math.cos(Math.toRadians(m-h));
 		}
 		result = A*A + B*B - 2*A*B*cos;
 		result = Math.pow(result, 0.5);
 		//System.out.println(h);
 		//System.out.println(m);

 		System.out.println(result);
 	}
 }

Measured memory_bytes: 36028
N = int(input())
A = [int(input()) for _ in range(N)]
if 0 < A[0]:
    print(-1)
    exit()
ans = 0
for i in range(1, N):
    if 1 < A[i] - A[i - 1]:
        print(-1)
        exit()
    elif A[i] - A[i - 1] == 1:
        ans += 1
    elif A[i] == A[i - 1]:
        ans += A[i]
    else:
        ans += A[i]
print(ans)

Measured memory_bytes: 11048
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;
int main(){
    int N;
    string S;
    cin>>N>>S;
    int count=0;
    int ma=0;
    
    FOR(i,1,S.size()){
        string t=S.substr(0,i);
        string u=S.substr(i);
        set<char>s1;
        set<char>s2;
        set<char>s3;
        //cout<<t<<" "<<u<<endl;

        rep(j,t.size()){
            s1.insert(t[j]);
        }

        rep(j,u.size()){
            s2.insert(u[j]);
        }

        set_intersection(s1.begin(),s1.end(),s2.begin(),s2.end(),inserter(s3,s3.end()));
        //s1とs2の積集合をs3に入れる
        
        ma=max((int)s3.size(),ma);
    }
        cout<<ma<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-5;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int a,b,c;cin>>a>>b>>c;
    cout<<a*b/2<<endl;
}


Measured memory_bytes: 256
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  double n;
  cin >> n;
  cout << 6.28 * n << endl;
}


Measured memory_bytes: 3780
import numpy as np
N=int(input().strip())
a=list(map(int,input().strip().split()))

half=sum(a)/2
sum_=0
min_=np.inf
for i in a:
    sum_+=i
    dist=abs(sum_-half)
    if dist<min_:
        min_=dist
ans=int(min_//0.5)
print(ans)

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

int main(){
	long a,b,c,d,g;
  	cin >> a >> b >> c >> d >> g;
  	a*=4;b*=2;
	long t = min(min(a,b),c);
  	cout<< g/2*min(2*t, d)+t*(g%2)<<endl;
}

Measured memory_bytes: 256
import string
n,k = map(int, input().split())
digs = string.digits + string.ascii_letters


def int2base(x, base):
    if x < 0:
        sign = -1
    elif x == 0:
        return digs[0]
    else:
        sign = 1

    x *= sign
    digits = []

    while x:
        digits.append(digs[int(x % base)])
        x = int(x / base)

    if sign < 0:
        digits.append('-')

    digits.reverse()

    return ''.join(digits)
  
print(len(int2base(n,k)))

Measured memory_bytes: 3768