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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll H,W;
ll N;
ll a[10005];
ll grid[105][105];

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>H>>W>>N;

rep(i,N) cin>>a[i];

ll color=0;
rep(h,H){
	if(h%2==0){
		rep(w,W){
		grid[h][w]=color+1;
		a[color]--;
		if(a[color]==0) color++;
		}
	}else{
		rep(w,W){
		ll ww=W-1-w;
		grid[h][ww]=color+1;
		a[color]--;
		if(a[color]==0) color++;
		}
	}
}

rep(h,H){
	rep(w,W){
		if(w==W-1) cout<<grid[h][w];
		else cout<<grid[h][w]<<" ";
	}
	cout<<endl;
}

}
	


Measured memory_bytes: 512
K = int(input())

def snuke(n):
  sum_num = sum(map(int, list(str(n))))
  return n / sum_num

ans = 1
digit = 0
while K > 0:
  print(ans)
  if snuke(ans + 10**digit) > snuke(ans + 10**(digit+1)):
    digit += 1
  ans += 10**digit
  K -= 1

Measured memory_bytes: 3188
let readIntArray _ =
    stdin.ReadLine().Split(" ") |> Array.map int

let rec solve count list =
    match list with
    | (num1, c1, a1) :: (num2, c2, a2) :: xx ->
        if num2 - num1 = 1
        then solve (c1 + a1 + count) ((num2, c2, a2) :: xx)
        else solve (c1 + count) ((num2, c2, a2) :: xx)
    | [ (_, c1, _) ] -> solve (c1 + count) []
    | [] -> count

stdin.ReadLine()
|> readIntArray
|> Array.indexed
|> Array.sortBy snd
|> Array.zip
<| (readIntArray ())
|> Array.map (fun ((i, n), a) -> (i, n, a))
|> Array.zip (Array.append (readIntArray ()) [| 0 |])
|> Array.sortBy (fun (_, (i, _, _)) -> i)
|> Array.map (fun (a, (_, i, c)) -> (i, c, a))
|> Array.toList
|> solve 0
|> printfn "%d"


Measured memory_bytes: 30128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <utility>
#include <map>
int main(){
	int N,M,X;
	std::cin >> N >> M >> X;
    int cost1=0,cost2=0,input;
    for(int i=0;i<M;i++){
        std::cin >> input;
        if(input < X){
            cost1++;
        }else{
            cost2++;
        }
    }
    std::cout << std::min(cost1,cost2) <<std::endl;
    return 0;
}

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

inline namespace atcoder {
    using i32 = int32_t; using u32 = uint32_t;
    using i64 = int64_t; using u64 = uint64_t;
    using f32 = float; using f64 = double;

    template <typename T, size_t Depth>
    struct vector_helper { using type = vector<typename vector_helper<T, Depth - 1>::type>; };
    template <typename T>
    struct vector_helper<T, 0> { using type = T; };
    template <typename T, size_t Depth>
    using vector_t = typename vector_helper<T, Depth>::type;

    template <typename T> using vec = vector_t<T, 1>;
    template <typename T> using vvec = vector_t<T, 2>;
    template <typename T> using vvvec = vector_t<T, 3>;
}

int main() {
    int bingo[3][3];
    for (auto &e1 : bingo) for (auto &e2 : e1) cin >> e2;
    int n; cin >> n;

    bool hole[3][3];
    for (auto &e1 : hole) for (auto &e2 : e1) e2 = false;

    while (n--) {
        int b; cin >> b;
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                if (bingo[i][j] == b) {
                    hole[i][j] = true;
                }
            }
        }
    }

    cout << (
        (hole[0][0] && hole[0][1] && hole[0][2]) ||
        (hole[1][0] && hole[1][1] && hole[1][2]) ||
        (hole[2][0] && hole[2][1] && hole[2][2]) ||
        (hole[0][0] && hole[1][0] && hole[2][0]) ||
        (hole[0][1] && hole[1][1] && hole[2][1]) ||
        (hole[0][2] && hole[1][2] && hole[2][2]) ||
        (hole[0][0] && hole[1][1] && hole[2][2]) ||
        (hole[0][2] && hole[1][1] && hole[2][0])
        ? "Yes" : "No"
    ) << endl;
}



Measured memory_bytes: 3640
from bisect import bisect_left
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    L = [int(i) for i in readline().split()]
    L.sort()

    ans = 0
    for i in range(N-1):
        L_i = L[i]
        for j in range(i+1, N):
            idx = bisect_left(L, L_i + L[j])
            ans += idx - (j + 1)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define INT long long
#define oo 6e18
using namespace std;
INT n, x, a[110], ans;

int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>x;
    for(int i = 0 ; i < n ; i++ ) cin>>a[i];
    sort(a, a+n);
    for(int i = 0 ; i < n ; i++ )
    {
        if( i < n-1 )
        {
            if( x >= a[i] ) x -= a[i], ans++;
        }
        else if( x == a[i] ) ans++;

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


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

int main(){
  int n;
  cin >> n;
  int d[n];
  int i,j;
  int ans=0;

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

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
        ans += d[i] * d[j];
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <stdlib.h>
#include <algorithm>

#define rep(i,s,t) for(int i=s;i<t;i++)
#define mp(a,b) make_pair(a,b)
#define mii map<int,int>

using namespace std;

int main(void){

	while(true){
		int M,T,P,R;
		cin >> M >> T >> P >> R;

		map<int,map<int,set<int,greater<int> > >,greater<int> > standing;

		int solve[T+1];
		int time[T+1];
		int pena[T+2][P+1];
		rep(i,0,T+1){
			solve[i]=0;
			time[i]=0;
			rep(j,0,P+1)
				pena[i][j]=0;
		}

		if(M==0 && T==0 && P==0 && R==0) break;

		rep(rnd,0,R){
			int m,t,p,j;
			cin >> m >> t >> p >> j;
			if(j==0){
				solve[t]++;
				time[t]+=m+pena[t][p]*20;
			}else{
				pena[t][p]++;
			}
		}

		rep(i,1,T+1)
			standing[solve[i]][time[i]].insert(i);

		int cnt=0;
		for(map<int,map<int,set<int,greater<int> > >,greater<int> > ::iterator it=standing.begin();it!=standing.end();it++){
			map<int,set<int,greater<int> > > inmp=(*it).second;
			for(map<int,set<int,greater<int> > >::iterator jt=inmp.begin();jt!=inmp.end();jt++){
				set<int,greater<int> > inset=(*jt).second;
				int size=inset.size();
				for(set<int,greater<int> >::iterator kt=inset.begin();kt!=inset.end();kt++){
					cout << (*kt);
					cnt++;
					if(--size>0) cout << "=";
				}
				if(cnt<T) cout << ",";
			}
		}
		cout << endl;


	}
	

	return 0;
}

Measured memory_bytes: 1216
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

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

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	vector<int> nv;
	int N, K;
	cin >> N >> K;
	REP(i, N) {
		int num;
		cin >> num;
		nv.push_back(num);
	}
	sort(nv.begin(), nv.end());

	vector<int> kv;
	kv.push_back(1);
	REPS(i, 1, nv.size()) {
		if (nv[i] != nv[i - 1]) {
			kv.push_back(1);
		}
		else {
			kv.back()++;
		}
	}
	sort(kv.begin(), kv.end());
	reverse(kv.begin(), kv.end());

	int ans = 0;
	if (kv.size() > K) {
		REPS(i, K, kv.size()) {
			ans += kv[i];
		}
	}
	cout << ans;
	system("pause");
	return 0;
}

Measured memory_bytes: 2548
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <fstream>
#include <string>
#include <sstream>
#include <math.h>
#include <set>
#include <map>
using namespace std;
#define rep(i,n) for(int i = 0; i < n ; i++)
#define pb push_back
static const int MAX = 100000;
static const int INF = 1000000;

typedef pair<int, int> P;
typedef pair<P, int> PP;

int main(void){
  int V,E; cin >> V >> E;
  vector<int> list[MAX]; int into[V];
  int a,b;
  rep(i,V){
    into[i] = 0;
  }
  rep(i,E){
    cin >> a >> b;
    list[a].pb(b);
    into[b] += 1;
  }
  queue<int> Q;
  rep(i,V){
    if (into[i] == 0) Q.push(i);
  }

  while(!Q.empty()){
      cout << Q.front() << endl;

      //cout << endl;

      rep(i,list[Q.front()].size()){
        into[list[Q.front()][i]] -= 1;
        if(into[list[Q.front()][i]] == 0) Q.push(list[Q.front()][i]);
      }


      Q.pop();
  }




  return 0;
}

Measured memory_bytes: 5856
#include <cstdio>
using namespace std;

int main(){
    int A, B;
//    int landscape;
    bool fl = true;
    int dotVBlocks, sharpVBlocks;

    scanf("%d%d",&A, &B);

    dotVBlocks = (A-1) / 50;
    sharpVBlocks = (B-1) / 50;

    printf("%d %d\n",dotVBlocks*2+sharpVBlocks*2+4,100);

    for(int i = 0; i < dotVBlocks; i++){
        fl = true;
        for(int j = 0; j < 100; j++){
            if(fl) printf("#");
            else printf(".");
            fl = !fl;
        }
        printf("\n");
        for(int j = 0; j < 100; j++){
            printf("#");
        }
        printf("\n");
    }

    fl = true;
    for(int j = 0; j < 100; j++){
        if(fl) printf("#");
        else if(j <= ((A-1)%50)*2) printf(".");
        else printf("#");
        fl = !fl;
    }
    printf("\n");


    for(int j = 0; j < 100; j++){
        printf("#");
    }
    printf("\n");

    for(int j = 0; j < 100; j++){
        printf(".");
    }
    printf("\n");


    fl = true;
    for(int j = 0; j < 100; j++){
        if(fl) printf(".");
        else if(j <= ((B-1)%50)*2) printf("#");
        else printf(".");
        fl = !fl;
    }
    printf("\n");


    for(int i = 0; i < sharpVBlocks; i++){
        for(int j = 0; j < 100; j++){
            printf(".");
        }
        printf("\n");
        fl = true;
        for(int j = 0; j < 100; j++){
            if(fl) printf("#");
            else printf(".");
            fl = !fl;
        }
        printf("\n");
    }


/*
    landscape = (A+B)*2-2;

    printf("2 %d\n",landscape);

    for(int i = 0; i < landscape; i++){
        if(i <= A*2-2) printf("#");
        else printf(".");
    }

    printf("\n");

    for(int i = 0; i < landscape; i++){
        if(fl) printf("#");
        else printf(".");
        fl = !fl;
    }
    printf("\n");
*/
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

class Main {
	public static Scanner sc = new Scanner(in);
	public static Random rand=new Random();

	public void run() {


		while(true){
			int n=sc.nextInt(),r=sc.nextInt();
			if(n==0 && r==0)return;
			int[] ca=new int[n];
			for(int i=0;i<n;i++){
				ca[i]=n-i;
			}

			while(r--!=0){
				int[] cp=Arrays.copyOf(ca,n);
				int p=sc.nextInt()-1,c=sc.nextInt();
				for(int i=0;i<c;i++){
					ca[i]=cp[p+i];
				}
				for(int i=0;i<p;i++){
					ca[i+c]=cp[i];
				}
			}
			ln(ca[0]);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}

	public int[] nextIntArray(int n){
		int[] res=new int[n];
		for(int i=0;i<n;i++){
			res[i]=sc.nextInt();
		}
		return res;
	}
	public static void pr(Object o) {
		out.print(o);
	}
	public static void ln(Object o) {
		out.println(o);
	}
	public static void ln() {
		out.println();
	}
}

Measured memory_bytes: 29780
from itertools import chain

def swap(head, tail):
    return (tail, head)

s = list(input())
q = int(input())

head = []
tail = []
count = 0

for _i in range(q):
    query = input()
    if query == "1":
        count += 1
        head, tail = swap(head, tail)
    else:
        _n, f, c = tuple(query.split())
        if f == "1":
            head.append(c)
        else:
            tail.append(c)

s = s if count % 2 == 0 else reversed(s)
print("".join(tuple(chain(reversed(head), s, tail))))


Measured memory_bytes: 8368
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int n, a, b, c;
int l[10];

int rec_func(int cur, int la, int lb, int lc){
    if (cur==n){
        if (la!=0&&lb!=0&&lc!=0){
            return abs(a-la) + abs(b-lb) + abs(c-lc) - 30;
        }else{
            return 10000;
        }
    }
    int ret0 = rec_func(cur+1, la, lb, lc);
    int ret1 = rec_func(cur+1, la+l[cur], lb, lc) + 10;
    int ret2 = rec_func(cur+1, la, lb+l[cur], lc) + 10;
    int ret3 = rec_func(cur+1, la, lb, lc+l[cur]) + 10;
    return min({ret0, ret1, ret2, ret3});
}


int main(){
    cin >> n >> a >> b >> c;

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

    int ans = rec_func(0, 0, 0, 0);
    cout << ans << endl;
}

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

int main() {
  int d;
  cin >> d;
  if (d == 22) {
    cout << "Christmas Eve Eve Eve" << endl;
  } else if (d == 23) {
    cout << "Christmas Eve Eve" << endl;
  } else if (d == 24) {
    cout << "Christmas Eve" << endl;
  } else if (d == 25) {
    cout << "Christmas" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#define inf 2147483647
#define N 1000010
#define p(a) putchar(a)
#define For(i,a,b) for(int i=a;i<=b;++i)

using namespace std;
int x,y;
void in(int &x){
    int y=1;char c=getchar();x=0;
    while(c<'0'||c>'9'){if(c=='-')y=-1;c=getchar();}
    while(c<='9'&&c>='0'){ x=(x<<1)+(x<<3)+c-'0';c=getchar();}
    x*=y;
}
void o(int x){
    if(x<0){p('-');x=-x;}
    if(x>9)o(x/10);
    p(x%10+'0');
}

signed main(){
    in(x);in(y);
    o((x*3+y)/2);
    return 0;
}

Measured memory_bytes: 256
n, k, q = gets.split.map(&:to_i)
count = Array.new(n, 0)
q.times do
  num = gets.to_i
  count[num-1] += 1
end

n.times do |i|
  ops = q - count[i]
  if k - ops > 0
    puts "Yes"
  else
    puts "No"
  end
end


Measured memory_bytes: 3196
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <vector>
using namespace std;

class Dice
{
	
private:
	int pips[6];
	
public:
	Dice(const int*);
	int get_top();
	void roll_north();
	void roll_south();
	void roll_east();
	void roll_west();
	bool compare(const Dice*);
};

///////////////////////////////////////
Dice::Dice(const int* pips)
{
	for(int i = 0; i < 6; ++i)
	{
		this->pips[i] = pips[i];
	}
	
	srand( time(NULL) );
}

///////////////////////////////////////
int Dice::get_top()
{
	return pips[0];
}

////////////////////////////////////////
void Dice::roll_north()
{
	int temp;
	temp = pips[0];
    pips[0] = pips[1];
    pips[1] = pips[5];
    pips[5] = pips[4];
    pips[4] = temp;
}

////////////////////////////////////////
void Dice::roll_south()
{
	int temp;
	temp = pips[0];
    pips[0] = pips[4];
    pips[4] = pips[5];
    pips[5] = pips[1];
    pips[1] = temp;
}

////////////////////////////////////////
void Dice::roll_east()
{
	int temp;
	temp = pips[0];
    pips[0] = pips[3];
    pips[3] = pips[5];
    pips[5] = pips[2];
    pips[2] = temp;
}

////////////////////////////////////////
void Dice::roll_west()
{
	int temp;
	temp = pips[0];
    pips[0] = pips[2];
    pips[2] = pips[5];
    pips[5] = pips[3];
    pips[3] = temp;
}

//////////////////////////////////////////
bool Dice::compare(const Dice* other)
{
	for(int i = 0; i < 6; ++i){
		if(i == 4) roll_east();
		if(i == 5) roll_north();
		roll_north();
		
		for(int j = 0; j < 4; ++j){
			roll_east();
			
			for(int k = 0; k < 6; ++k){
				if(pips[k] != other->pips[k]) break;
				if(k == 5) return true;
			}}}
	
	return false;
}





int main()
{
	int n;
	int pips[6];
	vector<Dice*> dices;
	
	cin >> n;
	
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < 6; ++j){
			
			cin >> pips[j];
		}
		dices.push_back(new Dice(pips));
	}
	
	
	
	
	
	for(int i = 0; i < n-1; ++i){
		for(int j = i+1; j < n; ++j){
			
			if(dices[i]->compare(dices[j])){
				cout << "No" << endl;
				return 0;
			}}}
	
	cout << "Yes" << endl;
	
	return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
const int N=4e6+5;
bitset<N>f;
int main(){
	int n,s=0;cin>>n;f[0]=1;
	for(int i=0,x;i<n;i++)cin>>x,f|=f<<x,s+=x;
	for(int i=(s+1)/2;i<=s;i++)if(f[i]){cout<<i;break;}
	return 0;
}

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

int main(){
  	int N,i;
  	scanf("%d",&N);
  	
	char str[N][100],X[100];
  	int num[N];
    
  	for(i=0;i<N;i++){
    	scanf("%s %d",str[i],&num[i]);
    }
  	scanf("%s",X);
  	//printf("%s\n",X);
  	int cnt = 0;
  	int sum = 0;
  	for(i = 0; i< N;i++){
  		if(strcmp(X,str[i]) == 0){
          cnt = 1;
          num[i] = 0;
        //  printf("%s \n",str[i]);
        }
    	if (cnt == 1) {
          sum = sum + num[i]; 
          
        }
    }
  	printf("%d",sum);
return 0;
}

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

const int N = 1e5 + 1;

int dp[N];
vector < int > t[N];

int func(int v)
{
	if(dp[v] != 0)
	{
		return dp[v];
	}
	
	int res = 0;
	
	for(int i: t[v])
	{
		res = max(res, func(i));
	}
	
	dp[v] = res + 1;
	
	return res + 1;
}



int main()
{
	int n, m;
	cin >> n >> m;
	
	for(int i = 0; i < m; i++)
	{
		int x, y;
		cin >> x >> y;
		t[x].push_back(y);
	}
	
	int res = 0;
	
	for(int v = 1; v <= n; v++)
	{
		if(dp[v] == 0)
		{
			func(v);
		}
		
		res = max(res, dp[v]);
	}
	
	cout << res - 1;
	
	return 0;
}

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

int main()
{
  int n, x;
  cin >> n >> x;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int ans = 0;

  int i = 0;
  while (x >= a[i]) {
    if (i + 1 == n) {
      if (x == a[i]) ans++;
      break;
    }
    x -= a[i];
    ans++;
    i++;
  }
  cout << ans << endl;
}


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

using namespace std;


int main(){
  string s;
  cin>>s;
  int isa=0,isb=0;
  for(int i=0;i<3;i++){
      if(s[i]=='A'){
          isa=1;
      }
      if(s[i]=='B'){
          isb=1;
      }
  }
  
  if(isa==1 && isb==1){
      cout<<"Yes";
  }
  else{
      cout<<"No";
  }
  
  
  
  return 0;
}
 

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

using namespace std;

const int mod = 1e9 + 7;

int N;
vector< int > g[201];
bool beet[200];
int dp1[201][201];
int dp2[201][201][201];
int child[201];


void rec(int idx)
{
  for(auto &to : g[idx]) {
    rec(to);
    child[idx] += child[to];
  }
  ++child[idx];

  if(g[idx].empty()) {
    dp1[idx][1] = 1;
    return;
  }

  int now = 0;
  vector< int > cur(1, 0);
  cur[0] = 1;
  for(auto &to : g[idx]) {
    vector< int > nxt(now + child[to] + 1, 0);
    for(int i = 0; i <= now; i++) {
      for(int j = 0; j <= child[to]; j++) {
        for(int k = 0; k <= now + child[to]; k++) {
          (nxt[k] += (1LL*cur[i] * dp1[to][j] % mod * dp2[i][j][k] % mod)) %= mod;
        }
      }
    }
    now += child[to];
    cur.swap(nxt);
  }
  for(int i = 1; i <= child[idx]; i++) {
    dp1[idx][i] = cur[i - 1];
  }
}

int main()
{
  cin >> N;
  for(int i = 1; i < N; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    beet[b] = true;
  }

  int sub = 200;
  for(int i = 0; i < N; i++) {
    if(!beet[i]) g[sub].push_back(i);
  }

  dp2[0][0][0] = 1;
  for(int i = 0; i < 201; i++) {
    for(int j = 0; j < 201; j++) {
      for(int k = 0; k < 201; k++) {
        if(i && j && k) (dp2[i][j][k] += dp2[i - 1][j - 1][k - 1]) %= mod;
        if(i && k) (dp2[i][j][k] += dp2[i - 1][j][k - 1]) %= mod;
        if(j && k) (dp2[i][j][k] += dp2[i][j - 1][k - 1]) %= mod;
      }
    }
  }

  rec(sub);
  int ret = 0;
  for(int i = 0; i <= N + 1; i++) (ret += dp1[sub][i]) %= mod;
  cout << ret << endl;
}

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

#define INF (1<<29)

set<string> st;

void solve(int K, int S, vector<string> &s, string str)
{
    if (K == 0) {
        st.insert(str);
        return;
    }
    
    int N = s.size();
    for (int i = 0; i < N; i++) {
        if (S >> i & 1) continue;
        solve(K-1, S|(1<<i), s, str + s[i]);
    }
}

int main()
{
    int N, K;
    while (cin >> N, N) {
        vector<string> s(N);
        cin >> K;
        for (int i = 0; i < N; i++) {
            cin >> s[i];
        }
        st.clear();
        solve(K, 0, s, "");
        cout << st.size() << endl;
    }
    return 0;
}

Measured memory_bytes: 3476
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  string s;
  cin>>s;
  if(n>=3200)
  {
    cout<<s<<"\n";
  }
  else
  {
    cout<<"red\n";
  }
  return 0;
}

Measured memory_bytes: 256
object Main extends App {
	val nh = scala.io.StdIn.readLine.split(" ").map(_.toLong)
	var a = new Array[Long](nh(0).toInt)
	var b = new Array[Long](nh(0).toInt)

	for(i<-0 until nh(0).toInt){
		val temp = scala.io.StdIn.readLine.split(" ").map(_.toLong)
		a(i) = temp(0)
		b(i) = temp(1)
	}

	b = b.sorted.reverse

	val max = a.max
	var ans = 0
	var temp = nh(1)

	for(i<-0 until nh(0).toInt){
		if(temp <=0){

		}else if(b(i) >= max){
			temp -= b(i)
			ans += 1
		}
	}

	if(temp <=0) println(ans)
	else println(ans + (temp + max - 1)/max)


}

Measured memory_bytes: 53344
def factorial(n):
  ans = 1
  for i in range(n):
    ans *= i+1
    ans %= mod
  return ans


mod = 998244353
n = int(input())
s = input()
ans = 1
r,g,b = 0,0,0
rg,rb,gb = 0,0,0
for i in s:
  if i == "R":
    if gb > 0:
      ans *= gb
      gb -= 1
    elif g > 0:
      ans *= g
      g -= 1
      rg += 1
    elif b > 0:
      ans *= b
      b -= 1
      rb += 1
    else:
      r += 1
  elif i == "G":
    if rb > 0:
      ans *= rb
      rb -= 1
    elif r > 0:
      ans *= r
      r -= 1
      rg += 1
    elif b > 0:
      ans *= b
      b -= 1
      gb += 1
    else:
      g += 1
  elif i == "B":
    if rg > 0:
      ans *= rg
      rg -= 1
    elif r > 0:
      ans *= r
      r -= 1
      rb += 1
    elif g > 0:
      ans *= g
      g -= 1
      gb += 1
    else:
      b += 1
  ans %= mod
print((factorial(n) * ans) % mod)


Measured memory_bytes: 3956
#include <iostream>

int main()
{
    int n = 0, k = 0;
    std::cin >> n >> k;
    int i = 1;
    int kk = k;
    while (true)
    {
        if (kk > n) {
            break;
        }
        kk *= k;
        i++;
    }
    std::cout << i;

    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	s := iSScan(n)
	ans := sum(s)
	if ans%10 != 0 {
		fmt.Println(ans)
	} else {
		min := ans
		for _, v := range s {
			if v%10 != 0 {
				min = smaller(min, v)
			}
		}
		fmt.Println(ans - min)
	}
}


Measured memory_bytes: 1776
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double num1 = scanner.nextInt();
        double num2 = scanner.nextInt();
        double sum = num1 + num2;
        double avg = sum/2;
        System.out.println((int)Math.ceil(avg));
    }
}


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

int main()
{
  int n;
  cin >> n;
  cout << pow(n, 3) << endl;
  return 0;
}

Measured memory_bytes: 4120
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> to(n);
  vector<int> in(n);
  rep(i, n-1+m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    to[a].push_back(b);
    in[b]++;
  }
  queue<int> que;
  rep(i, n) {
    if (!in[i])
      que.push(i);
  }
  vector<int> tps;
  while (!que.empty()) {
    int a = que.front();
    que.pop();
    tps.push_back(a);
    for (auto e : to[a]) {
      in[e]--;
      if (!in[e])
        que.push(e);
    }
  }
  vector<int> ans(n);
  rep(i, n) {
    for (auto e : to[tps[i]])
      ans[e] = tps[i]+1;
  }
  rep(i, n)
    cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 7672
/*
    Problem 45
    https://onlinejudge.u-aizu.ac.jp/problems/2199
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const ll LINF = 1LL << 50;
const int YMAX = 256;
const int YMIN = 0;
const int NMAX = 20004;
const int MMAX = 20;
/* global variables */
vector<ll> input(NMAX);
vector<int> code(MMAX);
vector<vector<ll>> dp(NMAX, vector<ll>(YMAX, LINF));
/* function */
void calc(int N, int M) {
    for (int i = 0; i < M; i++) cin >> code[i];
    for (int i = 0; i < N; i++) cin >> input[i];

    // init
    for (int i = 0; i <= N; i++) for (int j = YMIN; j < YMAX; j++) dp[i][j] = LINF;
    dp[0][128] = 0;  // y0 = 128
    // calc
    // dp[i][j]
    // iこ目のinpuまで圧縮して, yi == jである時の最小値
    for (int i = 1; i <= N; i++) {  // 1 ~ Nこのinputを圧縮
        for (int ypre = 0; ypre < YMAX; ypre++) {  // 前のyは
            for (int j = 0; j < M; j++) {  // 何番目のcode
                // 次のyi
                ll yi = max(0, min(YMAX - 1, ypre + code[j]));  // 0 <= yi <= 255
                ll cost = pow(yi - input[i-1], 2);
                // dp[i][yi] <- dp[i-1][ypre]の遷移
                dp[i][yi] = min(dp[i][yi], dp[i-1][ypre] + cost);
            }
        }
    }

    ll ans = *min_element(dp[N].begin(), dp[N].end());
    cout << ans << '\n';
}
/* main */
int main(){
    while (true) {
        int N, M;
        cin >> N >> M;
        if (N + M == 0) return 0;
        calc(N, M);
    }
}


Measured memory_bytes: 43508
#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
//#define rep(i, n) for(int (i) = 0, TmP = (n); (i) < (int)TmP ; ++(i))
#define asort(v, n) sort((v), (v + n)) //Using array
#define vsort(v) sort((v).begin(), (v).end()) // Using vector
#define vint vector<int>
typedef long long ll;

using namespace std;

signed main(){
  double a, b, h, m, PI = 3.14159265359;
  cin >> a >> b >> h >> m;

  double angle1, angle2;
  angle1 = m * PI / 30;
  angle2 = (60 * h + m) * PI / 360;
  double ang = max(angle1, angle2) - min(angle1, angle2);
  if(ang > PI)ang = 2 * PI - ang;
  double ans = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(ang));
  cout << fixed << setprecision(11) << ans << endl;
}


Measured memory_bytes: 4212
n,d,a = map(int,input().split())
attack = [0 for _ in range(n)]
event = []
for i in range(n):
  x,h = map(int,input().split())
  h = (h-1)//a+1
  event.append([x-d,0,h,i])
  event.append([x+d,1,h,i])
event.sort()
#print(event)
ans = 0
now = 0
for j in range(2*n):
  x,m,h,i = event[j]
  if m == 0:
    if h > now:
      attack[i] += h-now
      ans += h-now
      now = h
  else:
    now -= attack[i]
print(ans)

Measured memory_bytes: 83936
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long lli;

const int MAX=1<<17,mod=1e9+7;

int n;
int _abs(int a) {
	return a<0 ? -a : a;
}
int main() {
	int px=0,py=0,x=0,y=0,f=1,pt=0,t;
	scanf("%d",&n);
	
	while(n--) {
		scanf("%d%d%d",&t,&x,&y);
		
		int dt=t-pt, d=_abs(x-px)+_abs(y-py);
		if(dt<d || dt%2 != d%2) f=0;
	}
	puts(!f ? "No" : "Yes");

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
    long long n,a;
    cin>>n;
    for (long long i=1;i<=n;i++)
    {
        long long pf;
        pf=i*i;
        if (pf<=n) a=pf;
    }
    cout<<a<<endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
#define pi acos(-1)
#define eps 0.000001
#define inf (1e18 + 7)
using namespace std;

int n;
char ch[100005], ch2[100005];

int get(int &a, int &b, int c)
{
    if(c == 1)
        a = n, b = 2;
    else if(c == n)
        a = 1, b = n - 1;
    else
        a = c - 1, b = c + 1;
}

bool get2()
{
    for(int j = 2;j < n;j++)
    {
        if(ch[j] == 'o')
        {
            if(ch2[j] == 'S')
                ch2[j + 1] = ch2[j - 1];
            else
            {
                if(ch2[j - 1] == 'S')
                    ch2[j + 1] = 'W';
                else
                    ch2[j + 1] = 'S';
            }
        }
        else
        {
            if(ch2[j] == 'W')
                ch2[j + 1] = ch2[j - 1];
            else
            {
                if(ch2[j - 1] == 'S')
                    ch2[j + 1] = 'W';
                else
                    ch2[j + 1] = 'S';
            }
        }
    }
    bool flag = 0;
    for(int i = 1;i <= n;i++)
    {
        int a, b;
        get(a, b, i);
        if(ch2[i] == 'W')
        {
            if(ch[i] == 'o')
            {
                if(ch2[a] == ch2[b])
                {
                    flag = 1;
                    break;
                }
            }
            else
            {
                if(ch2[a] != ch2[b])
                {
                    flag = 1;
                    break;
                }
            }
        }
        else
        {
            if(ch[i] == 'o')
            {
                if(ch2[a] != ch2[b])
                {
                    flag = 1;
                    break;
                }
            }
            else
            {
                if(ch2[a] == ch2[b])
                {
                    flag = 1;
                    break;
                }
            }
        }
    }
    if(flag)
        return false;
    return true;
}

int main()
{
    scanf("%d", &n);
    scanf("%s", ch + 1);
    if(n == 1)
    {
        printf("S\n");
        return 0;
    }
    ch2[1] = 'S';
    ch2[2] = 'S';
    if(get2())
    {
        printf("%s\n", ch2 + 1);
        return 0;
    }
    ch2[1] = 'S';
    ch2[2] = 'W';
    if(get2())
    {
        printf("%s\n", ch2 + 1);
        return 0;
    }
    ch2[1] = 'W';
    ch2[2] = 'S';
    if(get2())
    {
        printf("%s\n", ch2 + 1);
        return 0;
    }
    ch2[1] = 'W';
    ch2[2] = 'W';
    if(get2())
    {
        printf("%s\n", ch2 + 1);
        return 0;
    }
    printf("-1\n");
    return 0;
}
/*

    if(!flag)
    {
        printf("%s\n", ch2 + 1);
        return 0;
    }
    */


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


void solve() {
    ll i,j,k,l,r,x,y; string s;
    bool exit = false;
    ll N;
    cin>>N;
    ll a[N];
    FOR(i,N){
        cin>>a[i];
    }
    ll cnt=0;
    FOR(i,N){
        ll tgt = a[i];
        while(true){
            if(tgt%2==0){
                tgt /= 2;
                cnt ++;
            }else
                break;
        }
    }
    cout<<cnt<<endl;
    /*cin>>N;
    vector<ll> V;
    FOR(x,N+1) {
            FOR(y,N+1) {
                    ll ret=1;
                    FOR(i,x) ret*=2;
                    FOR(i,y) ret*=5;
                    V.push_back(ret);
            }
    }
    sort(ALL(V));
    FORR(v,V) cout<<v<<endl;*/
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}



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

int main() {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  for (auto& p : x) {
    for (auto& e : p) {
      cin >> e;
    }
  }
  int r = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int p = 0;
      for (int k = 0; k < d; k++) p += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      r += p == int(sqrt(p)) * int(sqrt(p));
    }
  }
  cout << r << endl;
}


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


int main(){
    ll N; cin >> N;
    vector<vector<int>> A(2, vector<int>(N)), DP(2, vector<int>(N)); 
    for(int i = 0; i < 2; i++) for(int j = 0; j < N; j++) cin >> A[i][j];
    DP[0][0] = A[0][0];
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < N; j++){
            if(i-1 >= 0 && j-1 >= 0){
                DP[i][j] = max(DP[i-1][j], DP[i][j-1]) + A[i][j];
            }
            else if(i-1 >= 0){
                DP[i][j] = DP[i-1][j]+A[i][j];
            }
            else if(j-1 >= 0)DP[i][j] = DP[i][j-1] + A[i][j];
        }
    }
    ll ans = DP[1][N-1];
    cout << ans << endl;
}

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

using namespace std;
long long n;
int ans;
int Solve(long long x,long long k)
{
    while(x%k==0)
    {
        x/=k;
    }
    return x%k==1;
}
int main()
{
    cin>>n;
    long long x = n-1;
    for(long long i=1;i<=sqrt(x);i++)
    {
        if(x%i==0)
        {
            ans++;
            if(i!=x/i)
                ans++;
        }
    }
    for(long long i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            ans+=Solve(n,i);
            if(i!=n/i)
                ans+=Solve(n,n/i);
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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


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

  if (N % 2) {
    cout << 0 << endl;
    return 0;
  }

  ll num2 = 0;
  ll base2 = 2;

  ll N2 = N;
  while (base2 <= N) {
    num2 += N2 / base2;
    base2 *= 2;
  }

  ll num5 = 0;
  ll base5 = 5;

  ll N5 = N;
  while (base5 <= N) {
    num5 += (N5 / base5) / 2;
    base5 *= 5;
  }

  ll ans = min(num2, num5);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)|(1<<(i)))
#define togglebit(n,i) ((n)^(1<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MOD (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
ll fre[500005];
ll a[500005];
bool ispalindrome(string s){
    ll sz=s.size();
    for(ll i=0;i<sz;i++){
        if(s[i]!=s[sz-i-1]){
            return false;
        }
    }
    return true;
}
int main(){
    double m,i,j,k,l,p,q;
    ll n;
    scanf("%lld",&n);
    m=n/3.00;
    l=m*m*m;
    printf("%.10lf",l);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();

		int out =0;

		for(int i=0; i<=A; i++){
			for(int j=0; j<=B; j++){
				for(int k=0; k<=C; k++){
					if(500*i+100*j+50*k == X){
						out++;
					}
				}

			}
		}
		// 出力
		System.out.println(out);
	}
}

Measured memory_bytes: 24916
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << sqrt(pow((x1 - x2), 2) + pow((y1 - y2), 2)) << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



Measured memory_bytes: 3276
from collections import Counter
N, K = map(int, input().split())
A = list(map(int, input().split()))

C = Counter()
table = [None]*N
for i in range(N-1, -1, -1):
    a = A[i]
    C[a] = i
for i in range(N-1, -1, -1):
    a = A[i]
    table[i] = C[a]
    C[a] = i
cost = [1 + table[i] - i if table[i] > i else 1+ table[i] - i + N for i in range(N)] 
table = [(1+t)%N for t in table]
loop = 0
st = 0
en = None
while en != 0:
    en = table[st]
    loop += cost[st]
    st = en
K = (N*K) % loop
st = 0
while K - cost[st] >= 0:
    K -= cost[st]
    st = table[st]
sS = set()
S = []
for i in range(K):
    a = A[(st+i)%N]
    if a in sS:
        sS.remove(a)
        while S[-1] != a:
            sS.remove(S.pop())
        S.pop()
    else:
        S.append(a)
        sS.add(a)
print(*S)


Measured memory_bytes: 121032
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

	static final int X = 0;
	static final int Y = 1;
	
	public static void main(String[] args) throws IOException 
	{
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		int N = Integer.parseInt(str.substring(0, str.indexOf(" ")));
		int M = Integer.parseInt(str.substring(str.indexOf(" ") + 1));
		int Students[][] = new int[N][2];
		int CheckPoints[][] = new int[M][2];
		int Lan[][] = new int[N][2];
		for(int i = 0; i < N; i++)
		{
			str = br.readLine();
			Students[i][X] = Integer.parseInt(str.substring(0, str.indexOf(" ")));
			Students[i][Y] = Integer.parseInt(str.substring(str.indexOf(" ") + 1));
			Lan[i][0] = 1000000000;
			Lan[i][1] = 0;
		}
		for(int i = 0; i < M; i++)
		{
			str = br.readLine();
			CheckPoints[i][X] = Integer.parseInt(str.substring(0, str.indexOf(" ")));
			CheckPoints[i][Y] = Integer.parseInt(str.substring(str.indexOf(" ") + 1));
		}
		for(int i = 0; i < N; i++)
		{
			for(int j = 0; j < M; j++)
			{
				if(Lan[i][0] > Math.abs(Students[i][X] - CheckPoints[j][X]) + Math.abs(Students[i][Y] - CheckPoints[j][Y]))
				{
					Lan[i][0] = Math.abs(Students[i][X] - CheckPoints[j][X]) + Math.abs(Students[i][Y] - CheckPoints[j][Y]);
					Lan[i][1] = j + 1;
				}
			}
		}
		for(int i = 0; i < N; i++)
		{
			System.out.println(Lan[i][1]);
		}
	}

}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) (long long)((a).size())
const double pi = 3.14159265358979323846;

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    ll n,i,j;
    cin>>n;
    string s;
    cin>>s;
    vector<ll> pw(n),ae(n);
    pw[0]=0;
    ae[n-1]=0;
    for(i=1;i<n;i++)
    {
        if(s[i-1]=='E') 
        {
            pw[i] = pw[i-1];
        }
        else 
        {
            pw[i] = pw[i-1]+1;
        }
    }
    for(i=n-2;i>=0;i--)
    {
        if(s[i+1]=='E')
        {
            ae[i] = ae[i+1]+1;
        }
        else
        {
            ae[i] = ae[i+1];
        }
    }
    ll ans = 1e18;
    for(i=0;i<n;i++) ans = min(ans, pw[i]+ae[i]);
    cout<<ans;
}

Measured memory_bytes: 5396
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <cstring>
#include <cinttypes>
using namespace std;
 
using ll=int64_t;
#define int ll
 
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;
 
void printSpace(){
	printf(" ");
}
 
void printEoln(){
	printf("\n");
}

int read(){
	int i;
	scanf("%" SCNd64,&i);
	return i;
}
void print(const string& s,int suc=1){
	printf("%s", s.c_str());
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

void print(int x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}
 
string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}
 
char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template <typename T>
vector<T> readVec(int size) {
	using namespace std;
	vector<T> vec(size);
	for (int i = 0; i < size; ++i) {
		cin >> vec[i];
	}
	return vec;
}
template <typename T>
void printVec(const vector<T> &vec, int size, const string &sep = " ") {
	using namespace std;
	if (vec.empty()) return;
	cout << vec[0];
	for (int i = 1; i < size; ++i) {
		cout << sep << vec[i];
	}
	cout << endl;
	return;
}
#define printAll(vec) PrintSize(vec, vec.size())

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

	auto a = readVec<int>(3);
	int sum = 0;
	REP(i, a[0] + 1) {
		int targ = i;
		int temp = 0;
		while (targ >= 1) {
			temp += targ % 10;
			targ /= 10;
		}
		if (temp >= a[1] && temp <= a[2]) {
			sum += i;
		}
	}
	print(sum);
	return 0;
}

Measured memory_bytes: 256
while True:
  try:
    a,b=map(int,input().split())
    if a<b:
      a,b=b,a
    s=b
    r=a%s
    while True:
      if r==0:
        G=s
        break
      else:
        s,r=r,s%r
    L=int((a*b)/G)
    print(G,L)
  except EOFError:
    break


Measured memory_bytes: 5596
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}



int main(){
	
	string s;
	cin>>s;
	if(s[0]!='A'){
		cout<<"WA"<<endl;
		return 0;
	}
	int c=0;
	for(int i=2;i<s.size()-1;i++){
		if(s[i]=='C')c++;
	}
	if(c!=1){
		cout<<"WA"<<endl;
		return 0;
	}
	c=0;
	rep(i,s.size()){
		if(s[i]>=(int)'A' && s[i]<='Z') c++;
	}
	if(c!=2){
		
		cout<<"WA"<<endl;
		return 0;
	}
	cout<<"AC"<<endl;
		return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int u)
{
  int v;
  color[u]=GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++)
    {
      if(M[u][v]==0) continue;
      if(color[v]==WHITE)
	{
	  dfs_visit(v);
	}
    }
  color[u]=BLACK;
  f[u]=++tt;
}

void dfs()
{
  int u;
  for(u=0;u<n;u++) color[u]=WHITE;
  tt=0;
  
  for(u=0;u<n;u++)
    {
      if(color[u]==WHITE) dfs_visit(u);
    }
  for(u=0;u<n;u++)
    {
      printf("%d %d %d\n",u+1,d[u],f[u]);
    }
}

int main()
{
  int u,v,k,i,j;

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

  for(i=0;i<n;i++)
    {
      scanf("%d %d",&u,&k);
      u--;
      for(j=0;j<k;j++)
	{
	  scanf("%d",&v);
	  v--;
	  M[u][v]=1;
	}
    }

  dfs();
  
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map>       // pair
#include <string>
#include <stdio.h>
#include <numeric>
using namespace std;

int main(int argc, char const *argv[])
{
    int N,K;
    cin>>N>>K;
    vector<int> vec(N);
    for (int i = 0; i < N; i++)
    {
        cin>>vec[i];
    }
    int sum = 0;
    for (int i = 0; i < N; i++)
    {
        sum += min(vec[i],K-vec[i]);
    }

    cout<<sum*2;

    
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

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

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for {
		sc.Scan()
		a := sc.Text()

		if a == "0" {
			break
		}
		ans := 0
		for i := 0; i < len(a); i++ {
			ans += int(a[i]) - '0'
		}
		fmt.Println(ans)
	}
}



Measured memory_bytes: 1096
#include <bits/stdc++.h>
#define r(i, n) for (ll i=0;i<n;i++)
#define ll long long
#define llc(n) ll n; cin >> n;
using namespace std;
int main() {
  string s;
  cin >> s;
  ll m=s.length(),n=(s.length())/2,a=0;
  r(i,n) {
    if(s.at(i)!=s.at(m-1-i)) a++;
  }
  cout << a << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    long I = sc.nextInt();
    long O = sc.nextInt();
    long T = sc.nextInt();
    long J = sc.nextInt();
    long L = sc.nextInt();
    long S = sc.nextInt();
    long Z = sc.nextInt();
    long ans = I / 2 * 2 + J / 2 * 2 + L / 2 * 2;
    if (J > 0 && L > 0 & I > 0) {
      ans = Math.max(ans, (I - 1) / 2 * 2 + 3 + (J - 1) / 2 * 2 + (L - 1) / 2 * 2);
    }

    ans += O;
    System.out.println(ans);
  }

}


Measured memory_bytes: 9808
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b,k,i;
int main() {
	scanf("%d %d %d",&a,&b,&k);
	for(i=a;i<=min(a+k-1,b);i++)
		printf("%d\n",i);
	for(i=max(i,b-k+1);i<=b;i++)
		printf("%d\n",i);
}

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

int debt_in_weeks(int weeks)
{
    int borrow = 100000;
    for (;weeks != 0 ; weeks--)
        borrow = ceil((borrow * 1.05) / 1000) * 1000;

    return borrow;
}

int main()
{
    int weeks;
    cin >> weeks;
    cout << debt_in_weeks(weeks)<< endl;

    return 0;
}

Measured memory_bytes: 1164