akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

const lint MOD = pow(10, 9) + 7;

lint gcd(lint a, lint b) {
	//aとbの最大公約数を返す
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(a % b, b);
}

lint lcm(lint a, lint b) {
	//aとbの最小公倍数を返す
	return a / gcd(a, b) * b;
}

lint sgm(lint n) {
	//0からの総和を返す
	return n * (n + 1) / 2;
}

lint fact(lint n) {
	//n!を返す
	if (n == 0) return 1;
	else return n * fact(n - 1);
}

lint power(lint x, lint n, lint m) {
	//(x^n)%mを返す
	lint res = 1;
	x %= m;
	while (n > 0) {
		if (n % 2 == 1) {
			res = res * x % m;
		}
		x = x * x % m;
		n /= 2;
	}
	return res;
}

/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/


int main() {
	int N;
	cin >> N;
	vector<double>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	double ave = 0;
	rep(i, N) {
		ave += A[i];
	}
	ave /= N;
	double m = 100000;
	rep(i, N) {
		m = min(m, abs(A[i] - ave));
	}
	rep(i, N) {
		if (abs(A[i] - ave) == m) {
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

M = 0
boxes = [0]*N
for i in reversed(range(N)):
    num_balls = 0
    for k in range(i, N, i+1):
        num_balls += boxes[k]
    if num_balls%2 != a[i]:
        boxes[i] = 1
        M += 1

print(M)
for i in range(N):
    if boxes[i]==1:
        print(i+1)

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

int main(){
  int K;
  string S;
  int a;
  int i;
  cin>>K;
  cin>>S;
  a=S.size();

  if(a>K){
    for(i=0;i<K;i++){
      cout<<S.at(i);
    }
    cout<<"..."<<endl;
  }
  else{
    cout<<S<<endl;
  }
}

Measured memory_bytes: 3592
package main
 
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)
 
func main() {
	var input = irLine(1)
	var A, B = float64(input[0][0]), float64(input[0][1])
 
	var a int = int(A/8.00*100.00) + 1
	var b int = a
 
	var ax, bx int = -1, -1
 
	for ; ; b-- {
		if int(float64(b)*0.08) == int(A) && int(float64(b)*0.10) == int(B) {
			ax = b
		}
		if int(float64(b)*0.10) < int(B) {
			break
		}
	}
 
	a = int(B/10.00*100.00) + 1
	b = a
 
	for ; ; b-- {
		if int(float64(b)*0.08) == int(A) && int(float64(b)*0.10) == int(B) {
			bx = b
		}
		if int(float64(b)*0.08) < int(A) {
			break
		}
	}
 
	switch {
	case ax != -1 && bx != -1:
		fmt.Printf("%d", mini(ax, bx))
	case bx == -1:
		fmt.Printf("%d", ax)
	case ax == -1:
		fmt.Printf("%d", bx)
	default:
		fmt.Printf("%d", -1)
	}
}
 
func minf(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}
 
func mini(a, b int) int {
	if a > b {
		return b
	}
	return a
}
 
func paw(f float64, num int) float64 {
	var result float64 = 1
	for i := 0; num > i; i++ {
		result *= f
	}
	return result
}
 
//StrStdin Read standard input data
func StrStdin(line int) [][]string {
	var stringInput [][]string
	scanner := bufio.NewScanner(os.Stdin)
 
	for i := 0; i < line; i++ {
		scanner.Scan()
		if s := scanner.Text(); s != "" {
			stringInput = append(stringInput, strings.Split(strings.TrimSpace((scanner.Text())), " "))
		} else {
			break
		}
	}
 
	return stringInput
}
 
//rLine Read standard input data
func rLine(line int) [][]string {
	var rdr = bufio.NewReaderSize(os.Stdin, 1000000)
	var buf = make([]byte, 0, 1000000)
	var stringInput [][]string
 
	for i := 0; i < line; {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			stringInput = append(stringInput, strings.Split(strings.TrimSpace((string(buf))), " "))
			buf = []byte{}
			i++
		}
	}
	return stringInput
}
 
func irLine(i int) [][]int {
	return alitoas(rLine(i))
}
 
//itoa converts string to integer
func itoa(s string) int {
	var i, _ = strconv.Atoi(s)
	return i
}
 
func itoas(S []string) []int {
	var result = make([]int, len(S))
	for i, s := range S {
		result[i] = itoa(s)
	}
	return result
}
 
func alitoas(S [][]string) [][]int {
	var result = make([][]int, len(S))
	for i, s := range S {
		result[i] = itoas(s)
	}
	return result
}
 
func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}
 
func gcd3(a, b, c int) int {
	return gcd(gcd(a, b), c)
}

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

int main() {

    int A;
    int B;
    int K;

    cin >> A >> B >> K;

    int cnt = 0;

    stack<int> s;

    for (int i = 1; i <= 100; i++) {
        if(A % i == 0 && B % i == 0){
            s.push(i);
        }
    }

    for (int i = 0; i < K - 1; i++) {
        s.pop();
    }
    cout << s.top() << endl;

    return 0;

}

Measured memory_bytes: 3600
/*input
15 10000000000
400000000 1000000000
800000000 1000000000
1900000000 1000000000
2400000000 1000000000
2900000000 1000000000
3300000000 1000000000
3700000000 1000000000
3800000000 1000000000
4000000000 1000000000
4100000000 1000000000
5200000000 1000000000
6600000000 1000000000
8000000000 1000000000
9300000000 1000000000
9700000000 1000000000
*/
#include <bits/stdc++.h>
#define mx 100007
using namespace std;
typedef long long int LL;
pair<LL,LL> ara[mx];
LL pre[mx], suf[mx];
int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
	LL n, c;
	cin >> n >> c;
	for(int i = 1; i<=n; i++)
	{
		cin >> ara[i].first >> ara[i].second;
	}
	LL ans = 0, sum = 0;
	for(int i = 1; i <= n; i++)
	{
		sum+=ara[i].second;
		pre[i] = max(pre[i - 1], sum - ara[i].first);
		ans = max(ans, pre[i]);
	}
	sum = 0;
	for(int i = n; i>=1; i--)
	{
		sum+=ara[i].second;
		suf[i] = max(suf[i + 1], sum + ara[i].first - c);
		ans = max(ans,suf[i]);
	}
	sum = 0;
	for(int i = 1; i < n; i++)
	{
		sum+=ara[i].second;
		LL now = sum - ara[i].first + suf[i + 1] - ara[i].first;
		ans = max(ans, now);
	}
	sum = 0;
	for(int i = n; i > 1; i--)
	{
		sum+=ara[i].second;
		LL now = sum + ara[i].first - c + pre[i - 1] + ara[i].first - c;
		ans = max(ans, now);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner=new Scanner(System.in);
		long m=scanner.nextLong();
		long n=scanner.nextLong();
		System.out.println(kpow(m,n));
	}

	private static long  kpow(long m, long n) {
		// TODO Auto-generated method stub
		long r=0,sum=1;
		while(n!=0){
			r=n%2;
			n=n/2;
			if(r==1)
				sum=(sum*m)%1000000007;
			m=(m*m)%1000000007;
		}
		return sum%1000000007;
	}

}



Measured memory_bytes: 26224
nums = list(map(str, input().split()))
flg = False
if len(set(nums)) != 4:
    pass
else:
    for num in nums:
        if num in "1974":
            flg = True
        else:
            flg = False
            break
if flg == True:
    print("YES")
else:
    print("NO")

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

#define ll long long
 
/*unordered_map <int, vector<int>> adj;
 
void dfs(int s, int *vis)
{
    vis[s] = true;
    for(autp i = adj[s].begin(); i != adj[s].end(); i++)
    {
        if(vis[*i] == false)
        {
            dfs(*i, vis);
        }
    }
}*/
 
 
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
	ll n;
	cin >> n;
	
	ll r = n % 1000;
	
	if(r == 0) cout<<"0\n";
	else cout<<1000-r<<"\n";
	
	return 0;
}


Measured memory_bytes: 3684
input_ab = input().split(' ')
a = int(input_ab[0])
b = int(input_ab[1])

ab = ""
ba = ""

for i in range(b):
  ab = ab + input_ab[0]

for i in range(a):
  ba = ba + input_ab[1]

dic = [ab, ba]
sdic = sorted(dic)

print(sdic[0])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, X, count;
  cin >> A >> B >> C >> X;
  count = 0;
  
  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        if (500 * i + 100 * j + 50 * k == X)
          count++;
      }
    }
  }
  cout << count;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    ll h, d;
    cin >> h >> d;
    d = 2 * d + 1;
    auto res = h / d + (h%d==0?0:1);
    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  auto input=[&](auto &x){
    Int k;
    cin>>k;
    for(Int i=0;i<k;i++){
      Int v;
      cin>>v;
      x.emplace(v);
    }
  };
  set<Int> a,b,c;
  input(a);
  input(b);
  input(c);
  
  set<Int> s;
  for(Int v:c){
    if(!a.count(v)) s.emplace(v);
    if( b.count(v)) s.emplace(v);
  }					 

  cout<<s.size()<<endl;
  return 0;
}



Measured memory_bytes: 3108
N, K, Q = map(int, input().split())
A = []
P = [0]*N
for q in range(Q):
	A.append(int(input()))
 
for q in range(Q):
	P[A[q]-1] += 1
	
for n in range(N):
	if K - (Q - P[n]) > 0:
		print('Yes')
	else:
		print('No')

Measured memory_bytes: 8636
const main = input => {
    const [X, Y] = input.trim().split(' ').map(x => parseInt(x));
    for (let i = 0; i <= X; i++) {
        const tsuru = i
        const kame = X - i
        if (tsuru * 2 + kame * 4 === Y) {
            console.log('Yes')
            return
        }
    }
    console.log('No')
}

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 30544
N, Q = map(int, input().split())
es = [[] for i in range(N)]
value = [0]*N

for i in range(N-1):
  a, b = map(int, input().split())
  es[a-1] += [b-1]
  es[b-1] += [a-1]

for i in range(Q):
  p, x = map(int, input().split())
  value[p-1] += x

stuck = [0]
log = [1]*N
log[0] = 0

while stuck:
  e = stuck.pop()
  for f in es[e]:
    if log[f]:
      log[f] = 0
      value[f] += value[e]
      stuck += [f]

print(*value)


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

int main(){
    long long n,m;
    cin >> n >> m;
    
    priority_queue <long long> a;
    rep(i,n){
        long long A;
        cin >> A;
        a.push(A);
    }

    int cnt = 0;
    while(cnt < m){
        long long tmp = a.top()/2;
        a.pop();
        a.push(tmp);
        cnt ++;
    }

    long long ans = 0;
    rep(i,n){
        ans += a.top();
        a.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 4264
import collections

n, x, y = map(int, input().split())
x -= 1
y -= 1

ans = []
for i in range(n):
    for j in range(i + 1, n):
        min_l = min(j - i, abs(x - i) + abs(y - j) + 1)
        ans.append(min_l)
t = collections.Counter(ans)
for i in range(1, n):
    print(t[i])

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

#define LL long long

#define FOR(INDEX, START, END) for (LL INDEX = (START); INDEX < (END); ++INDEX)
#define REP(INDEX, COUNT) for (LL INDEX = 0; INDEX < (COUNT); ++INDEX)

int main()
{
	LL A, B, C;
	cin >> A >> B >> C;

	if (A == B && B == C) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include "math.h"
#include "stdio.h"

using namespace std;

#define NONE -1
#define UP_SURFACE 0
#define SURFACE 1
#define RIGHT_SURFACE 2

#define IN_ROLL 7
#define IN_PITCH 8

class Dice{
public:
    int surface[6];
    
    void roleEast();
    void roleWest();
    void roleNorth();
    void roleSouth();
    void swap(int surface2[]);
    int getSurface(int num);
    bool isPitchSide(int num);
    bool isSame(Dice dice2);
};

void Dice::swap(int* surface2){
    for(int i = 0;i < 6;++i){
        surface[i] = surface2[i];
    }
}

void Dice::roleEast(){
    int tmp[6];
    tmp[0] = surface[3];
    tmp[3] = surface[5];
    tmp[5] = surface[2];
    tmp[2] = surface[0];
    tmp[1] = surface[1];
    tmp[4] = surface[4];
    swap(tmp);
}

void Dice::roleWest(){
    int tmp[6];
    tmp[3] = surface[0];
    tmp[5] = surface[3];
    tmp[2] = surface[5];
    tmp[0] = surface[2];
    tmp[1] = surface[1];
    tmp[4] = surface[4];
    swap(tmp);
}

void Dice::roleNorth(){
    int tmp[6];
    tmp[0] = surface[1];
    tmp[1] = surface[5];
    tmp[5] = surface[4];
    tmp[4] = surface[0];
    tmp[2] = surface[2];
    tmp[3] = surface[3];
    swap(tmp);
}

void Dice::roleSouth(){
    int tmp[6];
    tmp[0] = surface[4];
    tmp[4] = surface[5];
    tmp[5] = surface[1];
    tmp[1] = surface[0];
    tmp[2] = surface[2];
    tmp[3] = surface[3];
    swap(tmp);
}

int Dice::getSurface(int num){
    for(int i = 0;i < 6;++i){
        if(surface[i] == num){
            return i + 1;
        }
    }
    return NONE;
}

bool Dice::isPitchSide(int num){
    int surface = getSurface(num);
    if(surface == 3 || surface == 4){
        return true;
    }
    return false;
}

bool Dice::isSame(Dice dice2){
    int upSurface =  surface[UP_SURFACE];
    int frontSurface = surface[SURFACE];
    // 存在確認
    if(dice2.getSurface(frontSurface) == NONE || dice2.getSurface(upSurface) == NONE){
        return false;
    }
    while(frontSurface != dice2.surface[SURFACE]){
        if(dice2.isPitchSide(frontSurface)){
            dice2.roleEast();
            
        }
        else {
            dice2.roleSouth();
        }
    }
    int rollNum = 0;
    // upSurfaceを合わせる
    while(upSurface != dice2.surface[UP_SURFACE]){
        dice2.roleEast();
        if(++rollNum == 4){
            return false;
        }
    }
    
    for(int i = 0;i < 6;++i){
        if(surface[i] != dice2.surface[i]){
            return false;
        }
    }
    return true;
}

int main(){
    Dice dice[100];
    int num;
    
    cin >> num;
    
    for(int i = 0;i < num;++i){
        for(int j = 0;j < 6;++j){
            cin >> dice[i].surface[j];
        }
    }
    
    for(int i = 0;i < num;++i){
        for(int j = i + 1;j < num;++j){
            if(dice[i].isSame(dice[j])){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 3116
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

b=input()
if b=='A':
    print('T')
elif b=='T':
    print('A')
elif b=='C':
    print('G')
elif b=='G':
    print('C')

Measured memory_bytes: 3064
n=int(input())
S=input()
w,e='W','E'
if e not in S or w not in S:print(0);exit()
ecnt=len([1 for i in list(S) if i==e])
p0,p1=0,ecnt-int(S[0]==e)
ans=p0+p1
p=S[0]
for i in S[1:]:
  p0,p1=(p0+int(p==w),p1-int(i==e))
  #(l and gyaku,r and gyaku)
  ans=min(ans,p0+p1)
  p=i
print(ans)

Measured memory_bytes: 8144
#include <stdio.h>
#include <stdlib.h>
static const int N = 100;
int main(){
  int M[N][N];
  int n, u, k, v;
  int i,j;
  
  scanf("%d",&n);
  if(n < 1 || n > 100)
    exit(1);
    
  for(i = 0; i < n; i++){
    for(j = 0; j < n;j++)
      M[i][j] = 0;
  }
  for(i = 0; i < n; i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j = 0; j < k;j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }
  
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      if(j)
      printf(" ");
      printf("%d",M[i][j]);
    }
    printf("\n");
  }
      
  return 0;
}


























Measured memory_bytes: 2112
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    intl a[n];
    cin(i,a);
    intl cnt = 0;
    rep(i,n){
        cnt += 2 * min(a[i],m - a[i]);
    }
    cout << cnt << endl;
    return 0;
}

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

#define N 100005

int a[N], b[N], nxt[N], n;

using pii = pair <int, int>;

vector <pii> A, B;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++) scanf("%d", &a[i]), A.push_back(pii(a[i], i));
	for (int i = 1; i <= n; i ++) scanf("%d", &b[i]), B.push_back(pii(b[i], i));
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	for (int i = 0; i < n; i ++) if (A[i].first > B[i].first) return puts("No"), 0;
	for (int i = 0; i < n; i ++) {
		if (i > 1 && A[i].first <= B[i-1].first) return puts("Yes"), 0;
	}
	for (int i = 0; i < n; i ++) nxt[A[i].second] = B[i].second;
	int now = 1, cnt = 0;
	do {
		cnt ++;
		now = nxt[now];
	} while (now != 1);
	if (cnt < n) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 6168
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long c,a,b;
    cin>>c>>a>>b;
    if(c>1&&b>=a||c==1&&a==b) cout<<(c-2)*(b-a)+1<<endl;
    else cout<<0<<endl; 
 } 

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int a, b;
	scanf("%d %d", &a, &b);
	if(a >= 13){
		printf("%d\n", b);
	}else if(6 <= a && a <= 12){
		printf("%d\n", b / 2);
	}else{
		printf("%d\n", 0);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
typedef long long ll;
using namespace std;

int main() {
    int n;
    scanInt(n);
    ll as[n];
    rep(i, n) {
        cin >> as[i];
    }
    ll ans = 1;
    ll max = 1e18;
    rep(i, n) {
        if (as[i] == 0) {
            printf("0\n");
            return 0;
        }
        if (max / as[i] < ans) {
            for (;i < n; ++i) {
                if (!as[i]) {
                    printf("0\n");
                    return 0;
                }
            }
            printf("-1\n");
            return 0;
        }
        ans *= as[i];
    }
    printf("%lld\n", ans);
    return 0;
}


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

public class Main {

	static boolean[] primes;

	static void primeSet(final int MAX){
		primes = new boolean[MAX+1];

		primes[2] = true;
		for(int i=3;i<=MAX;i+=2){
			primes[i] = true;
		}
		int rt = (int) Math.sqrt(MAX);
		for(int i=3;i<=rt;i+=2){
			if(primes[i]){
				for(int j=i*i;j<=MAX;j+=i){
					primes[j] = false;
				}
			}
		}
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		while(stdIn.hasNext()){
			int n = stdIn.nextInt();
			primeSet(n+2);
			int cnt = 0;
			for(int i=1;i<=n;i++){
				if(primes[i]&&primes[n-i+1]){
					cnt++;
				}
			}
			System.out.println(cnt);
		}
	}
}

Measured memory_bytes: 12000
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll N;
  cin >> N;
  unordered_set<ll> st;
  rep (i, N) {
    ll A;
    cin >> A;
    if (st.count(A)) {
      cout << "NO" << endl;
      return;
    }
    st.insert(A);
  }
  cout << "YES" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}


Measured memory_bytes: 8520
#include <iostream>
using namespace std;
int main() {
	int x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int dx, dy;
	dx = x2 - x1;
	dy = y2 - y1;
	for (int i = 1; i <= dx; i++) {
		cout << 'R';
	}
	for (int i = 1; i <= dy; i++) {
		cout << 'U';
	}
	for (int i = 1; i <= dx; i++) {
		cout << 'L';
	}
	for (int i = 1; i <= dy; i++) {
		cout << 'D';
	}
	cout << 'D';
	for (int i = 1; i <= dx; i++) {
		cout << 'R';
	}
	cout << 'R' << 'U';
	for (int i = 1; i <= dy; i++) {
		cout << 'U';
	}
	cout << 'L' << 'U';
	for (int i = 1; i <= dx; i++) {
		cout << 'L';
	}
	cout << 'L' << 'D';
	for (int i = 1; i <= dy; i++) {
		cout << 'D';
	}
	cout << 'R'<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
    int N;  cin >> N;
    V A(N);  VECCIN(A);
    ll max_num = A[0];
    ll ans = 0;
    for(int i = 1 ; i < N ; i++){
      if(max_num < A[i])  max_num = A[i];
      else                ans += max_num - A[i];           
    }

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

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;
#define int long long
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  UnionFind(){}
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

void solve(ll N, ll M, vector<ll> a, vector<ll> x, vector<ll> y){
	UnionFind uf = UnionFind(N);
	for(int i = 0 ; i < x.size() ; i++){
		uf.unionSet(x[i], y[i]);
	}
	vector<int> items[100010];
	int cnt = 0;
	for(int i = 0 ; i < N ; i++){
		items[uf.root(i)].push_back(a[i]);
		if( uf.root(i) == i ) cnt++;
	}
	
	for(int i = 0 ; i < N ; i++){
		sort(items[i].begin(), items[i].end());
	}
	int rem = (cnt-1) * 2;
	ll ans = 0;
	vector<int> remItems;
	for(int i = 0 ; i < N ; i++){
		if( uf.root(i) == i ){
			if( rem > 0 ){
				ans += items[i][0];
				rem--;
				for(int j = 1 ; j < items[i].size() ; j++)
					remItems.push_back(items[i][j]);
			}
		}
	}

	sort(remItems.begin(), remItems.end());
	
	for(int i = 0 ; i < remItems.size() ; i++){
		if( rem > 0 ){
			rem--;
			ans += remItems[i];
		}
	}
	if( rem ) {
		cout << "Impossible" << endl;
	}else{
		cout << ans << endl;
	}

}

signed main(){	
	ll M;
	ll N;
	scanf("%lld",&N);
	vector<ll> a((N-1)-0+1);
	scanf("%lld",&M);
	vector<ll> x(M-1+1);
	vector<ll> y(M-1+1);
	for(int i = 0 ; i <= (N-1)-0 ; i++){
		scanf("%lld",&a[i]);
	}
	for(int i = 0 ; i <= M-1 ; i++){
		scanf("%lld",&x[i]);
		scanf("%lld",&y[i]);
	}
	solve(N, M, a, x, y);
	return 0;
}



Measured memory_bytes: 10356
#include <bits/stdc++.h>
using namespace std;
typedef struct UnionFindTree{
    vector<int> par;
    
    UnionFindTree(int n){
        par.resize(n, -1);
    }

    int find(int x){
        if(par[x] < 0) return x;
	return par[x] = find(par[x]);
    }

    bool unite(int x, int y){
        x = find(x);
	y = find(y);
	if(x == y) return false;
	if(par[x] > par[y]) swap(x, y);
	par[x] += par[y];
	par[y] = x;
	return true;
    }
}UF;

int main(){
  int v, d;
  int fib[1010];
  int a, b;
  a = b = 1;
  int mod = 1001;
  for(int i=0; i<1010; ++i){
    int c = (a + b) % mod;
    fib[i] = c;
    a = b;
    b = c;
  }
  while(scanf("%d%d", &v, &d) != EOF){
    int ans = v;
    UF uf(v);
    for(int i=0; i<v; ++i){
      for(int j=i+1; j<v; ++j){
	    if(abs(fib[i] - fib[j]) < d) ans -= uf.unite(i, j);
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3128
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());

bool is(ll *a,ll n)
{
	rep(i,n-1)
	{
		if(a[i]>a[i+1]) return 0;
	}
	return 1;
}

int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		// reverse(a.begin(),a.end());
		cin>>n;
		// n=s.length();
		ll a[n];
		rep(i,n) cin>>a[i];
		rep(i,n-1)
		{
			repe(j,i,n)
			{
				swap(a[i],a[j]);
				if(is(a,n)) {cout<<"YES";return 0;}
				swap(a[i],a[j]);
			}
		}
		cout<<"NO";
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000009
#define ll long long
using namespace std;
long long int n,num,a[200005],vis[200005];
int main()
{
    scanf("%lld%lld",&n,&num);
    for(int i=1; i<=n; i++)
        scanf("%lld",&a[i]),vis[i]=0;
    long long int pos1=1,pos2;
    while(vis[pos1]!=1)
    {
        vis[pos1]=1;
        pos1=a[pos1];
    }
    pos2=pos1;
    for(int j=1; j<=n; j++)
        vis[j]=0;
    int t=0;
    while(vis[pos2]!=1)
    {
        vis[pos2]=1;
        t++;
        pos2=a[pos2];
    }
    int b=0;
    pos2=1;
    while(1)
    {
        if(pos1==pos2)
            break;
        pos2=a[pos2],b++;
    }
    int c=0;
    if(num<=b)
    {
        pos2=1;
        while(1)
        {
            if(num==c)
                break;
            pos2=a[pos2],c++;
        }
        printf("%d\n",pos2);
        return 0;
    }
    num-=b;
    num%=t;
    pos2=pos1;
    c=0;
    while(1)
    {
        if(num==c)
            break;
        pos2=a[pos2],c++;
    }
    printf("%d\n",pos2);
    return 0;
}


Measured memory_bytes: 6964
n, m = map(int, input().split())
temp = None

for i in range(n):
    ka = list(map(int, input().split()))
    k = ka[0]
    aa = set(ka[1:])
    if temp is None:
        temp = aa
    else:
        temp.intersection_update(aa)

if temp is None:
    print(0)
else:
    print(len(temp))


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, divisor, modinv, bitSearch, bitList, dfs, bfs//
//dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 9999999999999; ll ans = INF;
vl flag, color, D; vll path;
//***********//
int main() {
	cin >> N;
	vl X(N), Y(N), H(N);
	for (i = 0; i < N; i++) {
		cin >> X[i] >> Y[i]>> H[i];
	}
	for (i = 0; i <= 100; i++) {
		for (j = 0; j <= 100; j++) {
			ll valid = 1;
			ll h = 0;
			ll h_max = INF;
			ll z = 0;
			for (k = 0; k < N; k++) {
				if (h > 0) {
					if (max(h - abs(X[k] - i) - abs(Y[k] - j), z) != H[k]) {
						valid = 0; break;
					}
				}
				else {
					if (H[k] > 0) {
						h = H[k] + abs(X[k] - i) + abs(Y[k] - j);
						if (h > h_max) {
							valid = 0;
							break;
						}
					}
					else {
						h_max = abs(X[k] - i) + abs(Y[k] - j);
					}
				}
				//cout << h << endl;
			}
			if (valid) {
				cout << i << " " << j << " " << h;
				exit(0);
			}
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9 + 10)
#define PI (acos(-1))
#define MOD (1000000007)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
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; }

ll DP[22][2097152] = {};
vector<int> cDP[22];

int bitcount(unsigned long n){
    const static unsigned char aa[] = {
        0, 1, 1, 2,
        1, 2, 2, 3,
        1, 2, 2, 3,
        2, 3, 3, 4,
    };
    int c = 0;
    for (int cc = 0; n; n >>= 4){
        c += aa[n & 0xf];
    }
    return c;
}

int main() {
    int N;
    cin >> N;
    int a[N][N];
    REP(i, N) {
        REP(j, N) {
            cin >> a[i][j];
        }
    }
    DP[0][0] = 1;
    int NN = 1<<N;
    REP(i, NN) {
        int c = bitcount(i);
        cDP[c].push_back(i);
    }

    REP(i, N) {
        vector<int> v = cDP[i+1];
        for (int j : v){
            REP(k, N){
                int aaa = j&(1<<k);
                if (aaa && (a[i][k] == 1)){
                    (DP[i+1][j] += DP[i][j-aaa]) %= MOD;
                }
            }
        }
    }
    cout << DP[N][int(pow(2, N))-1] << endl;

}

Measured memory_bytes: 320344
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n;
string s;

int main() {
    Vi v, vodd;
    int i = 1, val = i*(i+1)*(i+2)/6;
    while (val < 1e6) {
        v.push_back(val);
        if (val%2 == 1) vodd.push_back(val);
        i++; val = i*(i+1)*(i+2)/6;
    }
    Vl dp(1e6, 1e18), dpodd(1e6, 1e18);
    dp[0] = 0; dpodd[0] = 0;
    REP(i, 1e6) REP(j, v.size()) {
        if (i >= v[j]) dp[i] = min(dp[i-v[j]]+1, dp[i]);
    }
    REP(i, 1e6) REP(j, vodd.size()) {
        if (i >= vodd[j]) dpodd[i] = min(dpodd[i-vodd[j]]+1, dpodd[i]);
    }

    while (true) {
        cin >> n;
        if (n == 0) break;
        printf("%lld %lld\n", dp[n], dpodd[n]);
    }

    return 0;
}



Measured memory_bytes: 18212
#include <stdio.h>

int dfs(int n, int s, int x){
  int sum=0;
  if(n==0 && s==0)
    return 1;
  if(n>0){
      for(int i=x; i<10; i++){
          if(s-i>=0)
               sum+=dfs(n-1, s-i, i+1);
      }
  }
  return sum;
}

int main(void){
  int n, s;
  while(scanf("%d %d",&n,&s)!= EOF){
      if(n==0 && s==0)
        break;
      printf("%d\n",dfs(n, s, 0));
  }
  return 0;
}


Measured memory_bytes: 2036
#include<stdio.h>

int main(void){
	int i,n;
	int x = 100000;
	scanf("%d",&n);

	for(i=0;i<n;i++){
		x=x*1.05;
		if(x%1000!=0){
			x=(x/1000+1)*1000;
		}
	}
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 592
N, M = list(map(int,input().split()))
X = list(map(int,input().split()))

X.sort()
Inter = [X[i+1]-X[i] for i in range(M-1)]
#print(Inter)
Inter.sort()
# for i in range(M):

tmp=0
res=X[-1]-X[0]
# コマの個数が多ければ0
if(N>=M):
    print("0")
elif(N==1):
    print(res)
# elif(N==2):
#    print(X[-1]-X[0]-Inter[M-2])
else:
    for i in range(N-1):
        tmp+=Inter[M-(i+2)]
    print(res-tmp)
    #print("no")


Measured memory_bytes: 13964
#include<stdio.h>
#include<string.h>
int main()
{
	int n,m,i,f=0;
	char a[111],b[111];

	scanf("%s%s",a,b);

	n=strlen(a);
	m=strlen(b);
	if(n>m)
		f=1;
	else if(n<m)
		f=-1;
	for(i=0;i<n&&f==0;i++){
		if(a[i]>b[i])
			f=1;
		else if(a[i]<b[i])
			f=-1;
	}

	if(f==1)
		puts("GREATER");
	else if(f==0)
		puts("EQUAL");
	else
		puts("LESS");
	return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(c) begin(c), end(c)
#define range(i,a,b) for(int i = a; i < (int)(b); i++)
#define rep(i,b) range(i,0,b)
#define eb emplace_back
typedef long long ll;
// #define int ll
auto const inf = numeric_limits<int>::max()/4;

using Weight = int;
using Capacity = int;
struct Edge {
    int src, dst; Weight weight;
    Edge(int s, int d, int w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

pair<vector<Weight>, bool> spfa(const Graph &g, int s){
    const Weight inf = numeric_limits<Weight>::max()/4;
    const int n = g.size(); priority_queue<int> q;
    vector<Weight> dist(n, inf); vector<int> inQ(n);
    vector<int> count(n);
    dist[s] = 0; q.emplace(s); inQ[s] = true; ++count[s];
    bool negCycle = false;
    for(int i = 0; q.size(); i++){
        int v = q.top(); q.pop(); inQ[v] = false;
        for(auto &e : g[v]){
            if(dist[v] != inf && dist[e.dst] > dist[v] + e.weight){
                dist[e.dst] = dist[v] + e.weight;
                if(!inQ[e.dst]){
                    q.emplace(e.dst); inQ[e.dst] = true; ++count[e.dst];
                    if(count[e.dst] >= n){ negCycle = true; goto END; }
                }
            }
        }
    }
 END:;
    return make_pair(dist, !negCycle);
}

int main(){
    int V,E,r;
    while(cin >> V >> E >> r){
        Graph g(V);
        rep(i,E){
            int a,b,c;
            cin >> a >> b >> c;
            g[a].eb(a,b,c);
        }
        bool ok;
        vector<Weight> dist;
        tie(dist, ok) = spfa(g,r);
        if(ok){
            for(int i = 0; i < (int)dist.size(); i++){
                if(dist[i] == inf) cout << "INF";
                else cout << dist[i];
                cout << endl;
            }
        } else {
            cout << "NEGATIVE CYCLE" << endl;
        }
    }
}

Measured memory_bytes: 3216
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

a, b, c = map(int, input().split())
state = [[a,b,c]]
if a%2 == 0  and a == b  and b == c:
    print(-1)
else:
    while True:
        if a%2==1 or b%2==1 or c%2==1:
            print(count)
            exit()
        a_2 = a//2
        b_2 = b//2
        c_2 = c//2
        a = b_2 + c_2
        b = a_2 + c_2
        c = a_2 + b_2
        if [a,b,c] in state:
            print(-1)
        else:
            state.append([a,b,c])
            count += 1

Measured memory_bytes: 9524
import math
'''
時針：Aセンチ，12時間で1周
分針：Bセンチ，1時間で1周
0時ちょうどに針は重なっていた．H時M分のとき，2本の針の端点は何センチ離れているか．
'''
 
A,B,H,M= list(map(int, input().split()))
 
theta = 2*math.pi*H/12+2*math.pi*M/12/60 #時針の角度
phi = 2*math.pi*M/60 #分針の角度
  
C = math.sqrt(A**2+B**2-2*A*B*math.cos(theta-phi))
print(C)

Measured memory_bytes: 9532
import java.util.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        long N = sc.nextLong();
        sc.close();
       
        long max = N;
        for(long i = 2; (i*i) <= N; i++){
            if(N%i == 0){
                max = N/i;
            }
        }
        int count = 1;
        while(max/10 != 0){
            count++;
            max /= 10;
        }
        System.out.println(count);
   }
}

Measured memory_bytes: 21972
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

class State {
public:
  int x1,x2,y1,y2,num;
  State(){}

  bool operator < (const State s) const {
    if(x1 == s.x1) return y1 < s.y1;
    return x1 < s.x1;
  }

};

State t[10],t2[10];
int n;
int used[10];
int cnt;
map<int, int> mp; // num -> index


void solve(vector<int> v){

  for(int i=0; i<v.size(); i++){
    int index = v[i];
    if(used[index] != -1) continue;
    used[index] = cnt++;
    index = mp[index];
    //    cout << "index = " << mp[index] << endl;


    int X1 = t[index].x1, X2 = 50000, Y1 = t[index].y1, Y2 = t[index].y2;
    //    cout << "X1 = " << X1 << " X2 = " << X2 << " Y1 = " << Y1 << " Y2 = " << Y2 << endl;

    for(int j=0; j<n; j++){
      //      if(used[t[j].num] != -1)continue;
      if(t[j].y2 > Y2 && t[j].y1 < Y2 && t[j].x1 >= t[index].x1){
	  X2 = min(X2,t[j].x1);
	  break;
	}
    }



    vector<int>tmp;
    for(int j=0; j<n; j++){
      if(used[t[j].num] != -1)continue;
      if(t[j].y2 <= Y2 && X2 >= t[j].x2 && t[j].x1 >= X1){
	tmp.push_back(t[j].num);
	//	cout << "num = " << t[j].num + 1 << endl;
      }
    }
    solve(tmp);
  }
}

int main(){
  bool f = false;
  while(cin >> n && n){

    if(f) cout << endl;
    f = true;

    cnt = 1;
    fill(used,used+10,-1);

    for(int i=0; i<n; i++){
      cin >> t[i].x1 >> t[i].y1 >> t[i].x2 >> t[i].y2;
      if(t[i].x1 > t[i].x2) swap(t[i].x1,t[i].x2);
      if(t[i].y1 > t[i].y2) swap(t[i].y1,t[i].y2);
      t[i].num = i;
    }

    for(int i=0; i<n; i++) t2[i] = t[i];

    sort(t,t+n);
    
    for(int i = 0 ; i < n ; i++){
      mp[t[i].num] = i;
    }
    
    for(int i=0; i<n; i++){
      //      cout << "x1 = " << t[i].x1 << " y1 = " << t[i].y1 << " x2 = " << t[i].x2 << " y2 = " << t[i].y2 << 
      //	" num = " << t[i].num << endl;
    }


    vector<int>v;
    for(int i=0; i<n; i++) v.push_back(t[i].num);
    solve(v);

    for(int i=0; i<n; i++) cout << used[i] << endl;

  }
  return 0;
}

Measured memory_bytes: 1220
c11,c12,c13 = map(int,input().split())
c21,c22,c23 = map(int,input().split())
c31,c32,c33 = map(int,input().split())
if c11-c12  == c21-c22 and c11-c12 == c31-c32 and c12-c13 == c22-c23 and c12-c13 == c32-c33:
    print("Yes")
else:
    print("No")

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

int main(){
    int a[5];
    int k;  
    for(int i = 0; i < 5 ; i++){
        cin >> a[i];
    }
    cin >> k;
    bool flag = true;
    for(int i = 0 ; i < 4; i++){
        for(int j = i+1; j < 5 ; j++){
            if(a[j]-a[i] > k){
                flag = false;
                break;
            }
        }
        if(!flag)break;
    }
    if(flag){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }


}

Measured memory_bytes: 256
#include <stdio.h>

int max(int a, int b) {
  return a > b ? a : b;
}

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

int main(void) {
  int i, j, k, h, w;
  scanf("%d%d", &h, &w);
  char b[h][w + 10];
  int bfs[h][w];
  for(i = 0; i < h; ++i) scanf("%s", b[i]);
  for(i = 0; i < h; ++i) for(j = 0; j < w; ++j) b[i][j] -= '0', bfs[i][j] = 100000;
  bfs[0][0] = 0;
  for(i = 1; i < h + w; ++i) {
    for(j = max(0, i - w + 1); j <= min(h - 1, i); ++j) {
      if(i - j) bfs[j][i - j] = bfs[j][i - j - 1] + b[j][i - j];
      if(j && bfs[j][i - j] > bfs[j - 1][i - j] + b[j][i - j]) bfs[j][i - j] = bfs[j - 1][i - j] + b[j][i - j];
    }
  }
  /*for(i = 0; i < h; ++i) {
    for(j = 0; j < w; ++j) printf("%d ", bfs[i][j]);
    printf("\n");
  }*/
  printf("%d\n", bfs[h - 1][w - 1]);
  return 0;
}


Measured memory_bytes: 2764
#include<bits/stdc++.h>
using namespace std;
 
void solve()
{
    string s;cin >> s;
    char ch = s[(int)s.size()-1];
    if(ch != 's')
    {
        s.append("s");
    } else
    {
        s.append("es");
    }

    cout << s << '\n';
}   
 
signed main()
{
     int test_cases;test_cases=1;
     //cin >> test_cases;
     while(test_cases --> 0) solve();
}

Measured memory_bytes: 3620
fun main(args : Array<String>){

    val (n,m,x) = readLine()!!.split(' ').map { it.toInt() }
    val a = readLine()!!.split(' ').map { it.toInt() }

    var prev = 0
    var nxt = 0

    for(i in 0..a.size-1){
        if(a[i] > x)prev++
        else nxt++
    }

    println(Math.min(prev,nxt))

}


Measured memory_bytes: 38172
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>
using namespace std;
#define  LL long long

int num[111];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int x=i;
		for(int j=2;j<=sqrt(x);j++){
			if(x%j==0){
				while(x%j==0)
					num[j]++,x/=j;
			}
		}
		if(x>1)
			num[x]++;
	}
	int four=0,two=0;
	for(int i=2;i<=100;i++){
		if(num[i]>=4) four++;
		else if(num[i]>=2) two++;
	}
	int ans=0;
	for(int i=2;i<=100;i++){
		for(int j=2;j<=100;j++)
		{
			for(int k=j+1;k<=100;k++){
				if(i==k||i==j) continue;
				if(num[i]>=2&&num[j]>=4&&num[k]>=4)//a^4*b^4*c^2
					ans++;
			}
			if(i==j) continue;
			if(num[i]>=2&&num[j]>=24){//a^2*b^24
				ans++;
			}
			if(num[i]>=14&&num[j]>=4)//a^14*b^4
				ans++;
		}
		if(num[i]>=74){//a^74
			ans++;
		}
	}

	printf("%d\n",ans);


	return 0;
}



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

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

ll gcd(ll a, ll b) { for (; b; a %= b, swap(a, b)); return a; }

ll n, k;
int par[62][200001];

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

	cin >> n >> k;
	for (int i = 1; i <= n; i++) cin >> par[0][i];

	for (int i = 1; i < 62; i++)
	{
		for (int j = 1; j <= n; j++)
			par[i][j] = par[i - 1][par[i - 1][j]];
	}

	int cur = 1;
	for (int j = 0; j < 62; j++)
	{
		if (k & (1ll << j)) cur = par[j][cur];
	}

	cout << cur;
}

Measured memory_bytes: 52092
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[][] = new int [n][26];
		for (int i=0;i<n;i++) {
			String s = sc.next();
			for (int j=0;j<s.length();j++) {
				a[i][s.charAt(j)-'a']++;
			}
		}
		StringBuffer sb = new StringBuffer();
		for (int i=0;i<26;i++) {
			int min = a[0][i];
			for (int j=1;j<n;j++) {
				if (min>a[j][i]) {
					min = a[j][i];
				}
			}
			if (min >0) {
				for (int j=0;j<min;j++) {
					sb.append((char)('a'+i));
				}
			}
		}
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 21844
def main():
    N = int(input())
    S = input()
    from collections import Counter
    c = Counter(S)
    ans = 10**9
    past_w = 0
    past_e = 0
    for s in S:
        if s == "W":
            ans = min(ans, past_w + c["E"]-past_e)
            past_w += 1
        else:
            past_e += 1
            ans = min(ans, past_w + c["E"]-past_e)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 41816