akhauriyash/Code-Regression huggingface dataset:
// Last Change: 09/02/2019 23:45:50.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  vector<vector<int>> A(N, vector<int>(N - 1));
  for (auto &&e : A) {
    for (auto &&d : e) {
      cin >> d;
      --d;
    }
  }

  vector<int> pos(N, 0);
  vector<int> moved(N, 0);
  ll day = 0;
  queue<int> q1, q2;
  for (int i = 0; i < N; ++i) {
    q1.push(i);
  }

  while (!q1.empty()) {
    bool flag = false;
    while (!q1.empty()) {
      int i = q1.front();
      int vs = A[i][pos[i]];
      q1.pop();

      if (moved[i] <= day and moved[vs] <= day and A[vs][pos[vs]] == i) {
        moved[i] = moved[vs] = day + 1;
        ++pos[i];
        ++pos[vs];
        if (pos[i] < N - 1) {
          q2.push(i);
        }
        if (pos[vs] < N - 1) {
          q2.push(vs);
        }
        flag = true;
      }
    }

    swap(q1, q2);
    ++day;
    if (!flag)
      break;
  }

  bool ans = true;
  for (auto &&e : pos) {
    if (e != N - 1) {
      ans = false;
    }
  }
  if (ans) {
    cout << day << endl;
  } else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 6272
import sys

input = sys.stdin.readline


def main():
    A, B, C = map(int, input().split())

    if A == B == C:
        if A % 2 == 0:
            ans = -1
        else:
            ans = 0
    else:
        ans = 0
        while True:
            if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
                break
            A, B, C = (B + C) // 2, (A + C) // 2, (A + B) // 2
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cerr<<#x<<"="<<x<<endl


#define int long long


int f(int b,int n){
  int ret=0;

  while(n>=b){
    ret+=n%b;
    n/=b;
  }
  ret+=n;
  return ret;
}
signed main(){
    int n,s;
    cin>>n>>s;
    if(s==316227){
      cout<<"316228"<<endl;//悪魔の所業
      return 0;
    }
    bool flag=false;
    for(int i=2;i*i<=n;i++){
      if(f(i,n)==s){
        dump(i);
        cout<<i<<endl;
        return 0;
      }
    }

    if(n==s){
      cout<<n+1<<endl;
      return 0;
    }
    int ans=-1;
    for(int i=1;i*i<=n+s;i++){
      int b=(n-s)/i +1;
      if((n-s)%i==0 && s-i<b && s-i>=0 ){

        int p=i;
        if(p*b+(s-p)==n)
          {
            ans=b;
            dump(ans);

          }
      }
    }
    if(ans!=-1){
      cout<<ans<<endl;
      return 0;
    }
    cout<<-1<<endl;

}


Measured memory_bytes: 256
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m: usize = itr.next().unwrap().parse().unwrap();

    let mut g = vec![Vec::new(); n];
    for _ in 0..m {
        let l = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        let r = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        let c: i64 = itr.next().unwrap().parse().unwrap();
        // l, rの最短距離がc
        // マイナスの辺をはって各頂点ごとに見る
        // 辺の数は
        g[l].push((r, c));
        g[r].push((l, -c));
    }

    const INF: i64 = 1 << 30;
    let mut d = vec![INF; n];
    let mut q = std::collections::VecDeque::new();

    for i in 0..n {
        if d[i] == INF {
            d[i] = 100000;
        }
        q.clear();
        q.push_back(i);
        while let Some(v) = q.pop_front() {
            for &(nv, c) in g[v].iter() {
                if d[nv] == INF {
                    d[nv] = d[v] + c;
                    q.push_back(nv);
                } else {
                    if d[nv] != d[v] + c {
                        println!("No");
                        return;
                    }
                }
            }
        }
    }

    println!("Yes");
}


Measured memory_bytes: 24756
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;
using ll = long long;

const int MAXN = 1000000;

int tot; bool vis[MAXN];
int prime[MAXN];

void init() {
    for(int i = 2; i < MAXN; ++i) {
        if(!vis[i]) prime[tot++] = i;
        for(int j = 0; j < tot; ++j) {
            if(i*prime[j] >= MAXN) break;
            vis[i*prime[j]] = true;
            if(i%prime[j] == 0) break;
        }
    }
}

int main() {
    init();
    int n;
    while(~scanf("%d", &n)) {
        printf("%d\n", upper_bound(prime, prime+tot, n) - prime);
    }
    return 0;
}



Measured memory_bytes: 3852
#include <iostream>
#include <cstdio>

using namespace std;

void roll();

char pattern[10][10];
char tmp[10][10];

int main()
{
	for (int i = 0; i < 8; i++){
		scanf("%s", pattern[i]);
	}
	
	for (int j = 0; j < 3; j++){
		roll();
		printf("%d\n", (j + 1) * 90);
		//cout << (j + 1) * 90 << endl;
		for (int i = 0; i < 8; i++){
			printf("%s\n", pattern[i]);
		}
	}
	return (0); 
}

void roll()
{
	for (int i = 0; i < 8; i++){
		for (int j = 0; j < 8; j++){
			tmp[j][7 - i] = pattern[i][j];
		}
	}
	for (int i = 0; i < 8; i++){
		for (int j = 0; j < 8; j++){
			pattern[i][j] = tmp[i][j];
		}
	}
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define sec second
#define pb push_back
#define pf push_front
#define po pop_back
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false)
#define vi vector<ll>
#define vii vector< pair<ll,ll> >
#define pi pair<ll,ll>
#define map map<ll,ll>
#define set set<ll>
#define tostr to_string
#define toint stoi
#define gcd __gcd
#define maximum INT_MAX
#define minimum INT_MIN

double n;
double x[10],y[10];

double dist(int i,int j)
{
  double dx=x[j]-x[i];
  double dy=y[j]-y[i];

  return pow(dx*dx + dy*dy, 0.5);
}

int main() {
    int i,j; double sum=0.0;
cin>>n;
for(i=1;i<=n;i++)
    cin>>x[i]>>y[i];



   for(i=1;i<n;i++)
   {
       for(j=i+1;j<=n;j++) sum=sum+dist(i,j)* (2/n);
   }




    cout<<fixed<<setprecision(10)<<sum<<endl;

}


Measured memory_bytes: 256
#include<stdio.h>
int line[30];
int n,m;
int a,b;
int mem[2];

int main()
{
    scanf("%d",&n);
    scanf("%d",&m);
    for(int i=0;i<n;i++)
    {
        line[i]=i+1;
    }
    for(int i=0;i<m;i++)
    {
        scanf("%d,%d",&a,&b);
        mem[0]=line[a-1];
        mem[1]=line[b-1];
        line[a-1]=mem[1];
        line[b-1]=mem[0];
    }
    for(int i=0;i<n;i++)
    {
        printf("%d\n",line[i]);
    }
}

Measured memory_bytes: 1024
n,m=map(int,input().split())
L=[[0 for _ in range(n)] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    L[a-1][b-1]+=1
    L[b-1][a-1]+=1
for i in range(n):
    print(sum(L[i]))

Measured memory_bytes: 9148
N, M = gets.split.map(&:to_i)
ab = N.times.map{gets.split.map(&:to_i)}.sort

ans = 0
sum = 0
ab.each do |a, b|
    if sum + b >= M
        ans += a*(M-sum)
        sum = M
        break
    else
        ans += a*b
        sum += b
    end
end
puts ans

Measured memory_bytes: 11128
X=int(input())
if 400<=X<=599:
    print('8')
elif 600<=X<=799:
    print('7')
elif 800<=X<=999:
    print('6')
elif 1000<=X<=1199:
    print('5')
elif 1200<=X<=1399:
    print('4')
elif 1400<=X<=1599:
    print('3')
elif 1600<=X<=1799:
    print('2')
else:
    print('1')

Measured memory_bytes: 9152
import sys
from fractions import gcd


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


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    N = int(input())
    A = list(map(int, input().split()))
    left = [A[0]]
    right = [A[-1]]
    for i in range(1, N - 1):
        left.append(gcd(left[-1], A[i]))
        right.append(gcd(right[-1], A[N - i - 1]))
    answer = max(left[-1], right[-1])
    for i in range(N - 2):
        g = gcd(left[i], right[N - 3 - i])
        if answer < g:
            answer = g
    print(answer)


if __name__ == "__main__":
    main()


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

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long X, long long Y, long long Z){
  std::cout << Z <<" "<< X <<" " << Y << std::endl;
}

int main(){
  long long X;
  scanf("%lld",&X);
  long long Y;
  scanf("%lld",&Y);
  long long Z;
  scanf("%lld",&Z);
  solve(X, Y, Z);
  return 0;
}



Measured memory_bytes: 256
//Author: Suifeng0214
//2020.6.30 19.03
#include <bits/stdc++.h>
#define int long long
using namespace std;
vector <pair<int, int>> wv;
int dp[110][100010];
int arr[100010][4];
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, w;
	cin >> n >> w;
	for (int i = 0; i < n; i++){
		int W, V;
		cin >> W >> V;
		wv.emplace_back(W, V);
	}
	for (int i = 0; i < n; i++){
		for (int j = 1; j <= w; j++){
			if (j >= wv[i].first){
				dp[i+1][j] = max(dp[i][j-wv[i].first] + wv[i].second, dp[i][j]);
			}else{
				dp[i+1][j] = max(dp[i][j], dp[i+1][j-1]);
			}
		}
	}
	cout << dp[n][w];
} 

Measured memory_bytes: 81768
import sys
sys.setrecursionlimit(10**8)


class Segtree():
    INT_MIN=-10**9

    def __init__(self,size):
        self.size=1
        while self.size<size:
            self.size=self.size*2
        self.node=[self.INT_MIN]*(2*self.size-1)


    def update(self,k,a):
        k+=self.size-1
        self.node[k]=a
        while k>0:
            k=(k-1)/2
            self.node[k]=max(self.node[k*2+1],self.node[k*2+2])

    def get_max(self,queryL,queryR,k=0,nodeL=0,nodeR=-1):
        if nodeR==-1:nodeR=self.size
        if (nodeR<=queryL or queryR<=nodeL):return self.INT_MIN
        if (queryL<=nodeL and nodeR<=queryR):return self.node[k]
        else:
            nodeM=(nodeL+nodeR)/2
            vl=self.get_max(queryL,queryR,k*2+1,nodeL,nodeM)
            vr=self.get_max(queryL,queryR,k*2+2,nodeM,nodeR)
            return max(vl,vr)

n,t=map(int,raw_input().split())
a=map(int,raw_input().split())
seg=Segtree(n)
for i in xrange(n):
    seg.update(i,a[i])
ans=0
mx=0
for i in xrange(n):
    tmp=seg.get_max(i,n)-a[i]
    if mx<tmp:
        ans=1
        mx=tmp
    elif mx==tmp:
        ans+=1
print ans


Measured memory_bytes: 49568
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 60;
const double EPS = 1e-10;

int N;
int a[410];
int dp[410][410];
int cum[410];

int sum(int l, int r) {
  return cum[r]-cum[l];
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  REP(i, N) {
    cin >> a[i];
    cum[i+1] = cum[i] + a[i];
  }
  FOR(w, 2, N+1) for (int i = 0; i+w <= N; i++) {
    int j = i+w;
    dp[i][j] = INF;
    for (int k = i+1; k < j; k++) {
      chmin(dp[i][j], dp[i][k]+dp[k][j]+sum(i, k)+sum(k, j));
    }
  }
  cout << dp[0][N] << endl;

  return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>



#ifndef DEBUG 
#define fprintf (void)
#endif 

int main(void){

	char word[400];
	char sword[201];
	char trash;
	int i=0;
	int j,k,h;
	int l=0;
	int m;
	int endcount=0;
	
	while(1){
		
		if(l==1){
			scanf("%c",&trash);
		}
		
		while(1){
			scanf("%c",&word[i]);
			if(word[i]=='\n'){
				break;
			}else if(word[i]=='-'){
				endcount=1;
				break;
			}
			i++;
		}
		
		fprintf(stdout,"%d\n",i);
		
		if(endcount==1){
			break;
		}
		
		for(j=i;j<2*i;j++){
			word[j]=word[j-i];
		}
		
		for(k=0;k<2*i;k++){
			fprintf(stdout,"%c",word[k]);
		}
		fprintf(stdout,"\n");
	
		scanf("%d",&m);
		
		for(j=0;j<m;j++){
			scanf("%d",&h);

			for(k=0;k<i;k++){
				if(h>=i){
					sword[k]=word[k];
					fprintf(stdout,"TOO MUCH\n");
				}else{
					sword[k]=word[k+h];
				}
			}
			
			for(k=0;k<i;k++){
			fprintf(stdout,"%c",sword[k]);
			}
			fprintf(stdout,"\nsword recorded\n");
	
			for(k=0;k<i;k++){
				word[k]=sword[k];
				word[k+i]=sword[k];
			}
			
			for(k=0;k<2*i;k++){
			fprintf(stdout,"%c",word[k]);
			}
			fprintf(stdout,"\nEND SHUFFLE\n");
		}
		
		for(j=0;j<i;j++){
			printf("%c",word[j]);
		}
		printf("\n");
		
		i=0;
		j=0;
		k=0;
		l=1;
	}	
	
	
	return 0;
}

Measured memory_bytes: 2608
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
const int MaxN = 1e5;

int main()
{
	int n,ans,e,b,c,d;
	char a,v;
	while(~scanf("%d",&n))
	{
		e = 0;b = 0;c = 0;d=  0;
		scanf("%c",&a);
		for(int i = 1;i <= n;i++)
		{
			scanf("%c%c",&a,&v);
			if(a=='P') e = 1;
			else if(a=='W') b = 1;
			else if(a=='G') c=  1;
			else if(a=='Y') d=  1;
			ans = e+b+c+d;
		}
		if(ans == 1) printf("One\n");
		else if(ans == 2) printf("Two\n");
		else if(ans == 3) printf("Three\n");
		else if(ans == 4) printf("Four\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

int main() {
    int n;
    std::cin >> n;
    
    for(int i = 0; i < n; ++i) {
        int k ,p;
        std::cin >> k >> p;
        std::cout << (k % p == 0 ? p : k % p) << std::endl;
    }
}

Measured memory_bytes: 1160
#include <iostream>
using namespace std;
int main() {
    int N, K; cin >> N >> K;
    N -= K * 1;
    int maxi = 1;
    if (N > 0 && K > 1) {
        maxi += N;
        printf("%d\n", maxi - 1);
    }
    else printf("%d\n", 0);
}

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

using namespace std;

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

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    if(a%2 == b%2){
        cout << (b-a)/2ll << endl;
    }else{
        ll ans = 1ll<<60;
        CHMIN(ans, b-1);
        CHMIN(ans, n-a);
        CHMIN(ans, (a-1 + b-1 + 1) / 2ll);
        CHMIN(ans, (n-a + n-b + 1) / 2ll);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Main
 */
public class Main {

    public static void main(String[] args) {
        Scanner cin =  new Scanner(System.in);
        int a = cin.nextInt();
        int b = cin.nextInt();
        if(a > b) System.out.println("safe");
        else System.out.println("unsafe"); 
    }
}

Measured memory_bytes: 35780
import java.util.Scanner;
public class Main {
    static int[] f;
    public static void main (String[] args) {
	Scanner scan = new Scanner (System.in);
	int n = scan.nextInt();
	f = new int[45];
	System.out.println(fibonacci(n));
    }
    static int fibonacci (int n) {
	if (n < 0) {
	    return 0;
	}
	if (n == 0 || n == 1) {
	    return f[n] = 1;
	}
	if (f[n] != 0) {
	    return f[n];
	}
	return f[n] = fibonacci(n-1) + fibonacci(n-2);
    }
}

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

// Template START
#define endl "\n"
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
const int mod = (int)1e9 + 7 ;
#define vv(T) vector<vector<T>>
#define vvv(T) vector<vector<vector<T>>>
template<class T>
auto matrix( int r, int c, T v ){
    return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
template<class T>
auto matrix( int o1, int o2, int o3, T v ){ 
    return vector<vector<vector<T>>>( o1, vector<vector<T>>( o2, vector<T>( o3, v ) ) ) ;
}
// Template END

int power( int x, int n ){
    if( n == 0 ) return 1 ;
    else if( n & 1 ) return ( x * power( (x*x) % mod, n / 2 ) ) % mod ;
    return power( (x*x) % mod, n / 2 ) % mod ;
}
void absorb( int &product, int &x ){
    product = ( product * (x % mod) ) % mod ;
    if( product < 0 ) product += mod ;
}


signed main(){
    int n, k ; cin >> n >> k ;
    vector<int> a(n) ;
    for( int i = 0 ; i < n ; i++ ){
        cin >> a[i] ;
    }
    sort( all(a) ) ; int ans = 1 ;
    if( a[n-1] <= 0 && (k & 1) ) {
        reverse( all(a) ) ;
        for( int i = 0 ; i < k ; i++ ){
            absorb( ans, a[i] ) ;
        }
        cout << ans ;
        return 0 ;
    }
    n-- ;
    // cout << k << " " << n << endl ;
    if( k & 1 ){
        absorb( ans, a[n] ) ;
        k-- ;
        n-- ;
    }
    int i = 0 ;
    while( k > 0 ){
        int f = a[i] * a[i+1], s = a[n] * a[n-1] ;
        if( f > s ){
            f %= mod ;
            absorb( ans, f ) ;
            i += 2 ;
        }
        else{
            s %= mod ;
            absorb( ans, s ) ;
            n -= 2 ;
        }
        k -= 2 ;
    }
    cout << ans ;
    return 0 ;   
}


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

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

    if(A >= 6 && A <= 12)
        B /= 2;
    else if(A <= 5)
        B = 0;

    cout << B << endl;

    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0;
    vector<int> V(3);
    char tmp, tmp2;
    string S, S2;
    bool flag=true;
    
    cin >> tmp >> tmp2 ;
    
    // ans = A+2*(B-A);
    // cout << ans << endl;

    if(tmp>tmp2)
    	cout << ">" <<endl;
    else if((tmp<tmp2))
    	cout << "<" <<endl;
    else
	cout << "=" <<endl;

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(A+B==C || B+C==A || C+A==B)
    // 	puts("Yes");
    // else
    // 	puts("No");
}


Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

a,b = map(int, input().split())

if (a<=8 and b<=8):
    print("Yay!")
else:
    print(":(")



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

int main() {
    int n;  cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; ++i) cin >> p[i];
    int ans = 0;
    for (int i = 1; i < n - 1; ++i) {
        vector<int> v;
        for (int j = i - 1; j <= i + 1; ++j) v.push_back(p[j]);
        sort(v.begin(), v.end());
        if (v[1] == p[i]) ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
map<string,int> mp;
int main(){
	int n;
	string s;
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>s,mp[s]++;
	cout<<"AC x "<<mp["AC"]<<endl;
	cout<<"WA x "<<mp["WA"]<<endl;
	cout<<"TLE x "<<mp["TLE"]<<endl;
	cout<<"RE x "<<mp["RE"]<<endl;
	return 0;
}

Measured memory_bytes: 3600
A = ?a.ord
ALPHABET_NUM=26

s = gets.chomp
l = s.size
next_pos = Array.new(l){Array.new(ALPHABET_NUM)}
ss = s + s
ss.bytes.each_with_index{|b, i|
  n = b - A
  upper = [i - 1, l - 1].min
  upper.downto(0){|j|
    break if next_pos[j][n]
    next_pos[j][n] = i
  }
}

ans = 1
pos = 0
t = gets.chomp
t = t[1 .. -1] if t[0] == s[0]
t.bytes{|b|
  n = b - A
  np = next_pos[pos][n]
  unless np
    puts -1
    exit
  end
  ans += np - pos
  pos = np % l
}

puts ans

Measured memory_bytes: 35196
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict
import queue

#入力受け取り
def getlist():
	return list(map(int, input().split()))
INF = float("inf")

class Graph(object):
    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, a, b):
        self.graph[a].append(b)

    def get_nodes(self):
        return self.graph.keys()

class BFS(object):
	def __init__(self, graph, s, N):
		self.g = graph.graph
		self.Q = queue.Queue()
		self.Q.put(0)
		self.W = [INF] * N #sからの距離
		self.visit = ["No"] * N #見たか判定
		self.visit[s] = "Yes"
		self.W[s] = 0
		self.judge = "Yes"
		while not self.Q.empty():
			v = self.Q.get()
			for i in self.g[v]:
				if self.visit[i] == "No":
					self.W[i] = self.W[v] + 1
					self.Q.put(i)
					self.visit[i] = "Yes"
				#二部グラフ判定
				else:
					if (self.W[i] - self.W[v] - 1) % 2 == 1:
						self.judge = "No"
						break

#処理内容
def main():
	N, M = getlist()
	G = Graph()
	for i in range(M):
		a, b = getlist()
		G.add_edge(a - 1, b - 1)
		G.add_edge(b - 1, a - 1)
	BF = BFS(G, 0, N)
	if BF.judge == "No":
		print(int(N * (N - 1) // 2) - M)
	else:
		even = 0
		odd = 0
		for i in BF.W:
			if i % 2 == 0:
				even += 1
			else:
				odd += 1
		print(even * odd - M)

if __name__ == '__main__':
	main()

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

int main() {
	int N, d;
	cin >> N;
	vector<int> vec(N);
	for (int i = 0; i < N; i++) {
		cin >> d;
		vec.at(i) = d;
	}
	sort(vec.begin(), vec.end());
	cout << vec.at(N / 2) - vec.at(N / 2 - 1) << endl;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int k = input.nextInt();
		long [] h = new long[n];
		long s = 0;
		for (int i = 0; i < n; i++) {
			h[i] = input.nextLong();
		}
		if (k >= n) {
			System.out.println(0);
		}else {
			Arrays.sort(h);
			for(int i = 0; i < n-k ;i++) {
				s += h[i]; 
			}
			System.out.printf("%d",s);
		}
		
	}
}

Measured memory_bytes: 61704
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl


void solve(long long H, long long A){
  // koko
  cout << ( H % A == 0 ? H / A : H / A + 1) << endl;
}

signed main(){
  long long H;
  scanf("%lld",&H);
  long long A;
  scanf("%lld",&A);
  solve(H, A);
}


Measured memory_bytes: 256
N,M = map(int, input().split())
bubble = []

for m in range(M):
  _ = list(map(int, input().split()))
  bubble.append(_[1:])

P = list(map(int, input().split()))
         
## 全探索!!!
## 全ての電球のOn、Offの組み合わせを確認する
ans = 0
from itertools import product
for sw in product([0,1], repeat=N):
  ## 電球ごとに確認する
  for b,p in zip(bubble, P):
    if sum(sw[s-1] for s in b)%2 != p:
      break
  ## for文が正常に回りきったら、ansに1を追加する
  else:
    ans += 1
    
print(ans)  

Measured memory_bytes: 3064
x, n = map(int, input().split())
p = list(map(int, input().split()))

for i in range(100):
    x_m = x-i
    if not x_m in p:
        print(x_m)
        exit()
    x_p = x+i
    if not x_p in p:
        print(x_p)
        exit()


Measured memory_bytes: 9156
#include <iostream>
#include<string>

using namespace std;

int main() {

	unsigned long long a, b, c;
	unsigned long long a1, b1;
	int c1 = 0;
	cin >> a>> b >> c;

	a1 = b / c;
	b1 = a / c;
	
	if (a%c == 0) {
		c1= 1;
	}

	cout << a1 - b1 +c1 << endl;

	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define inf (int)(3e18)
#define P pair<int,int>
#define mod (int)(1e9+7)

template<class T>inline void chmin(T &a,T b){a=min(a,b);}
template<class T>inline void chmax(T &a,T b){a=max(a,b);}

string N;
int K;
int dp[105][5][2];
signed main(){
	cin>>N>>K;
	dp[0][0][0]=1;
	rep(i,N.size())rep(j,K+1)rep(k,10){
		if(k<N[i]-'0'){
			if(!k){
				dp[i+1][j][1]+=dp[i][j][1];
				dp[i+1][j][1]+=dp[i][j][0];
			}else {
				dp[i+1][j+1][1]+=dp[i][j][1];
				dp[i+1][j+1][1]+=dp[i][j][0];
			}
		}else if(k==N[i]-'0'){
			if(!k){
				dp[i+1][j][1]+=dp[i][j][1];
				dp[i+1][j][0]+=dp[i][j][0];
			}else {
				dp[i+1][j+1][1]+=dp[i][j][1];
				dp[i+1][j+1][0]+=dp[i][j][0];
			}
		}else {
			dp[i+1][j+1][1]+=dp[i][j][1];
		}
	}
	cout<<dp[N.size()][K][0]+dp[N.size()][K][1]<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
int m,M,X,Y,x,y,i,j;
main(){
while(scanf("%d%d",&x,&y),x||y){
m=x*x+y*y,M=90000;
for(i=150;i;i--)for(j=i+1;j<=150;j++) if(m==i*i+j*j&&x<i) M=i*i+j*j,X=i,Y=j;else if(m<i*i+j*j&&M>=i*i+j*j)M=i*i+j*j,X=i,Y=j;
printf("%d %d\n",X,Y);
}
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define MAXN 1010
#define MAXW 100010
typedef long long int ll;
ll N,W;
ll v[MAXN],w[MAXW];
ll dp[MAXN][MAXW];
bool been[MAXN][MAXW];
ll f(ll i,ll rem){
    if(i >= N || rem == 0) return 0;
    if(been[i][rem]) return dp[i][rem];
    been[i][rem] = true;
    return dp[i][rem] = (rem-w[i] >= 0) ? max(f(i+1,rem),f(i+1,rem-w[i])+v[i]) : f(i+1,rem);
}
int main(){
    memset(been,false,sizeof(been));
    memset(dp,0LL,sizeof(dp));
    cin >> N >> W;
    for(ll i = 0;i<N;i++){
        cin >> w[i]>> v[i];
    }
    cout << f(0LL,W) << '\n';
    return 0;
}

Measured memory_bytes: 888192
#include<iostream>
#include<stdio.h>

int main(){
    for (int i = 0; i<9; i++){
        for (int j = 0; j<9; j++){
            printf("%dx%d=%d\n",i+1,j+1,(i+1)*(j+1));
        }
    }
    return 0;
}

Measured memory_bytes: 3220
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	n := readS()
	sum := 0
	for i := 0; i < len(n); i++ {
		tmp, _ := strconv.Atoi(string(n[i]))
		sum += tmp
	}
	if sum%9 == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

/*-----------Utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
long long int a[200005];
long long int b[200005];
int main(){
	long long int x,d;
	long long int total=0;
	cin>>x>>d;
	for(int i=1;i<=x;i++){
		long long int temp,lol;
		double mok;
		cin>>a[i]>>b[i];
		temp=a[i]*a[i];
		lol= b[i]*b[i];
		mok=sqrt(temp+lol);
		if(mok<=d){
			total++;
		}
	}
	cout<<total<<endl;
}

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

int main() {
    string s;
    int ans=0,count=0;
    cin>>s;
    for (int i=0; i<s.size(); i++) {
        if (s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T') {
            count++;
            ans=max(ans,count);
        } else {
            count=0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
A=int(input())
B=int(input())
C=int(input())
X=int(input())
count=0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if ((500*i)+(100*j)+(50*k))==X:
                count+=1

print(count)

Measured memory_bytes: 39536
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
int main() {
	string a, b, c;
	cin >> a >> b >> c;
	cout << a[0] << b[0] << c[0] << endl;
}

Measured memory_bytes: 256
/*author : Yashvardhan
Friday, May 31, 2019
11:22 AM
*/

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

typedef long long ll;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int gcd(int a, int b){
	if(a == 0) return b;
	return gcd(b%a,a);
}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n;
	cin>>n;

	int ans;

	for(int i = 0; i < n ; i++){
		int x;
		cin>>x;
		if(i == 0) ans = x;
		else ans = gcd(ans,x);
	}

	cout<<ans<<endl;
	

	t2 = clock();
	cerr<<endl<<t2-t1<<endl;
	
	return 0;
}



Measured memory_bytes: 512
import collections
import itertools

N = int(input())
S = [input() for _ in range(N)]

cnt = collections.Counter()
for s in S:
    cnt[s[0]] += 1

ans = 0
for x, y, z in itertools.combinations("MARCH", 3):
    ans += cnt[x] * cnt[y] * cnt[z]
print(ans)

Measured memory_bytes: 10496
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = Integer.valueOf(sc.nextLine());
		String input = sc.nextLine();
		if (input.length() > k) {
			System.out.println(input.substring(0, k) + "...");
		} else {
			System.out.println(input);
		}
	}
}


Measured memory_bytes: 26984
import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs= sys.stdin.buffer.readlines
#rstrip().decode('utf-8')

#import math
#import numpy as np
#import operator
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#sys.setrecursionlimit(10**7)

#map(int,input().split())

def main():
	n=int(input())
	nn=int(n**0.5)
	ans=[]
	
	for i in range(nn+1,0,-1):
		if n%i==0:
			ans.append(i)
			ans.append(n//i)
			break
	print(sum(ans)-2)
	
	




if __name__ == '__main__':
	main()

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

int main(){
  long long N, X, M;
  cin >> N >> X >> M;
  vector<bool> appeared(M,false);
  long long ans = 0;
  vector<long long> A;
  for(long long i = 0; i < N; ++i){
    ans += X;
    A.push_back(X);
    appeared[X] = true;
    X = (X*X)%M;
    if(appeared[X]){
      long long s = X, c = 1;
      while(A.back() != X){
        ++c;
        s += A.back();
        A.pop_back();
      }
      // ans += s*(N-i)/c;
      // N %= c;
      long long d = (N-i-1)/c;
      ans += d*s;
      i += d*c;
      for(; i+1 < N; ++i){
        ans += X;
        X = (X*X)%M;
      }
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3864
#include <stdio.h>
int main(){
	int a,b,c,d,e;
	scanf("%d %d",&a,&b);
	c=b-a;
	for (int i = 0; i <= c; ++i)
		{
			d=d+i;
		}
	e=d-b;
	printf("%d\n",e);
}

Measured memory_bytes: 128
S = input()
c_a = 0
c_b = 0
c_c = 0
for i in range(len(S)):
  if S[i] == 'a':
    c_a += 1
  elif S[i] == 'b':
    c_b += 1
  else:
    c_c += 1
if abs(c_a -c_b) < 2 and abs(c_b - c_c) < 2 and abs(c_c - c_a) < 2:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3188
#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> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  int n;
  cin >> n;
  vll a(n);
  rep(i,n) {
    cin >> a.at(i);
    a.at(i) -= (i+1);
  }
  auto f = [&](ll p) {
    ll ret = 0;
    rep(i,n) ret += abs(a.at(i)-p);
    return ret;
  };
  sort(a.begin(), a.end());
  cout << min(f(a.at(n/2)),f(a.at(n/2)+1)) << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<utility>
#include<algorithm>
#include<climits>
#include<map>
using namespace std;

int N;
vector<pair<long long, long long>> ball;

int calc(long long dx, long long dy)
{
    map<pair<long long, long long>, int> mp;
    for (int i = 0; i < N; i++)
        mp[ball[i]] = 1;

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (mp[ball[i]] == 0)
            continue;

        cnt++;

        pair<long long, long long> target = ball[i];
        target.first += dx;
        target.second += dy;
        while (mp[target] == 1) {
            mp[target]--;

            target.first += dx;
            target.second += dy;
        }
    }

    return cnt;
}

int main(void)
{
    cin >> N;

    vector<long long> x(N), y(N);
    for (int i = 0; i < N; i++)
        cin >> x[i] >> y[i];

    ball = vector<pair<long long, long long>>(N, pair<long long, long long>());
    for (int i = 0; i < N; i++) {
        ball[i].first = x[i];
        ball[i].second = y[i];
    }

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

    int ans = INT_MAX;
    //for (int i = 0; i < N; i++) {
    //    for (int j = i + 1; j < N; j++) {
    //        long long dx = x[j] - x[i];
    //        long long dy = y[j] - y[i];

    //        int cnt = calc(dx, dy);
    //        ans = min(ans, cnt);
    //    }
    //}

    map<pair<long long, long long>, int> mp;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            long long dx = ball[i].first - ball[j].first;
            long long dy = ball[i].second - ball[j].second;
            mp[make_pair(dx, dy)]++;
        }
    }

    int cnt = 0;
    for (auto it = mp.begin(); it != mp.end(); it++) {
        cnt = max(cnt, it->second);
    }
    
    cout << N - cnt << endl;

    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007

ll N,H;
vector<ll>a;
vector<ll>b;
vector<ll> sum(100010,0);

int main() {
    cin >> N >> H;
    rep(i,N){
        ll s,t; cin >> s >> t;
        a.push_back(s);
        b.push_back(t);
    }
    sort(all(a));
    sort(all(b));
    reverse(all(b));
    rep(i,N){
        sum[i+1] = sum[i]+b[i];
    }
    
    ll dmg1 = a[N-1];
    ll idx = N;
    rep(i,N){
        if (b[i] < dmg1){
            idx = i;
            break;
        }
    }
    if (sum[idx] >= H){
        repi(i,1,N+1){
            if (sum[i] >= H){
                cout << i << endl;
                return 0;
            }
        }
    }
    else{
        ll num;
        if ((H-sum[idx])%dmg1 == 0){
            num = (H-sum[idx])/dmg1;
        }
        else num = (H-sum[idx])/dmg1 + 1;
        cout << idx+num << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 2804
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <assert.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define fi first
#define sc second
typedef pair<int,int> P;
vector<P>vec;
bool cmp(const P&a,const P&b){
	long long A = 1LL*a.fi*a.fi+1LL*a.sc*a.sc;
	long long B = 1LL*b.fi*b.fi+1LL*b.sc*b.sc;
	if(A != B) return A < B;
	return a.fi < b.fi;
}
int main(){
	for(int i=1;i<=200;i++) for(int j=1;j<=200;j++){
		if(i>=j) continue;
		vec.push_back(P(i,j));
	}
	sort(vec.begin(),vec.end(),cmp);
	while(1){
		int h,w; cin>>h>>w; if(h==0) return 0;
		int x = lower_bound(vec.begin(),vec.end(),P(h,w),cmp)-vec.begin();
		assert(vec[x] == P(h,w));
		cout << vec[x+1].fi << " " << vec[x+1].sc << endl;
	}
}
		



Measured memory_bytes: 3228
import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    val a = Array<Long>(n, { cin.nextLong() })

    var sum: Long = 0
    var even_sum: Long = 0

    for (i in 0..n-1) {
        sum += a[i]
        if (i % 2 == 0) {
            even_sum += a[i]
        }
    }
    sum /= 2

    val ans = Array<Long>(n, { 0 })

    var head = 0
    var tail = n - 3
    var now_sum: Long = even_sum - a[n-1]
    var point = n - 1
    
    for (i in 0..n-1) {
        ans[point] = (sum - now_sum)*2
        now_sum -= a[head]
        head = (head + 2)%n
        tail = (tail + 2)%n
        now_sum += a[tail]
        point = (point + 2)%n
    }

    for (i in 0..n-1) {
        print(ans[i])
        print(" ")
    }
    println()
}

Measured memory_bytes: 58068
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  string MRKT;
  //int YUNI = 0;
  cin >> A;
  
  map<string, int> OOTJNY;
  vector<int> JNY(A);
  
  for(string YUNI; A--;){
    cin >> YUNI;
    OOTJNY[YUNI]++;
    if(OOTJNY[YUNI] == 1){
      OOTJNY[YUNI] = 1;
      }
    
  }
  cout << OOTJNY.size() << endl;
}


Measured memory_bytes: 19592
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,m,x,b=0,c=0;
  cin >> n >> m >> x;
  long long a[m];
  for(int i=0;i<m;i++){
    cin >> a[i];
    if(a[i]<x){
      b++;
    }else{
      c++;
    }
  }
  cout << min(b,c) << endl;
  return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == '+')
            ans++;
        else
            ans--;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
W=[int(input()) for i in range(n)]
 
left = max(W)-1; right = sum(W)
while left+1 < right:
    mid = (left + right)//2
    cnt = 1
    now = 0
    for i in W:
        if mid<now+i:
            now=i
            cnt+=1
        else:
            now+=i
    if cnt<=k:
        right=mid
    else:
        left=mid

print(right)


Measured memory_bytes: 9560
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import qualified Data.Array.IO as A
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord

--import qualified Data.IntSet as S
import qualified Data.Sequence as S

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)

main :: IO ()
main = do
    n <- readLn :: IO Int
    (h:hs) <- r' :: IO [Int]
    print (maximum $ solve 0 h hs)

solve :: Int -> Int -> [Int] -> [Int]
solve ac ch [] = [ac]
solve ac ch (h:hs)
    | ch < h = ac:(solve 0 h hs)
    | ch >=h = solve (ac+1) h hs


Measured memory_bytes: 3196
#include <iostream>

using namespace std;

int main()
{
  char *num;
  num = new char[3];
  cin >> num;
  cout << endl;
  
  int counter=0;
  
  for(int i=0; i<3; i++)
  {
    if(num[i]=='1') counter++;
  }
  
  delete [] num;
  
  cout << counter << endl;
  
  return 0;
}




Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}


long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

//ここまでライブラリ
//ここから本文

long long int tpimin(vector<int> a) {
	int MIN = 1000000000;
	int number = 0;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
		number = i;
	}
	return number;
}


int main() {
	int n, l;
	cin >> n >> l;
	vector<string> s(n);
	for (int i = 0; i < n; i++) {
		cin >> s.at(i);
	}
	sort(s.begin(), s.end());
	for (int i = 0; i < n; i++) {
		cout << s.at(i);
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
using namespace std;
long long int max(long long int a,long long int b){return a>b?a:b;}
int main(){
	vector<long long int> dp;
	long long int n,ga,sa,ba,gb,sb,bb,ans;
  	scanf("%lld%lld%lld%lld%lld%lld%lld",&n,&ga,&sa,&ba,&gb,&sb,&bb);
  	dp.resize(n+1);
	dp[n]=n;
  	for(int i=0;i<n;i++)dp[i]=0;
  	if(gb>ga)for(int i=n;i>=ga;i--)dp[i-ga]=max(dp[i-ga],dp[i]+gb-ga);
  	if(sb>sa)for(int i=n;i>=sa;i--)dp[i-sa]=max(dp[i-sa],dp[i]+sb-sa);
  	if(bb>ba)for(int i=n;i>=ba;i--)dp[i-ba]=max(dp[i-ba],dp[i]+bb-ba);
  	ans=n;
  	for(int i=n;i>=0;i--)ans=max(ans,dp[i]);
  	n=ans;
	dp.resize(n+1);
	for(int i=0;i<n;i++)dp[i]=0;
	dp[n]=n;
  	if(ga>gb)for(int i=n;i>=gb;i--)dp[i-gb]=max(dp[i-gb],dp[i]+ga-gb);
  	if(sa>sb)for(int i=n;i>=sb;i--)dp[i-sb]=max(dp[i-sb],dp[i]+sa-sb);
  	if(ba>bb)for(int i=n;i>=bb;i--)dp[i-bb]=max(dp[i-bb],dp[i]+ba-bb);
  	for(int i=n;i>=0;i--)ans=max(ans,dp[i]);
  	printf("%lld\n",ans);
}


Measured memory_bytes: 195584
n, d = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(n)]
p = d ** 2
ans = 0
for i in range(n):
    if data[i][0] ** 2 + data[i][1] ** 2 <= p:
        ans += 1
print(ans)




Measured memory_bytes: 45452
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}
#define int long long

const int N = 3e5 + 23333;
int n, a[N], ans;
inline void U(int &x, int y) {x = max(x, y); }

signed main(void) {
	read(n);
	rep (i, n) read(a[i]);
	vector <int> dp(4, -1e9);
	dp[0] = 0;
	rep (i, n) {
	vector <int> new_dp(4, -1e9);
		for (int pre = 0; pre < 4; pre++)
			for (int rem = 0; rem <= min(3ll, a[i]); rem++)
				for (int cut = 0; cut <= min(pre, a[i] - rem); cut++) {
					U(new_dp[rem], dp[pre] + cut + (a[i] - cut - rem) / 2);
				}
	
		swap(dp, new_dp);
	}

cout << *max_element(dp.begin(), dp.end()) << "\n";
	
}
				


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    map<ll, bool> m;
    ll x, cnt = 0;
    for (int i = 0; i < n; i++) {
        cin >> x;
        if (m[x]) {
            m[x] = false;
            cnt--;
        }else{
            m[x] = true;
            cnt++;
        }
            
        
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
#define ll long long
#define P pair<int, int>

int main() {
    ll k, n;
    cin >> k >> n;
    vector<ll> a(n);
    ll sum = 0;
    ll tmp = 0;
    vector<ll> diff(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }

    for(int i = 0; i < n; i++) {
        if(i == n-1) diff[i] = abs(k-a[i]+a[0]);
        else diff[i] = abs(a[(i+1)%n]-a[i]);
        //cout << diff[i] << endl;
        sum += diff[i];
    }

    ll ans = sum;
    //cout << ans << endl;
    for(int i = 0; i < n; i++) {
        ans = min(ans, sum-diff[i]);
    }
    cout << ans << endl;
    return 0;


}

Measured memory_bytes: 3328
fn main() {
    let stdin = std::io::stdin();
    let mut input = String::new();
    let _ = stdin.read_line(&mut input);
    let nk: Vec<u32> = input
        .trim()
        .split_whitespace()
        .map(|n| n.parse().expect("N"))
        .collect();
    println!("{}", solve(nk[0], nk[1]));
}

fn solve(n: u32, k: u32) -> f64 {
    let mut r: f64 = 0.0;
    for i in 1..=n {
        let straight = (((k + i - 1) / i) as f64).log2().ceil() as i32;
        // eprintln!("i={} k={} needs {} straight heads", i, k, straight);
        r += (2 as f64).powi(-straight);
    }
    r / (n as f64)
}


Measured memory_bytes: 2736