akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int n=s.length();
    ll mod=1e9+7;
    vector <vector <ll> > dp;
    vector <ll> row;
    row.resize(n,0);
    dp.resize(13,row);
    if(s[0]=='?')
    {
        for(int i=0;i<10;i++)
            dp[i][0]=1;
    }
    else
        dp[s[0]-48][0]=1;
    for(int i=1;i<n;i++)
    {
        if(s[i]=='?')
        {
            for(int digit=0;digit<10;digit++)
            {
               for(int j=0;j<13;j++)
                (dp[(j*10+digit)%13][i]+=dp[j][i-1])%=mod; 
            }
        }
        else
        {
            for(int j=0;j<13;j++)
                (dp[(j*10+s[i]-48)%13][i]+=dp[j][i-1])%=mod;
        }
    }

    cout<<dp[5][n-1]<<endl;

    
    
    
    return 0;   
}


 
 


Measured memory_bytes: 11472
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#define MAX_N 200000
using namespace std;

int main() {
  int n, k, ans=0, kind=0, count=0;
  int tmp;
  vector<int> v, w;

  scanf("%d", &n);
  scanf("%d", &k);
  for(int i=0;i<n;i++){
    scanf("%d", &tmp);
    v.push_back(tmp);
  }
  sort(v.begin(), v.end());
  tmp=0;
  for(int i=0; i<n;i++){
    if(tmp!=v[i]){
      tmp=v[i];
      kind++;
      if(count!=0) w.push_back(count);
      count=1;
    }else{
      count++;
    }
  }
  w.push_back(count);
  sort(w.begin(), w.end());
  for(int i=0;i<kind-k;i++){
    ans+=w[i];
  }
  printf("%d\n", ans);
  return 0;
}

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

using namespace std;

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < sz(v);i++)

vector<int> x,s;
int finds(int key,int imin,int imax){
    if (imax < imin) {
        return -1;
    } else {
        int imid = imin + (imax - imin) / 2;
        if (s[imid] > key) {
            return finds(key, imin, imid - 1);
        } else if (s[imid] < key) {
            return finds(key, imid + 1, imax);
        } else {
            return imid;
        }
    }
}

int main(){
    int n;

    int buf;
    cin>>n;
    REP(i,n){
        cin>>buf;
        x.pb(buf);
    }
    copy(x.begin(), x.end(), back_inserter(s) );
    sort(all(s));
    int c=n/2;
    REP(i,n){
        if(finds(x[i],0,n-1)>=c){
            cout<<s[c-1]<<endl;
        }else{
            cout<<s[c]<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3828
@DDD=1;$x=!++$i,map$x+=/^D/*((${/./;$'}[$i]+=!/ABC|A.*C.*B|CAB/*${/.$/;$`}[$i-1])%=$%=1e9+7),glob'{A,B,C,D}'x4for 1..<>;print$x%$%

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll a,b,k;
    scanf("%lld %lld %lld",&a,&b,&k);
    if(a<=k)
        printf("%lld %lld\n",(ll)0,max((ll)0,b+a-k));
    else
        printf("%lld %lld\n",a-k,b);
    return 0;
}


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

int main(){
	string s;
	cin>>s;
	int a,b;
	a=(s[0]-'0')*10+(s[1]-'0');
	b=(s[2]-'0')*10+(s[3]-'0');
	if(a>=13&&b>=13){
		cout<<"NA"<<endl;
		return 0;
	}
	else if(a==0&&b==0){
		cout<<"NA"<<endl;
	}
	else if(1<=a&&a<=12&&1<=b&&b<=12){
		cout<<"AMBIGUOUS"<<endl;
		return 0;
	}
	else if(1<=a&&a<=12&&13<=b&&b<=99){
		cout<<"MMYY"<<endl;
		return 0;
	}
	else if(1<=a&&a<=12&&b==0){
		cout<<"MMYY"<<endl;
		return 0;
	}
	else if(a==0&&1<=b&&b<=12){
		cout<<"YYMM"<<endl;
		return 0;
	}
	else if(13<=a&&a<=99&&1<=b&&b<=12){
		cout<<"YYMM"<<endl;
		return 0;
	}
	else{
		cout<<"NA"<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
def main():
    abcd = input()

    for b in [format(i, '03b') for i in range(8)]:
        s = int(abcd[0])
        expr = abcd[0]
        for i in range(3):
            if b[i] == '0':
                s += int(abcd[i + 1])
                expr += '+'
            else:
                s -= int(abcd[i + 1])
                expr += '-'
            expr += abcd[i + 1]

        if s == 7:
            print(expr + '=7')
            exit()

if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int M = int.Parse(str[1]);
		int[]A = new int[N];
		string[] str2 = Console.ReadLine().Split();
		long sum = 0;
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str2[i]);
			sum += A[i];
		}
		Array.Sort(A,(x,y)=>y-x);
		int a = 1;
		var pq = new PriorityQueue<int>((x,y)=>y-x);
		for(var i=0;i<M;i++){
			if(i<N){
				pq.Enqueue(A[i]);
			}
			int b = pq.Dequeue();
			int b2 = b - b/2;
			sum -= b2;
			pq.Enqueue(b/2);
		}
		Console.WriteLine(sum);
	}
}

class PriorityQueue<T>
{
    private readonly List<T> heap;
    private readonly Comparison<T> compare;
    private int size;
    public PriorityQueue() : this(Comparer<T>.Default) {} 
    public PriorityQueue(IComparer<T> comparer) : this(16, comparer.Compare) { }
    public PriorityQueue(Comparison<T> comparison) : this(16, comparison) { }
    public PriorityQueue(int capacity, Comparison<T> comparison)
    {
        this.heap = new List<T>(capacity);
        this.compare = comparison;
    }
    public void Enqueue(T item)
    {
        this.heap.Add(item);
        var i = size++;
        while (i > 0)
        {
            var p = (i - 1) >> 1;
            if (compare(this.heap[p], item) <= 0)
                break;
            this.heap[i] = heap[p];
            i = p;
        }
        this.heap[i] = item;

    }
    public T Dequeue()
    {
        var ret = this.heap[0];
        var x = this.heap[--size];
        var i = 0;
        while ((i << 1) + 1 < size)
        {
            var a = (i << 1) + 1;
            var b = (i << 1) + 2;
            if (b < size && compare(heap[b], heap[a]) < 0) a = b;
            if (compare(heap[a], x) >= 0)
                break;
            heap[i] = heap[a];
            i = a;
        }
        heap[i] = x;
        heap.RemoveAt(size);
        return ret;
    }
    public T Peek() { return heap[0]; }
    public int Count { get { return size; } }
    public bool Any() { return size > 0; }
}

Measured memory_bytes: 24156
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int k,n,a[100001];
    cin>>k>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    if((k-1)%(n-1)==0) cout << (k-1)/(n-1) <<endl;
    else cout << (k-1)/(n-1)+1 << endl;
    return 0;
}

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

std::string L;
long long mod = 1e9 + 7;

long long modpow(long long a, long long n) {
    long long res = 1;
    while(n > 0) {
        if(n & 1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long calc(int n, bool max){
    if(L.size() == n){
        return 1;
    }
    if(L[n] == '1'){
        long long tmp = (2 * calc(n + 1, max)) % mod;
        tmp = (tmp + modpow(3, L.size() - n - 1)) % mod;
        return tmp;
    }else{
        if(max){
            return (calc(n + 1, true)) % mod;
        }else{
            return (3 * calc(n + 1, false)) % mod;
        }
    }
}

int main(){
    std::cin >> L;
    
    std::cout << calc(0, true) << std::endl;
    
    return 0;
}



Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back
int H;
int W= 5;
int S[10][10];
int B[10][10];
int main() {
  while(true){
    cin >> H;
    if(H==0)return 0;
    int ans = 0;
    rep(i,H)
      {
	rep(j,W)
	  {
	    cin>>S[i][j];
	    
	  }
      }
  
    while(1)
      {
	 bool flag=true;
	memset(B,0,sizeof(B));
	/*rep(i,H)
	  {
	    rep(j,W)
	      {
		printf("%d ",S[i][j]);
		
	      }
	      }*/
	rep(i,H)
	  {
	    repi(j,2,W)
	      {
		if(S[i][j]!=-1 && S[i][j]==S[i][j-1] && S[i][j-1]==S[i][j-2])
		  {
		    B[i][j]=B[i][j-1]=B[i][j-2]=1;
		    flag=false;
		  }
	      }
	  }
	//printf("%d",flag);
	if(flag)break;
	rep(k,H)
	  {
	    //int k = H-i-1;
	    rep(j,W)
	      {
		if(B[k][j])
		  {
		    ans += S[k][j];
		    int p = k;
		    while(true)
		      {
			if(p==0||S[p-1][j]==-1)
			  {
			    S[p][j]=-1;
			    break;
			  }
			else
			  {
			    S[p][j]=S[p-1][j];
			    p--;
			  }
		      }
		     		   
		  }
	      }
	  }
      }
    printf("%d\n",ans);
  }
}

Measured memory_bytes: 3140
#include<stdio.h>

int main(){
	
	int a,b,c,temp=0;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
	    temp=a;
	    a=b;
	    b=temp;
	}
	if(b>c){
	    temp=b;
	    b=c;
	    c=temp;
	}
	if(a>b){
	    temp=a;
	    a=b;
	    b=temp;
	}
	
	printf("%d %d %d\n",a,b,c);
	
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 1992
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,T;
  cin>>N>>T;
  vector<pair<int,int>> P(N);
  for(int i=0;i<N;i++){
    cin>>P.at(i).first>>P.at(i).second;
  }
  int ans=1000;
  bool a=false;
  for(int i=0;i<N;i++){
    if(P.at(i).second<=T){
      ans=min(ans,P.at(i).first);
      a=true;
    }
  }
  if(a){
    cout<<ans<<endl;
  }
  else{
    cout<<"TLE"<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>

#define ll long long

using namespace std;

int main() {

	ll int n;

	cin >> n;

	ll int min = 1000000000000;
	if (n > 1000000) {
		for (int i = 2; i <= 1000000; i++) {
			ll int c;
			if (n % i == 0) {
				c = (i - 1) + (n / i - 1);
				if (c < min)
					min = c;
			}
		}
	}
	else {
		for (int i = 2; i <= n; i++) {
			ll int c;
			if (n % i == 0) {
				c = (i - 1) + (n / i - 1);
				if (c < min)
					min = c;
			}
		}
	}

	if (min == 1000000000000)cout << n - 1 << endl;
	else cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
x = sorted(map(int, input().split()))
if n >= m:
    print(0)
else:
    dif = []
    for i in range(m-1):
        dif.append(x[i + 1] - x[i])
    dif = sorted(dif)
    for _ in range(n-1):
        dif.pop()
    print(sum(dif))

Measured memory_bytes: 13968
import numpy as np
N,M,C = map(int,input().split())
B = input().split()
B = np.array([int(i) for i in B])
A = np.array([list(map(int, input().split())) for _ in range(N)])
count = 0
for i in range(N):
    if np.dot(B,A[i])+C>0:
        count+=1
print(count)

Measured memory_bytes: 12432
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A, B, C, D;
		int start, end;
		int ans;

		A = Integer.parseInt(sc.next());
		B = Integer.parseInt(sc.next());
		C = Integer.parseInt(sc.next());
		D = Integer.parseInt(sc.next());

		if(B < C || D < A){
			ans = 0;
		}else{
			start = Math.max(A, C);
			end = Math.min(B, D);
			ans = end - start;
		}

		System.out.println(ans);

	}

}

Measured memory_bytes: 23892
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <map>

using namespace std;

int main()
{
    int64_t objects, max_weight;
    cin >> objects >> max_weight;

    map<int64_t, int64_t> max_values;
    max_values[0] = 0;

    for (int64_t i = 0; i < objects; i += 1) {
        int64_t weight, value;
        cin >> weight >> value;

        map<int64_t, int64_t> new_values(max_values);
        for (const auto &p : max_values) {
            auto new_weight = p.first + weight;
            auto new_value = p.second + value;

            if (new_weight <= max_weight) {
                new_values[new_weight] = max(new_values[new_weight], new_value);
            }
        }
        max_values = new_values;
    }

    int64_t res = 0;
    for (const auto &p : max_values) {
        res = max(res, p.second);
    }

    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
	public static void main(String[]  args) {
		Scanner scanner = new Scanner(System.in);

		int n = scanner.nextInt();
		int a[][] = new int[n][n];
		
		for (int i = 0; i < n; i ++) {
			int u = scanner.nextInt() - 1;
			int k = scanner.nextInt();
			
			for (int j = 0; j < k; j ++) {
				a[u][scanner.nextInt() - 1] = 1;
			}
		}

		scanner.close();
		
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < n - 1; j ++) {
				System.out.print(a[i][j] + " ");
			}
			System.out.println(a[i][n - 1]);
		}
	}
} 



Measured memory_bytes: 32324
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int m, k;
	cin >> m >> k;
	if(k > (1 << m) - 1){
		cout << -1 << endl;
	} else if(m == 1){
		if(k == 0){
			cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
		} else {
			cout << -1 << endl;
		}
	} else {
		for(int i = 0; i < (1 << m); i++){
			if(i != k) cout << i << " ";
		}
		cout << k << " ";
		for(int i = (1 << m) - 1; i >= 0; i--){
			if(i != k) cout << i << " ";
		}
		cout << k << endl;
	}
}

Measured memory_bytes: 1792
#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() {
  int N; cin >> N;
  int ans = 0;
  for(int i = 1; i <= N; i++)
    if(to_string(i).size()%2 != 0) ans++;

  cout << ans << endl;
}


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

int main(int argc, char *argv[]){
	int max[3]={0,0,0};
	int tmp;
    for (int i=0; i < 10; ++i){
		cin >> tmp;
		if(max[0]<tmp ){
			max[2]=max[1]; max[1]=max[0]; max[0]=tmp; 
		}
		else if(max[1]<tmp ){
			max[2]=max[1]; max[1]=tmp; 
		}
		else if(max[2]<tmp ){
			max[2]=tmp; 
		}
	}

	for (int i = 0; i < 3; ++i){
		cout << max[i] << endl	;	
	}

    return 0;
}

Measured memory_bytes: 1160
N = int(input())
L = list(map(int,input().split()))
L.sort()
from bisect import bisect_left
ans = 0
for i in range(N-2):
    a = L[i]
    for j in range(i+1,N-1):
        b = L[j]
        k = bisect_left(L,a+b)
        ans += k-j-1
print(ans)

Measured memory_bytes: 3188
function Main(input) {
	var id = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
	var tmp = id.split(",");
	console.log(parseInt(tmp[input-1]));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
import sys
def input():
    return sys.stdin.readline()[:-1]
s=input()

for i in range(len(s)):
    if i%2==0:
        if s[i]=="L":
            print("No")
            quit()
    if i%2==1:
        if s[i]=="R":
            print("No")
            quit()

print("Yes")

Measured memory_bytes: 38384
a = sorted(list(map(int, input().split())))
ans = 0
if (a[0]%2==0 and a[1]%2==0) or (a[0]%2!=0 and a[1]%2!=0):
    ans = a[2]-a[1] + (a[2]-(a[0]+a[2]-a[1]))//2
else:
    ans = 1
    a[1] += 1
    a[2] += 1
    ans += (a[1]-a[0])//2 + a[2]-a[1]
print(ans)

Measured memory_bytes: 9200
#include<bits/stdc++.h>
 
#define REP(i,s,N) for (long long i=s;i<(N); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;


ll ans=0;

int main(){
	string S;
	cin >> S;
	ll K;
	cin >> K;
  string T;
  T=S;
  T[0] = '*';
	
  ll S_max = S.length();
  ll T_max = T.length();
  ll S_count = 0;
  ll T_count = 1;
 
  // S[S_max] = ' ';
	REP(i,0,S_max){
		if(S[i] == S[i+1]){
			S_count++;
            S[i+1] = '*';
		}
	}
  
  
 
   // T[T_max] = ' ';
  	REP(i,0,T_max){
		if(T[i] == T[i+1]){
			T_count++;
            T[i+1] = '*';
		}
	}
 // cout << S_count << endl;
 // cout << T_count << endl;

int a;
if(S[S_max-1]==S[0]){
  if(T[T_max-1]=='*'){
   ans = (K+1)/2 * S_count + K/2 * T_count;
    a =1;
  }else{
    ans = (K-1)*T_count + S_count;
    a =2;
  }
}else{
  ans = K*S_count;
  a=3;
}
  //cout << a << endl;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""
def main():
    K = int(input())
    A, B = map(int, input().split())
    answer = ""
    if A % K == 0:
        answer = "OK"
    elif (A//K + 1)*K <= B:
        answer = "OK"
    else:
        answer = "NG"
    print(answer)

if __name__ == "__main__":
    main()




Measured memory_bytes: 9180
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#include <bits/stdc++.h>
using namespace std;
//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;
const int mod = 1000000009;

int n,l,r,a[200010],tmp;
ll ret;

int main(){
    I(n);
    REP(i,n) I(a[i]);

    while( r < n ){
        while ((tmp | a[r]) != (tmp ^ a[r])){
            tmp ^= a[l];
            l++;
        }
        ret += (r-l+1);
        tmp |= a[r];

        r++;
    }
    cout << ret << endl;
}

Measured memory_bytes: 1024
use std::cmp::*;
use std::io::*; //Not mine.
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .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")
}
fn main() {
    let n: usize = read();
    let mut abc = vec![vec![0; 3]; n];
    let mut ans = vec![vec![0; 3]; n];
    for i in 0..n {
        abc[i] = (0..3).map(|_| read()).collect();
    }
    ans[0][0] = abc[0][0];
    ans[0][1] = abc[0][1];
    ans[0][2] = abc[0][2];
    let three: usize = 3;
    for i in 1..n {
        for j in 0..three {
            for k in 0..three {
                if j != k {
                    ans[i][k] = max(ans[i][k], ans[i - 1][j] + abc[i][k]);
                }
            }
        }
    }
    let mut out = 0;
    for i in 0..three {
        out = max(out, ans[n - 1][i]);
    }
    println!("{}", out);
}


Measured memory_bytes: 12824
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define N 100005
#define inf 1000000005
#define mod 1000000007
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define int ll
using namespace std;
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,t,l,a[N],b[N],c;
signed main(){
	n=read();l=read();t=read();c=1;
	F(i,1,n){
		a[i]=read();
		if (read()==1){
			c+=(a[i]+t)/l;
			b[i]=(a[i]+t)%l;
		}
		else{
			c-=(l-a[i]-1+t)/l;
			b[i]=((a[i]-t)%l+l)%l;
		}
	}
	c=(c%n+n)%n;if (c==0) c=n;
	sort(b+1,b+n+1);
	F(i,c,n) wrn(b[i]);
	F(i,1,c-1) wrn(b[i]);
	return 0;
}

Measured memory_bytes: 2816
#include <stdio.h>

main(){
    long h,n=1,w=3500;
    long N;

    scanf("%d",&N);

    for(h=1;h<3501;h++){
        if(!(N<4*h))continue;
        //printf("\rh=%d ...",h);
        for(n=h;n<=3500;n++){
            if(!(N*h<n*(4*h-N)))continue;
            for(;w>=n;w--){
                if(N*n*h<w*(4*h*n-N*h-N*n)){
                    continue;}
                if(4*h*n*w==N*(n*h+h*w+w*n)){
                    printf("%d %d %d\n",h,n,w);
                    return 0;
                }else break;
            }
        }w=3500;
    }
}


Measured memory_bytes: 128
H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]

yx = []
for i in range(H*W):
    y = i // W
    x = W - i % W - 1 if y % 2 else i % W 
    yx.append((y, x))

ans = []
for i in range(H*W-1):
    y, x = yx[i]
    if a[y][x] % 2:
        yd, xd = yx[i+1]
        a[y][x] -= 1
        a[yd][xd] += 1
        ans.append((y+1, x+1, yd+1, xd+1))

n = len(ans)
print(n)
for i in range(n):
    print(*ans[i])


Measured memory_bytes: 52180
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
print(N**3)


Measured memory_bytes: 66376
n = STDIN.gets.to_i
for i in 0.. n-1
  d = STDIN.gets.split(//)
  for j in 0.. d.length-1
    d[j] = d[j].to_i
  end
  puts (d.sort!.reverse*"")[0..7].to_i - (d*"").to_i
end

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;

signed main(){
    int n;
    cin >> n;
    vector<vector<int>> edges(n);
    for(int i = 0; i < n - 1; ++i){
        int a, b;
        cin >> a >> b;
        edges[--a].emplace_back(--b);
        edges[b].emplace_back(a);
    }
    vector<int> par(n, -2);
    vector<vector<int>> chi(n);
    vector<int> siz(n, 0);
    function<void(int,int)> f = [&](int x, int y){
        par[x] = y;
        if(x)
            siz[x] = siz[y] + 1;
        for(auto& ed : edges[x]){
            if(par[ed] == -2)
                f(ed, x);
            if(par[ed] == x)
                chi[x].push_back(ed);
        }
    };
    f(0, -1);
    vector<i64> mi(n, -MOD);
    vector<i64> ma(n, MOD);
    int q, qq;
    cin >> q;
    for(int i = 0; i < q; ++i){
        int a, b;
        cin >> a >> b;
        mi[--a] = b;
        ma[a] = b;
        qq = a;
    }
    vector<int> out(n);
    queue<int> que;
    for(int i = 0; i < n; ++i)
        if(!(out[i] = chi[i].size()))
            que.emplace(i);

    int fl = (siz[qq] ^ mi[qq]) & 1;
    for(int i = 0; i < n; ++i)
        siz[i] = (siz[i] ^ fl) & 1;

    auto g = [&]{

        while(!que.empty()){
            int t = que.front();
            que.pop();
            if(par[t] != -1 && !(--out[par[t]]))
                que.emplace(par[t]);

            for(auto& c : chi[t]){
                mi[t] = max(mi[t], mi[c] - 1);
                ma[t] = min(ma[t], ma[c] + 1);
            }
            if(mi[t] > ma[t]){
                cout << "No" << endl;
                return false;
            }
        }

        vector<i64> ans(n, INF);
        if((ma[0] & 1) != siz[0]){
            --ma[0];
        }
        if(ma[0] < mi[0]){
            cout << "No" << endl;
            return false;
        }
        ans[0] = ma[0];
        function<void(int)> gg = [&](int x){
            if(x){
                ma[x] = min(ma[x], ans[par[x]] + 1);
                mi[x] = max(mi[x], ans[par[x]] - 1);
                if((ma[x] & 1) != siz[x]){
                    --ma[x];
                }
                if(ma[x] < mi[x]){
                    cout << "No" << endl;
                    exit(0);
                }
                ans[x] = ma[x];
            }
            for(auto& c : chi[x])
                gg(c);
        };
        gg(0);
        // [mi[i], ma[i]]の範囲内なら子が条件を満たすように置ける
        for(int i = 0; i < n; ++i)
            if(mi[i] > ma[i]){
                cout << "No" << endl;
                return false;
            }

        cout << "Yes" << endl;
        for(int i = 0; i < n; ++i)
            cout << ans[i] << endl;
    };
    g();
}


Measured memory_bytes: 21632
#include <bits/stdc++.h>
#define P pair<int,int>
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dp[41][401][401];
int a[40], b[40], c[40];
int main() {
	int n, Ma, Mb;
	cin >> n >> Ma >> Mb;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i] >> c[i];
	}
	for (int i = 0; i < n + 1; i++) {
		for (int ca = 0; ca < 401; ca++) {
			for (int cb = 0; cb < 401; cb++) {
				dp[i][ca][cb] = INF;
			}
		}
	}
	dp[0][0][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int ca = 0; ca < 401; ca++) {
			for (int cb = 0; cb < 401; cb++) {
				if (dp[i][ca][cb] == INF) {
					continue;
				}
				dp[i + 1][ca][cb] = min(dp[i + 1][ca][cb], dp[i][ca][cb]);
				dp[i + 1][ca + a[i]][cb + b[i]] = min(dp[i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]);
			}
		}
	}
	int ans = INF;
	for (int ca = 1; ca < 401; ca++) {
		for (int cb = 1; cb < 401; cb++) {
			if (ca * Mb == cb * Ma) {
				ans = min(ans, dp[n][ca][cb]);
			}
		}
	}
	if (ans == INF) {
		cout << -1 << endl;
	} else {
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 25984
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
  var k = next();
  return a[k-1];
}

Measured memory_bytes: 22964
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; ++i)
#define rep(i, n) repl(i, 0, n)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using G = vector<vector<int>>;
const int MOD = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, -1, 0, 1};

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;
}

int main()
{
    int h, w, k;
	cin >> h >> w >> k;
	vector<string> s(h);
	rep(i, h) {
		cin >> s[i];
	}
	G ans(h, vector<int>(w));
	vector<int> cnt(h, 0);
	int num = 1;
	rep(i, h) {
		int last = 0;
		rep(j, w) {
			ans[i][j] = num;
			if(s[i][j] == '#') {
				cnt[i]++;
				num++;
				last = j+1;
			}
		}
		repl(k, last, w) {
			ans[i][k]--;
		}
	}
	int fi = 0;
	rep(i, h) {
		if(cnt[i] != 0) {
			fi = i;
			break;
		}
	}
	rep(i, h) {
		if(cnt[i] == 0) {
			if(i < fi) {
				rep(j, w) {
					ans[i][j] = ans[fi][j];
				}
			}
			else {
				rep(j, w) {
					ans[i][j] = ans[i-1][j];
				}
			}
		}
	}
	rep(i, h) {
		rep(j, w) {
			printf("%d%c", ans[i][j], j == w-1? '\n' : ' ');
		}
	}
    return 0;
}


Measured memory_bytes: 4256
N, M  = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
B = sorted(A, key = lambda x:x[0])
hon = 0
cost = 0
for i in range(N):
  hon += B[i][1]
  if hon >= M:
    cost += B[i][0]*(B[i][1]-(hon-M))
    break
  else:
    cost += B[i][0]*B[i][1]
print(cost)


Measured memory_bytes: 65368
//In the name of God
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout);
#define pb push_back
#define Mp make_pair
#define F first
#define S second

ll n, d[maxn], vis[maxn];
priority_queue<pll> q;

int main(){
    fast_io;

    cin >> n;
    fill(d, d + n, inf);
    q.push(Mp(0, 0));
    while(!q.empty()){
        ll v = q.top().S;
        ll x = -q.top().F;
        q.pop();
        if(vis[v]){
            continue;
        }
        if(v){
            if(d[v * 10 % n] > x){
                q.push(Mp(-x, v * 10 % n));
                d[v * 10 % n] = x;
            }
        }
        if(d[(v + 1) % n] > x + 1){
            q.push(Mp(-x - 1, (v + 1) % n));
            d[(v + 1) % n] = x + 1;
        }
    }
    cout << d[0];

    return 0;
}


Measured memory_bytes: 5048
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX_B 8

char board[MAX_B][MAX_B];

void scan_board(void);
void print_board(void);
void kibaku(int x, int y);
int check_scan(char *a);

int main(void) {
    int st_x, st_y, data_count, g;
    scanf("%d",&data_count);
    for(g = 1; g <= data_count; g++) {
        scan_board();
        //print_board();
        scanf("%d %d",&st_y, &st_x);
        kibaku(--st_x, --st_y);
        printf("Data %d:\n",g);
        print_board();
    }
    return 0;
}

void kibaku(int x, int y) {
    int i, j;
    board[x][y] = '0';
    //printf("%d %d\n",x, y);
    for(i = -3; i < 4; i++) {
        if(x + i >= 0 && x + i < 8) {
            if(board[x + i][y] == '1') {
                kibaku(x + i, y);
            }
        }
    }
    for(j = -3; j < 4; j++) {
        if(y + j >= 0 && y + j < 8) {
            if(board[x][y + j] == '1') {
                kibaku(x, y + j);
            }
        }
    }
}

void print_board(void) {
    int i, j;
    for(i = 0; i < MAX_B; i++) {
        for(j = 0; j < MAX_B; j++) {
            printf("%c",board[i][j]);
        }
        puts("");
    }
}

void scan_board(void) {
    int i, j;
    for(i = 0; i < MAX_B; i++) {
        scanf("%s",board[i]);
    }
}

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

int main()
{
  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    while (n--) {
      int pm, pe, pj;
      cin >> pm >> pe >> pj;
      if (pm == 100 || pe == 100 || pj == 100 || pm+pe >= 180 || pm+pe+pj >= 240)
	cout << "A" << endl;
      else if (pm+pe+pj >= 210 || (pm+pe+pj >= 150 && (pm >= 80 || pe >= 80)))
	cout << "B" << endl;
      else
	cout << "C" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int a[N];
int gcd(int n, int m)
{
	return m == 0 ? n : gcd(m, n % m);
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	n++;
	for (int i = 1; i <= n; i++) cin >> a[i];
	int g = 0;
	for (int i = 2; i <= n; i++)
	{
		g = gcd(g, abs(a[i] - a[i - 1]));
	}
	cout << g << endl;
	return 0;
}

Measured memory_bytes: 640
//itp1_10b
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
 int a,b,c;
 double s,l,h,cl;
 double rad=M_PI/180;

 cin>>a>>b>>c;
 cl=sqrt(a*a+b*b-2.0*a*b*cos(c*rad));
 h=b*sin(c*rad);
 l=a+b+cl;
 s=a*h/2.0;
 printf("%.8f\n",s);
 printf("%.8f\n",l);
 printf("%.8f\n",h);

 return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
#define MAX {INT_MAX,INT_MAX}
#define P pair<int,int>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;

int N;
P dat[600000];
void init(int n_) {
    N = 1;
    while (N < n_)N *= 2;
    for (int i = 0; i < 2 * N - 1; i++)dat[i] =MAX;
}
void update(int k, int a) {
    k += N - 1;
    dat[k] = {a,k-(N-1)};
    while (k > 0) {
        k = (k - 1) / 2;
        dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
}
P query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l)return MAX;
    if (a <= l&&r <= b)return dat[k];
    else {
        P vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        P vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
}
int bit[200008], n;
void add(int k, int x) {
	k++;
    while (k <= n) {
        bit[k] += x;
        k += k&-k;
    }
}
int sum(int k) {
	k++;
    int res = 0;
    while (k > 0) {
        res += bit[k];
        k -= k&-k;
    }
    return res;
}
signed main(){
	string a;cin>>a;
	int b;cin>>b;
	init(a.length());
	n=a.length()+5;
	for(int i=0;i<(int)a.length();i++){update(i,a[i]-'a');add(i,i);add(i+1,-i);}
	string ans;
	for(int i=0;i<(int)a.length();i++){
		int l=0,r=a.length()+1;//(l,r]
		while(r-l>1){
			int k=(l+r)/2;
			if(sum(k)<=b)l=k;
			else r=k;
			}
		P t=query(0,r,0,0,N);
		ans+=char(t.first+'a');
		add(t.second+1,-1);
		b-=sum(t.second);
		update(t.second,INT_MAX);
		}
	cout<<ans<<endl;
	}

Measured memory_bytes: 8280
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>

using namespace std;

int main(void)
{
    string s;
    while(cin>>s) {
        int n = s.length();
        int joi=0, ioi=0;
        for(int i=0; i<n-2; i++) {
            if(s[i] == 'J' && s[i+1] == 'O' && s[i+2] == 'I')
                joi++;
            if(s[i] == 'I' && s[i+1] == 'O' && s[i+2] == 'I')
                ioi++;
        }
        cout << joi << endl;
        cout << ioi << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
int main(){
  int s1, s2, s3;
  cin >> s1;
  s3 = s1 % 2;
  s2 = s1 / 10 % 2;
  s1 = s1 / 100;
  
  cout << s1 + s2 + s3 << endl;

}

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

using namespace std;
#define int long long
const int MOD = 1000000007;

vector<vector<pair<int, int> > > g;
vector<int> B;
void dfs(int a, int par, int d) {
	B[a] = d;
	for (auto p : g[a]) {
		if (p.first != par) {
			dfs(p.first, a, d ^ ((int)1 << p.second));
		}
	}
}
int pcnt(int a) {
	int res = 0;
	while (a > 0) {
		res += a % 2;
		a /= 2;
	}
	return res;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	g.resize(N);
	B.resize(N);
	int res = 0;
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].emplace_back(b, i);
		g[b].emplace_back(a, i);
	}
	dfs(0, -1, 0);
	int M;
	cin >> M;
	vector<int> C(M);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		C[i] = (B[a] ^ B[b]);
	}
	for (int i = 0; i < (1 << M); i++) {
		int x = 0;
		int cnt = 1;
		for (int j = 0; j < M; j++) {
			if (i & (1 << j)) {
				cnt = -cnt;
				x |= C[j];
			}
		}
		//cerr << i << " " << pcnt(x) << endl;
		res += cnt * ((int)1 << ((N - 1) - (pcnt(x))));
	}
	cout << res << endl;
}

Measured memory_bytes: 256
/* ****GT_18**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        string s;
        cin>>s;
        set<char> ss;
        sort(all(s));
        if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3])
            cout<<"Yes";
        else
            cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define INF 100000005
#define MAX 1002
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

int b[201][3];
int main(){
	int n, a[201][3], ans;
	scanf("%d", &n);
	rep(i,n)rep(j,3){
		scanf("%d", &a[i][j]);
		b[a[i][j]][j]++;
	}
	for(int i = 0;i < n;i++){
		ans = 0;
		for(int j = 0;j < 3;j++){
			if(b[a[i][j]][j] < 2)ans += a[i][j];
		}
		printf("%d\n", ans);
	}
	return 0;
}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)+1):((m)-(n)+1)),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

vector<string> sp(string s) {
  vector<string>r;
  int idx=0;
  rep (i, s.size()) {
    if (s[i] == ' ') {
      r.push_back(s.substr(idx, i - idx));
      idx = i + 1;
    }
  }
  r.push_back(s.substr(idx,s.size()));
  return r;
}

int main() {

  for (string s;;) {
    getline(cin, s);
    if (s == "END OF INPUT") break;
    auto v = sp(s);
    for (string w : v) {
      cout << w.size();
    } cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1192
#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,ans;
    string a="Sunny",b="Cloudy",c="Rainy";
    cin>>s;

    if (s==a) ans=b;
    else if(s==b) ans=c;
    else ans=a;

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,M;
    cin >> N >> M;
    vector<int> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(),A.end());
    int S = 1;
    for(int i = 1; i < N; i++){
        if(A[i-1] != A[i]) S++;
    }
    vector<int> B(S);
    int j = 0;
    B[j] = 1;
    for(int i = 1; i < N; i++){
        if(A[i-1] == A[i]) B[j]++;
        else{
            j++;
            B[j]++;
        }
    }
    int ans = 0;
    sort(B.begin(),B.end());
    int i = 0;
    while(M < S){
        ans += B[i];
        S--;
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<ctype.h>
int main(void){
   char s[201];
   char a[201];
   char x[5];
   int m,h;
   int len;
   int i,j;

   sprintf(x,"-");
   scanf("%s",s);
   while(strcmp(s,x)){
      len=strlen(s);
      scanf("%d",&m);
      for(i=0;i<m;i++){
         scanf("%d",&h);
         for(j=0;j<h;j++){
            a[j]=s[j];
         }
         for(j=0;j<len-h;j++){
            s[j]=s[j+h];
         }
         for(j=0;j<h;j++){
            s[len-h+j]=a[j];
         }
      }
      printf("%s\n",s);
      scanf("%s",s);
   }
}

Measured memory_bytes: 592
import java.util.*;
import java.io.*;
import java.math.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main{
    static long mod=1000000007;
    // static int dx[]={1,-1,0,0};
    // static int dy[]={0,0,1,-1};
    // static int dx[]={1,-1,0,0,1,1,-1,-1};
    // static int dy[]={0,0,1,-1,1,-1,1,-1};
    // PriorityQueue<Integer> que = new PriorityQueue<Integer>(); 
    //HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
    //ArrayList<Integer> lis = new ArrayList<Integer>();
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int d=sc.nextInt();
        String ans="NO";
        for( int i=0; i<=n-1; i++){
            if( a+(long)i*d+(long)(n-i-1)*(-c) >= b && 
                a+(long)i*c+(long)(n-i-1)*(-d) <= b )
                {ans="YES";break;}
        }

        out.println(ans);       
        out.flush();
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }

    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }
     
    static boolean bit(long x,int k){
        // weather k-th bit (from right) be one or zero
        return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
    }
}

class Pair implements Comparable<Pair>{
    int x,y;
    Pair(int x, int y) {
        this.x=x;
        this.y=y;
    } 
    public int compareTo(Pair p){//descend
        return p.x - x;
    } 

}

class P implements Comparable<P>{
    int diff,id1,id2;
    P(int diff, int id1,int id2) {
        this.diff=diff;
        this.id1=id1;
        this.id2=id2;
    } 
      
    public int compareTo(P p){//ascend
        return diff - p.diff;
    } 
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

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


struct dat{
  ll v,f;
};

int n;
ll A[N];
dat dp[N][N];

int main(){
  
  cin>>n;

  for(int i=0;i<n;i++) cin>>A[i];

  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++) dp[i][j].v=0,dp[i][j].f=0;

  for(int i=0;i<n;i++) dp[i][i].v=A[i];

  for(int i=0;i<n-1;i++){

    for(int l=0;l<n;l++){
      
      int r=(l+i)%n;

      if(dp[l][r].f==0){

	if(A[(l-1+n)%n]>A[(r+1)%n])dp[(l-1+n)%n][r].v=max(dp[(l-1+n)%n][r].v,dp[l][r].v);
	else dp[l][(r+1)%n].v=max(dp[l][(r+1)%n].v,dp[l][r].v);
	
      }else{
	
	dp[(l-1+n)%n][r].v=max(dp[(l-1+n)%n][r].v,dp[l][r].v+A[(l-1+n)%n]);
	dp[l][(r+1)%n].v=max(dp[l][(r+1)%n].v,dp[l][r].v+A[(r+1)%n]);
	
      }
      
      dp[(l-1+n)%n][r].f=dp[l][(r+1)%n].f=!dp[l][r].f;
      
      
    }

  }

  ll ans=0;
  
  for(int l=0;l<n;l++)
    for(int r=0;r<n;r++) ans=max(ans,dp[l][r].v);
  
  cout<<ans<<endl;
  
  return 0;
}

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

int main (){
  int a,b,c;cin>>a>>b>>c;
  
  if(a==b && b==c){
    cout<<1;
    }else if(a==b||b==c||c==a){
    cout<<2;
    } else {
    cout<<3;
    }
  cout<<endl;
  
  return 0;
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
const int N=505;
int n,m,d[N][N],c[N][N],f[3][N];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	  for(int j=1;j<=m;j++)
	    scanf("%d",&d[i][j]);
	for(int i=1;i<=n;i++)
	  for(int j=1;j<=n;j++)
	    scanf("%d",&c[i][j]);
//	for(int i=1;i<=n;i++)
//	  for(int j=1;j<=n;j++)
//	    v[(i+j)%3].push_back(pii(i,j));
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			for(int k=1;k<=n;k++){
				f[(j+k)%3][i]+=d[c[j][k]][i];
			}
		}
	}
	int ans=1e9;
	for(int i=1;i<=m;i++)
	  for(int j=1;j<=m;j++)
	    for(int k=1;k<=m;k++)
	      if(i!=j&&j!=k&&k!=i)
	        ans=min(ans,f[0][i]+f[1][j]+f[2][k]);
	cout<<ans<<endl;
	return 0;
}


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

int main()
{
    int h, w;
    cin >> h >> w;

    vector<string> s(h);
    for (int i = 0; i < h; i++) cin >> s[i];

    vector<int> ign, ignr;
    for (int i = 0; i < h; i++) {
        bool f = false;
        for (int j = 0; j < w; j++) {
            f += s[i][j] == '#';
        }
        if (f) continue;
        ignr.push_back(i);
    }
    for (int j = 0; j < w; j++) {
        bool f = false;
        for (int i = 0; i < h; i++) {
            f += s[i][j] == '#';
        }
        if (f) continue;
        ign.push_back(j);
    }

    int idxr = 0;
    for (int i = 0; i < h; i++) {
        int idx = 0;
        if (ignr.size() && ignr[idxr] == i) {
            idxr++;
            continue;
        }
        for (int j = 0; j < w; j++) {
            if (ign.size() && ign[idx] == j) {
                idx++;
                continue;
            }
            cout << s[i][j];
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int main()
{
    int n; cin >> n;
    int A[n], B[n];
    for (int i = 0; i < n; i++)
    {
        cin >> A[i] >> B[i];
    }
    sort(A, A+n); sort(B, B+n);
    if (n % 2 == 1)
    {
        cout << B[n/2] - A[n/2] + 1 << '\n';
    }
    else
    {
        cout << B[n/2] + B[n/2-1] - A[n/2] - A[n/2-1] + 1 << '\n';
    }
    return 0;
}

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

int X, Y, Z;

int main(){
    scanf("%d%d%d", &X, &Y, &Z);
    int cnt = 0;
    int total = Y +Z;
    while(total + Z <= X) {
        total += Y + Z;
        cnt++;
    }
    printf("%d", cnt);
    return 0;
}


Measured memory_bytes: 256