akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int D, N;
  cin >> D >> N;
  if(D==0){
    if(N<100){
      cout << N << endl;
    }
    else{
      cout << 101 << endl;
    }
  }
  else if(D==1){
    if(N<100){
      cout << 100*N << endl;
    }
    else{
      cout << 10100 << endl;
    }
  }
  else{
    if(N<100){
      cout << 10000*N << endl;
    }
    else{
      cout << 1010000 << endl;
    }
  }
}

Measured memory_bytes: 256
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
struct Node {
    int key;
    struct Node *prev;
    struct Node *next;
};
   
struct Node *note;
   
void insert(int key) {
    struct Node *x = (struct Node *)malloc(sizeof(struct Node));
    x->key = key;
    note->next->prev = x;
    x->next = note->next;
    note->next = x;
    x->prev = note;
}
   
struct Node* search(int key) {
    struct Node *x = note->next;
    while(x != note && x->key != key ) {
        x = x-> next;
    }
    return x;
}
   
void deleteNode(struct Node *t) {
    if (t == note) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
}
 void deleteKey(int key) {
    deleteNode(search(key));
}  
void deleteFirst() {
    deleteNode(note->next);
}
   
void deleteLast() {
    deleteNode(note->prev);
}
   
void print() {
    struct Node *x;
    x = note->next;
    int i = 0;
    while(1) {
        if (x == note) break;
    	if(i++ > 0) printf(" ");
        printf("%d", x->key);
        x = x->next;
    }
    printf("\n");
}
   
   
int main(void) {
    int key, n;
    char order[20];
    scanf("%d", &n);
    note = (struct Node *)malloc(sizeof(struct Node));
    note->next = note;
    note->prev = note;
    for (int i = 0; i < n; i++) {
        scanf("%s%d",order, &key);
        if(order[0] == 'i') {
            insert(key);
        }else if(order[0] == 'd') {
            if(strlen(order) > 6) {
                if( strlen(order) > 10) {
                    deleteFirst();
                }else if( strlen(order) > 9) {
                    deleteLast();
                }
            }else {
                deleteKey(key);
            }
        }
    }
    print();
    return 0;
}

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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

const int MOD = (int)1e9 + 7;
int exp(int a, int b){
    if (b == 0) return 1;
    if (b & 1){
        return (ll)a * exp(a, b-1) % MOD;
    }
    int tmp = exp(a, b/2);
    return (ll)tmp * tmp % MOD;
}
int main(){
    std::ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    vi arr(n);
    for (int i = 0; i < n; i++) cin >> arr[i];
    sort(arr.begin(), arr.end());
    vi brr;
    for (int i = 0; i < n; i++) {
        brr.push_back(abs(i - (n - i - 1)));
    }
    sort(brr.begin(), brr.end());
    if (arr != brr) cout << 0 << endl;
    else cout << exp(2, n/2) << endl;

}


Measured memory_bytes: 1276
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
using namespace std;
int main() {
  int a, b, x;
  cin >> x >> a >> b;
  int diff = b - a;
  if(diff <= 0) cout << "delicious" << endl;
  else if(diff <= x) cout << "safe" << endl;
  else cout << "dangerous" << endl;
}


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

int main()
{
    int n;
    int i, j = 0;
    long long int ans1 = -1, ans2 = -1;
    
    cin >> n;
    
    int a[n];
    
    for(i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    sort(a, a+n, greater<int>());
    
    while((ans2 == -1) && (j < n-1)) {
        if(a[j] == a[j+1]) {
            if(ans1 == -1) {
                ans1 = a[j];
                j++;
            } else {
                ans2 = a[j];
                j++;
            }
        }
        j++;
    }
    
    if((ans1 == -1) || (ans2 == -1)) {
        cout << "0\n";
    } else {
        cout << ans1 * ans2 << endl;
    }
    
    return 0;
}

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

long convert(long n);

int main(void){
  long n;
  while(1){
    cin>>n;
    if(n==-1)break;
    cout<<convert(n)<<endl;
  }
  return 0;
}

long convert(long n){
  long base=1;
  long retval=0;
  while(n>0){
    retval+=base*(n%4);
    base*=10;
    n=n/4;
  }
  return retval;
}



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

int main() {
  string a, b;
  cin >> a >> b;
  string ans = "Alice";
  if (b=="1"&& a=="1") {ans="Draw";}
  else if (b=="1") {ans="Bob";}
  else if (a!="1") {
    if (b.size()>a.size()) {ans = "Bob";}
    else if (b.size()==a.size()) {
      if (a[a.size()-1]==b[b.size()-1]) {ans="Draw";}
      else if (a[a.size()-1]<b[b.size()-1]) {ans="Bob";}
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define N 100003

int n,m,ans;
int g[N],f[N];

inline int read(){
	int X=0,w=0;
	char ch=0;
	while (ch<'0' || ch>'9')
	  w|=ch=='-',ch=getchar();
	while (ch>='0' && ch<='9')
	  X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
	return w ? -X : X;
}

int main(){
	m=read();n=read();
	for (int i=1;i<=n;i++)
	  g[i]=read();
	sort(g+1,g+1+n);
	if (m>=n){
		puts("0");
		return 0;
	}
	ans=g[n]-g[1];
	for (int i=1;i<n;i++)
	  f[i]=g[i]-g[i+1];
	sort(f+1,f+n);
	for (int i=1;i<=m-1;i++)
	  ans+=f[i]; 
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"os"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a+b >= 10 {
		fmt.Println("error")
		os.Exit(0)
	}
	fmt.Println(a + b)
}

// nの階乗(mod M) ただしMは素数
// return: nまでの階乗を示す全値(e.g., fact[5] = 5!を示す値)
func mfactorial(n int, M int) []int {
	fact := make([]int, n+1)
	fact[0] = 1
	for i := 1; i <= n; i++ {
		fact[i] = (fact[i-1] * i) % M
	}
	return fact
}

// x^n (mod M) ただしMは素数
// See https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
func mpow(x, n, M int) int {
	ans := 1
	for n != 0 {
		if n&1 == 1 {
			ans = ans * x % M
		}
		x = x * x % M
		n = n >> 1
	}
	return ans
}

// nCk (mod M) ただしMは素数
// @see https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
func combi(n, k, M int) int {
	return commonPermutationAndCombination(n, k, M, true)
}

// nPk (mod M) ただしMは素数
// @see https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
func permutation(n, k, M int) int {
	return commonPermutationAndCombination(n, k, M, false)
}

func commonPermutationAndCombination(n, k, M int, combi bool) int {
	if n == 0 && k == 0 {
		return 1
	} else if n < k || n < 0 {
		return 0
	}
	fact := mfactorial(n, M)

	ans := fact[n] * mpow(fact[n-k], M-2, M) % M
	if combi {
		ans *= mpow(fact[k], M-2, M) % M
	}

	return ans % M
}


Measured memory_bytes: 512
#include <iostream>
#include <map>
#include <set>
#include <cmath>

using namespace std;

typedef pair<int, int> P;
typedef set<P> S;
typedef S::iterator I;

int main() {
    int n;
    P p;
    while (true) {
        S points;
        int max_square = 0;
        cin >> n;
        if (n == 0) {
            return 0;
        }
        for (int i = 0; i < n; ++i) {
            cin >> p.first >> p.second;
            points.insert(p);
        }
        for (I i1 = points.begin(); i1 != points.end(); ++i1) {
            for (I i2 = points.begin(); i2 != points.end(); ++i2) {
                P dp1(i2->first - i1->first, i2->second - i1->second);
                P dp2(i1->first - i2->first, i1->second - i2->second);
                P p3(-dp1.second + i1->first, dp1.first + i1->second);
                P p4(dp2.second + i2->first, -dp2.first + i2->second);
                int square = dp1.first * dp1.first + dp1.second * dp1.second;
                if (square < max_square) {
                    continue;
                }
                if (points.find(p3) != points.end() && points.find(p4) != points.end()) {
                    max_square = square;
                }
            }
        }
        cout << max_square << endl;
    }
}

Measured memory_bytes: 1332
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int inf=1e9;
const LL mod=998244353;
#define mem(a,b) memset(a,b,sizeof(a))
int max(int a,int b) {return a>b?a:b;}
char a[10]={"keyence"};
int main()
{
    char s[1000];
    scanf("%s",s);
    int n=strlen(s);
    int m=n-7;
    for(int i=0;i<=7;i++)
    {
        int fg=0,j;
        for(j=0;j<i;j++,fg++)
        {
            if(s[j]!=a[fg]) break;
        }
       // printf("%d %d",i,fg);
        if(j<i) continue;
        for(j=i+m;j<n;j++,fg++)
        {
            if(s[j]!=a[fg]) break;
        }
       // printf("  %d  %d \n",fg,j);
        if(j==n)
        {
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	string s, t;
	cin >> s >> t;
	int cnt = 0;
	for(int i = 0; i < sz(s); i++){
		if(s[i] != t[i])
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 3928
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using vl = vector<long long>;
#define INF (lint)10000000000000000
#define mod (lint)1000000007
#define P pair<lint,lint>
lint n, k;
vl a;
vl f;
P e;//開けた箱のカウント
bool h = true;//出力用

bool solve(vl& r) {//判定用・trueだったら参照渡しのrに格納した情報を出力
	e.first = INF;//e.firstは,「前回宝のあった場所」
	for (int i = 0; i <= k; i++) {//K+1回or-になって終わるまでループし続ける
		lint s = INF;//large
		e.second = -INF;//前回宝のあった場所以外で一番残り開けられる回数の少ない箇所
		for (int j = 0; j < n; j++) {
			if (j != e.first && s >= a[j]) {//宝の開けられる回数の最小値をe.secondに記録
				e.second = j;
				s = a[j];
			}
		}
		for (int j = 0; j < n; j++) {
			if (j != e.first && j != e.second) {//まず開くものだけ
				r.push_back(j + (lint)1);//開く順番を参照渡しした配列に記録
				a[j]--;//e.firstとe.second以外の要素は-1する
				if (a[j] < 0) { //0未満になっていたら強制的に飛ぶ
					h = false;
					goto ageprocpp;//飛ぶ
				}
			}
		}
		e.first = e.second;//その後e.secondを開ける
		e.second++;
		r.push_back(e.second);
		e.second--;
		a[e.second]--;
		if (a[e.second] < 0) {//判定
			h = false;
			goto kaage;//飛ぶ
		}
	}

kaage:;
ageprocpp:;//飛ぶ
	return h;//gotoされていない限りはture
}

int main(void) {
	cin >> n >> k;
	a.resize(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];//入力
	/**/
	if (!solve(f)) //これで必勝法があるかどうかの判定
		printf("%d", -1);//無ければ-1
	else {
		printf("%zd\n", f.size());//必勝法のサイズ
		for (int i = 0; i < f.size(); i++) {
			if (i != f.size() - 1) //出力
				cout << f[i] << ' ';
			else
				cout << f[i];
		}
	}
	printf("\n");//どちらのパターンもここで改行する

	return 0;
}

Measured memory_bytes: 3824
li=[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]
k=int(input())

print(li[k-1])

Measured memory_bytes: 3060
#include <iostream>

int main()
{
    int X;
    std::cin >> X;

    if(X >= 30){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }

    //int end;
    //std::cin >> end;
    return 0;
}

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

int main(){
        int h, w, k;
        scanf("%d %d %d", &h, &w, &k);
        vector<vector<int>> cho(h, vector<int>(w));
        for(int i=0; i<h; i++){
                char s[w+1];
                scanf("%s", s);
                for(int j=0; j<w; j++){
                        cho[i][j] = (s[j]=='1');
                }
        }
        int ans = h+w-2;
        for(int bit=0; bit<(1<<(h-1)); bit++){
                vector<vector<int>> ac(0);
                vector<int> wa(cho[0]);
                bool cant = false;

                for(int i=0; i<h; i++){
                        if((bit>>i)&1){
                                ac.push_back(wa);
                                for(int j=0; j<w; j++) wa[j] = cho[i+1][j];
                        }else if(i==h-1) ac.push_back(wa);
                        else{
                                for(int j=0; j<w; j++){
                                        wa[j] += cho[i+1][j];
                                        if(wa[j]>k) cant = true;
                                }
                        }
                }

                if(cant) continue;

                vector<int> cnt(ac.size(), 0), lined(w-1, 0);
                for(int j=0; j<w; j++){
                        for(int i=0; i<ac.size(); i++){
                                cnt[i] += ac[i][j];
                                if(cnt[i]>k){
                                        lined[j-1] = 1;
                                        for(int X=0; X<ac.size(); X++) cnt[X] = ac[X][j];
                                        break;
                                }
                        }
                }


                int cand = __builtin_popcount(bit);
                for(int i: lined) cand += i;
                ans = std::min(ans, cand);
        }

        printf("%d\n", ans);
        return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

int main() {
	int N = 0;
	string S;
	int re = 0;
	int max = 0;
	cin >> N;
	cin >> S;
	rep(i, S.length()) {
		if (S[i] == 'I') {
			re++;
		}
		else {
			if (S[i] == 'D') {
				re--;
			}
		}
		if (max < re) {
			max = re;
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n, k, x, y; cin >> n >> k >> x >> y;
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (i <= k) ans += x;
        else ans += y;
    }
    cout << ans << endl;
}

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

int main() {
  int X;
  cin >> X;
 
  int Y = X % 100;
  int Z = X / 100;
  
  if (Y <= Z * 5){
    cout << 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
}
 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int n,a,b;
int main(){
	scanf("%d%d%d",&n,&a,&b);
	int tod=abs(a-b);
	if(tod%2==0)printf("Alice");
	else printf("Borys");
	return 0;
}

Measured memory_bytes: 256
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }

fn main() {
    input! {
        n: usize,
        k: usize,
        mut l: [usize; n],
    }
    l.sort();
    l.reverse();
    let ans: usize = l.into_iter().take(k).sum();
    println!("{}", ans);
}


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

int main()
{
    double a, b, x, theta, pi = acos(-1);
    cin >> a >> b >> x;

    if (x > a * a * b / 2) {
        theta = atan(2 * (a * a * b - x) / (a * a * a));
    } else {
        theta = atan((a * b * b) / (2 * x));
    }
    
    theta *= 180 / pi;

    cout << setprecision(10) << theta;
}

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

int main() {

  long long int n;
  cin >> n;

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

    if ( i % 3 == 0 ) {
      cout << " " << i;
      continue;
    }

    long long int j = i;
    while( j ) {

      if ( j % 10 == 3 ) {
	cout << " " << i;
	break;
      }
      j /= 10;

    }

  }

  cout << endl;

  return 0;

}

Measured memory_bytes: 1156
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define max 100

int stack[max],top=0;

void push(int );
int pop(void);

int main(){
  char s[max];
  int a;
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      push(pop()+pop());
    }
    else if(s[0]=='-'){
      a=pop();
      push(pop()-a);
    } 
    else if(s[0]=='*'){
      push(pop()*pop());
    }
    else {
      push(atoi(s));
    }   
  }
  printf("%d\n",pop());
  return 0;
}

void push(int x){
  if(top<max)
    stack[top++]=x;
}
int pop(void){
  if(top>0)
    return stack[--top];
}



Measured memory_bytes: 2144
from sys import setrecursionlimit as SRL, stdin

SRL(10 ** 7)
rd = stdin.readline
rrd = lambda: map(int, rd().strip().split())
n, m = rrd()

e = [[] for _i in range(1 << 13)]

p = []
for i in range(m):
    a, b = rrd()
    lst = list(rrd())
    g = 0
    for j in lst:
        g |= 1 << (j - 1)
    p.append((a, g))

for i in range(1 << n):
    for j in p:
        e[i].append((i | j[1], j[0]))
inf = 10**10

dis = [inf] * (1 << 13)
vis = [0] * (1 << 13)
dis[0] = 0

from heapq import *

q = [(0, 0)]
while len(q):
    ds, now = heappop(q)
    if vis[now]:
        continue
    vis[now] = 1
    for next, cost in e[now]:
        if dis[next] > dis[now] + cost:
            dis[next] = dis[now] + cost
            heappush(q, (dis[next], next))

if dis[(1 << n) - 1] == inf:
    print(-1)
else:
    print(dis[(1 << n) - 1])


Measured memory_bytes: 160648
N, K = gets.split.map(&:to_i)
MOD = 10.pow(9) + 7

dp = Array.new(K+1, 0)
res = 0
K.downto(1) do |k|
  dp[k] = (K / k).pow(N, MOD)
  (k * 2).step(K, k) do |k_mult|
    dp[k] -= dp[k_mult]
  end
  res += dp[k] * k
  res %= MOD
end

puts res


Measured memory_bytes: 15096
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
    int n,m,cnt;
    char a[50][50],b[50][50];
    bool flag=false;
    cin>>n>>m;

    rep(i,0,n)
    rep(j,0,n) cin>>a[i][j];
    rep(i,0,m)
    rep(j,0,m) cin>>b[i][j];

    //一致しているかを調べる
    rep(i,0,n-m+1){
      rep(j,0,n-m+1){
        //起点の座標
        cnt=0;
        rep(k,0,m)
        rep(l,0,m){
          if(b[k][l]==a[i+k][j+l]) cnt++;
        }
        if(cnt==m*m){
          flag=true;
        }
      }
    }

    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

public class Main {

	public static void main(String[] args) {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = null;
		    try {
			    input = br.readLine();
		        
		    } catch (IOException e) {
	    	}
	    	String[] num = input.split(" ");
		    int a = Integer.parseInt(num[0]);
		    int b = Integer.parseInt(num[1]);
		    int d = a / b;
		    int r = a % b;
		    double f =(double)a / b; 
		System.out.printf("%d %d %f\n", d, r, f);
	}
}


Measured memory_bytes: 24892
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

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

struct edge{int to,cost;};
	
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n,c,k;
	cin >> n >> c >> k;

	int t[n];
	for(int i=0;i<n;i++){
		cin >> t[i];
	}
	sort(t,t+n);
	
	int ans=1,tmp;
	for(int i=0;i<n;){
		auto e=upper_bound(t,t+n,t[i]+k);
		tmp=min((int)(e-(&t[i])),c);
		i+=tmp;
		if(i<=n-1) ans++;
		else break;
		//cout << i << "人目の" << t[i] << "時で" << ans << "台目のバス登場 前のバスは" << tmp <<"人乗った\n";
	}
//	int a=0,i=1;
//	while(true){
//		if(a+i == n) break;
//		if(i<c && t[a]+k>=t[a+i]){
//			i++;
//		}else{
//			ans++;
//			a=a+i;
//			i=1;
//		}
//	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 640
list1 = raw_input().split()
list_B = raw_input().split()

N = int(list1[0])

M = int(list1[1])

C = int(list1[2])

count = 0

for n in range(N):
    item = raw_input().split()
    total = 0

    for m in range(M):
        total += int(item[m]) * int(list_B[m])

    total += C
    if total > 0:
        count += 1

print int(count)


Measured memory_bytes: 2692
import java.util.Scanner;
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 d=c-b;
	int e=b-a;

	if(d>0 && e>0){
	    System.out.println( "Yes" );
	}else{
	    System.out.println("No");
	}
		
    }

}

Measured memory_bytes: 26052
// AtCoder ABC109: A - ABC333
// 2019.9.12 bal4u

#include <stdio.h>

int main()
{
	int A, B, C;
	
	scanf("%d%d", &A, &B);
	for (C = 1; C <= 3; C++) {
		if (A*B*C % 2 == 1) { puts("Yes"); return 0; }
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 128
using System;
class Program
{
    static void Main(string[] args)
    {
        //入力
        int N = int.Parse(Console.ReadLine());
        int[] a = new int[N];
        string[] s = Console.ReadLine().Split(' ');
        for (int i = 0; i < s.Length; i++)
        {
            a[i] = int.Parse(s[i]);
        }


        bool flag = true;
        for (int i=N-1; i>=1; i--)
        {
            if (a[i] + 1 == a[i - 1])
            {
                a[i - 1]--;
            }else if (a[i] >= a[i - 1])
            {
            }
            else
            {
                flag = false;
                break;
            }
        }

        if (flag) Console.WriteLine("Yes");
        else Console.WriteLine("No");

    }

}

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

int prime[300000];

void init()
{
  for(int i = 2; i <= 300000; i++)
  {
    if(prime[i])
      continue;
    prime[i] = 1;
    for(int j = i + i; j <= 300000; j += i)
      prime[j] = 2;
  }
}

int main()
{
  init();
loop:
  int n, ans = 0;
  cin >> n;
  if(!n)
    return 0;
  for(int i = n; i < 2 * n; i++)
    ans += prime[i + 1] == 1;
  cout << ans << endl;
  goto loop;
}

Measured memory_bytes: 2332
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;

    int W[N];
    int sum_1 = 0;
    int sum_2 = 0;

    for (int i = 0; i < N; i++){
        cin >> W[i];
        if (i == 0){
            sum_1 += W[i];
        }
        else {
            sum_2 += W[i];
        }
    }

    int ans = abs(sum_1 - sum_2);
    for (int i = 1; i < N; i++){
        sum_1 += W[i];
        sum_2 -= W[i];
        ans = min(ans, abs(sum_1- sum_2));
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
  	int N;
  	cin>>N;
  	vector<int> P(N,0);
  	vector<int> vec(N,0);
  	for(int i=0; i<N; i++){
      int p; cin>>p;
      P[i]=p;
      vec[i]=p;
    }
  int count=0;
  int mi=P[0];
  for(int i=0; i<N; i++){
    if(P[i]<=mi) count++;
    mi=min(mi,P[i]);
  }
  cout<<count<<endl;
}
    
    
    
    

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

int main()
{
	int L,M,N;
	while(scanf("%d", &L), L)
	{
		bool end=false;
		int tot=0;
		for(int i=0; i<12; i++)
		{
			scanf("%d%d", &M,&N);
			if(tot>=L) continue;
			
			tot+=M-N;
			if(tot>=L) printf("%d\n", i+1);
		}
		
		if(tot<L) puts("NA");
	}
}

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

int main() {
  string N;
  cin >> N;
  
  char c;
  if (N.size() == 1) {
    c = N.at(0);
  } else if (N.size() == 2) {
    c = N.at(1);
  } else {
    c = N.at(2);
  }
  
  if (c == '2' || c == '4' || c == '5' || c == '7' || c == '9') {
    cout << "hon" << endl;
  } else if (c == '0' || c == '1' || c == '6' || c == '8') {
    cout << "pon" << endl;
  } else {
    cout << "bon" << endl;
  }
}

Measured memory_bytes: 3632
n = int(input())
root = int((n - 1)** 0.5)
count = 0
for i in range(1, root + 1):
    if (n - i * i)  % i == 0:
        count +=  (n - i * i)  // i * 2 - 1
    else:
        count +=  (n - i * i)  // i * 2 + 1

print(count)

Measured memory_bytes: 9432
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

int main() {
  int n;
  cin >> n;
  V<V<int>> to(n);
  V<int> a(n - 1), b(n - 1);
  rep(i, n - 1) {
    int p, q;
    cin >> p >> q;
    --p;
    --q;
    a[i] = p;
    b[i] = q;
    to[p].push_back(q);
    to[q].push_back(p);
  }

  int num = 1;
  V<int> c(n, -1);
  queue<int> q;
  c[0] = 0;
  q.push(0);
  while (!q.empty()) {
    auto e = q.front();
    q.pop();
    int tmp = 1;
    for (auto i : to[e]) {
      if (c[i] >= 0) continue;
      if (tmp == c[e]) tmp++;
      c[i] = tmp++;
      num = max(c[i], num);
      q.push(i);
    }
  }
  cout << num << endl;
  rep(i, n - 1) printf("%d\n", c[b[i]]);
}


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

public class Main {
	public static void main(String args[]){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		try{
			String[] strBR = insBR.readLine().split(" ");
			int intX = Integer.parseInt(strBR[0]);
			int intY = Integer.parseInt(strBR[1]);
			int intRectangle = intX * intY;
			int intLength = 2 * (intX + intY);
			System.out.println(intRectangle + " " + intLength);
		}catch(IOException e){

		}catch(NumberFormatException e){

		}
	}
}



Measured memory_bytes: 24308
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll gcd(ll x, ll y){
    if (y==0) return x;
    else return gcd(y, x%y);
}

int main(){

    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    
    vector<ll> left_gcd_sum(N);
    vector<ll> right_gcd_sum(N);

    left_gcd_sum[0] = A[0];
    right_gcd_sum[N-1] = A[N-1];
    for(int i = 1; i < N; i++){
        left_gcd_sum[i] = gcd(left_gcd_sum[i-1],A[i]);
        right_gcd_sum[N-1-i] = gcd(right_gcd_sum[N-i], A[N-1-i]);
    }
    

    ll ans = 1;
    rep(i,N){
        ll current_gcd;
        if (i == 0) current_gcd = right_gcd_sum[1];
        else if(i == N-1) current_gcd = left_gcd_sum[N-2];
        else current_gcd = gcd(left_gcd_sum[i-1], right_gcd_sum[i+1]);
        ans = max(ans, current_gcd);
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string s;cin>>s;
  	bool cflag=false;
  	for(int i=0;i<s.size();i++){
    	if(s[i]=='C') cflag=true;
      	if(cflag){
      		for(int j=i+1;j<s.size();j++){
            	if(s[j]=='F'){
                  cout<<"Yes"<<endl;
                  return 0;
                }
            }
    	}
    }
  	cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    string S;
    cin >> S;
    if (S[5] == '0') {
        if (S[6] < '5') {
 
            cout << "Heisei" << endl;
        }
        else
        {
            cout << "TBD" << endl;
        }
    }
    else
    {
        cout << "TBD" << endl;
    }
 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
void print(char str[], int a, int b);
void reverse(char str[], int a, int b);
void replace(char str[], int a, int b, char p[]);
 
int main(void)
{
    int i;
 
    char str[1001];
    scanf("%s", str);
 
    int op_num;
    scanf("%d", &op_num);
 
    char op[8];
    int a, b;
    for (i = 1; i <= op_num; i++) {
        scanf("%s", op);
        scanf("%d %d", &a, &b);
 
        if (strcmp(op, "print") == 0) {
            print(str, a, b);
        } else if (strcmp(op, "reverse") == 0) {
            reverse(str, a, b);
        } else {
            char p[1001];
            scanf("%s", p);
            replace(str, a, b, p);
        }
    }
 
    return 0;
}
 
void print(char str[], int a, int b)
{
    int i;
    for (i = a; i <= b; i++) {
        printf("%c", str[i]);
    }
    printf("\n");
}
 
void reverse(char str[], int a, int b)
{
    char tmp[1001];
    int i;
    for (i = a; i <= b; i++) {
        tmp[i] = str[b + a - i];
    }
    for (i = a; i <= b; i++) {
        str[i] = tmp[i];
    }
}
 
void replace(char str[], int a, int b, char p[])
{
    int i;
    for (i = 0; i < b - a + 1; i++) {
        str[a + i] = p[i];
    }
}

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

int main()
{
	int n, k, i, x, f, prev=0, mx=0;
	cin>>k>>n;
	for(i=0;i<n;i++){
		cin>>x;
		if(i==0)f = x;
		mx = max(x-prev, mx);
		prev=x;
	}
	mx = max(f+k-x,mx);
	cout << k-mx << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  string s;
  cin >> s;
  for(int i = 0; i < s.length(); i++) {
    char t = 'A' + (s[i] + n - 'A') % 26;
    cout << t;
  }
  cout << endl;
  return 0;
}

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

int main() {
	
	string s;
	cin>>s; int cnt=0;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='o')
		{
			cnt++;
		}
		
	}
	int p=15-s.length();
	if(cnt>=8||cnt+p>=8){cout<<"YES";}
	else{cout<<"NO";}
	
	
}

Measured memory_bytes: 256
from collections import deque
from collections import defaultdict
import sys
input = sys.stdin.readline

N = int(input())
T = defaultdict(list)
for _ in range(N-1):
    a, b, c = list(map(int, input().split()))
    T[a].append((b, c))
    T[b].append((a, c))

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

distance = [-1] * (N+1)
distance[K] = 0

d = deque()
d.append(K)

while d:
    node = d.popleft()
    for bc in T[node]:
        b, c = bc
        if distance[b] == -1:
            distance[b] = distance[node] + c
            d.append(b)

for _ in range(Q):
    x, y = list(map(int, input().split()))
    print(distance[x] + distance[y])


Measured memory_bytes: 81628
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m,ans;
int check(int x,int y){
	int num=0;
	while (x)num+=x%y,x/=y;
	return num==m;
}
signed main(){
	scanf("%lld%lld",&n,&m);
	if (n==m)ans=n+1;
	else ans=1e18;
	for (int i=2,j=1;i<=n;i=j+1){
		if (i<=1e6){
			if (check(n,i))ans=min(ans,i);
			j=i;
		}
		else {
			j=n/(n/i);
			if ((n/i+n%i)<m)continue;
			else {
				int l=i,r=j;
				while (l<r){
					int mid=(l+r)/2;
					if ((n/mid+n%mid)>m)l=mid+1;
					else r=mid;
				}
				if ((n/l+n%l)==m)ans=min(ans,l);
			}
		}
	}
	if (ans==1e18)puts("-1");
	else printf("%lld\n",ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[200010];
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		x--;
		a[x]=i;
	}
	ll now=a[0];
	ll ans=1;ll ans2=1;
	for(int i=1;i<n;i++){
		ll next=a[i];
		if(now<next){
			now=next;
			ans++;
			ans2=max(ans2,ans);
		}
		else{
			ans=1;
			now=next;
		}
	}
	cout << n-ans2;
	// your code goes here
	return 0;
}

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


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

    int N, M;
    cin >> N >> M;
    int A[N+M-1], B[N+M-1];
    std::map<int, deque<int> > in, out;
    for(int i=0; i<N-1+M; i++) cin >> A[i] >> B[i];
    int s[N];
    memset(s, 0, sizeof(s));
    for(int i=0; i<N-1+M; i++){
        s[B[i]-1]++;
    }
    int start = -1;
    for(int i=0; i<N; i++){
        if(s[i] == 0) start = i;
    }
    for(int i=0; i<N-1+M; i++){
        in[A[i]-1].push_back(B[i]-1);
        out[B[i]-1].push_back(A[i]-1);
    }

    std::deque<int> L;
    std::deque<int> S;
    S.push_back(start);

    while(len(S) > 0){
        int n = S[0];
        S.pop_front();
        L.push_back(n);
        deque<int>& v1 = in[n];
        while(len(v1) > 0){
            int m = v1[0];
            v1.pop_front();
            deque<int>& v2 = out[m];
            v2.erase(std::remove(v2.begin(), v2.end(), n), v2.end());
            if(len(v2) == 0){
                S.push_back(m);
            }
        }
    }
    //for(int x: L){
    //    std::cout << x << std::endl;
    //}

    for(int i=0; i<N-1+M; i++){
        in[L[A[i]-1]].push_back(B[i]-1);
        out[B[i]-1].push_back(A[i]-1);
    }

    int L2[len(L)];
    for(int i=0; i<len(L); i++) L2[L[i]] = i;

    map<int, vector<pair<int, int>>> ans;

    for(int i=0; i<N-1+M; i++){
        ans[B[i]-1].push_back(make_pair(L2[A[i]-1], A[i]-1));
    }
    for(auto& v: ans){
        sort(v.second.begin(), v.second.end());
        reverse(v.second.begin(), v.second.end());
    }

    for(int i=0; i<N; i++){
        if(len(ans[i]) == 0) std::cout << 0 << endl;
        else std::cout << ans[i][0].second+1 << endl;
    }
}



Measured memory_bytes: 157952
N, W = list(map(int,raw_input().split()))
dp = [float("inf") for i in range(100001)]
dp[0] = 0
for i in xrange(N):
  wi, vi = list(map(int,raw_input().split()))
  for v in xrange(100000-vi, -1, -1):
    dp[v+vi] = min(dp[v+vi],dp[v]+wi)
print(max([v for v in xrange(100001) if dp[v]<=W]))

Measured memory_bytes: 37516
s = input()
n = len(s)

a = '0'
b = '1'
for i in range(1,n):
    if a[i-1] == '0':
        a += '1'
    else:
        a += '0'
for i in range(1,n):
    if b[i-1] == '0':
        b += '1'
    else:
        b += '0'

ca, cb = 0, 0
for i in range(n):
    if a[i] != s[i]:
        ca += 1
    if b[i] != s[i]:
        cb += 1

print(min(ca,cb))

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

#define mod      1e9+7;
#define INF      1e9+9;
#define ps(x,y)  fixed<<setprecision(y)<<x
# define PI 3.14159265358979323846264338327950 L
typedef long long ll;
typedef unsigned long long ull;
vector<pair<ll,ll>> v[200005];
ll col[200005];
void dfs(ll r,ll p,ll d){
	if(d%2==1)
		col[r]=1;
	for(auto x: v[r]){
		if(x.first!=p){
			dfs(x.first,r,d+x.second);
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
#endif
	ll n;
	cin>>n;
	for(ll i=1;i<n;i++){
		ll a,b,w;
		cin>>a>>b>>w;
		v[a].push_back({b,w});
		v[b].push_back({a,w});
	}
	dfs(1ll,-1ll,0ll);
	for(ll i=1;i<=n;i++)
		cout<<col[i]<<endl;
	return 0;
}

Measured memory_bytes: 15636
// atcoder.jp/contests/tdpc/tasks/tdpc_game
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define rep(i, s, n) for (ll i = s; i < n; ++i)
#define repd(i, s, n) for (ll i = s; n < i; --i)
#define repa(e, vec) for (auto &&e : (vec))
#define repv(e, vec) for (auto e : (vec))
#define dump(x) cerr << #x << " = " << (x) << " | ";
#define _mp make_pair
#define _pb push_back
#define _lb lower_bound
#define _ub upper_bound
#define _sz(x) (int)x.size()
#define _count(arr, target) count(arr, arr + (sizeof(arr)), target)
#define _all(x) (x).begin(), (x).end()

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

using namespace std;

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

ll solve(ll n, vector<ll> va, vector<ll> vb, vector<ll> vc) {
    ll ans = 0;
    ll u = 0;
    ll l = 0;

    rep(i, 0, n) {
        l = lower_bound(va.begin(), va.end(), vb[i]) - va.begin();
        u = vc.end() - upper_bound(vc.begin(), vc.end(), vb[i]);
        ans += u * l;
    }

    return ans;
}

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

    vector<ll> va(n), vb(n), vc(n);
    rep(i, 0, n) cin >> va[i];
    rep(i, 0, n) cin >> vb[i];
    rep(i, 0, n) cin >> vc[i];
    sort(_all(va));
    sort(_all(vb));
    sort(_all(vc));

    ll ans = solve(n, va, vb, vc);
    cout << ans << "\n";
}


Measured memory_bytes: 7952
import numpy as np

def main()->None:
    c_1 = list(map(int, input().split()))
    c_2 = list(map(int, input().split()))
    c_3 = list(map(int, input().split()))
    c = np.array([c_1, c_2, c_3],dtype=int)

    a = np.empty(3, dtype=int)
    b = np.empty(3, dtype=int)
    
    a[0] = 0
    range_3 = range(3)
    for j in range_3:
        b[j] = c_1[j] - a[0]
    for i in range(1, 3):
        a[i] = c[i][0] - b[0]

    # 条件通りかどうか判定するのに探索
    good = True
    for i, a_i in enumerate(a):
        for j, b_j in enumerate(b):
            if a_i + b_j != c[i][j]:
                good = False

    if good: print("Yes")
    else: print("No")


if __name__ == "__main__":
    main()

Measured memory_bytes: 14536
#include<bits/stdc++.h>
using namespace std;
const int maxn=200010;
long long d[maxn];
int color[maxn];
vector<int>a[maxn];
long long num=0;
bool bfs(int s) 
{  
	queue<int>q;
    q.push(s);  
    color[s] = 1;
    num++;
    while(!q.empty()) 
	{  
        int u = q.front();  
        q.pop();  
        for(int i = 0; i < a[u].size(); i++)   
        {
	         if(color[a[u][i]] == -1) 
			 {  
	            q.push(a[u][i]);
	            color[a[u][i]] = !color[u];
	            if(color[a[u][i]]==1) num++;
	         }  
	         if(color[u] == color[a[u][i]])   return false;  
        }
    }
    return true;       
} 
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		a[l].push_back(r);
		a[r].push_back(l);
		d[l]++;
		d[r]++;
	}
	long long N=n;
	for(int i=1;i<=n;i++) color[i]=-1;
	if(bfs(1))
	{
		long long ans=0;
		for(int i=1;i<=n;i++)
		{
			long long ret;
			if(color[i]==1) ret=N-num;
			else ret=num;
			ans+=ret-d[i];
		}
		printf("%lld",ans/2);
	}
	else
	{
		printf("%lld",N*(N-1)/2-m);
	}
}  

Measured memory_bytes: 9728
#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
using namespace std;
#define sd(n) scanf("%d", &n)
#define sdd(n, m) scanf("%d%d", &n, &m)
#define sddd(n, m, k) scanf("%d%d%d", &n, &m, &k)
#define pd(n) printf("%d\n", n)
#define pc(n) printf("%c", n)
#define pdd(n, m) printf("%d %d\n", n, m)
#define pld(n) printf("%lld\n", n)
#define pldd(n, m) printf("%lld %lld\n", n, m)
#define sld(n) scanf("%lld", &n)
#define sldd(n, m) scanf("%lld%lld", &n, &m)
#define slddd(n, m, k) scanf("%lld%lld%lld", &n, &m, &k)
#define sf(n) scanf("%lf", &n)
#define sc(n) scanf("%c", &n)
#define sff(n, m) scanf("%lf%lf", &n, &m)
#define sfff(n, m, k) scanf("%lf%lf%lf", &n, &m, &k)
#define ss(str) scanf("%s", str)
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = a; i >= n; i--)
#define mem(a, n) memset(a, n, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mod(x) ((x) % MOD)
#define gcd(a, b) __gcd(a, b)
#define lowbit(x) (x & -x)
typedef pair<int, int> PII;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const int inf = 0x3f3f3f3f;
inline int read()
{
    int ret = 0, sgn = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            sgn = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
    {
        ret = ret * 10 + ch - '0';
        ch = getchar();
    }
    return ret * sgn;
}
inline void Out(int a) //ê?3?ía1ò
{
    if (a > 9)
        Out(a / 10);
    putchar(a % 10 + '0');
}

ll gcd(ll a, ll b)
{
    return b == 0 ? a : gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
///快速幂m^k%mod
ll qpow(ll x, ll n, ll mod)
{
    if (n == 0)
        return 1;
    ll res = qpow((x * x) % mod, n / 2, mod) % mod;
    if (n & 1)
        res = (res * x) % mod;
    return res % mod;
}
// 快速幂求逆元
int Fermat(int a, int p) //费马求a关于b的逆元
{
    return qpow(a, p - 2, p);
}

///扩展欧几里得
ll exgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1;
        y = 0;
        return a;
    }
    ll g = exgcd(b, a % b, x, y);
    ll t = x;
    x = y;
    y = t - a / b * y;
    return g;
}

ll m, p;
ll ans, res, x;
ll n, a, b;

int main()
{
    ans = 0;
    slddd(n, a, b);
    res = a + b;
    if (a == 0)
        puts("0");
    else
    {
        x = n / res;
        ans += x * a;
        if (n % res > a)
            ans += a;
        else
            ans += n % res;
        pld(ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

bool seen[100005];
int dp[100005];
vector<pii> edges[100005];
void solve() {
  int n;
  cin >> n;
  for(int i = 1; i < n; i++) {
    int a, b, w;
    cin >> a >> b >> w;
    a--;
    b--;
    w %= 2;
    edges[a].push_back({b, w});
    edges[b].push_back({a, w});
  }
  seen[0] = true;
  queue<int> q;
  q.push(0);
  while(!q.empty()) {
    int curr = q.front();
    q.pop();
    for(pii out: edges[curr]) {
      if(seen[out.first]) continue;
      seen[out.first] = true;
      dp[out.first] = dp[curr] ^ out.second;
      q.push(out.first);
    }
  }
  for(int i = 0; i < n; i++) cout << dp[i] << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


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

int main(){
  int i,j,a;
  stack<int>S1;
  stack<pair<int,int> >S2;
  vector<int>ans;
  char ch;
  int sum=0;
  for(i=0;cin>>ch;i++){
    if(ch=='\\')S1.push(i);
    else if(ch=='/' && S1.size()>0){
      j=S1.top();
      S1.pop();
      a=i-j;
      sum+=i-j;
      while(S2.size() >0 && S2.top().first > j){
	a+=S2.top().second;
	S2.pop();
      }
      S2.push(make_pair(j,a));
    }
  }
  //

  while(S2.size() > 0){
    ans.push_back(S2.top().second);
    S2.pop();
  }
  reverse(ans.begin(),ans.end());
  cout << sum << endl;
  cout << ans.size();
  for(i=0;i<ans.size();i++){
    cout << " ";
    cout << ans[i];
    
  }
  cout << endl;

  return 0;
  
}

Measured memory_bytes: 3164
// https://atcoder.jp/contests/abc067/tasks/abc067_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  int n, k, sum = 0;
  cin >> n >> k;
  vector<int> l(n);
  REP(i, n)
  {
    cin >> l[i];
  }

  sort(ALL(l));

  REP(i, k)
  {
    sum += l[n-i-1];
  }

  cout << sum << '\n';

  return 0;
}


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

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

    char a, b;
    cin >> a >> b;
    if (a == b) {
        cout << 'H';
    }
    if (a != b) {
        cout << "D";
    }
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
n=int(input())
edge=[[] for _ in range(n)]
for i in range(n-1):
    x,y=map(int,input().split())
    edge[x-1].append(y-1)
    edge[y-1].append(x-1)
def dfs(node,dist,distl):
    distl[node]=dist
    for e in edge[node]:
        if distl[e]==-1:
            dfs(e,dist+1,distl)
dista,distb=[-1]*n,[-1]*n
dfs(0,0,dista)
dfs(n-1,0,distb)
a,b=0,0
for i in range(n):
    if dista[i]<=distb[i]:
        a+=1
    else:
        b+=1
print('Fennec' if a>b else 'Snuke')

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

int main()
{
    long long N, K, Q;
    cin >> N >> K >> Q;
    vector<long long> a(Q);
    vector<long long> n(N);
    for (long long i = 0; i < Q;i++){
        cin >> a.at(i);
    }
    for (long long i = 0; i < N; i++)
    {
        n.at(i)=K-Q;
    }
    //cout << endl;

    for (long long i = 0; i < Q; i++)
    {
        n.at(a.at(i)-1)++;

    }
    cout << endl;
    for (long long i = 0; i < N; i++)
    {
        if(n.at(i)>0){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
        
    }
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
void fl()
{
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
int main()
{
//   fl();
	long long n;
	scanf("%lld",&n);
	if(n%2)
	{
		puts("0");
		return 0;
	}
	long long ans=0;
	long long power=1;
	for(int i=1;i<=25;i++)
	{
		power*=5;
		if(power>n)
			break;
		ans+=n/(power*2);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

string table1[32]={"101","000000","000011","10010001","010001","000001","100101","10011010","0101","0001","110","01001","10011011","010000","0111","10011000","0110","00100","10011001","10011110","00101","111","10011111","1000","00110","00111","10011100","10011101","000010","10010010","10010011","10010000"};
char table2[6]={' ','\'',',','-','.','?'};

string binary(int num){
	string ans="";
	for(int i=4;i>=0;i--){
		ans+=(char)(num/(int)pow(2,i)+'0');
		num-=(num/(int)pow(2,i))*(int)pow(2,i);
	}
	return ans;
}

string change(char c){
	string ans;
	if(isalpha(c)){
		int num=c-'A';
		ans=binary(num);
	}else{
		if(c==' ')ans=binary(26);
		else if(c=='.')ans=binary(27);
		else if(c==',')ans=binary(28);
		else if(c=='-')ans=binary(29);
		else if(c=='\'')ans=binary(30);
		else if(c=='?')ans=binary(31);
	}
	if(ans.size()<5)ans='0'+ans;
	return ans;
}

string rechange(string str){
	int size=str.size();
	string pack="",ans="";
	int counta=0;
	while(counta<size){
		pack+=str[counta];
		for(int i=0;i<32;i++){
			if(pack==table1[i]){
				if(i<6){
					ans+=table2[i];
				}else{
					ans+=(char)(i-6+'A');
				}
				pack="";
				break;
			}
		}
		counta++;
	}
	return ans;
}

int main(){
	string s;
	while(getline(cin,s)){
		int size=s.size();
		string alt="";
		rep(i,size){
			alt+=change(s[i]);
		}
		cout<<rechange(alt)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1248