akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace C_test_For_Atcorder
{

    public static class Extensions
    {
        public static string Reverse(this string sourse){
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }


        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var D = cin.ReadInt;
            var X = cin.ReadInt;
            var Ai = new int[N];
            for (int i = 0; i < N;i++){
                Ai[i] = cin.ReadInt;
            }
            int countAll = 0;
            for (int i = 0; i < N;i++){
                int j = 0;
                while(1+j*Ai[i]<=D){
                    countAll++;
                    j++;
                }
            }
            Console.WriteLine(X+countAll);
            return;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue inputStream;

        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return (string)inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return (string)inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }

}


Measured memory_bytes: 11220
import sys
sys.setrecursionlimit(pow(10, 6))

n = int(input())
nodes = [[] for _ in range(n)]
visited = [False for _ in range(n)]
dist = [0 for _ in range(n)]

def dfs(i, d):
  dist[i] = d
  for cn, c in nodes[i]:
    if not visited[cn]:
      visited[cn] = True
      dfs(cn, d+c)

for _ in range(n-1):
  u, v, w = map(int, input().split())
  nodes[u-1].append((v-1, w))
  nodes[v-1].append((u-1, w))

visited[0] = True
dfs(0, 0)

for c in dist:
  if c % 2 == 0:
    print(0)
  else:
    print(1)


Measured memory_bytes: 167968
#include <iostream>
#include <vector>
#include <algorithm>
#define For(n) for(int i=0;i<n;i++)

using namespace std;
int main() {
    //int A = 'A',a='a',Z='Z',z='z';

    //cout << A<<" "<<Z <<"\n"<<a<<" " << z;
    char x;
    cin >> x;
    int X = x;
    if(X >=65 && X <=90 ) cout << "A\n";
    else cout <<"a\n";
    return 0;
}


Measured memory_bytes: 3068
H, W = map(int,input().split())
S = [input() for i in range(H)]
S = ["."*(W)]+S+["."*(W)]
S = ["."+s+"." for s in S]
ans = True
for h in range(1,H+1):
    if ans == False:
        break
    for w in range(1,W+1):
        if S[h][w]=="#":
            if not(S[h-1][w]=="#" or S[h+1][w]=="#" or S[h][w+1]=="#" or S[h][w-1]=="#"):
                ans = False
                break
print("Yes" if ans else "No")

Measured memory_bytes: 38896
i,j=map(int,input().split())
listA=[]
for n in range(i):
    listA.append(list(map(int,input().split())))
    listA[n].append(sum(listA[n]))
listA.append([])
for n in range(j+1):
    number=0
    for m in range(i):
        number+=listA[m][n]
    listA[i].append(number)
for n in range(i+1):
    print(' '.join(map(str,listA[n])))



Measured memory_bytes: 5704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
#define pb push_back
#define INF 1e10 + 7
#define MOD 1000000007

struct Edge {
	int s;
	int t;
};
using VE = vector<Edge>;
using VVE = vector<VE>;




int main(int argc, char **argv) {
	int n;
	ll kkk;
	cin >> n >> kkk;
	VL a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	ll sum = 0;
	for (int i = 0; i < n; ++i) {
		sum += a[i];
	}
	VL a2;
	for (ll i = 1; i * i <= sum; ++i) {
		if(sum % i == 0){
			a2.pb(i);
			a2.pb(sum / i);
		}
	}
	sort(a2.begin(), a2.end());
//	for (int i = 0; i < a2.size(); ++i) {
//		cout << a2[i] << endl;
//	}
	ll ans = 1;
	for (int i = 0; i < a2.size(); ++i) {
		VL a3;
		for (int j = 0; j < n; ++j) {
			a3.pb(a[j] % a2[i]);
		}
		sort(a3.begin(), a3.end());
		int l = 0;
		int r = n - 1;
		ll tmp = 0;
		ll need = 0;
		while(l <= r) {
			if(tmp <= 0) {
				need += a3[l];
				tmp += a3[l]; l ++;
			}else {
				tmp -= a2[i] - a3[r]; r --;
			}
		}
//		cout << a2[i] << " " << need << endl;
		assert(tmp == 0);
		if(need <= kkk) {
			ans = max(ans, a2[i]);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
int main(){
    string s;
    cin >> s;
    int l = s.length();
    int count = 0;
    for(int i = 0; i < l/2; i++){
        if(s[i] != s[l-1-i]) count++;
    }
    cout << count << endl;
}
  

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

bool inRange(int x) { return 1 <= x && x <= 12; }

int main() {
  int y, m;
  scanf("%2d%2d", &y, &m);
  if (inRange(y)) {
    puts(inRange(m) ? "AMBIGUOUS" : "MMYY");
  } else {
    puts(inRange(m) ? "YYMM" : "NA");
  }
}


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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define mod 1000000007
#define INF 100000000
#define fk first
#define sv second

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

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  FOR(i, 1, 10){
    FOR(j, 1,  10){
      cout << i << 'x' << j << '=' << i * j << endl;
    }
  }
}

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

int main(){
  int sum=0;
  string s;
  cin>>s;
  for(int i=0;i<4;i++){
    if(s.at(i)=='+'){
      sum++;
    }else{
      sum--;
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static int[][] map;
	static int[][] directions8= {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
	static int[][] directions4= {{-1,0},{1,0},{0,-1},{0,1}};
	static int ans;
	static Square[] squares;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true) {

			int N = sc.nextInt();

			if(N==0) {
				break;
			}

			squares = new Square[N];
			squares[0] = new Square();
			int maxHeight = 0;
			int minHeight=0;
			int maxWidth = 0;
			int minWidth = 0;


			for(int i = 1; i < N; i++) {
				int preNum = sc.nextInt();
				int dir = sc.nextInt();

				squares[i] = new Square(squares[preNum], dir);

				if(squares[i].height > maxHeight) {
					maxHeight = squares[i].height;
				}
				if(squares[i].height < minHeight){
					minHeight =  squares[i].height;
				}
				if(squares[i].width > maxWidth) {
					maxWidth = squares[i].width;
				}
				if(squares[i].width < minWidth){
					minWidth =  squares[i].width;
				}
			}
			System.out.println((maxWidth - minWidth +1)+" "+(maxHeight - minHeight+1));
		}
	}

	//BFS用に二つの配列を足し算する
	static int[] addArrayElms(int[] a, int[] b) {
		int[] c = new int[a.length];
		for(int i = 0; i < a.length; i++) {
			c[i] = a[i] + b[i];
		}
		return c;
	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
		return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
		return b == 0 ? a: gcd(b, a % b);
	}
}

class Square{
	int height;
	int width;
	public Square() {
		this.height = 0;
		this.width = 0;
	}
	Square(Square pre, int direction){
		if(direction == 0 ) {
			this.height = pre.height;
			this.width = pre.width -1;
		}else if(direction == 1) {
			this.height = pre.height-1;
			this.width = pre.width;
		} else if(direction == 2) {
			this.height = pre.height;
			this.width = pre.width +1;
		} else {
			this.height = pre.height +1;
			this.width = pre.width;
		}
	}

}



Measured memory_bytes: 40400
import java.util.*;
public class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);
        
        // input K
        int x1 = sc.nextInt();
        int y1 = sc.nextInt();
        int x2 = sc.nextInt();
        int y2 = sc.nextInt();
        int x3 = 0;
        int y3 = 0;
        int x4 = 0;
        int y4 = 0;
        
        int x = x2-x1;
        int y = y2-y1;
        
        x3 = x2 - y;
        y3 = y2 + x;
        x4 = x1 - y;
        y4 = y1 + x;
        
        System.out.println(x3+" "+y3+" "+x4+" "+y4);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,nt=1,cot=0;
  cin >>a>>b;
  while(true){
    if(nt>=b)break;
    nt+=a-1;
    ++cot;
  }
  cout << cot;
}

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

int main(void){
    int n,z,w;
    cin>>n>>z>>w;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    if(n==1) cout<<abs(a[0]-w)<<endl;
    else cout<<max(abs(a[n-1]-w),abs(a[n-1]-a[n-2]))<<endl;
    return 0;
}


Measured memory_bytes: 256
/*
 * AtCoder.c
 *
 *  Created on: 2016/07/23
 *      Author: たけぱん
 */



#include <stdio.h>

int main(void){
	int a,b,c;
	scanf("%d %d",&a,&b);
	c=(b-a)%2;
	if(a>0){
		printf("Positive\n");
	}else if(b>0){
		printf("Zero\n");
	}else if(c==0){
		printf("Negative\n");
	}else if(c!=0){
		printf("Positive\n");
	}
	return 0;
}


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

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

	int K, X;
	cin >> K >> X;

	for(int i = X - K + 1; i < X + K - 1; i++)
		cout << i << " ";
	cout << X+K-1 << endl;

	return 0;
}

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

priority_queue<long long>x; 
priority_queue<long long ,vector<long long>,greater<long long> >y;
long long l[300001],r[300001],s[300001]; 
int main()
{
	int n,m,t;	
	long long ans=-100000000000000,p,q;	
	scanf("%d",&n);
	for(int i=1;i<=3*n;i++)
	{
	    scanf("%lld",&s[i]);
	}
	p=0;
	q=0;
	for(int i=1;i<=3*n;i++)
	{
		y.push(s[i]);
		p+=s[i];
		l[i]=p;
		x.push(s[3*n-i+1]);
		q+=s[3*n-i+1];
		r[3*n-i+1]=q;
		if(y.size()>n)
		{
			p-=y.top();
			l[i]=p;
			y.pop();
		}
		if(x.size()>n)
		{
			q-=x.top();
			r[3*n-i+1]=q;
			x.pop();
		}
	}
	for(int i=n;i<=2*n;i++)
	{
		if (l[i]-r[i+1]>ans) 
		  ans=l[i]-r[i + 1];
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 9068
#include <bits/stdc++.h>
#define int long long
using namespace std;

string s;

signed main()
{
	cin>>s;
	
	int cnt=0,maxv=0;
	for (int i=0;i<s.size();i++)
	{
		if (s[i]=='R')  cnt++;
		else
		{
			maxv=max(maxv,cnt);
			cnt=0;
		}
	}
	if (cnt)  maxv=max(maxv,cnt);
	cout<<maxv<<endl;
	
	return 0;
}

Measured memory_bytes: 3620
//============================================================================
// Name        : 123C.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

#include<stdio.h>

using namespace std;

int main() {
	long long N;
	vector<long long>vehicle(5);
	cin >> N;
	for(int i = 0; i < 5; ++i)cin >> vehicle[i];
	sort(vehicle.begin(), vehicle.end());
	long long t = (N + vehicle[0] - 1) / vehicle[0];

	cout << t + 4 << endl;

	return 0;
}


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

queue<pair<int, pair<int, int>>> Q; //first number: distance to coordinate, second pair: store coordinates
int H, W;
char G[1005][1005];
int dist[1005][1005];

int dr[4] = {1, -1, 0, 0};
int dc[4] = {0, 0, -1, 1};

int main(){
    cin >> H >> W;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> G[i][j];
            if(G[i][j] == '#'){
                Q.push(make_pair(0, make_pair(i, j)));
            }
        }
    }

    memset(dist, -1, sizeof(dist));

    while (!Q.empty()){
        int d = Q.front().first, r = Q.front().second.first, c = Q.front().second.second;//takes out nearest node
        Q.pop();
        if(dist[r][c] != -1) continue;//check if visited
        dist[r][c] = d;//update the distance
        for (int i=0; i<4; i++){
            if(r + dr[i] >= 0 && r + dr[i] < H && c + dc[i] >= 0 && c + dc[i] < W)
                Q.push(make_pair(d + 1, make_pair(r + dr[i], c + dc[i])));
        }
    }

    int ans = 0;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            ans = max(ans, dist[i][j]);
        }
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 53448
N, M = map(int, input().split())

friends = [set() for _ in range(N)]
for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    friends[a].add(b)
    friends[b].add(a)
# print(friends)

visited = [0]*N #グループを作って合ったら
ans = 0
for i in range(N):
    if visited[i]:
        continue
    tmp = list(friends[i])
    ans_tmp = 1
    visited[i] = 1
    while tmp:
        t = tmp.pop()
        if not visited[t]:
            visited[t] = 1
            ans_tmp += 1
            for j in friends[t]:
                tmp.append(j)

    ans = max(ans, ans_tmp)
print(ans)


Measured memory_bytes: 72632
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
  string s;
  cin>>s;
  ll ans=s.size()/2;

  FOR(i,0,s.size()-1){
    if(s[i]=='p')ans--;
  }




  cout<<ans<<endl;



  return 0;
}
 


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

int main(){
  int X,Y;
  cin >> X >> Y;
  for(int i=0;i<101;i++){
    for(int j=0;j<101;j++){
      if(i+j==X && 2*i+4*j==Y){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3580
from collections import Counter

n = int(input())
v = list(map(int, input().split()))
even = [v[i] for i in range(n) if i % 2 == 0]
odd = [v[i] for i in range(n) if i % 2 == 1]

ecnt = Counter(even).most_common() + [(0, 0)]
ocnt = Counter(odd).most_common() + [(0, 0)]
if ecnt[0][0] == ocnt[0][0]:
    print(min(len(even) - ecnt[0][1] + len(odd) - ocnt[1][1],
              len(even) - ecnt[1][1] + len(odd) - ocnt[0][1]))
else:
    print(len(even) - ecnt[0][1] + len(odd) - ocnt[0][1])

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

int main(int argc, const char * argv[]) {



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

    /////////////////////
    // Write code below /
    /////////////////////
    int A[5],k;
    string flag="Yay!";

    cin>>A[0]>>A[1]>>A[2]>>A[3]>>A[4]>>k;

    rep(i,5){
        for(int j=i;j<5;j++){
            if(A[j]-A[i]>k){
                flag=":(";
            }
        }
    }

    cout<<flag<<endl;

    return 0;
}


Measured memory_bytes: 256
s=input()
t=input()
ans=1001
n=len(s)
m=len(t)
for i in range(n-m+1):
  cnt=0
  x=s[i:i+m]
  for j in range(m):
    if x[j]!=t[j]:
      cnt+=1
  ans=min(ans,cnt)
print(ans)

Measured memory_bytes: 9116
k,a,b=map(int,input().split())
cnt=0
if b<a+2:
    print(k+1)
else:
    if k>=a+1:
        k-=a+1
        cnt+=b
        q,modulo=divmod(k,2)
        cnt+=q*b-q*a+modulo
        print(cnt)
    else:
        print(k+1)
    

Measured memory_bytes: 38384
import java.io.*;

public class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            int S = Integer.parseInt(br.readLine());
            System.out.printf("%d:%d:%d\n", S/3600, (S%3600)/60, S%60);
        } catch(IOException e) {
            System.out.println(e);
        }
    }
}


Measured memory_bytes: 24724
#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	int i,j,a[105],b[105],n,m,x,y,m1,m2;
	cin>>n>>m>>x>>y;
	for(i=0;i<n;i++)cin>>a[i];
	for(i=0;i<m;i++)cin>>b[i];
	for(i=1;i<n;i++)
		if(a[i]>a[0])a[0]=a[i];
	for(i=1;i<m;i++)
		if(b[i]<b[0])b[0]=b[i];
	if(a[0]<b[0]&&a[0]>x&&a[0]<y)cout<<"No War";
	else cout<<"War";
	return 0;
}

Measured memory_bytes: 256
// while (clock()<=69*CLOCKS_PER_SEC)
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(),x.end()
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define erase_duplicates(x) sort(all(x)); (x).resize(distance((x).begin(), unique(all(x))));


using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<
T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<LL> VLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long double LD;
typedef pair<LD,LD> PLD;
typedef vector<LD> VLD;
typedef vector<PLD> VPLD;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<" = "<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<" = "<<h<<", "; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#define cerr if(0)cout
#endif

const int maxn = (1e6)+7;
const int maxk = 20;
const int inf = (1e9)+7;
const LL LLinf = ((LL)1e18)+7LL;
const LD eps = 1e-9;
const LL mod = 1e9+7;

// ***************************** CODE ***************************** //

string tab[maxn];
int odl[maxn];
int num[maxn];
int n;

void dfs(int x)
{
  for(int i = 1;i <= n;i++)
    if(tab[x][i] == '1')
    {
      if(num[i] != 0)
      {
        if(num[i] == num[x])
        {
          cout<<-1;
          exit(0);
        }
      }
      else
      {
        num[i] = num[x] ^ 3;
        dfs(i);
      }
    }
}

int bfs(int x)
{
  for(int i = 1;i <= n;i++)
    odl[i] = inf;
  odl[x] = 1;
  queue<int> q;
  q.push(x);
  int res = 0;
  while(SZ(q))
  {
    int a = q.front();
    res = max(res, odl[a]);
    q.pop();
    for(int i = 1;i <= n;i++)
      if(tab[i][a] == '1' and odl[i] == inf)
      {
        odl[i] = odl[a] + 1;
        q.push(i);
      }
  }
  return res;
}

int main()
{
	_upgrade
  cin>>n;
  for(int i = 1;i <= n;i++)
  {
    cin>>tab[i];
    tab[i] = "#" + tab[i];
  }
  int res = 0;
  for(int i = 1;i <= n;i++)
    if(num[i] == 0)
    {
      num[i] = 1;
      dfs(i);
    }
  for(int i = 1;i <= n;i++)
    res = max(res, bfs(i));
  cout<<res;


	return 0;
}


Measured memory_bytes: 11904
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

enum { UP = 0, RIGHT, DOWN, LEFT };
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };
int x, y;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> x >> y;

    if (x == 0 and y == 0) {
        cout << 1 << endl;
        return;
    }

    int sx = 0, sy = 0, tx = 0, ty = 0;
    int dir = LEFT;
    int col = 2;

    rep(_, 0, 101010) {
        int sx2 = sx, tx2 = tx, sy2 = sy, ty2 = ty;

        if (dir == DOWN) {
            ty2 = sy - 1;
            sy2 = ty2 - (tx - sx + 1) + 1;
        } else if (dir == LEFT) {
            sx2 = tx + 1;
            tx2 = sx2 + (ty - sy + 1) - 1;
        } else if (dir == UP) {
            sy2 = ty + 1;
            ty2 = sy2 + (tx - sx + 1) - 1;
        } else if (dir == RIGHT) {
            tx2 = sx - 1;
            sx2 = tx2 - (ty - sy + 1) + 1;
        }

        if (sx2 <= x and x <= tx2 and sy2 <= y and y <= ty2) {
            cout << col << endl;
            return;
        }

        col++;
        if(3 < col) col = 1;

        dir = (dir + 1) % 4;

        chmin(sx, sx2);
        chmin(sy, sy2);
        chmax(tx, tx2);
        chmax(ty, ty2);

        //printf("%d %d %d %d\n", sx, tx, sy, ty);
    }
}



Measured memory_bytes: 3140
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
int main()
{
  int n;cin >> n;
  int x = n % 10;
  if(x == 0 || x == 1 || x == 6 || x == 8) cout << "pon" << "\n";
  else if(x == 3) cout << "bon" << "\n";
  else cout << "hon" << "\n";
  return 0;
}


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

int main(){
  int a,b,c;
  cin >>a >>b >>c;
  cout << (a+b)*c/2 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main() {
	double pi = 3.141592653589793238;

	double r;
	cin >> r;

	printd(r * 2 * pi);
	return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n;cin>>n;
  string s;cin>>s;

  vector<ll>r(n), g(n), b(n);
  rep(i, n){
    if(s[i]=='R')r[i]++;
    if(s[i]=='G')g[i]++;
    if(s[i]=='B')b[i]++;
  }
  rrep1(i, n-1){
    r[i-1]+=r[i];
    g[i-1]+=g[i];
    b[i-1]+=b[i];
  }

  map<pair<char, char>, char>m;
  m[{'R','G'}]='B';
  m[{'G','R'}]='B';
  m[{'R','B'}]='G';
  m[{'B','R'}]='G';
  m[{'G','B'}]='R';
  m[{'B','G'}]='R';

  ll result = 0;

  rep(i, n-2){
    char c1 = s[i];
    for(int j=i+1; j<n-1; j++){
      char c2 = s[j];
      if(c1==c2)continue;

      if(m[{c1,c2}]=='R'){
        result += r[j+1];
      }else if(m[{c1,c2}]=='G'){
        result += g[j+1];
      }else if(m[{c1,c2}]=='B'){
        result += b[j+1];
      }

      int i3 = j+j-i;
      if(i3>=n)continue;
      char c3 = s[i3];
      if(c3==m[{c1,c2}])result--;

    }
  }

  cout<<result<<endl;  

  return 0;
}


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

#define CO const
#define IN inline
typedef long long int64;

template<class T> IN T read(){
	T x=0,w=1;char c=getchar();
	for(;!isdigit(c);c=getchar())if(c=='-') w=-w;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*w;
}
template<class T> IN T read(T&x){
	return x=read<T>();
}

CO int N=2e5+10;
namespace treap{
	int ch[N][2],pri[N],tot;
	int val[N],mn[N],mx[N];
	
	IN int new_node(int v){
		int x=++tot;
		pri[x]=rand()^rand()<<15,val[x]=mn[x]=mx[x]=v;
		return x;
	}
	IN void push_up(int x){
		mn[x]=ch[x][0]?mn[ch[x][0]]:val[x];
		mx[x]=ch[x][1]?mx[ch[x][1]]:val[x];
	}
	int merge(int x,int y){
		if(!x or !y) return x+y;
		if(pri[x]>pri[y]){
			ch[x][1]=merge(ch[x][1],y);
			return push_up(x),x;
		}
		else{
			ch[y][0]=merge(x,ch[y][0]);
			return push_up(y),y;
		}
	}
	void split(int x,int v,int&l,int&r){
		if(!x) {l=r=0; return;}
		if(val[x]<=v)
			l=x,split(ch[l][1],v,ch[l][1],r),push_up(l);
		else
			r=x,split(ch[r][0],v,l,ch[r][0]),push_up(r);
	}
	IN void push_back(int&x,int v){
		x=merge(x,new_node(v));
	}
	IN void pop_back(int&x,int v){
		split(x,v-1,x,*new int);
	}
}

int a[N],q[2*N];

int main(){
	srand(20030506);
	int n=read<int>();
	for(int i=1;i<=n;++i) read(a[i]);
	
	int L=1,R=0;
	for(int i=1;i<=n;++i){
		if(i==1 or a[i-1]>a[i]) ++R; // divide the permutation into monotone segments
		treap::push_back(q[R],a[i]);
	}
	int last=n; // consecutive elements in the end removable
	for(;last and treap::mx[q[R]]==last;--last)
		treap::pop_back(q[R],last);
	
	int ans=0;
	while(last){
		++ans;
		for(;L<R and !q[L];++L); // skip empty segments
		int x=q[L],mx=treap::mx[x]; // all elements in the first segment are high
		for(int i=++L;i<=R and mx!=last;++i)if(q[i]){
			if(treap::mx[q[i]]<mx) continue;
			int l,r;treap::split(q[i],mx,l,r);
			q[i]=l,x=treap::merge(x,r),mx=treap::mx[x];
			if(q[i-1] and treap::mx[q[i-1]]<treap::mn[q[i]]) // merge segments
				q[i]=treap::merge(q[i-1],q[i]),q[i-1]=0;
		}
		if(q[R] and treap::mx[q[R]]<treap::mn[x])
			x=treap::merge(q[R],x),q[R]=0;
		q[++R]=x;
		for(;last and treap::mx[q[R]]==last;--last)
			treap::pop_back(q[R],last);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 13568
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
     sc.Scan()
     i, e := strconv.Atoi(sc.Text())
     if e != nil {
     	panic(e)
     }
     return i
}

func main() {
	sc.Split(bufio.ScanWords)
	k := nextInt()
	a := nextInt()
	b := nextInt()
	ans := "NG"

	for i:=1; k*i<=b; i++{
		if k*i >= a {
			ans = "OK"
		}
	}

	fmt.Println(ans)
}  	 


Measured memory_bytes: 1756
#include <cstdio>
#include <cmath>
#define R(i, n) for(int i = 0;i < n;i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define P(a) printf("%d", a)
#define INF 1000000000
using namespace std;
typedef long long ll;

ll N;

int main() {
	scanf("%lld", &N);
	int i;
	for (i = sqrt(N); i > 0; i--) {
		if (N % i == 0) break;
	}
	printf("%lld\n", i + N/i - 2);
}



Measured memory_bytes: 128
"use strict";

const main = arg => {

  const input = arg.trim().split("\n");

  const N = parseInt(input[0].split(" ")[0]);
  //const M = parseInt(input[0].split(" ")[1]);
  const A = input[1].split(" ").map(n=>parseInt(n));
  let result = [];
  
  for(let i = 0; i < N; i++ ) {
  	result.push(0)
  }
  for(let j = 0; j < A.length; j++ ) {
	result[A[j] - 1] += 1;
  }
  result.forEach(a => console.log(a))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 63476
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e16;

/*
<url:https://abc087.contest.atcoder.jp/tasks/abc087_a>
問題文============================================================
 あなたは、X 円を持ってケーキとドーナツを買いに出かけました。
 
 あなたはまずケーキ屋で 1 個 A 円のケーキを 1 個買いました。
 次に、ドーナツ屋で 1 個 B 円のドーナツをできるだけたくさん買いました。
 
 これらの買い物のあと手元に残っている金額は何円ですか。
=================================================================

解説=============================================================
 やるだけ
================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll X,A,B; cin >> X >> A >> B;
    cout << (X-A)%B << endl;
	return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

static const ULL MOD = 1000000007LL;
int n;
char s[100005];
uint64_t dp[100005][13];

void solve() {
    uint64_t ans=0;
    scanf("%s", s);
    n = strlen(s);
    // dp[i][j] := 先頭 i 文字として考えられるもののうち，13 で割ったあまりが j であるものの数
    dp[0][0] = 1;
    REP0(i, n) {
        int c; // i 文字目の数
        if (s[i] == '?') c = -1;
        else c = s[i] - '0';  // toInt
        REP0(j, 10) {
            if (c != -1 and c != j) continue;
            REP0(ki, 13) {
                dp[i+1][(ki*10+j) % 13] += dp[i][ki];
            }
        }
        REP0(j, 13) dp[i+1][j] %= MOD;
    }
    ans = dp[n][5];
    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout<<std::fixed<<std::setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 10496
N = int(input())
A = list(map(int, input().split()))

rev_A = sorted(A, reverse=True)

if 0 in rev_A:
    print(0)
    exit()
else:
    limit = 10 ** 18
    current = 1

    for x in range(N):
        current *= rev_A[x]

        if current > limit:
            print(-1)
            exit()
    print(current)


Measured memory_bytes: 84508
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
	int n;
	cin >> n;
	ll ans = 1;
	while (true)
	{
		if ((ans+1)*(ans+1) > n) break;
		ans++;
	}
	cout << ans*ans << endl;
	
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    ll x, a, b, ans;
    cin >> x;
    a = x/11;
    b = x%11;
    ans = 2*a;
    if(1 <= b && b <= 6) {
        ans++;
    }
    else if(7 <= b && b <= 10) {
        ans += 2;
    }

    cout << ans;

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    ll n;
    cin>>n;
    ll a,b;
    cin>>a>>b;
    ll answer=INFLL;
    if (a<b)
        swap(a,b);
    ll c=a,d=b;
    if ((a-b)%2==0) {
        cout << (a - b) / 2;
        return 0;
    }
    else
    {
        ll ans=0;
        ans+=b-1;
        a-=b-1,b=1;
        if ((a-b)%2==0) {
           answer=min(answer,(a - b) / 2 + ans);
        }
        else
        {
            ans++;
            a--;
            answer=min(ans+(a-b)/2,answer);
        }
        a=c,b=d;
        ans=0;
        ans+=n-a;
        b+=n-a,a=n;
        if ((a-b)%2==0)
            answer=min(answer,(a-b)/2+ans);
        else
        {
            ans++;
            b++;
            answer=min(ans+(a-b)/2,answer);
        }
        cout<<answer;
    }




}

Measured memory_bytes: 256
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed() ios::sync_with_stdio(0);cin.tie(0);
#define file() freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define trace(x) cerr << #x << " = " << x << endl
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(v)   v.begin(),v.end()
#define rall(v)   v.rbegin(),v.rend()
#define sl(a)   scanf("%lld",&a)
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define pi acos(-1)
#define en '\n'
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>mi;
typedef pair<ll,ll>pll;
typedef vector<pll> vll;
typedef set<ll>st;
typedef set<char>sc;
ll dx[] = {-1,+1,0,0,+1,-1,+1,-1};
ll dy[] = {0,0,-1,+1,+1,+1,-1,-1};
const ll mx = 1e5+123;
const ll MOD = 1e9+7;
const ll INF = LLONG_MAX;

template <class T> T power(T a,T b){a%=MOD;if(!a) return 0;T p=1;while(b>0){if(b&1){p*=a;p%=MOD;}a*=a;a%=MOD;b=b>>1;}return p;}
template <class T> void print(vector<T> &v){for(T u:v){cout<<u<<" ";}cout<<endl;}
template <class T> T gcd(T a, T b){return (b!=0?gcd<T>(b,a%b):a);}
template <class T> T lcm(T a, T b){return (a/gcd<T>(a,b)*b);}

int main()
{
    speed();
    string s="ACL";
    ll a;
    cin>>a;
    rep(i,a)
    cout<<s;
    cout<<endl;



return 0;
}



Measured memory_bytes: 3608
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Ciniii(A,B,C);
    cout << ((A+B+C>=22)? "bust":"win") << nn;
    return 0;
}

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

int main(){
    int t,p,r;
    while(1){
        cin>>t>>p>>r;
        if(t == 0 && p ==0 && r ==0) break;
        vector<vector<int> > wa(t,vector<int>(p,0)),ac(t+1,vector<int>(p+1,0));
        vector<int> tsum(t,0);
        
        for(int i=0; i<r; i++){
            int tid,pid,time;
            string s;
            cin>>tid>>pid>>time>>s;
            tid--,pid--;
            if(s == "CORRECT"){
                ac[tid][pid]++;
                tsum[tid] += wa[tid][pid]*1200+time;
            }

            else if(s == "WRONG"){
                wa[tid][pid]++;
            }
        }

        vector<int> ans(t);

        for(int i=0; i<t; i++){
            for(int j=0; j<p; j++){
                if(ac[i][j])ans[i]++;
            }
        }
        vector<pair<int,pair<int,int> > > data(t);

        for(int i=t-1; i>=0; i--){
            data[i].first = -ans[i];
            data[i].second.second = i+1;
            data[i].second.first = tsum[i];
        }

        sort(data.begin(),data.end());

        for(int i=0; i<t; i++){
            cout<<data[i].second.second<<" "
            <<-data[i].first<<" "<<data[i].second.first<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3180
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll K;
ll N;

int main(){


    
    cin >> N;
    cin >> K;

    if(K-N>=N){
        cout << N << endl;
    }else{
        ll key;
        key = N/K;

        ll minN;
        minN=N;
        minN=min(minN,abs(N-key*K));
        minN=min(minN,abs(N-(key+1)*K));
        minN=min(minN,abs(N-(key-1)*K));
        cout << minN << endl;

    }
    

}

Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	ints := strToIntSlice(scanLine(scanner));

	var coinNum int
	if ints[0] < ints[1] {
		coinNum = ints[1] * 2 - 1
	} else if ints[0] > ints[1] {
		coinNum = ints[0] * 2 - 1
	} else {
		coinNum = ints[0] + ints[1]
	}

	fmt.Print(coinNum);
}

func scanLine(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func strToIntSlice(line string) []int {
	strSlice := strings.Split(line, " ")

	var intSlice []int
	for _, str := range strSlice {
		intValue, _ := strconv.Atoi(str)
		intSlice = append(intSlice, intValue)
	}

	return intSlice
}

Measured memory_bytes: 640
#include "iostream"
#include "vector"
#include "algorithm"
using namespace std;

bool comparison( int a, int b )
{
    if( 0 == (a%10) ) return true;
    if( 0 == (b%10) ) return false;

    if( (a%10) > (b%10) ) return true;

    return false;
}

int main()
{
    vector<int> v(5);
    for( int i=0 ; i<5 ; i++ ) cin >> v[i];
    sort( v.begin(), v.end(), comparison );
    int temp = 0;

    for( int i=0 ; i<4 ; i++ )
    {
        if( 0 == (v[i] % 10) ) temp += v[i];
        else                   temp += v[i] + (10 - (v[i]%10) );    
    }

    temp += v[4];

    cout << temp << endl;
}


Measured memory_bytes: 256
/*Bismillahir Rahmanir Rahim*/


#include<bits/stdc++.h>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#define pb push_back
#define ll long long int
#define dd double
using namespace std;

int main()
{
    ll q,n,x;
    vector<ll>vc;
    cin>>q;
    while(q--)
    {
        cin>>n;
        if(n==0)
        {
            cin >> x;
           vc. pb (x);
        }
        else if(n==2)
        {
            if(!vc.empty())
            {
                vc.pop_back();
            }
        }
        else
        {
            if(!vc.empty())
            {
                cin>>x;
                cout<<vc[x]<<endl;
            }
        }
        
    }

return 0;

}


Measured memory_bytes: 4912
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<cstdlib>
using namespace std;

int main(){
  int a, b, d;
  cin >> a >> b;
  vector<int> c(a);
  for(int i = 0; i < a; i++) {
    cin >> c[i];
  }
  for(int i = 1; i <= b; i++) {
    int point = 0;
    while(a - 1 > point) {
      if(c[point] % i > c[point + 1] % i) {
        d = c[point];
        c[point] = c[point + 1];
        c[point + 1] = d;
      }
      point++;
    }
  }
  for(int i = 0; i < a; i++) {
    cout << c[i] << endl;
  }
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5])
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n, k, a;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> a;
    }
    if(n <= k) cout << 1;
    else{;
        int ans = 1;
        int i = k;
        while(i < n){
            i+=k-1;
            ans++;
        }
        cout << ans;
    }
    return 0;
}


Measured memory_bytes: 256
global primeList
primeList = []

def primeFactorize(X):
  global primeList
  result = set()
  for prime in primeList:
      while X % prime == 0:
        result.add(prime)
        X //= prime
  if X != 1:
      result.add(X)
  return result

A,B = map(int,input().split())

isPrime = [True for i in range(1000001)]
isPrime[0] = isPrime[1] = False;
primeList.append(2)
for i in range(4,1000001,2):
  isPrime[i] = False

for i in range(3,1000001,2):
    if not isPrime[i]:
      continue
    primeList.append(i)
    for j in range(i, 1000000//i + 1):
      isPrime[i*j] = False

pA = primeFactorize(A)
pB = primeFactorize(B)
print(len(pA.intersection(pB)) + 1)




Measured memory_bytes: 14056