akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

int** make2dArray(int x,int y){
	int** array = (int**)malloc(sizeof(int*) * x);
	for (int i = 0; i < x; i++) {
		array[i] = (int*)malloc(sizeof(int) * y);
	}
	return array;
}
void printArray(int* a, int length) {
	for (int i = 0; i < length; i++) {
		printf("%d ", a[i]);
	}
}
void print2dIntArray(int** a,int x,int y) {
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < y; j++) {
			if (j == y - 1) {
				printf("%d\n", a[i][j]);
			}
			else {
				printf("%d ", a[i][j]);
			}
		}
	}
}
void print2dLongArray(long long** a, int x, int y) {
	for (int i = 0; i < x; i++) {
		for (int j = 0; j < y; j++) {
			if (j == y - 1) {
				printf("%llu\n", a[i][j]);
			}
			else {
				printf("%llu ", a[i][j]);
			}
		}
	}
}
int* getColFromArray(int** array, int x, int j) {
	int* a = (int*)malloc(sizeof(int) * x);
	for (int i = 0; i < x; i++) {
		a[i] = array[i][j];
	}
	return a;
}
long long int arrayTimes(int* a1, int* a2, int length) {
	long long int res = 0;
	for (int i = 0; i < length; i++) {
		res = res + a1[i] * a2[i];
	}
	return res;
}
void call(int n) {
	for (int i = 1; i <= n; i++) {
		int x = i;
		if (x % 3 == 0) {
			printf(" %d", i);
			continue;
		}
		do{
			if (x % 10 == 3) {
				printf(" %d", i);
				break;
			}
			x /= 10;
		} while (x);
	}
}
char change(char ch) {
	if (ch >= 'a' && ch <= 'z') {
		ch = ch - 'a' + 'A';
	}
	else if (ch >= 'A' && ch <= 'Z') {
		ch = ch - 'A' + 'a';
	}
	return ch;
}

int toNumber(char ch) {
	if (ch >= 'a' && ch <= 'z') {
		return ch - 'a';
	}
	else if (ch >= 'A' && ch <= 'Z') {
		return ch - 'A';
	}
	else {
		return -1;
	}

}

bool sub_str(char* s, char* p) {
	int j;
	for (int i = 0; s[i] != '\0'; i++) {
		if (s[i] == p[0]) {
			j = 0;
			while (p[j] != '\0') {
				j++;
				if (p[j] != s[(i + j) % strlen(s)]) {
					break;
				}
			}
			if (p[j] == '\0') {
				return true;
			}
			else {
				continue;
			}
		}
	}
	return false;
}

int main() {
	char s[101];
	char p[101];
	scanf("%s", &s);
	scanf("%s", &p);
	int j;
	if (sub_str(s, p)) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
}




Measured memory_bytes: 2112
N = int(input())
x = [[] for _ in range(N)]
y = [[] for _ in range(N)]
A = [None] * N
for i in range(N):
  A[i] = int(input())
  for j in range(A[i]):
    a, b = map(int, input().split())
    x[i].append(a)
    y[i].append(b)

ans = 0
for i in range(2**N):
  flag = True
  for j in range(N):
    for k in range(A[j]):
      # 正直者の発言が矛盾しなければ良い
      if (i >> j) & 1:
        if ((i >> (x[j][k]-1)) & 1) != y[j][k]:
          flag = False
          break
  if flag:
    count = sum([int(b) for b in bin(i)[2:]])
    ans = max(ans, count)
print(ans)

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

int main() {
  
  int a, b;
  cin >> a >> b;
  
  int c = 1, d = 0;  
  
  while(c < b) { 
    c--;
    c += a;
    d++;
  }
  
  cout << d << endl;  
  
}

Measured memory_bytes: 256
from collections import *
K=int(input())
D=[K+1]*K
D[1]=1
Q=deque([1])
def bfs():
  global Q,D,K
  v=0
  while len(Q):
    v=Q.popleft()
    if D[v*10%K]>D[v]:
      D[v*10%K]=D[v]
      Q.appendleft(v*10%K)
    if D[(v+1)%K]>D[v]+1:
      D[(v+1)%K]=D[v]+1
      Q.append((v+1)%K)

bfs()
print(D[0])

Measured memory_bytes: 75668
A,B,C,K = map(int,input().split(" "))
#1がA枚
#0がB枚
#-1がC枚
#K枚引いて和が最大

def solve():
    k = K
    ans = 0
    if A - k >= 0:
        print(k)
        return

    if A - k < 0:
        ans += A
        k -= A

    if B - k >= 0:
        print(ans)
        return

    if B - k < 0:
        k -= B

    ans -= k

    print(ans)

solve()

Measured memory_bytes: 9032
import math

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
P_count = 0
Q_count = 0
for i in range(N - 1):
    P_count += (P[i] - 1) * math.factorial(N - 1 - i)
    Q_count += (Q[i] - 1) * math.factorial(N - 1 - i)
    for j in range(i + 1, N - 1):
        if P[j] > P[i]:
            P[j] -= 1
        if Q[j] > Q[i]:
            Q[j] -= 1
result = abs(P_count - Q_count)
print(result)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define N 100100
using namespace std;
inline void read(int &x)
{
	x=0;
	static int p;p=1;
	static char c;c=getchar();
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c-48);c=getchar();}
	x*=p;
}
int a,b;
int mapp[110][110];
int main()
{
	read(a);read(b);
	for(int i=51;i<=100;i++)
		for(int j=1;j<=100;j++)
		mapp[i][j]=1;
	int sum1=1,sum2=1;
	if(sum1<a)
	{
		for(int i=1;i<=51;i+=2)
		{
			if(i%2==0)
			{
			for(int j=2;j<=100;j+=2)
			if(sum1<a)sum1++,mapp[i][j]=1;
			else goto end;
			}
			else 
			for(int j=1;j<=100;j+=2)
			if(sum1<a)sum1++,mapp[i][j]=1;
			else goto end;
		}
end:;
	}
	if(sum2<b)
	{
		for(int i=100;i>=52;i-=2)
		{
			if(i%2==0)
			{
			for(int j=1;j<=100;j+=2)
			if(sum2<b)sum2++,mapp[i][j]=0;
			else goto endd;
			}
			else 
			{
			for(int j=2;j<=100;j+=2)
			if(sum2<b)sum2++,mapp[i][j]=0;
			else goto endd;
			}
		}
endd:;
	}
	cout<<100<<" "<<100<<endl;
	for(int k=1;k<=100;k++,puts(""))
		for(int l=1;l<=100;l++)
			printf("%c",mapp[k][l]==1?'.':'#');
	return 0;
}

Measured memory_bytes: 256
MODULO_BY = 10**9 + 7

def squaring_factorial(n)
  (1..n).to_a.inject(1) { |product, i| product * i**2 % MODULO_BY }
end

m, n = gets.split.map(&:to_i).sort
if n - m > 1
  puts 0
elsif n == m
  puts squaring_factorial(m) * 2 % MODULO_BY
else
  puts squaring_factorial(m) * n % MODULO_BY
end

Measured memory_bytes: 2684
package main

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

var H, W int

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 10000000)
	fmt.Scan(&H, &W)

	q := make([][]int, 0)
	m := make([][]bool, H)

	for i := 0; i < H; i++ {
		line, _, _ := reader.ReadLine()
		m[i] = make([]bool, W) // Falseで初期化されている

		for j, v := range line {
			if string(v) == "#" {
				q = append(q, []int{i, j})
				m[i][j] = true
			}
		}
	}
	fmt.Println(bfs(q, m))
}

func bfs(q [][]int, m [][]bool) int {
	var ans int

	for len(q) != 0 {
		ans++
		len := len(q)

		for i := 0; i < len; i++ {
			var y, x int = q[0][0], q[0][1]
			q = append(q[1:])

			if 0 <= y+1 && y+1 < H && m[y+1][x] == false {
				m[y+1][x] = true
				q = append(q, []int{y + 1, x})
			}
			if 0 <= y-1 && y-1 < H && m[y-1][x] == false {
				m[y-1][x] = true
				q = append(q, []int{y - 1, x})
			}
			if 0 <= x+1 && x+1 < W && m[y][x+1] == false {
				m[y][x+1] = true
				q = append(q, []int{y, x + 1})
			}
			if 0 <= x-1 && x-1 < W && m[y][x-1] == false {
				m[y][x-1] = true
				q = append(q, []int{y, x - 1})
			}
		}
	}
	return ans - 1
}


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

int main() {
  int N, A, B;
  cin >> N >> A ;
  
  B = N % 500;
    
    if (B <= A){
      cout << "Yes" << endl;
    }
  
    else{
      cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	static void lnJudge(char a, boolean ln){
		if(ln == true){
			System.out.println(a);
		}else{
			System.out.print(a);			
		}
	}
	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		while(true){
			int H = sc.nextInt();
			int W = sc.nextInt();
			if(H == 0 && W == 0){
				break;
			}
			
			for(int i = 0; i < H; i++){
				char p;
				if(i == 0 || i == H -1){
					p = '#';
				}else{
					p = '.';
				}
				for(int j = 0; j < W; j++){
					if(j == W -1){
						lnJudge('#', true);
					}else if(j == 0){
						lnJudge('#', false);
					}
					else{
						lnJudge(p, false);
					}
				}
			}
			System.out.println("");
		}
		sc.close();
	}
}

Measured memory_bytes: 35636
//#include <bits/stdc++.h>
#include<iostream>
#include<numeric>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//----------program from here----------

int ctoi(char c) {
  if('0'<=c && c <= '9') return c-'0';
  return 0;
}

int main(){
  ll N=0,x=0;
  cin >> N >> x;
  ll a[N],WA=0;
  for(int i=0;i<N;++i){
    cin >> a[i];
    WA += a[i];
  }
  sort(a,a+N);
  int count = 0;
  if(WA<x){
    cout << N-1 << endl;
  }else{
    for(int i=0;i<N;++i){
      x = x - a[i];
      if(x<0){
        break;
      }
      ++count;
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC086A
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] n = Console.ReadLine().Split(' ');
			int a = int.Parse(n[0]);
			int b = int.Parse(n[1]);

			if ((a * b) % 2 == 0)
				Console.WriteLine("Even");

			else
				Console.WriteLine("Odd");

			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll N, D; cin >> N >> D;
	ll cnt = 0;
	for (int i = 0; i < N; i++) {
		ll x, y; cin >> x >> y;
		if (x * x + y * y <= D*D)cnt++;
		//cout << x * x + y * y << endl;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3632
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n]

    }
    let mut ans = 0;
    for i in 0..n {
        if a[i] % 2 == 1 && i % 2 == 0 {
            ans += 1;
        }
    }
    println!("{:?}", ans);
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int a, b;
    string s;
    cin >> a >> b >> s;

    rep(i, a + b + 1)
    {
        if (i == a)
        {
            if (s[i] != '-')
            {
                cout << "No" << '\n';
                return 0;
            }
        }
        else
        {
            if (!('0' <= s[i] && s[i] <= '9'))
            {
                cout << "No" << '\n';
                return 0;
            }
        }
    }
    cout << "Yes" << '\n';

    return 0;
}


Measured memory_bytes: 3604
while True:
    n = input() + 1
    if n == 1:
        break
    H = map(int, raw_input().split())
    
    for i in range(n):
        A = list(H)
        A.pop(i)
        diff = [A[j+1] - A[j] for j in range(n-2)]
        if all(v == diff[0] for v in diff):
            print H[i]
            break

Measured memory_bytes: 6336
/// awoooooo

# include <bits/stdc++.h>
# define sz(x) (int)((x).size())

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;

const int N = (int)2e5 + 5;
const int inf = (int)1e9 + 7;

int n;
int cnt[N];

int main(){
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i){
    scanf("%d", cnt + i);
  }
  ll ans = 0;
  for(int i = 1; i <= n; ++i){
    if(cnt[i - 1] && cnt[i]){
      ++ans;
      cnt[i]--;
    }
    ans += cnt[i] / 2;
    cnt[i] %= 2;

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


Measured memory_bytes: 640
n = [int(i) for i in input().split(' ')]
a = n[0]
b = n[1]
c = n[2]
d = n[3]
ans_list = []
ans_list.append(a*c)
ans_list.append(a*d)
ans_list.append(b*c)
ans_list.append(b*d)
print(max(ans_list))

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

int main(){
    int n;
    cin >> n;
    string s;
    vector<int> c(4);
    vector<string> a(4);
    a[0] = "AC"; a[1] = "WA"; a[2] = "TLE"; a[3] = "RE";
    rep(i, n){
        cin >> s;
        if(s == "AC"){
            c[0]++;
        }else if(s == "WA"){
            c[1]++;
        }else if(s == "TLE"){
            c[2]++;
        }else{
            c[3]++;
        }
    }
    rep(i, 4){
        cout << a[i] << " x " << c[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	string ans[10][10]={
	{
		"0",
		"0 1",
		"0 1 2",
		"0 1 2 3",
		"0 1 2 3 4",
		"0 1 2 3 4 5",
		"0 1 2 3 4 5 6",
		"0 1 2 3 4 5 6 7",
		"0 1 2 3 4 5 6 7 8",
		"0 1 2 3 4 5 6 7 8 9"
	},
	{
		"1 0",
		"1",
		"1 2",
		"1 2 3",
		"1 2 3 4",
		"1 2 3 4 5",
		"1 2 3 4 5 6",
		"1 2 3 4 5 6 7",
		"1 2 3 4 5 6 7 8",
		"1 2 3 4 5 6 7 8 9"
	},
	{
		"2 1 0",
		"2 1",
		"2",
		"2 3",
		"2 3 4",
		"2 3 4 5",
		"2 3 4 5 6",
		"2 3 4 5 6 7",
		"2 3 4 5 6 7 8",
		"2 3 4 5 6 7 8 9"
	},
	{
		"3 2 1 0",
		"3 2 1",
		"3 2",
		"3",
		"3 4",
		"3 4 5",
		"3 4 5 6",
		"3 4 5 6 7",
		"3 4 5 6 7 8",
		"3 4 5 6 7 8 9"
	},
	{
		"4 3 2 1 0",
		"4 3 2 1",
		"4 3 2",
		"4 3",
		"4",
		"4 5",
		"4 5 6",
		"4 5 6 7",
		"4 5 6 7 8",
		"4 5 6 7 8 9"
	},
	{
		"5 4 3 2 1 0",
		"5 4 3 2 1",
		"5 4 3 2",
		"5 4 3",
		"5 4",
		"5",
		"5 6",
		"5 6 7",
		"5 6 7 8",
		"5 6 7 8 9"
	},
	{
		"6 7 8 9 5 4 3 2 1 0",
		"6 7 8 9 5 4 3 2 1",
		"6 7 8 9 5 4 3 2",
		"6 7 8 9 5 4 3",
		"6 7 8 9 5 4",
		"6 7 8 9 5",
		"6",
		"6 7",
		"6 7 8",
		"6 7 8 9"
	},
	{
		"7 8 9 5 4 3 2 1 0",
		"7 8 9 5 4 3 2 1",
		"7 8 9 5 4 3 2",
		"7 8 9 5 4 3",
		"7 8 9 5 4",
		"7 8 9 5",
		"7 8 9 5 4 3 2 1 0 1 2 3 4 5 6",
		"7",
		"7 8",
		"7 8 9"
	},
	{
		"8 9 5 4 3 2 1 0",
		"8 9 5 4 3 2 1",
		"8 9 5 4 3 2",
		"8 9 5 4 3",
		"8 9 5 4",
		"8 9 5",
		"8 9 5 4 3 2 1 0 1 2 3 4 5 6",
		"8 9 5 4 3 2 1 0 1 2 3 4 5 6 7",
		"8",
		"8 9"
	},
	{
		"9 5 4 3 2 1 0",
		"9 5 4 3 2 1",
		"9 5 4 3 2",
		"9 5 4 3",
		"9 5 4",
		"9 5",
		"9 5 4 3 2 1 0 1 2 3 4 5 6",
		"9 5 4 3 2 1 0 1 2 3 4 5 6 7",
		"9 5 4 3 2 1 0 1 2 3 4 5 6 7 8",
		"9"
	}
};
	int n,a,b;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		cout<<ans[a][b]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1208
# a1x + b1y = c1
# a2x + b2y = c2
def solve(a1, b1, c1, a2, b2, c2)
  x = (c1*b2 - c2*b1) / (a1*b2 -a2*b1)
  x = 0.0 if x == -0.0
  y = (a1*c2 - a2*c1) / (a1*b2 -a2*b1)
  y = 0.0 if y == -0.0
  return x, y
end

$<.each do |l|
  a, b, c, d, e, f = l.split.map(&:to_f)
  x, y = solve(a, b, c, d, e, f)
  printf("%.3f %.3f\n", x, y)
end

Measured memory_bytes: 6140
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;
const ll MAX_N = 8;

ll N, M;
std::vector< std::vector<ll> > vedge(MAX_N, std::vector<ll>(MAX_N, INF));

ll dfs(ll v, std::vector<bool>& visited)
{
  bool all_visited = true;

  for (ll i = 0; i < N; i++) {
    if (visited[i] == false) {
      all_visited = false;
    }
  }

  if (all_visited) {
    return 1;
  }

  ll ret = 0;
  for (ll i = 0; i < N; i++) {
    if (visited[i]) continue;
    if (vedge[v][i] == INF) continue;
    visited[i] = true;
    ret += dfs(i, visited);
    visited[i] = false;
  }

  return ret;
}

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

  std::cin >> N >> M;

  for (ll i = 0; i < M; i++) {
    ll a, b;
    std::cin >> a >> b;
    a--; b--;
    vedge[a][b] = 1;
    vedge[b][a] = 1;
  }

  std::vector<bool> visited(N, false);
  visited[0] = true;
  ll ans = dfs(0, visited);

  std::cout << ans << std::endl;

  return 0;
}


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

int main()
{
    long long int n,ar[100005],br[100005],cr[100005],sum=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        ar[i] = 999999;
    }
    for(int i=1;i<n;i++){
        cin>>br[i];
    }
    for(int i = 1;i<n;i++){
            int k = ar[i];
        if(ar[i] > br[i]) {
            ar[i] = br[i];
        }
        if(ar[i+1] > br[i]){
            ar[i+1] = br[i];
        }
    }
    for(int i=1;i<=n;i++){
        sum = sum+ar[i];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
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(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll m;cin>>m;
    ll res = -1;
    ll cum = 0;
    rep(i,m) {
        ll d,c;cin>>d>>c;
        ll x = cum + c * d;
        res += c;
        cum += c * d;
    }
    DEBUG{
        cout << res << endl;
    }
    ll a = 0;
    while(cum >= 10) {
        DEBUG{
            cout << cum << endl;
        }
        res += cum / 10;
        a = cum % 10;
        cum = cum / 10 + a;
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount

const ll MOD = 1000000007;

ll f[101010];
void init() {
    f[0] = 1;
    for(int i = 1; i<101010; i++) f[i] = (f[i - 1] * i) % MOD;
}
//---------------------------------------------------------------------------------------------------
ll inv(ll x) {
    ll res = 1;
    ll k = MOD - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k /= 2;
    }
    return res;
}
//---------------------------------------------------------------------------------------------------
ll C(int n, int k) {
    ll a = f[n]; // = n!
    ll b = f[n-k]; // = (n-k)!
    ll c = f[k]; // = k!

    ll bc = (b * c) % MOD;

    return (a * inv(bc)) % MOD;
}

int main() {
    init();
    int N, P; cin>>N>>P;
    vector<int> A(N);
    bool ok=true;
    ll a = 1;
    for(int i=0;i<N;i++)a*=2LL;
    for (int i = 0; i < N; i++){
        cin>>A[i];
        if(A[i]&1)ok=false;
    }
    
    if(ok){
        if(P==0)cout<<a<<endl;
        else cout<<0<<endl;
    }else cout<<a/2<<endl;

    return 0;
}

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


void print_arr(int* arr, int len) {
    for (int i = 0; i < len; i++) {
        if (i > 0) cout << ' ';
        cout << arr[i];
    }
    cout << endl;
}

int selectionSort(int* arr, int len) {
    int min;
    int count = 0;

    for (int i = 0; i < len; i++) {
        min = i;
        for (int j = i + 1; j < len; j++) {
            if (arr[j] < arr[min]) {
                min = j;
            }
        }

        if (min != i) {
            swap(arr[min], arr[i]);
            count++;
        }
    }

    return count;
}

int main() {
    int N;
    int arr[100];
    int count;

    cin >> N;
    for (int i = 0; i < N; i++) cin >> arr[i];

    count = selectionSort(arr, N);
    print_arr(arr, N);
    cout << count << endl;
}


Measured memory_bytes: 3084
import java.util.Arrays;
import java.util.Scanner;

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();
        int Y = sc.nextInt();

        int[] x = new int[N];
        int[] y = new int[M];

        for (int i = 0; i < N; i++) {
            x[i] = sc.nextInt();
        }

        for (int i = 0; i < M; i++) {
            y[i] = sc.nextInt();
        }

        Arrays.sort(x);
        Arrays.sort(y);

        if (x[x.length - 1] < y[0] && X < y[0] && Y > x[x.length - 1]) {
            System.out.println("No War");
        } else {
            System.out.println("War");
        }
    }
}

Measured memory_bytes: 22484
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		boolean[] isPrime = new boolean[123456*2 + 10];
		Arrays.fill(isPrime, true);
		isPrime[0]=isPrime[1]=false;
		for(int i = 2; i*i <= isPrime.length; i++){
			if(isPrime[i]){
				for(int j = i+i; j < isPrime.length; j+=i){
					isPrime[j]=false;
				}
			}
		}
		Scanner cin = new Scanner(System.in);
		while(true){
			int n = cin.nextInt();
			if(n==0){
				break;
			}
			int count=0;
			for(int i = n+1; i <= 2*n; i++){
				if(isPrime[i]){
					count++;
				}
			}
			System.out.println(count);
		}
	}

}

Measured memory_bytes: 13000
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <vector>
#include <deque>
#include <cstdlib>
#include <numeric>
#include <cstring>
#include <ctime>
#include <climits>
#include <sstream>
#include <complex>
#define Mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define Rep(__i,__n) for(int __i = 0 ; __i < (__n);__i++)
#define Range(_ind,_a,_b) for(int _ind = (_a) ; _ind <(int)(_b);_ind++)
#define iRange(_i,_a,_b,_c) for(int _i = (_a) ; _i <(int)_b;_i+=_c)
#define All(__cont)  (__cont).begin(),(__cont).end()
#define ForEach(_itr,_cont) for(auto _itr  = _cont.begin();_itr !=  _cont.end();_itr++)


using namespace std;
typedef complex<double> P;
typedef long long ll;
typedef vector<int> vi ;
typedef vector<double> vd;
typedef vector<vector <int> > vvi;
typedef vector<vector<double> > vvd;
typedef pair<int,int> pii;
const int inf = INT_MAX / 3;
const double eps = 1e-9;

template <typename T >
void output(T a,string label = ""){
#ifdef DEBUG
  cout<<"[" <<(label==""?"":label + ":")<< a <<  "]"<< endl;
#endif
}
template <typename T>
void output(vector<T> &vec){
#ifdef DEBUG
  cout << "[";
  ForEach(itr,vec){
    if(itr != vec.begin())cout << ",";
    cout << *itr;
  }
  cout << "]"<<endl;;
#endif
}
#ifndef __NOT__MAIN
int main(){
  int N, Ma, Mb;
  cin >> N >> Ma >> Mb;
  const int INF = 1<<30;
  vvi dp(401, vi(401, INF));
  dp[0][0] = 0;
  Rep(_i,N) {
    int a, b,c;
    cin >> a>> b >> c;
    for(int i = 400; i >= 0;  i--) {
      int x  = i + a ;
      for (int j = 400; j >= 0; j--) {
	int y = j + b;
	if(dp[i][j] >= INF){
	  continue;
	}
	dp[x][y] = min(dp[i][j] + c, dp[x][y]);
      }
    }
  }
  int ans = INF;
  Rep(i,401) {
    Rep(j, 401) {      
      if (i * Mb == j * Ma && i + j > 0){ 
	ans = min(ans,dp[i][j]);
      }
    }
  }
  cout <<(ans == INF ? -1 : ans) << endl;
}
#endif


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	/* --------------------------------------------------------------------
	   main
	 * -------------------------------------------------------------------- */
	static final int[] A = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	public static void main(String args[]) throws Exception {

		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		sc.close();

		System.out.println(A[K-1]);
	}
}


Measured memory_bytes: 21844
n,m = map(int,input().split())
N = [list(map(int, input().split())) for _ in range(n)]
M = [list(map(int, input().split())) for _ in range(m)]

def kyori(X,Y):
    return abs(X[0]-Y[0])+abs(X[1]-Y[1])

def near_p(hito):
    temp = []
    for _ in range(m):
        temp.append(kyori(hito,M[_]))
    return temp.index(min(temp))+1

for i in range(n):
    print(near_p(N[i]))


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

int main() {
	string A, B;
	cin >> A >> B;
	if (A.size() > B.size()) {
		puts("GREATER");
	}
	else if (A.size() < B.size()) {
		puts("LESS");
	}
	else {
		for (int i = 0;i < A.size();++i) {
			if (A[i] > B[i]) {
				puts("GREATER");
				return 0;
			}
			else if (A[i] < B[i]) {
				puts("LESS");
				return 0;
			}
		}
		puts("EQUAL");
	}
	return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    }
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

const MOD: usize = 1000000007;

fn main() {
    input!{
        mut S: chars,
    }
    let N = S.len();
    let mut dp = vec![vec![0; 13]; N+1];
    dp[0][0] = 1;
    let mut w = 1;
    S.reverse();
    for i in 0..N {
        if S[i] == '?' {
            for d in 0..10 {
                for j in 0..13 {
                    dp[i+1][(j + d * w) % 13] += dp[i][j];
                    dp[i+1][(j + d * w) % 13] %= MOD;
                }
            }
        } else {
            let d = S[i] as usize - b'0' as usize;
            for j in 0..13 {
                dp[i+1][(j + d * w) % 13] += dp[i][j];
                dp[i+1][(j + d * w) % 13] %= MOD;
            }
        }
        w *= 10;
        w %= 13;
    }
    println!("{}", dp[N][5]);
}


Measured memory_bytes: 18684
#include <bits/stdc++.h>
// #pragma GCC optimization ("O3,unroll-loops")
// #pragma GCC target ("avx,avx2,fma")
using namespace std;

#define _ << ": " <<
#define watch1(var1) (cerr << (#var1) _ var1 << '\n')
#define watch2(var1, var2) cerr << (#var1) _ var1 << ", " << (#var2) _ var2 << '\n'
#define watch3(var1, var2, var3) cerr << (#var1) _ var1 << ", " << (#var2) _ var2 << ", " << (#var3) _ var3 << '\n'
#define wloop(size, arr) cerr << (#arr) << ": "; for (int i = 0; i < size; i++) cerr << arr[i] << " \n"[i+1 == size]

template<typename... Args>
void read(Args&... args) { ((cin >> args), ...); }

template<typename... Args>
void show(Args... args) { ((cout << args << " "), ...); }

#define ints(a...) int a; read(a)
#define longs(a...) int64_t a; read(a)
#define IN(a) for (auto &it : a) cin >> it

const int N = 2e6 + 10;
const int MOD = 1e9 + 7;
vector<int64_t> fact(N), ifact(N);

int64_t pow_n(int64_t a, int p, const int mod = MOD) {
    int64_t ans = 1;
    a %= mod;
    while(p) {
        if(p & 1) ans = (ans * a)%mod;
        a = (a * a)%mod;
        p >>= 1;
    }
    return ans;
}

int inv(int a) {
    return pow_n(a, MOD - 2);
}

void precal() {
    fact[0] = fact[1] = 1;
    for (int i = 2; i < N; i++) fact[i] = fact[i - 1] * i % MOD;

    ifact[N - 1] = inv(fact[N - 1]);
    for (int i = N - 2; ~i; i--) ifact[i] = ifact[i + 1] * (i + 1) % MOD;
}

int mul(int64_t a, int64_t b) {
    return a * b % MOD;
}

int ncr(int n, int r) {
    if (r > n) return 0;
    return mul(mul(fact[n], ifact[r]), ifact[n - r]);
}

void solve() {
    precal();
    ints(k);
    string s; cin >> s;
    int64_t ans = 0, n = s.size();
    for (int i = 0; i < n; i++) {
        ans += ncr(n + k, i) * pow_n(25, n + k - i) % MOD;
        if (ans >= MOD) ans -= MOD;
    }
    ans = pow_n(26, n + k) - ans;
    if (ans < 0) ans += MOD;
    show(ans);
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1; 
    // cin >> T;
    while (T--) solve();
    return 0;
}

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

ll INF = 1e+18;

int 
main()
{
  int N, M, K; cin >> N >> M >> K;
  vector<int> A(N);
  rep(i, 0, N) cin >> A[i];
  vector<int> B(M);
  rep(i, 0, M) cin >> B[i];

  vector<ll> acum(N + 1, 0);
  rep(i, 0, N) acum[i + 1] = A[i] + acum[i];
  vector<ll> bcum(M + 1, 0);
  rep(i, 0, M) bcum[i + 1] = B[i] + bcum[i];
  
  int ans = 0;
  rep(a, 0, N + 1){
    if(K - acum[a] < 0) break;
    int b = lower_bound(bcum.begin(), bcum.end(), K - acum[a]) - bcum.begin();
    if(b != 0 && acum[a] + bcum[b] != K){
      --b;
    }
    if(ans < a + b) ans = a + b;
  }

  cout << ans << endl;

}


Measured memory_bytes: 8012
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

#define REP(i,f,n) for(int i=(f); i < (n); ++i)
#define PER(i,f,n) for(int i=(n-1); i >= f; --i)

//----------------------------------
//----------------------------------

constexpr int64_t CALCNUM = 2000000;

bool primes[CALCNUM];

signed main()
{
	for(int i = 0; i < CALCNUM; i++)
		primes[i] = true;
    ios::sync_with_stdio(false);
	vector<int> prime;

	for(int i = 2; i <CALCNUM ; i++)
	{
		if(primes[i])
		{
			prime.push_back(i);
			for(int j = 2 * i; j < CALCNUM; j += i)
				primes[j] = false;
		}
	}
	int n;
	while(cin >> n)
	{
		for(int i = 0; i < prime.size(); ++i)
			if(prime[i] > n){
				cout << i <<'\n'; break;
			}
	}
}

Measured memory_bytes: 5624
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return list(sys.stdin.readline())
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007
 
#A
a, b = LI()
print((a+b+1)//2)

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

using namespace std;
//FILE *fi=freopen("1.txt","r",stdin);
int k;
int sum;
int main()
{
    cin>>k;
    for(int i=1;i<=k;i++)
    {
        for(int j=1;j<=k;j++)
        {
            for(int t=1;t<=k;t++)
            {
                sum+=__gcd(i,__gcd(j,t));
            }
        }
    }
    cout<<sum;
    return 0;
}


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

using namespace std;
using LL = long long;

const int N = 5005;
const int inf = 1e9;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
	int n, k;
	string s;
	cin >> n >> k >> s;
	s[k - 1] = s[k - 1] - 'A' + 'a';
	cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long
#define dl          double
#define pb          push_back
#define eb          emplace_back
#define mp          make_pair
#define F           first
#define S           second
#define endl        "\n"
#define rep(i,a,b)  for(i=a;i<b;i++)
#define all(v)      v.begin(),v.end()
#define allr(v)     v.rbegin(),v.rend()
#define mod         1000000007
#define CIN(V,s,n)  for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n) for(int i=s;i<n;i++){cout <<  V[i] << " ";} cout << endl;
#define fast        ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);   for(ll i=0;i<V.size();i++) V[i] = 0;
#define N           100005
using namespace std;

bool SbS(const pair<int,int> &a,const pair<int,int> &b)
{return (a.second < b.second);}

ll SUMD(ll n);
ll BS(vector<ll> &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
bool P[2002LL];
void Sieve(int n=N);
int nCrModp(int n, int r, int p);
vector<ll> PF(ll n);
ll Powb(ll b,ll n);

int main()
{
fast;
ll q=1;
//cin >> q;
while(q--)
{
   ll n,m,k,i,j,l,r,a,t,b,c,u,v,w,p;
   cin >> n >> m >> k;


   cout << max(0LL,k-n+m)<< endl;

}
    return 0;
}

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

ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<ll> &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid]==ser)
    {
        return mid;
    }
    else if(PS[mid] > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                P[j]=false;
            }
        }
    }

}

int nCrModp(int n, int r, int p)
{
    int C[r+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        for (int j = min(i, r); j > 0; j--)

            C[j] = (C[j] + C[j-1])%p;
    }
    return C[r];
}

vector<ll> PF(ll n)
{
    vector<ll> pf;
    if(n%2==0)
    {
        pf.pb(2LL);
        n = n/2;
        while(n%2==0)
            n = n/2;
    }
    for(ll i=3;i<=sqrt(n);i+=2)
    {
        ll flag=1;
        while(n%i==0)
        {
            if(flag)
            {
                pf.pb(i);
                flag=0;
            }
            n = n/i;
        }
    }
    if(n>2)
        pf.pb(n);

    //COUT(pf,0,pf.size());
    return pf;
}




Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

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

    int year=0, month=0, day=0, count=0;

    year = (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
    month = (s[5] - '0') * 10 + (s[6] - '0');
    day = (s[8] - '0') * 10 + (s[9] - '0');

    if (year <= 2019 && month <= 4 && day <= 30) {
        cout << "Heisei";
    }
    else {
        cout << "TBD";
    }
    return 0;
} 


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int x,y,grp[13]={0,1,3,1,2,1,2,1,1,2,1,2,1};
  scanf("%d%d",&x,&y);
  if(grp[x]==grp[y])
    puts("Yes");
  else
    puts("No");
  return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <cmath>

using namespace std;

int main(void) {
    long long int N;
    cin >> N;
    for(long long int i=(long long int)sqrt(N)+1; i; i--) {
        if(N%i == 0) {
            cout << i+(N/i) - 2 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

 int main() {
    int n, R[200000];

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

     int maxv = -1000000000;
     int minv = R[0];

     for (int j = 1; j < n; j++) {
         maxv = std::max(maxv, (R[j] - minv));
         minv = std::min(minv, R[j]);
     }

     std::cout << maxv << std::endl;

     return 0;


}


Measured memory_bytes: 3880
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

const int MAXN = 100005;

struct Edge
{
	int to;
	int nxt;
}edge[MAXN << 1];

int n,m,id;
int first[MAXN];
int fa[MAXN];

pair<int,int> p[MAXN];

ll f[MAXN];
ll a[MAXN];
ll b[MAXN];
ll sum[MAXN];
ll suf[MAXN];

bool vis[MAXN];

int getroot(int u)
{
	return u == fa[u] ? u : fa[u] = getroot(fa[u]);
}

void addE(int u,int v)
{
	edge[++id] = (Edge){v,first[u]};
	first[u] = id;
}

int main()
{
	scanf("%d%d",&n,&m);
	for (int i = 1;i <= n;i++)
	{
		scanf("%lld%lld",&a[i],&b[i]);
		a[i] = max(0ll,a[i] - b[i]);
		p[i] = make_pair(a[i],i);
	}
	for (int u,v,i = 1;i <= m;i++)
	{
		scanf("%d%d",&u,&v);
		addE(u,v);
		addE(v,u);
	}
	sort(p + 1,p + n + 1);
	for (int i = 1;i <= n;i++)
	{
		fa[i] = i;
		sum[i] = b[i];
	}
	for (int i = 1;i <= n;i++)
	{
		int u = p[i].second;
		vis[u] = 1;
		vector<pair<ll,ll> > t;
		for (int j = first[u];j;j = edge[j].nxt)
		{
			int v = edge[j].to;
			if (vis[v] && getroot(v) != u)
			{
				t.push_back(make_pair(f[getroot(v)] - sum[getroot(v)],sum[getroot(v)]));
				sum[u] += sum[getroot(v)];
				fa[getroot(v)] = u;
			}
		}
		sort(t.begin(),t.end());
		if (!t.size())
		{
			f[u] = a[u] + b[u];
			continue;
		}
		suf[t.size()] = 0;
		ll all = 0;
		for (int j = t.size() - 1;j >= 0;j--)
		{
			suf[j] = max(t[j].first + t[j].second,suf[j + 1] + t[j].second);
			all += t[j].second;
		}
		ll sum = 0,tot = 0;
		f[u] = 1e18;
		for (int j = 0;j < t.size();j++)
		{
			f[u] = min(f[u],max(max(tot,sum + suf[j + 1]),max(all - t[j].second + a[u] + b[u],all + b[u] + t[j].first)));
			tot = max(tot,sum + t[j].first + t[j].second);
			sum += t[j].second;
		}
		if (t.size() == 1)
			f[u] = min(f[u],max(a[u] + b[u],b[u] + t[0].first + t[0].second));
	}
	printf("%lld\n",f[getroot(1)]);
	return 0;
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    for (int i = 1; i <= b; i++) {
        if ((a * i % b) == c) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}


Measured memory_bytes: 256
import sys
from collections import deque

N,M=map(int, sys.stdin.readline().split())

nl=[ [] for i in range(N+1) ]

for i in range(M):
	u,v=map(int, sys.stdin.readline().split())
	nl[u].append(v)

S,T=map(int, sys.stdin.readline().split())

V=[ [ None for j in range(3) ] for i in range(N+1) ]
V[S][0]=0


q=deque()
q.append( (S,0) )

while q:
	x=q.popleft()
	fro=x[0]
	cur_mod=x[1]

	for to in nl[fro]:
		next_mod=(cur_mod+1)%3
		if V[to][next_mod] is None:
			V[to][next_mod]=V[fro][cur_mod]+1
			if V[T][0] is not None:
				break
			q.append( ( to, next_mod ) )


if V[T][0] is None:
	print -1
else:
	print V[T][0]/3

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,k;
    cin >> n >> k;
    ll sup = (n-1)*(n-2)/2;
    if(k > sup){
        cout << -1 << endl;
        return 0;
    }
    vector<pair<ll,ll>> ans;
    for(i = 2;i <= n;++i){
        ans.emplace_back(1,i);
    }
    bool flag = false;
    for(i = 2;i <= n-1;++i){
        for(j = i+1;j <= n;++j){
            if(sup == k){
                flag = true;
                break;
            }
            ans.emplace_back(i,j);
            --sup;
        }
        if(flag) break;
    }
    cout << ans.size() << endl;
    for(i = 0;i < ans.size();++i){
        cout << ans.at(i).first << " " << ans.at(i).second << endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

int main() {
   
   int N, M;
   cin >> N;
   string s[N];
   map<string, int> smap;
   for (int i = 0; i < N; i++) {
      cin >> s[i];
      smap[s[i]]++;
   }
   cin >> M;
   string t[M];
   map<string, int> tmap;
   for (int i = 0; i < M; i++) {
      cin >> t[i];
      tmap[t[i]]++;
   }
   int ans = 0;
   int ans_tmp;
   for (int i = 0; i < N; i++) {
      string tmp = s[i];
      ans_tmp = smap[tmp]-tmap[tmp];
      if (ans_tmp > ans) ans = ans_tmp;
   }
   for (int i = 0; i < M; i++) {
      string tmp = t[i];
      ans_tmp = smap[tmp]-tmap[tmp];
      if (ans_tmp > ans) ans = ans_tmp;
   }
   std::cout << ans << std::endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define nmax 100005
using namespace std;
int dp[nmax], h[nmax];

int modul(int k)
{
    if (k < 0)
        return -k;
    return k;
}

int main()
{
    int n, i, j, k;

    cin >> n >> k;
    for (i = 1; i <= n; i++)
        cin >> h[i];

    dp[1] = 0;
    for (i = 2; i <= n; i++)
        dp[i] = 1 << 30;

    for (i = 1; i <= n; i++)
        for (j = 1; j <= k && i + j <= n; j++)
            dp[i + j] = min(dp[i + j], dp[i] + modul(h[i] - h[i + j]) );

    cout << dp[n];
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
using std::cin;
using std::cout;
using std::vector;

template <typename T>
class BIT {
    // 1-indexed
    std::vector<T> data;
    std::size_t size;

   public:
    BIT(const std::size_t &n, const T &value = 0) {
        data.assign(n + 1UL, value);
        size = n;
    }

    // add value to idx-th
    void add(const std::size_t &idx, const T &value = 1) {
        for (std::size_t i = idx; i <= size; i += i & (~i + 1UL)) {  // LSB
            data.at(i) += value;
        }
    }

    // sum of [1, idx]
    T sum(const std::size_t &idx) {
        T res = 0;
        for (std::size_t i = idx; i > 0UL; i -= i & (~i + 1UL)) {  // LSB
            T d = data.at(i);                                      // cast
            res += d;
        }
        return res;
    }

    // sum of [first, last]
    T sum(const std::size_t &first, const std::size_t &last) {
        T res = sum(last) - sum(first - 1UL);  // cast
        return res;
    }

    std::size_t getSize() { return size; }  // debug用
};

int main() {
    int n;
    cin >> n;
    vector<int> aval(100005);
    std::fill(aval.begin(), aval.end(), 0);
    for (int i = 1; i <= n; ++i) {
        int ai;
        cin >> ai;
        aval.at(ai)++;
    }

    long s = 0;
    for (int i = 1; i <= 100000; ++i) {
        s += aval.at(i) * (long)i;
    }
    int q;
    cin >> q;
    for (int qi = 0; qi < q; qi++) {
        int b, c;
        cin >> b >> c;
        s -= aval.at(b) * (long)b;
        s += aval.at(b) * (long)c;
        aval.at(c) += aval.at(b);
        aval.at(b) = 0;
        cout << s << '\n';
    }
    return 0;
}

Measured memory_bytes: 3784
#include<stdio.h>
#include<string.h>
#define LEN 100000

typedef struct pp{
  char name[100];
  int time;
} P;

P Q[LEN];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail = (tail+1) % LEN;
}

P dequeue(){
  P x = Q[head];
  head = (head+1) % LEN;
  return x;
}

int min(int a, int b){ return a < b ? a : b;}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for(int i=1; i<=n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].time);
  }
  head = 1;
  tail = n+1;
  while(head!=tail){
    u = dequeue();
    c = min(q, u.time);
    u.time -= c;
    elaps += c;
    if(u.time > 0) enqueue(u);
    else{
      printf("%s %d\n", u.name, elaps);
    }
  }
  return 0;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

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

    int cnt = 0;
    REP2(i,1,N+1){
        if(i%2==0) continue;
        int yaku = 0;
        REP2(j,1,i+1){
            if(i%j==0) yaku++;
        }
        if(yaku==8) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sync ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD  1000000007 
int powm(int base,int exp,int mod=MOD) {int ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
int32_t main()
{
  sync
	int n;
	cin>>n;
	int ans=n*(n-1)/2;
	cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	cin >> N;
	int x[10], y[10];
	for (int i = 0; i < N; i++) cin >> x[i] >> y[i];
	int R[] = {0,1,2,3,4,5,6,7,8};
	int sum = 1;
	for (int i = 0; i < N; i++) {
		sum *= i + 1;
	}
	double ans = 0.0;
	do
	{
		for (int i = 0; i < N - 1; i++) {
			ans += sqrt((x[R[i]] - x[R[i + 1]]) * (x[R[i]] - x[R[i + 1]]) + (y[R[i]] - y[R[i + 1]]) * (y[R[i]] - y[R[i + 1]]));
		}
	} while (next_permutation(R,R+N));
	printf("%.10f\n", ans / sum);
}


Measured memory_bytes: 256
import queue
N,M=map(int,input().split())
adj=[[] for s in range(N+1)]
parent=[-1]*(N+1)
for i in range(M):
    A,B=map(int,input().split())
    adj[A].append(B)
    adj[B].append(A)
q=queue.Queue()
q.put((1,0))
while(not q.empty()):
    x,p=q.get()
    if parent[x]!=-1:
        continue
    parent[x]=p
    for next in adj[x]:
        if parent[next]==-1:
            q.put((next,x))
print('Yes')
for k in parent[2:]:
    print(k)

Measured memory_bytes: 40272
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        
        if (n > 81) {
            System.out.println("No");
            return;
        }

        for (int i = 1; i < 10; i++) {
            for (int j = 1; j < 10; j++) {
                if (i * j == n) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }
}


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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)


int main(){
    string s,t;
    int a,b;
    cin>>s>>t>>a>>b;
    string u;
    cin>>u;

    if(u==s)a--;
    if(u==t)b--;

    cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=(int) n;i--)
#define p(s) cout<<(s)<<endl
#define DEBUG(x,y) cout<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl;
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll inf=1e9+7;

int N;
ll T[101];
int main(){
	cin>>N;
	REP(i,0,N) {
		cin>>T[i];
	}
	ll c=1;
	REP(i,0,N){
		ll g=__gcd(T[i],c);
		c=T[i]/g*c;
	}
	p(c);
	return 0;
}


Measured memory_bytes: 256