akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {

    static Deque<Integer> queue = new ArrayDeque<Integer>();
    static List<List<Integer>> edgeList = new ArrayList<List<Integer>>();
    static int[] distArray;
    static int[] route;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int m = Integer.parseInt(scan.next());

        for (int i = 0; i <= n; i++) {
            edgeList.add(new ArrayList<Integer>());
        }
        distArray = new int[n + 1];
        Arrays.fill(distArray, -1);
        route = new int[n + 1];
        Arrays.fill(route, -1);

        for (int i = 0; i < m; i++) {
            int a = Integer.parseInt(scan.next());
            int b = Integer.parseInt(scan.next());
            edgeList.get(a).add(b);
            edgeList.get(b).add(a);
        }
        scan.close();

        addNode(0, 1, 0);
        while (!queue.isEmpty()) {
            int curNode = queue.poll();
            for (int i : edgeList.get(curNode)) {
                addNode(curNode, i, distArray[curNode] + 1);
            }
        }

        for (int i = 1; i <= n; i++) {
            if (distArray[i] == -1) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
        for (int i = 2; i <= n; i++) {
            System.out.println(route[i]);
        }

    }

    private static void addNode(int from, int node, int dist) {
        if (distArray[node] != -1) {
            return;
        }

        route[node] = from;
        distArray[node] = dist;
        queue.add(node);
    }

}


Measured memory_bytes: 77884
#include<iostream>
#define MAX 9
using namespace std;
int main(){
  int i = 1, j = 1;
  int sum;
  for( i = 1 ; i <= MAX ; i++ ){
    for(j = 1 ; j <= MAX ; j++ ){
      sum = i * j;
      cout << i << "x" << j << "=" << sum << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2996
#include <bits/stdc++.h>
using namespace std;
int _I(){ int x ; scanf("%d", &x); return x; }
int mp[ 10005 ];
int ar[ 200005 ];
void solve()
{
    long long h;
    cin>>h;
    long long c = 0;
    while( h )
    {
        c++;
        h /= 2;
    }
    //cout<<c<<"
    long long ans = (1LL<<c)-1;
    cout<<ans<<"\n";
}
int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main() {
    int z = 0, o = 0;
    string s;cin >> s;
    int n = s.size();
    for (int i = 0; i < n; i++) {
        if (s[i] == '0') z++;
        else if (s[i] == '1') o++;
    }
    cout << 2 * min(z, o) << endl;
    
}

Measured memory_bytes: 512
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	string s;
	cin>>n>>k>>s;
	s[k-1]+='a'-'A';
	cout<<s;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
  int n,m;
  int *result;
  int i;
  int tmp;
  int *success;
  int *penalty;
  int total_s=0,total_p=0;
  char tmp_s[3];
  char *ac="AC";
  char *wa="WA";
  
  scanf("%d %d",&n,&m);
  result=(int*)malloc(sizeof(int)*n);
  success=(int*)malloc(sizeof(int)*n);
  penalty=(int*)malloc(sizeof(int)*n);
  for(i=0;i<n;i++){
    result[i]=0;
    success[i]=0;
    penalty[i]=0;
  }
  
  for(i=0;i<m;i++){
    scanf("%d %s",&tmp,tmp_s);
    if(result[tmp-1]==0 && strncmp(tmp_s,wa,2)==0){
      penalty[tmp-1]++;
    } else if(result[tmp-1]==0 && strncmp(tmp_s,ac,2)==0){
      success[tmp-1]++;
      result[tmp-1]=1;
    }
  }
  
  for(i=0;i<n;i++){
    if(success[i]==1){
      total_p+=penalty[i];
      total_s++;
    }
  }
  
  printf("%d %d",total_s,total_p);
  free(result);
}


Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {

		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(reader.readLine());
		String[] rb = reader.readLine().split("");
		int r_count = 0;
		for (int i = 0; i < N; i++) {
			if (rb[i].equals("R")) {
				r_count++;
			}
		}
		int b_count = N - r_count;
		if (r_count > b_count) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

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

    int h, w, i, j;

    cin >> h >> w;

    char s[h + 1][w + 1];



    for( i = 1 ; i <= h ; i = i + 1 ){

         for( j = 1 ; j <= w ; j = j + 1 ){

              cin >> s[i][j];

              }

         }


    for( i = 1 ; i <= h ; i = i + 1 ){

         for( j = 1 ; j <= w ; j = j + 1 ){

              if( s[i][j] == '#' ){

                  if( s[i][j + 1] == '#' || s[i + 1][j] == '#' || s[i][j - 1] == '#' || s[i - 1][j] == '#' ) i = i;

                  else{

                         cout << "No" << endl;

                         return 0;

                         }

                  }

              }

         }


    cout << "Yes" << endl;


    return 0;

    }

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int c = Integer.parseInt(sc.next());
if(a<=c&&c<=b){
    out.println("Yes");
}else{
    out.println("No");
}
}
}

Measured memory_bytes: 21844
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<vector>
#include<queue>
#include<tuple>
using namespace std;

char s[20][20];
int d[20][20];
bool visited[20][20];

int d4[5]={0,1,0,-1,0};//0-3 1-4

int main(){
  
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,ans=0;
    cin>>h>>w;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>s[i][j];


    //for(int i=0;i<h;i++)for(int j=0;j<w;j++)cout<<s[i][j]<<"\n "[j!=w-1];

    for(int i=0;i<h;i++)for(int j=0;j<w;j++){

        if(s[i][j]=='#')continue;
        //init
        for(int i=0;i<h;i++)for(int j=0;j<w;j++)d[i][j]=0;
        for(int i=0;i<h;i++)for(int j=0;j<w;j++)visited[i][j]=false;

        queue<tuple<int,int,int>>q;
        q.push(make_tuple(i,j,0));
        visited[i][j]=true;
        d[i][j]=0;
        while(!q.empty()){
            tuple<int,int,int> p=q.front();q.pop();
            
            //cout<<get<0>(p)<<get<1>(p)<<endl;
            d[get<0>(p)][get<1>(p)]=get<2>(p);
            
            for(int i=0;i<4;i++){
                int ni=get<0>(p)+d4[i],nj=get<1>(p)+d4[i+1];
                if(0<=ni&&ni<h&&0<=nj&&nj<w){
                    if(visited[ni][nj]==false&&s[ni][nj]=='.')visited[ni][nj]=true,q.push(make_tuple(ni,nj,get<2>(p)+1));
                }
            }
        }
        //for(int i=0;i<h;i++)for(int j=0;j<w;j++)cout<<d[i][j]<<"\n "[j!=w-1];
        for(int i=0;i<h;i++)for(int j=0;j<w;j++)ans=max(ans,d[i][j]);
    }
    cout<<ans<<endl;
  
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll 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()
{
    string x;
    cin >> x;
    int ans=x.size();
    int s=0;
    int t=0;
    bool b=true;
    REP(i,x.size()){
        if(b&&x[i]=='S'){
            ans-=min(s,t)*2;
            b=false;
            if(s>t){
                s-=t-1;
                t=0;
            }
            else{
                s=1;
                t=0;
            }
        }
        else if(x[i]=='S'){
            s++;
        }
        else{
            b=true;
            t++;
        }
    }
    ans-=min(s,t)*2;
    cout << ans << endl;
}


Measured memory_bytes: 640
N = int(input())
A = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]

monster = 0
for i in range(N):
    if A[i] >= B[i]:
        A[i]=A[i]-B[i]
        monster += B[i]
    else:
        monster += A[i]
        remain = B[i]-A[i]
        A[i]=0
        if A[i+1]>remain:
            monster += remain
            A[i+1] -= remain
        else:
            monster+=A[i+1]
            A[i+1]=0
print(monster)

Measured memory_bytes: 18624
#include<bits/stdc++.h>
#define intt long long 
using namespace std;
const int maxx = 2001;
int read(){int k;scanf("%d",&k);return k;}
int lin[maxx],n,m,len;
int dp1[maxx];
int dp2[maxx];
int L[maxx];
int MAX,k;
int son[maxx];
int X[maxx];
int Y[maxx];
int top=0;
int f[maxx];
int ans=0;
int lim;
struct edge{
	int y,next;
}e[maxx*10];
void init(int x,int y){e[++len].y=y;e[len].next=lin[x];lin[x]=len;}
void insert(int x,int y){init(x,y);init(y,x);}
void dfs(int x,int dp,int fa=0){
	if(dp==lim+1)return ;
	ans++;
	f[x]=1;
	for(int i=lin[x];i;i=e[i].next){
		int y=e[i].y;
		if(y==fa)continue;
		if(f[y]==0){
			dfs(y,dp+1);
		}
	}
}
int Ans=0;
void slove(){
	if(k%2==0){
		lim=k/2;
		for(int i=1;i<=n;i++){
			memset(f,0,sizeof(f));ans=0;
			dfs(i,0,0);
			Ans=max(Ans,ans);
		}
	}
	else {
		lim=k/2;
		for(int i=1;i<=n-1;i++){
			memset(f,0,sizeof(f));
			ans=0;
			dfs(X[i],0,Y[i]);
			dfs(Y[i],0,X[i]);
			Ans=max(Ans,ans);
		}
	}
	cout<<n-Ans<<endl;
}
int main(){
	n=read();k=read();
	for(int i=1;i<=n-1;i++){
		int x=read();int y=read();
		X[i]=x;Y[i]=y;
		insert(x,y);
	}
	slove();
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int B[4][3][10];
void disp() {
  for (int i = 0; i < 4; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 10; k++) {
        cout << " ";
        cout << B[i][j][k];
      }
      cout << endl;
    }
    if (i < 3)
      cout << "####################" << endl;
  }
}
int main() {
  int n;
  cin >> n;
  while (n--) {
    int b, f, r, v;
    cin >> b >> f >> r >> v;
    B[b - 1][f - 1][r - 1] += v;
  }
  disp();
  return 0;
}


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

int main() {
    long long n,m;
    cin >> n >> m;
    long long a[100005];
    //int b[100005];
    for(int i=0; i<n; i++) cin >> a[i];
    long long p=1;
    for(int i=0; i<n; i++){
        long long x=1;
        while(a[i]%2==0){
            a[i] /= 2;
            x *= 2;
        }
        if(i==0){
            p=x;
        } else if(p != x){
            cout << 0 << endl;
            return 0;
        }
    }

    p /= 2;
    long long s=1;
    for(int i=0; i<n; i++){
        s = s/__gcd(s,a[i])*a[i];
        if(s*p>m){
            cout << 0 << endl;
            return 0;
        }
    }

    cout << (m+s*p)/(2*s*p) << endl;
}

Measured memory_bytes: 1024
n = int(input())
lsa = list(map(int,input().split()))
lsb = list(map(int,input().split()))
p = 0
t = []
for i in range(n):
    if i ==0:
        p += sum(lsb) + lsa[0]
        t.append(p)
        p = 0
    else:
        p += sum(lsa[:i+1]) + sum(lsb[i:])
        t.append(p)
        p = 0
print(max(t))


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

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

#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()

const ll inf = 1e18;
const int N = 100100;

ll n, m, k, a[N], dp[N][305], ans;

int main() {
	cin >> n >> m >> k;
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
		dp[i][1] = a[i];
	}
	for (ll i = 2; i <= k; i++) {
		deque<ll> d;
		ll j;
		for (j = max(1LL, i - m); j < i; j++) {
			while (!d.empty() && dp[j][i - 1] >= dp[d.back()][i - 1])
				d.pop_back();
			d.push_back(j);
		}
		for ( ; j <= n; j++) {
			ll mx = dp[d.front()][i - 1];
			dp[j][i] = max(dp[j][i], mx + i * a[j]);
			while (!d.empty() && d.front() <= j - m)
				d.pop_front();
			while (!d.empty() && dp[j][i - 1] >= dp[d.back()][i - 1])
				d.pop_back();
			d.push_back(j);
		}
	}
	for (ll i = 1; i <= n; i++)
		ans = max(ans, dp[i][k]);
	cout << ans;
}


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

int main(void) {
  int n, k;
  cin >> n >> k;

  string s;
  cin >> s;

  if(s[k-1]=='A'){
    s[k-1]='a';
  } else if(s[k-1]=='B'){
    s[k-1]='b';
  } else {
    s[k-1]='c';
  }

  cout << s << endl;
}


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

int main(){
  int N,ans=0;
  int a[100000];

  cin>>N;
  for(int i=1;i<=N;i++)
    cin>>a[i];

  for(int i=1;i<=N;i++){
    if(a[a[i]]==i)
      ans++;
  }

  cout<<ans/2<<endl;;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>

using namespace std;

int main() {
    
    string S;
    cin >> S;
    
    int cnt=0;
    for(int i=0;i<3;i++){
        if(S[i]=='o'){
            cnt++;
        }
    }
    
    int ans=700;
    ans+= cnt*100;
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n);

    for(int i =0 ; i< n; ++i)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    vector<vector<int> > dp(n, vector<int> (3,0));

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for(int i = 1; i< n; ++i)
    {
        dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a[i];
        dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b[i];
        dp[i][2] = max(dp[i-1][0],dp[i-1][1]) + c[i];
    }

    int ans = 0;
    for(int j = 0; j< 3; ++j)
    {
        ans = max(ans,dp[n-1][j]);
    }
    cout << ans;


    return 0;
}

Measured memory_bytes: 6912
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 数字の数 */
	private static final int N = 3;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int[] a = new int[N];
			int sum = IntStream.range(0, N).map(i -> a[i] = scanner.nextInt()).sum();
			System.out.println(sum + Arrays.stream(a).max().getAsInt() * 9);
		}
	}
}


Measured memory_bytes: 36088
import std.stdio;
import std.algorithm;
import std.conv;
import std.string;
import std.array;
import std.math;

void main(){
  auto input = readln().chomp.split.map!(to!int);

  if(input[1] % input[0] == 0){
    writeln(input[0] + input[1]);
  }else{
    writeln(input[1] - input[0]);
  }
}


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

int main() {
	int64_t n, a, b, r;
	cin >> n >> a >> b;
	if (n == 1) {
		r = a == b;
	} else if (a > b) {
		r = 0;
	} else {
		r = ((n - 1) * b + a) - ((n - 1) * a + b) + 1;
	}
	cout << r << endl;
	return 0;
}


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

using namespace std;
int main(){
  string s;
   cin >>s;
  
  long res=1000;
  for(char c='a';c<='z';c++){
    string t=s;
    long cnt=0;
    
    while(1){
      bool flag=true;
      for(int i=1;i<t.length();i++){
      if(t[i-1]!=t[i]) flag=false;
     }
      if(flag) break;
      
     for(int i=0;i<t.length()-1;i++){
   if(t[i]==c||t[i+1]==c) t[i]=c;
      }
    t=t.substr(0,t.length()-1);
    cnt++;
  }
   res=min(cnt,res); 
  }
    
 cout << res << endl; 
}


Measured memory_bytes: 256
-- modules to import --

import qualified Data.ByteString.Char8
import qualified Data.Maybe
import           Prelude

-- functions for this task --

readInteger'    = Prelude.fst . Data.Maybe.fromJust . Data.ByteString.Char8.readInteger
readListInteger = Prelude.map readInteger' . Data.ByteString.Char8.words

getInteger     = readInteger'    <$> Data.ByteString.Char8.getLine
getListInteger = readListInteger <$> Data.ByteString.Char8.getLine

task_A :: Integer -> Integer -> Data.ByteString.Char8.ByteString
task_A num_piece_a num_piece_b
        | stat_a && stat_b == True = Data.ByteString.Char8.pack $ "Yay!"
        | Prelude.otherwise        = Data.ByteString.Char8.pack $ ":("
        where
        stat_a = num_piece_a <= (8 :: Integer)
        stat_b = num_piece_b <= (8 :: Integer)

-- the main process is as follows --

main :: IO ()
main = do

        -- STEP.01
        -- read out the given data
        [num_piece_a, num_piece_b] <- getListInteger

        -- STEP.02
        -- calculate & output the answer of this task
        Data.ByteString.Char8.putStrLn $ task_A (num_piece_a) (num_piece_b)

Measured memory_bytes: 380
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

// 300*11
#define BUF_SIZE 3500
#define COST_MAX 0x7f7f7f7f

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
#ifdef BUF_SIZE
    char line[BUF_SIZE];
    char *tmpbuf = line;
    int i;
    if(!fgets(line, BUF_SIZE, stdin)) return -1;
    for(i = 0; i < size; i++) {
        char *tmp = strtok(tmpbuf, " ");
        arr[i] = strtol(tmp, NULL, 10);
        tmpbuf = NULL;
    }
#else
#error
#endif
    return 0;
}

#define VERTEX_MAX 300

int main(void) {
    int cities;
    int graph[VERTEX_MAX][VERTEX_MAX];
    int roads[VERTEX_MAX][VERTEX_MAX];
    memset(roads, 0x7f, sizeof(int)*VERTEX_MAX*VERTEX_MAX);
    cities = get_int();

    int i, j, k;
    for(i = 0; i < cities; i++) {
        fget_array(graph[i], cities);
    }

    // Warshall Floyd (connect step)
    for(k = 0; k < cities; k++) {
        for(i = 0; i < cities; i++) {
            if(i == k) continue;
            for(j = 0; j < cities; j++) {
                if(i == j || j == k) continue;
                // < 2-billion
                int new = graph[i][k] + graph[k][j];
                // ensure that all roads are shortest path
                if(new < graph[i][j]) {
                    printf("-1\n");
                    return 0;
                }
                // building 2 roads are more convenient
                if(new == graph[i][j]) {
                    roads[i][k] = graph[i][k];
                    roads[k][j] = graph[k][j];
                }
            }
        }
    }

    // Warshall Floyd (remove step)
    for(k = 0; k < cities; k++) {
        for(i = 0; i < cities; i++) {
            if(i == k) continue;
            for(j = 0; j < cities; j++) {
                // ensure that i, j and k are all different
                if(i == j || j == k) continue;
                // < 2-billion
                int new = graph[i][k] + graph[k][j];
                // i<->j can be removed because of more convenient paths between i and j.
                if(new == graph[i][j]) {
                    roads[i][j] = 0;
                }
            }
        }
    }

    // we can't help building road
    for(i = 0; i < cities; i++) {
        for(j = 0; j < cities; j++) {
            if(roads[i][j] == COST_MAX) {
                roads[i][j] = graph[i][j];
            }
        }
    }

    uint64_t ans = 0;
    for(i = 0; i < cities; i++) {
        for(j = i+1; j < cities; j++) {
#ifdef DEBUG
            printf("%d, %d -> %d\n", i,j,roads[i][j]);
#endif
            ans += (uint64_t)roads[i][j];
        }
    }
    printf("%llu\n", ans);
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<ll,ll> P;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000007;
const int mod=1000000007;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}
int main(){
  int n;cin>>n;
  vi c(n,-1);
  c[0]=0;
  vector<vector<P>> v(n);
  rep(i,n){
    int a,b,x;cin>>a>>b>>x;
    x%=2;
    v[a-1].emplace_back(b-1,x);
    v[b-1].emplace_back(a-1,x);
  }
  queue<int> q;
  q.push(0);
  while(!q.empty()){
    int i=q.front();
    q.pop();
    for(auto j:v[i]){
      if(c[j.first]==-1){
        c[j.first]=c[i]+j.second;
        q.push(j.first);
      }
    }
  }
  rep(i,n)cout<<c[i]%2<<endl;
}

Measured memory_bytes: 8704
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import product, combinations,permutations
from copy import deepcopy
import sys
sys.setrecursionlimit(4100000)



if __name__ == '__main__':
    X  = int(input())
    if X>=30:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 10540
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if(s.length() == 2) System.out.println(s);
        else {
            for(int i = 2; i >= 0; i--) {
                System.out.print(s.charAt(i));
            }
            System.out.println();
        }
    } 
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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(){
    string s;cin>>s;
    if(s>"2019/04/30"){
        cout<<"TBD"<<endl;
    }
    else cout<<"Heisei"<<endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
const int MOD = 1000000009;
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int ice[10];
  int c;

  cin >> n;
  while(n != 0){
    memset(ice, 0, sizeof(ice));
    for(int i = 0;i < n;i++){
      cin >> c;
      ice[c]++;
    }
    
    for(int i = 0;i <= 9;i++){
      if(ice[i] == 0){
	cout << "-" << endl;
      }else{
	for(int j = 0;j < ice[i];j++){
	  cout << "*";
	}
	cout << endl;
      }
    }
    
    cin >> n;
  }
  return 0;
}




Measured memory_bytes: 3052
#include <stdio.h>
int main(void){
    char W[11], T[1100];
    int i, count=0;
    
    scanf("%s", &W);
    for(i=0; i<strlen(W); i++) {
        W[i] = tolower(W[i]); //大文字を小文字に変換
    }
    while(scanf("%s", &T)) {
        if (strcmp(T,"END_OF_TEXT") == 0)  break;
        for(i=0; i < strlen(T); i++) {
            T[i] = tolower(T[i]); 
        }
        if(strcmp(W,T) == 0) count++;
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 2068
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <fstream>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
typedef long long ll;

#define INF 1000000000

int main(){
    int n,k,m;
    while(cin>>n>>k>>m, n){
        vector<int> vec(n+1);
        repl(i,1,n) vec[i]=i+1;
        vec[n] = 1;

        vec[(m-1+n-1)%n+1] = (m+1-1)%n+1;
        int now=(m-1+n-1)%n+1;
        
        rep(i,n-2){
            rep(j,k-1){
                now = vec[now];
            }
//            dbg(vec[now]);
            vec[now] = vec[vec[now]];
        }

        cout<< vec[now] << endl;
    }

    return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
const long long INF = 1LL << 60;

int N,M;

int main(){
  cin >> N >> M;
  if(N == M) cout << "Yes";
  else cout << "No";
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    long L = sc.nextLong();
    long R = sc.nextLong();

    sc.close();

    long r = Math.min(R, L+2020);

    long min = 2018;
    
    for (long i = L; i <= r; i++){
      for (long j = i + 1; j <= r; j++){
        long m = i*j%2019;
        min = Math.min(min, m);
      }
    }

    System.out.println(min);
    
  }

}


Measured memory_bytes: 23252
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int A, B;
    cin >> A >> B;
    if(A < 10 && B < 10) {
        cout << A * B << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}

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

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

    ll A[N + 1];
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    // N+1は0枚あるとすると実装しやすい
    A[N] = 0;

    ll ans = 0;
    for (int i = 0; i < N; ++i) {
        // i同士のペアを作れるだけ作る
        ans += A[i] / 2;
        A[i] %= 2;

        // iとi+1のペアを作れれば作る
        if (A[i] > 0 && A[i + 1] > 0) {
            ++ans;
            --A[i];
            --A[i + 1];
        }
    }

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

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define rn return
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;


int main(){
    int a,b; cin >> a >> b;
    if (a<=0 && b>=0) { cout << "Zero"; rn 0;}
    if (a>0 && b>0) {cout << "Positive"; rn 0;}
    else cout << ((b-a+1)%2 == 0? "Positive" : "Negative");
    rn 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

struct edge {
    int to, cost;
};

int V;
vector<edge> G[1000000];
vector<edge> GG[1000000];
ll d[1000000];

void addedge(int st, int ed, int co) {
    edge e;
    e.to = ed;
    e.cost = co;
    G[st].push_back(e);
}

void addedge2(int st, int ed, int co) {
    edge e;
    e.to = ed;
    e.cost = co;
    GG[st].push_back(e);
}

bool moji[1000000];

int h[1000000];
vector<int> tsorted;

bool tsort() {
    fill(h, h + V, 0);
    for (int i = 0; i < V; i++) {
        int len = G[i].size();
        for (int j = 0; j < len; j++) {
            h[G[i][j].to]++;
        }
    }
    queue<int> que;
    for (int i = 0; i < V; i++) {
        if (h[i] == 0) {
            que.push(i);
            tsorted.push_back(i);
        }
    }
    while (!que.empty()) {
        int p = que.front();
        que.pop();
        int len = G[p].size();
        for (int i = 0; i < len; i++) {
            int mark = G[p][i].to;
            h[mark]--;
            if (h[mark] == 0) {
                que.push(mark);
                tsorted.push_back(mark);
            }
        }
    }
    int sortedsize = tsorted.size();
    if (sortedsize == V) {
        return true;
    } else {
        return false;
    }
}

int main() {
    int N, M;
    cin >> N >> M;
    string s;
    cin >> s;
    V = 2 * N;
    for (int i = 0; i < N; i++) {
        if (s[i] == 'A') {
            moji[i] = true;
        } else {
            moji[i] = false;
        }
    }
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        if (moji[a - 1] == moji[b - 1]) {
            addedge2(a - 1, b - 1 + N, 1);
            addedge2(b - 1, a - 1 + N, 1);
        } else {
            addedge2(a - 1 + N, b - 1, 1);
            addedge2(b - 1 + N, a - 1, 1);
        }
    }
    for (int i = 0; i < V; i++) {
        int len = GG[i].size();
        set<int> s;
        for (int j = 0; j < len; j++) {
            s.insert(GG[i][j].to);
        }
        for (auto itr = s.begin(); itr != s.end(); ++itr) {
            int j = *itr;
            addedge(i, j, 1);
        }
    }
    bool ok = tsort();
    if (ok) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 71928
import java.util.Scanner;

class Main{

    static void print(String[] s){
        for(int i = 0; i < s.length; i++){
            System.out.print((i == 0 ? "" : " ") + s[i]);
        }
        System.out.println();
    }

    static boolean isSame(String[] a, String[] b){
        for(int i = 0; i < a.length; i++){
            if(!a[i].equals(b[i]))  return false;
        }
        return true;
    }

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

        int n = Integer.parseInt(sc.nextLine());
        String[] array = sc.nextLine().split(" ");

        sc.close();

        String[] arrayB = array.clone();
        String[] arrayS = array.clone();

        int k = 0;
        while(k < n-1){
            for(int i = n-1; i > k; i--){
                if((int)(arrayB[i].charAt(1)) < (int)(arrayB[i-1].charAt(1))){
                    String tmp = arrayB[i];
                    arrayB[i] = arrayB[i-1];
                    arrayB[i-1] = tmp;
                }
            }
            k++;
        }

        print(arrayB);
        System.out.println("Stable");

        for(int i = 0; i < n; i++){
            int minj = i;
            for(int j = i; j < n; j++){
                if((int)(arrayS[j].charAt(1)) < (int)(arrayS[minj].charAt(1))){
                    minj = j;
                }
            }
            if(i != minj){
                String tmp = arrayS[i];
                arrayS[i] = arrayS[minj];
                arrayS[minj] = tmp;
            }
        }

        print(arrayS);
        if(isSame(arrayS,arrayB)){
            System.out.println("Stable");
        }else{
            System.out.println("Not stable");
        }
        
    }
}


Measured memory_bytes: 26320
#include <iostream>

using namespace std;

char mt[1000][1000];
int sum[1000];

int main()
{
    int n;
    cin >> n;
    bool fl = false;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
                cin >> mt[i][j];
                fl |= (mt[i][j] == '#');
        }
    }
    if (!fl)
    {
        cout << "-1\n";
        return 0;
    }
    int ans = 0;
    fl = false;
    for (int i = 0; i < n; ++i) {
        bool c = true;
        for (int j = 0; j < n; ++j) {
            c &= (mt[i][j] == '#');
        }
        if (c)
            fl = true;
    }
    if (!fl) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j)
                sum[i] += (mt[i][j] == '.');
        }
        int mn = n;
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                if (mt[i][j] == '#') {
                    mn = min(mn, sum[j]);
                    for (int h = 0; h < n; ++h) {
                        mn = min(mn, sum[h] + (mt[h][h] == '#' && mt[i][h] == '.') + 1);
                    }
                }
            }
        }
        ans += mn;
    }
    int blackcol = 0;
    for (int i = 0; i < n; ++i) {
        bool c = true;
        for (int j =0 ; j < n; ++j) {
            c &= (mt[j][i] == '#');
        }
        if (c) blackcol++;
    }
    ans += n - blackcol;
    cout << ans << endl;
    return 0;
}


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

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		char[] input = new char[20];
		br.read(input);

		String answer = "";
		for (int i = input.length; i > 0; i--) {
			answer += input[i - 1];
		}
		System.out.println(answer);

	}
}

Measured memory_bytes: 16864
#include <stdio.h>
#include <limits.h>
#define MAX 100

int main(){
	int n, m[MAX+1][MAX+1];
	int i, j, k, r, min;
	
	scanf("%d", &n);
	for(i=1;i<=n;++i) {
		scanf("%d %d", &m[i][i-1], &m[i+1][i]);
		m[i][i] = 0;
	}
	
	for(r=2;r<=n;++r){
		for(i=1;i<=n-r+1;++i){
			j=i+r-1;
			m[i][j] = INT_MAX;
			for(k=i;k<=j-1;++k){
				min = m[i][k]+m[k+1][j]+m[i][i-1]*m[k+1][k]*m[j+1][j];
				if(m[i][j] > min) m[i][j] = min;
			}
		}
	}
	printf("%d\n", m[1][n]);
	return 0;
}


Measured memory_bytes: 2772
function Main(input) {
  input = input.split("\n");
  var A = parseInt(input[0].split(" ")[0]);
  var B = parseInt(input[0].split(" ")[1]);
  var ans=0;
  if(A>=13){
    ans=B;
  }else if(A>=6){
    ans=B/2;
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21952
#include<stdio.h>
int main()
{
	int n,m;
	int t[101];
	int a[101];
	int i,j;
	int p,x;
	int sum;

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

	for(i=0;i<m;i++){
		sum = 0;
		for(j=0;j<n;j++){
			a[j] = t[j];
		}
		scanf("%d %d",&p,&x);
		a[p-1] = x;
		for(j=0;j<n;j++){
			sum += a[j];
		}
		printf("%d\n",sum);
	}

	return 0;
}


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

int f[30];

int main() {
    //ios_base::sync_with_stdio(false)
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    for(int i = 0; i < 30; i++)
        f[i] = 1e9;
    for(int i = 0; i < n; i++) {
        string s;
        cin >> s;
        vector<int> calc(30, 0);
        for(auto x: s)
            calc[x - 'a']++;
        for(int i = 0; i < 30; i++)
            f[i] = min(f[i], calc[i]);
    }
    string ans = "";
    for(int i = 0; i < 30; i++) {
        for(int j = 0; j < f[i]; j++)
            ans += 'a' + i;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  if(b==0){
    return a;
  }
  return gcd(b,a%b);
}
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int ans=a[0];
  for(int i=1;i<n;i++){
    ans=gcd(ans,a[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) do{}while(0)
#endif





ll n;

int main(){
	cin >> n;
	
	n = n % 1000;
	
	if ( n == 0 )
		cout << 0 << endl;
	else
		cout << 1000-n << endl;
	
	return 0;
}




Measured memory_bytes: 3636
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn main() {
  input! {
    x: isize
  };

  for a in -150..=150 {
    for b in -150..=150 {
      if a.pow(5) - b.pow(5) == x {
        println!("{} {}", a, b);
        std::process::exit(0);
      }
    }
  }
}


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

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

    string s;
    cin >> s;
    s.push_back('D');
    s = 'D' + s;
    int n = s.size();
    ll ans = 0;

    forx(i, 1, n - 1)
    {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
        {
            int j = i, k = i + 2;
            while (s[j - 1] == 'A')
                j--;
            while (s[k + 1] == 'B' && s[k + 2] == 'C')
                k += 2;
            ans += (ll)(i + 1 - j) * (ll)(k - i) / 2LL;
            rep(l, i - j + 1) s[k - l] = 'A';
            s[k - i + j - 1] = 'D';
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 788
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vv = vector<vector<ll>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))

#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()
#define PQ priority_queue<ll, vector<ll>, greater<ll>>

typedef pair<ll, ll> Pair;
bool pairCompare(const Pair &firstElof, const Pair &secondElof) {
  return firstElof.second > secondElof.second;
}

ll power(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = power(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * power(n, m - 1)) % MOD;
  }
}

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

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

  ll count = 0;
  REP(i, N) {
    if (S[i] == '(')
      count++;
    else if (count > 0)
      count--;
  }
  ll count2 = 0;
  for (ll i = N - 1; i >= 0; i--) {
    if (S[i] == ')')
      count2++;
    else if (count2 > 0)
      count2--;
  }

  REP(i, count) { S += ")"; }
  REP(i, count2) { S = "(" + S; }
  cout << S << endl;

  return 0;
}


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

int main(void) {
	int a, b, c;
	string ans;

	cin >> a >> b >> c;

	if ((a + b + c == 17) && (a * b * c == 175))
		ans = "YES";
	else
		ans = "NO";

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
fun pfactorize(n: Int): List<Pair<Int, Int>> {
    if (n == 0) return emptyList()
    if (n == 1 || n == 2 || n == 3) return listOf(n to 1)
    var m = n
    val primes = mutableListOf<Pair<Int, Int>>()
    for (i in 2..Math.sqrt(n.toDouble()).toInt()) {
        var exp = 0
        while (m % i == 0) {
            m /= i
            exp++
        }
        if (exp != 0) primes += i to exp
    }
    return primes
}

fun countDivisor(n: Int): Int {
    val pf = pfactorize(n)
    return pf.map(Pair<Int, Int>::second).fold(1) { acc, exp -> acc * (exp + 1) }
}

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ans = (1..n step 2).count { countDivisor(it) == 8 }
    println(ans)
}


Measured memory_bytes: 33680
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef pair<int,int> PII;
int a,b;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define MAX(a,b) a>b? a:b
#define MIN(a,b) a>b? b:a

int MINN(vector<int>a,int k){
int min=1e9;
REP(i,k){
  if(a[i]<=min)min=a[i];
}
return min;
}

int main(){
int n,y;
int a=-1,b=-1,c=-1;
cin>>n>>y;
for(int i=0;i<=n;i++){
  for(int j=0;j<=n-i;j++){
    int k=n-i-j;
    if(i*1e4+j*5e3+k*1e3==y){
      a=i;
      b=j;
      c=k;
      break;
    }
  }
}  
cout<<a<<" "<<b<<" "<<c<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int main(){
    string S;
    cin >> S;

    vector<int> count(26, 0);
    for(int i=0;i<S.size();i++){
        count[S[i]-'a']++;
    }
    bool ok = true;
    for(int i=0;i<26;i++){
        if(count[i] >= 2){
            ok = false;
            break;
        }
    }
    if(ok) cout << "yes" << endl;
    else cout << "no" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d;
  if(a<b){
    e=a;
  }else{
    e=b;
  }
  if(c<d){
    f=c;
  }else{
    f=d;
  }
  cout<<e+f<<endl;
}

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

//#pragma gcc optimize("O3,unroll-loop")
//#pragma gcc target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,abm,mmx,popcnt,tune=native")
//#define int long long
//#define double long double

int n, m, q, a[50], b[50], c[50], d[50], arr[10], ans;

void dfs(int p)
{
    if (p == n)
    {
        int score = 0;
        for (int i = 0; i < q; i++)
            if (arr[b[i] - 1] - arr[a[i] - 1] == c[i])
                score += d[i];
        ans = max(ans, score);
    }
    else
        for (int i = arr[p - 1]; i <= m; i++)
            arr[p] = i, dfs(p + 1);
}

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

    cin >> n >> m >> q;
    for (int i = 0; i < q; i++)
        cin >> a[i] >> b[i] >> c[i] >> d[i];

    for (int i = 1; i <= m; i++)
        arr[0] = i, dfs(1);

    cout << ans << '\n';

    return 0;
}

//      *   *  *****  *   *  *   *
//     *   *  *      **  *  *   *
//    *****  *****  * * *  *   *
//   *   *      *  *  **  *   *
//  *   *  *****  *   *   ***

//      ***** ***** *   * *     ***** *   * ***** *****
//        *  *   * *   * *       *   **  *   *   *   *
//       *  *   * ***** *       *   * * *   *   *****
//   *  *  *   *   *   *       *   *  **   *   *
//  ****  *****   *   ***** ***** *   *   *   *


Measured memory_bytes: 3640
#include <iostream>
#include <cstdlib>

using namespace std;

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

    long long cnt = 0;
    for(long long i=1; i<N+1; i++){
        if((i%3==0) || (i%5==0)){
            /* 何もしない */
        }
        else{
            cnt = cnt + i;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3604
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	map<int, int> mc;
	while (n--)
	{
		int x;
		cin >> x;
		if (mc.count(x)) mc.erase(x);
		else mc[x] = 1;
	}
	cout << mc.size() << endl;
	return 0;
}


Measured memory_bytes: 4864
import java.util.*;
import java.math.*;
/**
 * @author yamato
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in);
		double H = scanner.nextInt();
		double A = scanner.nextInt();
		double ans = Math.ceil(H/A);
		
		System.out.println((int)ans);
		
	}

}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv){vprint(v)};

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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    cout << max({a*c, a*d, b*c, b*d}) << endl;
}


Measured memory_bytes: 3688
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<stack>
using namespace std;

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

	if (N < K) {
		cout << 1;
		return 0;
	}
	if (K == 1 || N ==K)
	{
		cout << 0;
		return 0;
	}
	
	if (N > K)
	{
		N -= K;
		cout << N;
		return 0;
	}
}


Measured memory_bytes: 3592