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

int main() {
	string a,b,c;
	
	cin>>a;
	cin>>b;
	cin>>c;
	char t=a[0];
	a.erase(a.begin());
	int n=a.size()+b.size()+c.size();
	while(--n){
		if (t=='a'){
			if(!a.size()) break;
			t=a[0];
			a.erase(a.begin());
			
		}
		else if(t=='b'){
			if(!b.size()) break;
			t=b[0];
			b.erase(b.begin());
		}
		
		else {
			if(!c.size()) break;
			t=c[0];
			c.erase(c.begin());
		}
	}
	cout<<char(toupper(t));
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>

using namespace std;

class PrimeNumbers
{
 public:
  int solve( int n, int a[] );
  bool isPrime( int x );
};

int PrimeNumbers::solve( int n, int a[] )
{
  int result = 0;

  for( int i = 0; i < n; i++ )
    {
      if( isPrime(a[i]) )
        result++;
    }
  return result;
}

bool PrimeNumbers::isPrime(int x)
{
  if (x == 2)
    return true;
  
  for( int i = 2; i <= sqrt(x); i++ )
    {
      if( (x % i)  == 0 )
        return false;
    }
  return true;
}

int main( void )
{
  int n;
  int a[10000];

  PrimeNumbers *pn = new PrimeNumbers();

  cin >> n;

  for( int i = 0; i < n; i++)
    cin >> a[i];
  
  cout << pn -> solve( n, a ) << endl;

  delete pn;

  return 0;
}

Measured memory_bytes: 1228
import sys


if __name__ == '__main__':
    N = int(input())
    W = list(map(int, input().split()))

    min_diff = sys.maxsize
    for i in range(1, N):
        T = i
        wt = W[T-1]
        S1 = 0
        S2 = 0
        for j in range(0, N):
            if j+1 <= T:
                S1 += W[j]
            if j+1 > T:
                S2 += W[j]
        min_diff = min(min_diff, abs(S1-S2))

    print(min_diff)

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int a[] = new int[2];
		a[0] = sc.nextInt();
		a[1] = sc.nextInt();
		Arrays.parallelSort(a);
		if (a[0]+W>=a[1]) {
			System.out.println(0);
			return ;
		}
		System.out.println(a[1]-a[0]-W);
		return ;
	}
}

Measured memory_bytes: 35668
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string S;
    int ch;
    cin >> S;
    
    for(int i=0; i<S.length()-1; i++){
        ch = S[i];
        for(int j=i+1; j<S.length(); j++){
            if(ch == S[j]){
                cout << "no" << endl;
                return 0;
            }
        }
    }
    
    cout << "yes" << endl;
    return 0;

}


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

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> x(m);
    rep(i, 0, m) cin >> x[i];
    sort(x.begin(), x.end());
    vector<ll> d(m-1);
    ll ans = 0;
    rep(i, 0, m-1){
        d[i] = x[i+1] - x[i];
        ans += d[i];
    }
    sort(d.begin(), d.end(), greater<ll>());
    rep(i, 0, min(n-1, m-1)){
        ans -= d[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
	int n;
	scanf("%d",&n);
	if(n==1){
		printf("Hello World\n" );
	}else{
		int a,b;
		scanf("%d\n%d", &a,&b);
		printf("%d\n", a+b);
	}
	return 0;
}


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

// alias templates
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

// alias declaration
using ll = long long;
using str = string;

using vii = V<int>;
using vvii = V<vii>;

using vll = V<ll>;
using vvll = V<vll>;

using vs = V<str>;

// loops
#define FOR(i, a, b)  for (ll i = (a); i <= (ll)(b); i++) // [a,b]
#define rFOR(i, a, b) for (ll i = (b); i >= (ll)(a); i--) // [b,a]
#define REP(i, a) FOR((i), 0, (ll)(a)-1) // [0,a-1]

// for debug
#define dbg(a) cerr << "  " << (#a) << ": " << (a) << "\n";

// procon common constants
const ll MOD_BIG = 1e9 + 7;

int main(void){
    ll n,m;
    cin >> n >> m;
    vii a(m+1),b(m+1);
    vvii g(n+1);
    vii arrow(n+1, 0);
    queue<int> que;
    REP(i,m){
        cin >> a[i] >> b[i];
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }

    //幅優先探索
    arrow[1] = 1;
    que.push(1);

    while(!que.empty()){
        int current_room = que.front();
        que.pop();

        for(int i: g[current_room]){
            if(i!=1){
                if(arrow[i] == 0){
                    arrow[i] = current_room;
                    que.push(i);
                }
            }
        }
    }

    FOR(i,2,n){
        //cout << arrow[i] << endl;
        if(arrow[i]==0){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    FOR(i,2,n){
        cout << arrow[i] << endl;
    }


}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def rec(u, prev, li):
    li.append(u+1)
    visited[u] = 1
    for v in nodes[u]:
        if v != prev and visited[v] == -1:
            if rec(v, u, li):
                return True
    return True

N, M = MAP()
nodes = [[] for i in range(N)]
visited = [-1] * N
for i in range(M):
    a, b = MAP()
    a -= 1; b -= 1
    nodes[a].append(b)
    nodes[b].append(a)

ans = []
rec(0, -1, ans)
ans = ans[1:][::-1]
rec(0, -1, ans)

print(len(ans))
print(*ans)


Measured memory_bytes: 108540
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n;
    cin >> n;

    vector<lint> sum(n + 1);
    reps(i, n){
        cin >> sum[i];
        sum[i] += sum[i - 1];
    }

    lint ans = LLINF;
    reps(i, n){
        chmin(ans, abs((sum[n] - sum[i]) - sum[i]));
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 1792
from heapq import heappop,heappush,heapify
from collections import deque

N,M=map(int,input().split())
A,B,C = [0]*N,[0]*N,[0]*N
for i in range(N):
    A[i],B[i] = map(int,input().split())
    C[i]=[A[i],B[i]]
C.sort()
C=deque(C)

a=[]
heapify(a)
ans=0

for i in range(M,-1,-1):
    while C:
        if C[0][0]<=M-i:
            heappush(a,(-1)*C[0][1])
            C.popleft()
        else:
            break
    if len(a)>0:
        p = heappop(a)
        ans += (-1)*p
        
print(ans)

Measured memory_bytes: 29996
N = int(input())
A = list(map(int, input().split()))
S = set(A)
M = max(S)
A.sort()

pre_a = 0
for a in A:
    if a == pre_a:
        S.discard(a)
    if a in S:
        j = a * 2
        while j <= M:
            S.discard(j)
            j += a
    pre_a = a
print(len(S))

Measured memory_bytes: 32280
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {
  int a,b,c;
  cin >> a>>b>>c;
  int memo;
  
  for(int i=min(a,b)+1;i>0;i--) {
    if(a%i==0 && b%i==0) {
      memo = i;
      break;
    }
  }
  
  cout << (c%memo==0?"YES":"NO") << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int ll;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int a[5], k;
	for (int i = 0; i < 5; ++i) {
		cin >> a[i];
	}
	cin >> k;
	bool flag = false;
	for (int i = 0; i < 5; ++i) {
		for (int j = i + 1; j < 5; ++j) {
			if (abs(a[i] - a[j]) > k) {
				//cout << i << " " << j << "\n";
				flag = true;
				break;
			}
		}
	}
	if (!flag) cout << "Yay!\n";
	else cout << ":(\n";
}



Measured memory_bytes: 256
#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;

int main(){
	int n;
	cin >> n;
	vector<vector<int>> to(n);
	vector<int> a(n-1),b(n-1);
	rep(i,n-1){
		int x,y;
		cin >> x >> y;
		--x; --y;
		a[i] = x;
		b[i] = y;
		to[x].push_back(y);
		to[y].push_back(x);
		
	}
	
	int colorsize = 0;
	rep(i,n) colorsize = max(colorsize, (int)to[i].size());
	
	map<P,int> mp;
	function<void(int,int)> dfs = [&](int v, int col) {
		col++;
		for(auto next : to[v]){
			if(mp.find(P(v,next)) == mp.end()){
				mp[P(v,next)] = col%colorsize + 1;
				mp[P(next,v)] = col%colorsize + 1;
				dfs(next,col);
				col++;
			}
		}
		return;
	};
	
	dfs(0,-1);
	
	cout << colorsize << endl;
	rep(i,n-1) cout << mp[P(a[i],b[i])] << endl;
	
	return 0;
}


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

int main() {
  int x,gohyaku=0,go=0,hap;
  cin>>x;
  gohyaku=x/500;
  x%=500;
  go=x/5;
  hap=gohyaku*1000+go*5;
  cout<<hap<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,x;
    scanf("%d %d %d",&a,&b,&x);
    if(x<a)
        printf("NO\n");
    else if(x>a+b)
        printf("NO\n");
    else
        printf("YES\n");
    return 0;
}


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

using namespace std;

int hist[210000];

int main()
{
  int N, K;
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    hist[A]++;
  }
  
  vector<int> v;
  for (int i = 1; i <= 200000; i++) {
	if (hist[i] > 0) v.push_back(hist[i]);
  }
  sort(v.begin(), v.end());
  
  int ans = 0;
  for (int i = 0; i < (int)v.size() - K; i++) {
  	ans += v[i];
  }
  cout << ans << endl;
  
  return 0;
}
  

Measured memory_bytes: 2168
N,M=map(int,input().split())
A=[list(map(int,input().split())) for i in range(M)]
#Bは色　Cは個数
B=[0]*N
C=[1]*N
B[0]=1
for i in range(M):   
  if (B[(A[i][0]-1)]==1)and(C[(A[i][0]-1)]==1):
    B[(A[i][1]-1)]=1
    B[(A[i][0]-1)]=0
    C[(A[i][0]-1)]=0
    C[(A[i][1]-1)]+=1
  elif (B[(A[i][0]-1)]==1)and(C[(A[i][0]-1)]>1):
    B[(A[i][1]-1)]=1
    C[(A[i][0]-1)]-=1
    C[(A[i][1]-1)]+=1
  else:
    C[(A[i][0]-1)]-=1
    C[(A[i][1]-1)]+=1
    
    
print(sum(B))

Measured memory_bytes: 28964
import java.util.*;
import java.util.Arrays;

class Main {
  public static void main(String[] args) {
  	Scanner sc = new Scanner(System.in);
  	int N = sc.nextInt();
    int input[] = new int[N];
    int newput[] = new int[N];
    int a = 0;
    for (int i = 0; i < N ; i++){
    	a = sc.nextInt();
        input[i] = a;
        newput[i] = a;
	}
    Arrays.sort(newput);
    int first = newput[N-1];
    int second = newput[N-2];
    if ( first == second ) {
      for ( int i = 0; i < N ; i++){
      	System.out.println(first);
      }
    }
    else {
 		for ( int i = 0; i < N ; i++){
          if ( input[i] == first ){
            System.out.println(second);
          }
          else {
            System.out.println(first);
          }
      }  
    }
        
    }
}

Measured memory_bytes: 92380
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	
	public static void Main(string[] args)
	{
		string forecast = Console.ReadLine();
		string actual = Console.ReadLine();
		int r = 0;
		for(int i = 0; i < 3; i++)
		{
			if(forecast[i] == actual[i])
				r++;
		}
		Console.WriteLine(r);
	}
	
	
	public static long GCD(long a, long b)
	{
		if(b == 1)
			return a;
		long p = b / a;
		return GCD(a, b - a*p);
	}
	
	public static string[] Input()
	{
		return Console.ReadLine().Split(' ');
	}

	
	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}

}



Measured memory_bytes: 13140
x,y,z,k = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse = True)
b = sorted(list(map(int, input().split())), reverse = True)
c = sorted(list(map(int, input().split())), reverse = True)
ans = []
#---------------------
for p in range(min(k,len(a))):
  for q in range(min(k,len(b))):
    for r in range(min(k,len(c))):
      if((p+1)*(q+1)*(r+1) > k):
        break
      ans.append(a[p] + b[q] + c[r])
      
ans = sorted(ans, reverse = True)
for i in range(k):
  print(ans[i])

      



Measured memory_bytes: 9548
#include <iostream>
#include <vector>
#include<algorithm>
#include<map>
#include<cmath>
#include<set>
#include<string>
using namespace std;
int main() {
    long long int a, b,n;
    cin >> a >>  b;
    if (a % b == 0) {
        cout << -1 << endl;
        return 0;
    }
    cout << a << endl;
 }

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

using ll = long long;
const ll p = 1000000007;

ll power(ll x, ll y,ll p){
    ll res = 1;    
  
    x = x % p;  
  
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;  
  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return (res%p);  
} 

ll modInverse(ll n,ll p){
    return power(n,p-2,p);
}
ll nCr(ll n, ll k)  {  
    ll ans = 1;   
    if(k<0 || k>n){
        return 0;
    }
    k = min(k,n-k);
    for (ll i = 1; i <= k; ++i){  
        ans = ((ans*modInverse(i,p))%p * (n+1-i))%p;
    }  
  
    return ans;  
} 

int main(){
    ll n,a,b;
    cin >> n >> a >> b;

    ll sum = power(2,n,p)-1;
    //cout << (binomialCoeff(n,a))%m << " " << (binomialCoeff(n,b))%m << "\n";
    sum = ((sum - (nCr(n,a))-nCr(n,b))%p + p)%p;

    cout << (sum%p) << "\n";
    return 0;
}

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

using vi = vector<int>;
using ii = pair<int, int>;

int main() {
  cin.sync_with_stdio(false);
  cin.tie(NULL);

  int w, h;

  cin >> h >> w;
  set<ii> x, y;

  for (int i = 1; i <= w; i++) {
    y.insert(make_pair(0, i));
    x.insert(make_pair(i, i));
  }

  int a, b;
  for (int i = 1; i <= h; i++) {
    cin >> a >> b;
    ii st = make_pair(a, -1);
    ii end = make_pair(b, INT_MAX);
    for (auto it = x.lower_bound(st); it != x.upper_bound(end); it = x.lower_bound(st)) {
      int j = it->second;
      y.erase(make_pair(it->first - it->second, it->second));
      x.erase(it);
      
      if (x.lower_bound(st) == x.upper_bound(end)) {
        x.insert(make_pair(b == w ? INT_MAX : b + 1, j));
        y.insert(make_pair(b == w ? INT_MAX : b + 1 - j, j));
      }
    }

    int ans = y.begin()->first;
    cout << (ans == INT_MAX ? -1 : ans + i) << endl;
  }

  return 0;
}


Measured memory_bytes: 22376
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

a,b,k = inm()
print("{} {}".format(max(0,a-k), max(0,b-max(0,k-a))))


Measured memory_bytes: 38384
#include<iostream>

using namespace std;

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

int n;

cin >> n;
if (n%2==0){
    cout << 0.5 << endl;
}else{
    cout << (double)(n/2+1)/n << endl;
}

//////////////////////////////////////////////////////
return 0;}

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

int main()
{
	int n;
	cin >> n;
	vector<vector<int>> g( n, vector<int>( n ) );
	for( int i = 0; i < n; i++ ) {
		int u, k;
		cin >> u >> k;
		u--;
		for( int j = 0; j < k; j++ ) {
			int v;
			cin >> v;
			v--;
			g[u][v] = 1;
		}
	}

	for( int i = 0; i < n; i++ ) {
		for( int j = 0; j < n; j++ ) {
			if( j ) cout << " ";
			cout << g[i][j];
		}
		cout << endl;
	}
}



Measured memory_bytes: 3136
import java.util.*;
import java.math.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.math.BigInteger.*;
public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void debug(Object...os){
		System.err.println(deepToString(os));
	}
	class E{
		int x,y,z;

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + getOuterType().hashCode();
			result = prime * result + x;
			result = prime * result + y;
			result = prime * result + z;
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			E other = (E) obj;
			if (!getOuterType().equals(other.getOuterType()))
				return false;
			if (x != other.x)
				return false;
			if (y != other.y)
				return false;
			if (z != other.z)
				return false;
			return true;
		}

		private Main getOuterType() {
			return Main.this;
		}

		public E(int x, int y, int z) {
			super();
			this.x = x;
			this.y = y;
			this.z = z;
		}
		
	}
	void run(){
		Scanner sc=new Scanner(System.in);
		for(;;){
			int n=sc.nextInt();
			int h=sc.nextInt();
			if(n==0 && h==0)return;
			HashSet<E> set=new HashSet<E>();
			for(int l=0;l<h;l++){
				String s=sc.next();
				if(s.equals("xy")){
					int x=sc.nextInt()-1,y=sc.nextInt()-1;
					for(int i=0;i<n;i++){
						set.add(new E(x,y,i));
					}
				}
				if(s.equals("xz")){
					int x=sc.nextInt()-1,y=sc.nextInt()-1;
					for(int i=0;i<n;i++){
						set.add(new E(x,i,y));
//						bs[x][i][y]=true;
					}
				}
				if(s.equals("yz")){
					int x=sc.nextInt()-1,y=sc.nextInt()-1;
					for(int i=0;i<n;i++){
						set.add(new E(i,x,y));
//						bs[i][x][y]=true;
					}
				}
			}
//			int res=0;
//			for (int i = 0; i < n; i++) {
//				for (int j = 0; j < n; j++) {
//					for (int j2 = 0; j2 < n; j2++) {
//						if(!bs[i][j][j2])res++;
//					}
//				}
//			}
			System.out.println(n*n*n-set.size());
		}
	}
}

Measured memory_bytes: 17000
/* ex7_3
    sak_Citrue  */

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

int main(void){
    int height,width;
    char **ptr;
    scanf("%d %d",&height,&width);
    //行に出力があったか判定するフラグ
    char flag = 0;
    char *ptrrow = (char*)calloc(height,sizeof(char));
    char *ptrcol = (char*)calloc(width,sizeof(char));


    ptr = (char**)calloc(height,sizeof(char*));

    for(int i = 0;i<height;i++){
        ptr[i] = (char*)calloc(width,sizeof(char));
    }
    
    for(int i=0;i<height;i++){
        for(int j=0;j<width;j++){
            scanf(" %c",ptr[i]+j);
        }
    }
    
    //どの行を出力すべき列か走査
    for(int i=0;i<height;i++){
        for(int j=0;j<width;j++){
            if(*(ptr[i]+j)=='#'){
                *(ptrrow+i) = 1;
                break;
            }
        }
    }
    
    //どの列を出力すぺきか走査
    for(int i=0;i<width;i++){
        for(int j=0;j<height;j++){
            if(*(ptr[j] + i)=='#'){
                *(ptrcol+i) = 1;
                break;
            }
        }
    }
    
    
    //出力
    for(int i=0;i<height;i++){
        flag = 0;
        for(int j=0;j<width;j++){
            //出力すべき行、列にどちらも該当しているときのみ書き込む
            if(*(ptrrow+i)==1 && *(ptrcol+j)==1){
                printf("%c",*(ptr[i]+j));
                flag = 1;
            }
            //出力が存在した行末尾で改行
            if(j==width -1 && flag == 1){
                printf("\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1672
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun main(args: Array<String>) {
    val N = readInt()
    val B = readIntList()
    val A = Array(N) { 100000 }

    for (i in B.indices) {
        A[i] = B[i].coerceAtMost(A[i])
        A[i+1] = B[i].coerceAtMost(A[i+1])
    }

    println(A.sum())
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string S; cin >> S;
  if (S == "ABC") {
    cout << "ARC\n";
  }else {
    cout << "ABC\n";
  }

  return 0;
}



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


int main() {
    string S;
    cin >> S;
    int ans = 0;
    int leftcnt = 0;
    char leftcol;
    rep(i,S.size()) {
        if (leftcnt == 0) {
            leftcol = S.at(i);
            ++leftcnt;
        } else if (leftcnt > 0) {
            if (S.at(i) == leftcol) ++leftcnt;
            else {
                ans += 2;
                --leftcnt;
            }
        }
    }
    cout << ans << endl;
}


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

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  sort(a,a+n);
  reverse(a,a+n);
  ll ans=a[0];
  rep(i,2,n){
    ans+=a[i/2];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4380
n,k=map(int,input().split())
li=list(map(int,input().split()))
#print(li)
#now=len(list(set(li)))

move=0
#li.sort()
dic={}
for num in li :
  if num in dic.keys() :
    dic[num]=dic[num]+1
  else :
    dic[num]=1
#print(dic[1])
now=len(dic)
#while(k<now) :

for key, v in sorted(dic.items(), key=lambda x: x[1]):
  #print(now)
  if k>=now :
    break
  #print(str(k) + ": " + str(v))
  #print(now)
  move+=v
  now=now-1
  
print(move)
  

Measured memory_bytes: 38964
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pp;

vector<int> par[2];
vector<int> rnk[2];

void makeSets(int n, int d) {
    par[d].resize(n);
    rnk[d].resize(n);
    for(int i=0; i<n; i++) {
        par[d][i] = i;
        rnk[d][i] = 0;
    }
}

int find(int x, int d) {
    if(x != par[d][x]) par[d][x] = find(par[d][x], d);
    return par[d][x];
}

void unite(int xp, int yp, int d) {
    int x = find(xp, d);
    int y = find(yp, d);
    if(x == y) return;
    if(rnk[d][x] > rnk[d][y]) par[d][y] = x;
    else par[d][x] = y;
    if(rnk[d][x] == rnk[d][y]) rnk[d][y]++;
}

int main() {
    int N, K, L;
    cin >> N >> K >> L;
    
    for(int d=0; d<2; ++d) makeSets(N, d);

    for(int i=0; i<K+L; ++i) {
        int p,q;
        cin >> p >> q;
        --p; --q;
        if(i < K) unite(p, q, 0);
        else unite(p, q, 1);
    }

    map<pp, int> G;
    for(int i=0; i<N; ++i) {
        G[pp(find(i,0), find(i,1))] += 1;
    }
    
    for(int i=0; i<N; ++i) {
        cout << G[pp(find(i,0), find(i,1))] << (i+1<N ? ' ' : '\n');
    }
    return 0;
}

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

long long euclidean_gcd(long long a, long long b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main()
{
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	
	long long gcd = euclidean_gcd(c, d);

	long long c_div, d_div, cd_div;
	c_div = (b/c - (a-1)/c);
	d_div = (b/d - (a-1)/d);
	cd_div = (b/(c*d/gcd) - (a-1)/(c*d/gcd));

	cout << b-a+1-(c_div+d_div-cd_div) << endl;

}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include <algorithm>      //sort,二分探索,など
#include <bitset>         //固定長bit集合
#include <cmath>          //pow,logなど
#include <complex>        //複素数
#include <deque>          //両端アクセスのキュー
#include <functional>     //sortのgreater
#include <iomanip>        //setprecision(浮動小数点の出力の誤差)
#include <iostream>       //入出力
#include <iterator>       //集合演算(積集合,和集合,差集合など)
#include <map>            //map(辞書)
#include <numeric>        //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>          //キュー
#include <set>            //集合
#include <stack>          //スタック
#include <string>         //文字列
#include <unordered_map>  //イテレータあるけど順序保持しないmap
#include <unordered_set>  //イテレータあるけど順序保持しないset
#include <utility>        //pair
#include <vector>         //可変長配列

using namespace std;

int selection_sort(int A[], int N) {
    int count = 0;
	for (int i = 0; i < N; ++i) {
		int minj = i;
        for(int j = i; j < N; ++j){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        if(i != minj){
            swap(A[i], A[minj]);
            ++count;
        }
	}
    return count;
}

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

	int A[100] = {};
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	int count = selection_sort(A, N);
    for(int i = 0; i < N; ++i){
        if(i != 0) cout << " ";
        cout << A[i];
    }
    cout << "\n";
    cout << count << "\n";
	return 0;
}


Measured memory_bytes: 3204
import java.util.Scanner;

/**
 *
 * @author ena000078
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        String S  = sc.next();
        
        for(int i=0;i<S.length()-1;i++){
            int diff = S.indexOf(S.substring(i, i+1), i+1);
            if (diff!=-1){
                System.out.println("no");
                return;
            }
        }
        System.out.println("yes");
    }
    
}


Measured memory_bytes: 23764
fn main() {
    use std::collections::HashSet;
    let n: i64 = read();
    let mut m: HashSet<i64> = HashSet::new();

    for _ in 0..n {
        let a: i64 = read();
        if m.contains(&a) {
            println!("NO");
            return;
        }
        m.insert(a);
    }
    println!("YES");
}

use std::io::stdin;
use std::io::Read;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let token: String = cin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 10432
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto nm = readints;
    long m = nm[1];
    auto a = readints;

    int[long] d = [0: 1];
    long sum = 0;
    long ans = 0;
    for (int i = 0; i < a.length; i++) {
        sum = (sum + a[i]) % m;
        ans += d.get(sum, 0);
        d[sum]++;
    }
    writeln(ans);
}


Measured memory_bytes: 8400
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;



ll N, X,ans=1;
ll L[100];

string S;


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	
	
	cin >> N>>X ;
	int cur = 0;
	FOR(i, 0, N) {
		cin >> L[i];
		cur += L[i];
		if (cur <= X)ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	//min(a,b)...a,bの小さいほう
	//max(a,b)...     大きいほう
	int a;
	int b;
	int c;
	int d;
	int e;
	std::cin >> a >> b;
	cout << max(a + b, max(a - b, a*b)) << "\n";
	std::cin >> e;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=100005;

int h[maxn],mem;
struct
{
    int v,next;
}e[maxn<<1];
int num[maxn];
void add(int u,int v)
{
    e[mem].v=v;
    e[mem].next=h[u];
    h[u]=mem++;
}
bool can;
int deep[maxn];
int mi[maxn],mx[maxn];
void dfs(int u,int f)
{
    if(num[u]){
        mx[u]=mi[u]=num[u];
    }
    else{
        mx[u]=1000000000;
        mi[u]=-1000000000;
    }

    if(num[u]&&(abs(num[u]-deep[u])&1)){
        //printf("%d %d %d uuuu\n",num[u],deep[u],u);
        can=0;return ;
    }
    for(int i=h[u];i+1;i=e[i].next)
    {
        int v=e[i].v;
        if(v==f) continue;
        deep[v]=deep[u]+1;
        dfs(v,u);
        if(!can) return ;
        mi[v]--;
        mx[v]++;
        mi[u]=max(mi[u],mi[v]);
        mx[u]=min(mx[u],mx[v]);
    }
    if(mx[u]<mi[u]){
        //printf("%d %d %d\n",u,mx[u],mi[u]);
        can=0;
    }
}
void dfsnum(int u,int f)
{
    for(int i=h[u];i+1;i=e[i].next)
    {
        int v=e[i].v;
        if(v==f) continue;
        if(num[u]-1>=mi[v]){
            num[v]=num[u]-1;
        }
        else{
            num[v]=num[u]+1;
        }
        if(num[v]<mi[v]||num[v]>mx[v]) while(1);
        dfsnum(v,u);
    }
}
int main()
{
    int n;
    scanf("%d",&n);
    memset(h,-1,sizeof(h));mem=0;
    memset(num,0,sizeof(num));
    for(int i=1;i<n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        add(x,y);
        add(y,x);
    }
    int k;
    scanf("%d",&k);
    int root;
    for(int i=1;i<=k;i++)
    {
        int v,p;
        scanf("%d%d",&v,&p);
        num[v]=p+1;
        root=v;
    }
    if(k==0){
        root=1;
        num[1]=1;
    }
    deep[root]=num[root];can=1;
    dfs(root,root);
    if(can==0){
        printf("No\n");return 0;
    }
    dfsnum(root,root);
    printf("Yes\n");
    for(int i=1;i<=n;i++)
        printf("%d\n",num[i]-1);
    return 0;
}


Measured memory_bytes: 9088
using System;
using System.Linq;
using System.Collections.Generic;
class ProgramD
    {
        static void Main(string[] args)
        {
            //
            string input = Console.ReadLine();
            int n = int.Parse(input);
            string[] inputA = Console.ReadLine().Split(' ');
            int[] A = new int[n];
            int[] ans = new int[n];
            for(int i = 0; i < n; i++)
               A[i] = int.Parse(inputA[i]);

            for(int i = n/2; i < n;i++)
            {
                ans[i] = A[i];      
            }

            for(int i = n/2 - 1; i >= 0;i--)
            {
                int sum = 0;
                for(int j = i; j < n; j = j + (i + 1))
                {
                    if(j == i)
                        sum += A[j];
                    else
                        sum += ans[j];  
                }   
                ans[i] = sum % 2;
            }

            int count = 0;

            for(int i = 0; i < n;i++)
            {
                if(ans[i] == 1)
                    count++;
            }

            Console.WriteLine(count);

            for(int i = 0; i < n; i++)
            {
                if(ans[i] == 1)
               Console.Write(i + 1);
               Console.Write(" ");
            }
        }

           
    }

Measured memory_bytes: 29272
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }


int main() {
  int N; cin>>N;
  vector<int> p(N);
  REP(i,N) cin>>p[i];
  int d	= 0;
  for(int i = 0; i < N;	i++) {
    if(p[i] != i+1) d++;
  }
  YESNO(d == 0	|| d ==	2);
  return 0;
}


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

int N, M;
int P[100100];
int A[100100];
int B[100100];
int C[100100];
int T[100100];

int main() {
  cin >> N >> M;
  for (int i=0; i<M; i++) cin >> P[i];
  for (int i=0; i<N-1; i++) cin >> A[i] >> B[i] >> C[i];

  for (int i=1; i<M; i++) {
    int s = P[i-1]-1, d = P[i]-1;
    T[min(s, d)]++;
    T[max(s, d)]--;
  }
  long long ans = 0;
  long long t = 0;
  for (int i=0; i<N-1; i++) {
    t += T[i];
    ans += min(t*A[i], t*B[i] + C[i]);
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 5056
#include<stdio.h>
#include<string.h>

int main(){
	int n;
	int k;
	int l;
	int seen[3];
	int temp;
	int i,j;
	int result;
	char dir[6];
	scanf("%d",&n);
	while(n){
		result = 1;
		seen[0] = 1;
		seen[1] = 2;
		seen[2] = 3;
		for(k=0;k<n;k++){
			scanf("\n%s",&dir);
			if((int)dir[0]==78){
				i = 1;
				j = 0;
			}else if((int)dir[0]==69){
				i = 0;
				j = 2;
			}else if((int)dir[0]==87){
				i = 2;
				j = 0;
			}else if((int)dir[0]==83){
				i = 0;
				j = 1;
			}else if((int)dir[0]==82){
				i = 2;
				j = 1;
			}else{
				i = 1;
				j = 2;
			}
			temp = seen[i];
			seen[i] = 7 - seen[j];
			seen[j] = temp;
			result += seen[0];
		}
		printf("%d\n",result);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 0
import sys
#input = sys.stdin.buffer.readline

def main():
    S = input()
    P = 2019

    ans,base = 0,1
    MOD_list = 0
    d = {}
    d[0] = 1

    for st in S[::-1]:
        num = int(st)
        MOD_list = (MOD_list+num*base)%P
        if MOD_list not in d:
            d[MOD_list] = 1
        else:
            d[MOD_list] += 1
        base *= 10
        base %= P

    for v in d.values():
        ans += (v*(v-1))//2
        
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 80160
# -*- coding:utf-8 -*-
alist = [1,9,7,4]
listi = map(int,input().split(' '))
qlist = list(listi)

cnt = 0
if len(set(qlist)) != 4:
  print('NO')
else:
  for elm in qlist:
    if elm in alist:
      cnt+=1
  if cnt == 4:
    print('YES')
  else:
    print('NO')

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
char t[100002];
int main()
{
	scanf("%s",t);
	int len=strlen(t);
	for(int i=0;i<len;i++)
	{
		if(t[i]==t[i+1])
		{
			printf("%d %d",i+1,i+2);
			return 0;
		}
		if(t[i]==t[i+2])
		{
			printf("%d %d",i+1,i+3);
			return 0;
		}
	}
	printf("-1 -1");
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int main(void){
	int n=in(),i;
	long long dp[100];
	dp[0]=2;
	dp[1]=1;
	for(i=2;i<=n;i++)dp[i]=dp[i-1]+dp[i-2];
	llprint(dp[n]);
	return 0;
}

Measured memory_bytes: 128
//https://atcoder.jp/contests/abc150/tasks/abc150_b
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n , count = 0;
    string s ;
    cin >> n >> s ;
    for(int x = 0 ; x < s.size() ; x++)
    {
        if(s[x] == 'A' and s[x + 1] == 'B' and s[x + 2] == 'C')
        {
            count++;
        }
    }
    cout << count << endl ;
    return 0;
}

Measured memory_bytes: 256
#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;
}
int n;
vector <int> G[233333]; int dep[233333], fa[233333];
inline void L(int x, int y) {
	cout << x << " " << y << "\n";
	G[x].push_back(y); G[y].push_back(x);
}

inline void dfs(int u, int fat) {
	dep[u] = dep[fa[u] = fat] + 1;
	for (int v : G[u]) if (v != fat) dfs(v, u);
}

inline int get(int x, int y) {
#define P(x) ((x) - ((x) > n) * n)
	int p = 0;
	while (x != y) {
		if (dep[x] < dep[y]) swap(x, y);
		p ^= P(x); x = fa[x];
	}
	p ^= P(x);
	return p;
}

inline void chk() {
	dfs(1, 0);
	rep (i, n) {
		if (i != get(i, i + n)) {
			cout << i << "\n";
			assert(0);
		}
	}
}

int main(void) {
	read(n);
	re0 (k, 30) if ((1 << k) == n) return cout << "No", 0;
	cout << "Yes\n";
	L(1, 2); L(2, 3); L(3, 1 + n); L(1 + n, 2 + n); L(2 + n, 3 + n);
	for (int k = 5; k <= n; k += 2) {
		L(1 + n, k); L(k, k - 1); L(1 + n, k - 1 + n); L(k + n, k - 1 + n);
	}
	if (~n & 1) {
		for (int p = 2; p <= n; p++)
			if (2 <= (n ^ 1 ^ p) && (n ^ 1 ^ p) <= n - 1) {
				int x = p, y = n ^ 1 ^ p;
				if (x & 1) L(n, x); else L(n, x + n);
				if (y & 1) L(n + n, y); else L(n + n, y + n);
				goto END;
			}
	}
 END:;
	chk();
}


Measured memory_bytes: 16504
#pragma warning(disable: 4996)

#include <iostream>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cctype>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <bitset>
#include <numeric>
#include <string>
#include <set>
#include <tuple>
#include <utility>
#include <regex>
#include <deque>
#include <map>
#include <queue>
#include <stack>
#include <sstream>
using namespace std;

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

	string s;
	cin >> s;
	bool ok = true;
	if (s == "AAA") ok = false;
	if (s == "BBB") ok = false;
	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template<typename T> void print(const T & v);


int main() {
    ll N, K;
    cin >> N >> K;
    double ans = 0.0;
    for(ll i = 1; i <= N; i++){
        double p = 1.0;
        ll x = i;
        while(x < K){
            p /= 2.0;
            x *= 2;
        }
        ans += p;
    }
    ans /= N;
    printf("%.10f\n", ans);
    return 0;
}


// Use For Debug
template <typename T>
void print(T const & v){
    for(int i = 0; i < v.size(); i++){
        if(i) cout << " ";
        cout << v[i];
    }
    cout << endl;
}


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

using namespace std;

#define ll long long
ll input(){
	ll x=0,f=0;char ch=getchar();
	while(ch<'0'||ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return f? -x:x;
}

const int N=1e4+7;

ll dp[N];
struct node{
	ll w,s,v;
}a[1007];

bool cmp(node a,node b){
	return a.s-b.w>b.s-a.w;
}

int main(){
	int n=input();
	for(int i=1;i<=n;i++){
		a[i].w=input(),a[i].s=input(),a[i].v=input();
	}

	sort(a+1,a+1+n,cmp);

	for(int i=1;i<=n;i++){
		for(int j=a[i].w;j<=10000;j++)
			dp[min(j-a[i].w,a[i].s)]=max(dp[min(j-a[i].w,a[i].s)],dp[j]+a[i].v);
		dp[a[i].s]=max(dp[a[i].s],a[i].v);
	}
	ll Ans=0;
	for(int i=0;i<=10000;i++) Ans=max(Ans,dp[i]);
	printf("%lld\n",Ans);
}

Measured memory_bytes: 384
s = input()
for bit in range(1 << 3):
    tmp = int(s[0])
    sign = []
    for i in range(3):
        if bit & (1 << i):
            tmp += int(s[i+1])
            sign.append("+")
        else:
            tmp -= int(s[i+1])
            sign.append("-")
    
    if tmp == 7:
        print(s[0] + sign[0] + s[1] + sign[1] + s[2] + sign[2] + s[3] + "=7")
        exit()

Measured memory_bytes: 9148
#include<stdio.h>
int main(void){
	int a, b;
	char op;
	
	do{
		scanf("%d %c %d", &a, &op, &b);
		switch(op){
			case '?':
			goto EXIT;
			case '+':
			printf("%d\n", a+b);
			break;
			case '-':
			printf("%d\n", a-b);
			break;
			case '*':
			printf("%d\n", a*b);
			break;
			case '/':
			printf("%d\n", a/b);
			break;
		}
	}while(1);
	
	EXIT:
	return 0;
}



Measured memory_bytes: 2140
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;

#define pb push_back
#define All(a) a.begin(), a.end()
#define met(a, b) memset(a, b, sizeof(a))
#define rep1(i, l, r) for(int i = l; i <= r; ++i)
#define rep2(i, l, r) for(int i = l; i < r; ++i) 
#define per(i, r, l) for(int i = r; i >= l; --i)
typedef long long ll;
typedef double db;
typedef long double ldb;
const int NIL = -1;
const int oo = 0x3f3f3f3f;
const ll INF = 2e18;
const db eps = 1e-8;
const db PI = acos(-1.0);
const int maxn = 1e5 + 7;

char s[maxn];

inline int read(void)
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9')	{ if(ch == '-') f = -1; ch = getchar(); } 
	while(ch >= '0' && ch <= '9') {	x = (x << 1) + (x << 3) + ch - '0';	ch = getchar();	}
	return x * f;
}

inline void write(int x)
{
	if(x < 0) { putchar('-'); x = -x; }
    if(x>=10) write(x/10); 
	putchar(x%10+'0'); 
}

int main(void)
{
	int pos[26];
	bool flag = false;
	rep1(i, 0, 25) pos[i] = -oo; 
	scanf("%s", s);
	for(int i = 0; s[i]; ++i)
	{
		int t = s[i] - 'a';
		if(i - pos[t] <= 2)
		{
			flag = true;
			write(pos[t]+1); putchar(' '); write(i+1);
			break;
		}
		pos[t] = i;
	}
	if(!flag)
	{
		cout<<-1<<" "<<-1;
	}
	
	return 0;
} 

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int N, M;
	cin >> N >> M;

	int beki = 1;
	for(int i = 0; i < M; i++)
		beki *= 2;

	cout << beki * (1900*M + 100*(N-M)) << endl;

	return 0;
}

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

int main() {
    int N, count=0;
    string S;
    cin >> N>>S;
    for(int i=0;i<N-2;i++){
        if((S.at(i)=='A') && (S.at(i+1)=='B') && (S.at(i+2)=='C')){
            count++;
        }
    }
    cout << count <<endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  ll ans = 0;
  vector<vector <int> > table(m+1, vector<int>());
  rep(i,n){
    int a, b;
    cin >> a >> b;
    if(a <= m)
      table[a].push_back(b);
  }
  priority_queue<int> pq;
  for(int i = 1; i<m+1;i++) {
    for(auto ele : table[i]) {
      pq.push(ele);
    }
    if(!pq.empty()){
      ans += pq.top();
      pq.pop();
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5504
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let mut h = read::<i64>();
    let mut ans = 0i64;
    let mut coef = 1;
    while h != 0 {
        ans += coef;
        coef *= 2;
        h = h / 2;
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	int n,d;
	cin>>d>>n;
	if(d==0)
		cout<<n+(n==100);
	else if(d==1)
		cout<<n*100+(n==100)*100;
	else if(d==2)
		cout<<n*10000+(n==100)*10000;
	return 0;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    int count = n;
    for(int i=0;i<n;i++){
        for(int j=0;j<i;j++){
            if(h[i] < h[j]){
                count--;
                break;
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	char sa[101],sb[101],sc[101];
	int ia=0,ib=0,ic=0;
	
	scanf("%s",sa);
	scanf("%s",sb);
	scanf("%s",sc);
	
	char turn=sa[ia];
	ia++;
	
	while(1){
		if(turn == 'a'){
			turn = sa[ia];
			if(sa[ia]=='\0'){
				puts("A\n");
				break;
			}
			ia++;			
		}else if(turn == 'b'){
			turn = sb[ib];
			if(sb[ib]=='\0'){
				puts("B\n");
				break;
			}
			ib++;
		}else if(turn == 'c'){
			turn = sc[ic];
			if(sc[ic]=='\0'){
				puts("C\n");
				break;
			}
			ic++;
		}
	}
	
	return 0;
}

Measured memory_bytes: 128