akhauriyash/Code-Regression huggingface dataset:
# frozen_string_literal: true

def factor(n)
  return [1] if n == 1

  `factor #{n}|sed -r 's/[0-9]+://g'|tr ' ' '\n'|sort -n`.split.map(&:to_i)
end

# Example: factors(100) => {2=>2, 5=>2}
def factors_and_num(n)
  factors = factor(n)
  ret = Hash.new(0)
  factors.each do |i|
    ret[i] += 1
  end
  ret
end

def uniq_factor(n)
  `factor #{n}|sed -r 's/[0-9]+://g'|tr ' ' '\n'|sort -n|uniq`.split.map(&:to_i)
end

s = gets.chomp!
if s.scan(/hi/).join('').eql?(s)
  puts 'Yes'
else
  puts 'No'
end


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto &it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vl vector<long>
#define P pair<int,int>
using namespace std;

int high[1010];

void f(int n)
{
        if(n==1)
        {
                high[1]=1;
                return;
        }
        f(n-1);
        high[n]=high[n-1]+n;
}

main()
{
        f(1000);
        int l,r; cin>>l>>r;
        int d=r-l;
        cout<<high[d]-r<<endl;
}



Measured memory_bytes: 256
w,h,n = map(int, input().split())
li = [0, w, 0, h]
ans = 0
for i in range(n):
    x,y,a = map(int, input().split())
    if a == 1 and li[0] < x:
        li[0] = x
    elif a == 2 and li[1] > x:
        li[1] = x
    elif a == 3 and li[2] < y:
        li[2] = y
    elif a == 4 and li[3] > y:
        li[3] = y
W = li[1]-li[0]
H = li[3]-li[2]
print(0 if W < 0 or H < 0 else W*H)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdbool.h>
#include<string>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<utility>
#include<list>
typedef long long ll;
using namespace std;
ll num[100010] = { 0 };

int main() {
	ll a, b, n, sum = 0, k;
	cin >> n >> k;
	for (ll i = 0;i < n;i++) {
		cin >> a >> b;
		num[a] += b;
	}
	for (ll i = 1;i <= 100000;i++) {
		sum += num[i];
		if (sum >= k) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

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

int main() {
  long int n,count;
  cin>>n;
  vector<long int> a(n);
  count=0;
  for(long int i=0;i<n;i++){
    cin>>a.at(i);
    for(int j=a.at(i);j%2==0;j/=2)
      count++;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
int n,b,a;
ll h[SZ];
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	ll l=0,r=0;
	for(int i=1;i<=n;i++)
		scanf("%lld",h+i),r+=h[i]/a+1;
	a-=b;
	while(l<r)
	{
		ll x=(l+r)>>1,t=0;
		for(int i=1;i<=n;i++)
		{
			ll g=h[i]-x*b;
			if(h[i]/b+3<x||g<0) g=0;
			t+=(g+a-1)/a;
		}
		if(t>x) l=x+1; else r=x;
	}
	printf("%lld\n",l);
}


Measured memory_bytes: 1024
#include <stdio.h>


int main(){
    char str;
    
    while(1){
        scanf("%c", &str);
        if(str=='\n'){
            printf("\n");
            break;
        }else if(('A'<=str) && (str<='Z')){
            printf("%c",str - 'A' + 'a');
        }else if(('a'<=str) && (str<='z')){
            printf("%c",str - 'a' + 'A');
        }else{
            printf("%c", str);
        }
    }

    return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include<math.h>
using namespace std;
#define FOR(hoge,a) for(hoge=0;hoge<a;hoge++)
int light[100000];
int hairetu[100000];
int i,j;
int main() {
	int n;
	cin>>n;
	FOR(i,n){
		cin>>light[i];
	}
	int mae=light[0];
	int ato;
	int p=0;
	FOR(i,n-1){
		ato=light[i+1];
		if(ato!=mae){hairetu[p]++;}
		else{p++;}
		mae=ato;
	}
	if(p<=2){cout<<n<<endl;}
	else{
		int ans=0;
		FOR(i,p-1){
			int t=hairetu[i]+hairetu[i+1]+hairetu[i+2];
			ans=max(ans,t);
		}
		cout<<ans+3<<endl;
	}
	return 0;
}

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

public class Main{
    static Scanner sc = new Scanner(System.in);
    static int n = sc.nextInt();
    static int[] a = new int[n];
    static int[] b = new int[n];
    static int[] c = new int[n];

    public static void main(String[] args){
        for (int i=0; i<n; i++) a[i] = sc.nextInt();
        Arrays.sort(a);
        for (int i=0; i<n; i++) b[i] = sc.nextInt();
        Arrays.sort(b);
        for (int i=0; i<n; i++) c[i] = sc.nextInt();
        Arrays.sort(c);

        long ans = 0;

        for (int i=0; i<n; i++){
            long low = lowerbound(a, b[i]);
            long high = lowerbound(c, b[i]+1);

//            int high = upperbound(c, b[i]);
            long tmp = low*(n-high);
            ans += tmp;
        }

        System.out.println(ans);

    }

    private static int lowerbound(int[] x, int y){
        int left = 0;
        int right = n;
        while (left<right){
            int mid = (left+right)/2;
            if (x[mid]<y){
                left = mid+1;
            }else {
                right = mid;
            }
        }
//        System.out.println(left);
        return left;
    }

//    private static int upperbound(int[] x, int y){
//        int left = 0;
//        int right = n;
//        while (left<right){
//            int mid = (left+right)/2;
//            if ()
//        }
//    }
}

Measured memory_bytes: 96000
mod = 10**9+7
n, m = map(int, input().split())
l = [int(input()) for _ in range(m)]

t2 = 0
t1 = 1

for i in range(1,n+1):
  if l == [] or i != l[0]:
    t0 = (t2+t1)%mod
  else:
    l.pop(0)
    t0 = 0
  t2 = t1
  t1 = t0

print(t0)

Measured memory_bytes: 7080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[300005],ans[300005];
int n;
char dao(char a){
    if(a=='S') return 'W';
    if(a=='W') return 'S';
}
int deal(){
    for(int i=2;i<n;i++){
        if(s[i]=='o'){
            if(ans[i]=='S'){
                ans[i+1]=ans[i-1];
            }
            else{
                ans[i+1]=dao(ans[i-1]);
            }
        }
        else {
            if(ans[i]=='S'){
                ans[i+1]=dao(ans[i-1]);
            }
            else{
                ans[i+1]=ans[i-1];
            }
        }
    }
    int flag1=0,flag2=0;
    if(ans[1]=='S'){
        if(s[1]=='o'){
            if(ans[2]==ans[n]){
                flag1=1;
            }
        }
        else{
            if(ans[2]==dao(ans[n])){
                flag1=1;
            }
        }
    }
    else {
        if(s[1]=='o')
            if(ans[2]!=ans[n]) {
                flag1=1;
            }
        else
            if(ans[2]!=dao(ans[n])){
                flag1=1;
            }
    }
    if(ans[n]=='S'){
        if(s[n]=='o'){
            if(ans[1]==ans[n-1]){
                flag2=1;
            }
        }
        else{
            if(ans[1]==dao(ans[n-1])){
                flag2=1;
            }
        }
    }
    else {
        if(s[n]=='o'){
            if(ans[1]==dao(ans[n-1])){
                flag2=1;
            }
        }
        else{
            if(ans[1]==ans[n-1]){
                flag2=1;
            }
        }

    }
    if(flag1&&flag2) return 1;
    return 0;
}
int main(){

    scanf("%d%s",&n,s+1);
    ans[1]='S',ans[2]='S';
    if(deal()){
        printf("%s\n",ans+1);
        return 0;
    }
    ans[1]='S',ans[2]='W';
    if(deal()){
        printf("%s\n",ans+1);
        return 0;
    }
    ans[1]='W',ans[2]='S';
    if(deal()){
        printf("%s\n",ans+1);
        return 0;
    }
    ans[1]='W',ans[2]='W';
    if(deal()){
        printf("%s\n",ans+1);
        return 0;
    }
    printf("-1\n");
    return 0;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long Q = sc.nextLong();
    long H = sc.nextLong();
    long S = sc.nextLong();
    long D = sc.nextLong();
    long N = sc.nextLong();
    long min1l = Math.min(Math.min(4 * Q, 2 * H), S);
    long min2l = Math.min(Math.min(8 * Q, 4 * H), Math.min(2 * S, D));
    long ans = 0;
    if (N % 2 == 1) {
      ans = (N - 1) / 2 * min2l + min1l;
    } else {
      ans = N / 2 * min2l;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void) {
	int num, i, ans = 0, a;
	cin >> num;
	vector<int> d(num);
	a = num >> 1;
	for (i = 0; i < num; i++)
		scanf("%d", &d[i]);
	sort(d.begin(), d.end());
	printf("%d\n", d[a] - d[a - 1]);
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

template <class T>  
inline bool RD(T &ret) {  
        char c; int sgn;  
        if (c = getchar(), c == EOF) return 0;  
        while (c != '-' && (c<'0' || c>'9')) c = getchar();  
        sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0');  
        while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');  
        ret *= sgn;  
        return 1;  
}  
template <class T>  
inline void PT(T x) {  
        if (x < 0) putchar('-') ,x = -x;  
        if (x > 9) PT(x / 10);  
        putchar(x % 10 + '0');  
}

const int INF = 0x3f3f3f3f;
typedef long long LL;
typedef pair<int, int> pii;
typedef long double LD;



const int N = 1e5 + 100;
int a[N];
int main() {
	int n;
	RD(n);
	n *= 2;
	REP(i, 0, n) RD(a[i]);
	sort(a, a + n);
	int ans = 0;
	for(int i = 0; i < n; i += 2) ans += a[i];
	printf("%d\n", ans);
}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
#define keta fixed<<setprecision
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 998244353LL;
int main(){
	char op;
	int a,b;
	for(;;){
		std::cin >> a>>op>>b;
		if(op=='+')std::cout << a+b << std::endl;
		else if(op=='-')std::cout << a-b << std::endl;
		else if(op=='*')std::cout << a*b << std::endl;
		else if(op=='/')std::cout << a/b << std::endl;
		else if(op=='?')exit(0);
		
	}
}


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

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        Integer[] a = new Integer[n];
        Integer[] b = new Integer[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(scan.next());
            b[i] = Integer.parseInt(scan.next());
        }
        scan.close();

        Arrays.sort(a);
        Arrays.sort(b);

        if (n % 2 == 1) {
            System.out.println(b[(n - 1) / 2] - a[(n - 1) / 2] + 1);
        } else {
            int alow = a[n / 2 - 1];
            int ahigh = a[n / 2];
            int blow = b[n / 2 - 1];
            int bhigh = b[n / 2];
            System.out.println(blow + bhigh - alow - ahigh + 1);
        }

    }

}


Measured memory_bytes: 67984
# coding: utf-8
# Your code here!
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))

def saiki(lis,n,order):
    #print(order)
    if n==N:
        return order
    else:
        temp=0
        for item in lis[1:]:
            if lis[0]>item:
                temp+=1
        return saiki(lis[1:],n+1,order+temp*num[n]/len(lis))

num=[]
temp=1
for i in range(N):
    temp*=(i+1)
    num.append(temp)
num=num[::-1]

#print(num)

p=saiki(P,0,0)
q=saiki(Q,0,0)

print(abs(int(p-q)))

Measured memory_bytes: 3064
"""
まず、奇数個存在する文字種が複数ある場合は、回文にできない。
それ以外の場合は、回文にできる。
次に、操作の最小回数は、回文になった場合の各文字のインデックスを求めておき、BITを使って、入れ替えが必要な回数を求めて置く
"""
from collections import Counter
S = input()
N = len(S)
#各文字の出現回数をカウント
apperance = Counter(S)

#回文を作成できるか判定
flag = False
for k,v in apperance.items():
    if v%2==1:
        if flag:
            print(-1)
            exit()
        else:
            flag = True
            t = k


#place[s] -> 文字sの出現位置
place = {}
for i in range(N):
    s = S[i]
    if s not in place:
        place[s] = []
    place[s].append(i)

#memo[i] -> Sのi文字目の回文上でのインデックス
memo = [-1] *(N)

#回文前半、後半に含まれることになる文字に、回文上でのインデックスを割り当てる。
tmp = 0
tmpApperance = {}
for i in range(N):
    s = S[i]
    if s not in tmpApperance:
        tmpApperance[s] = 1
    else:
        tmpApperance[s] += 1
    if tmpApperance[s] <= apperance[s]//2:
        memo[i] = tmp
        backIdx = place[s][-tmpApperance[s]]
        memo[backIdx] = N-tmp-1
        tmp += 1


#回文の真ん中に含まれることになる文字に、回文上でのインデックスを割り当てる。
if flag:
    idx = N//2
    memo[place[t][len(place[t])//2]] = idx

class BIT:
    def __init__(self,n):
        self.size=n
        self.tree = [0]*(n+1)
    
    def sum(self,i):
        s = 0
        while i>0:
            s += self.tree[i]
            i -= i&-i
        return s
    
    def add(self,i,x):
        while i<=self.size:
            self.tree[i] += x
            i += i&-i
bit = BIT(N)
cnt = 0
for i in range(N):
    m = memo[i]+1
    bit.add(m,1)
    cnt += bit.sum(N)-bit.sum(m)

print(cnt)


Measured memory_bytes: 88408
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.io.OutputStreamWriter;
import java.math.BigInteger;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.io.IOException;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author ogiekako
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		MyScanner in = new MyScanner(inputStream);
		MyPrintWriter out = new MyPrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
    public void solve(int testNumber, MyScanner in, MyPrintWriter out) {
        String s = in.next();
        int res = 0;
        int depth = 0;
        for(char c:s.toCharArray()){
            if(c=='S'){
                depth++;
            }else{
                if(depth<=0){
                    res++;
                }else{
                    depth--;
                }
            }
        }
        res+=depth;
        out.println(res);
    }
}

class MyScanner {
    private final InputStream in;

    public MyScanner(InputStream in) {
        this.in = in;
    }

    private static final int BUFSIZE = 65536;
    int bufLen;
    int bufPtr;
    byte[] buf = new byte[BUFSIZE];

    public int read() {
        if (bufLen == -1)
            throw new InputMismatchException();
        if (bufPtr >= bufLen) {
            bufPtr = 0;
            try {
                bufLen = in.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (bufLen <= 0)
                return -1;
        }
        return buf[bufPtr++];
    }

    private char[] strBuf = new char[BUFSIZE];

    public String next() {
        int strLen = 0;
        int c;
        do {
            c = read();
            if (c == -1) throw new NoSuchElementException();
        } while (Character.isWhitespace(c));
        do {
            if (strLen + 1 >= strBuf.length) {
                char[] tmp = new char[strBuf.length * 2];
                System.arraycopy(strBuf, 0, tmp, 0, strBuf.length);
                strBuf = tmp;
            }
            strBuf[strLen++] = (char) c;
            c = read();
        } while (c != -1 && !Character.isWhitespace(c));
        return new String(strBuf, 0, strLen);
    }

}

class MyPrintWriter {
    PrintWriter out;

    public MyPrintWriter(OutputStream outputStream) {
        out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public void println(int a) {
        out.println(a);
    }

    public void close() {
        out.close();
    }

}



Measured memory_bytes: 10964
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;

vector<string> g;

int main() {
    
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    ll n, m, q;
    cin >> n >> m >> q;
    
    vector<ll> a(q);
    vector<ll> b(q);
    vector<ll> c(q);
    vector<ll> d(q);
    for (int i = 0; i < q; ++i)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }
    
    ll ret = 0;

    for (int i1 = 1; i1 <= m; ++i1)
    {
        for (int i2 = i1; i2 <= m; ++i2)
        {
            for (int i3 = i2; i3 <= m; ++i3)
            {
                for (int i4 = i3; i4 <= m; ++i4)
                {
                    for (int i5 = i4; i5 <= m; ++i5)
                    {
                        for (int i6 = i5; i6 <= m; ++i6)
                        {
                            for (int i7 = i6; i7 <= m; ++i7)
                            {
                                for (int i8 = i7; i8 <= m; ++i8)
                                {
                                    for (int i9 = i8; i9 <= m; ++i9)
                                    {
                                        for (int i10 = i9; i10 <= m; ++i10)
                                        {
                                            ll cur = 0;
                                            vector<ll> aa = {i1, i2, i3, i4, i5, i6, i7, i8, i9, i10};
                                            for (int i = 0; i < q; ++i)
                                            {
                                                if (aa[b[i]] - aa[a[i]] == c[i])
                                                {
                                                    cur += d[i];
                                                }
                                            }
                                            ret = max(ret, cur);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    
    cout << ret << endl;


    return 0;
}

Measured memory_bytes: 3628
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *
 
N = INT()
ab = [LIST() for _ in range(N-1)]
graph = [[] for _ in range(N)]

for a, b in ab:
	graph[a-1].append(b-1)
	graph[b-1].append(a-1)

length = [len(x) for x in graph]
ans = max(length)

color = defaultdict(int)

def coloring(n, previous, col): #頂点nにpreviousから色colで辿ってきた。
	cnt = 1
	for x in graph[n]:
		if x == previous:
			color[(n, x)] = col
			color[(x, n)] = col #やってきた頂点との間における色
		else:
			if cnt == col:
				cnt += 1
			color[(x, n)] = cnt
			color[(n, x)] = cnt
			coloring(x, n, cnt)
			cnt += 1

coloring(0, -1, 0)

print(ans)
for a, b in ab:
	print(color[(a-1, b-1)])

Measured memory_bytes: 95596
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll fc[225816]={1ll},nv[225816]={1ll};

ll rwpw(ll a, ll p = MOD-2){
	ll ret = 1ll;
	while(p){
		if(p%2){
			mul_mod(ret,a);
		}
		mul_mod(a,a);
		p /= 2;
	}
	return ret;
}

ll c(int n, int k){
	ll ret = fc[n];
	mul_mod(ret,nv[k]);
	mul_mod(ret,nv[n-k]);
	return ret;
}

int main(void){
	int n,k,i;
	ll ans=0ll,tmp;
	for(i=1; i<225816; ++i){
		fc[i] = fc[i-1];
		mul_mod(fc[i],i);
		nv[i] = rwpw(fc[i]);
	}
	cin >> n >> k;
	for(i=0; i<=k; ++i){
		if(!(i<n)){
			break;
		}
		tmp = c(n-1,n-i-1);
		mul_mod(tmp,c(n,i));
		add_mod(ans,tmp);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3712
#include <iostream>
using namespace std;
int a[100005];
int main( void )
{
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  for( int i=1; i<=N; i++ ) cin >> a[i];
  int ret = 0;
  for( int i=1; i<=N; i++ ){
    if( a[i] > i && a[a[i]] == i ) ret++;
  }
  cout << ret << endl;
}

Measured memory_bytes: 640
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int[] count = new int[26];
        scanner.next().chars().forEach(c -> count[c - 'A']++);
        System.out.println(count['R' - 'A'] > count['B' - 'A'] ? "Yes" : "No");
    }
}

Measured memory_bytes: 28756
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
	int a;cin>>a;
	cout<<48-a<<endl;
	return 0;
}


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

int main(void) {
  int i, j, k, n, num = 0;
  scanf("%d", &n);
  char c[10];
  for(i = 0; i < n; ++i) {
    scanf("%s", c);
    if(c[0] == 'A') num++;
    else num--;
    if(num < 0) {
      printf("NO\n");
      return 0;
    }
  }
  if(!num) printf("YES\n");
  else printf("NO\n");
  return 0;
}


Measured memory_bytes: 2688
/*▄███████▀▀▀▀▀▀███████▄
░▐████▀▒ЗАПУСКАЕМ▒▀██████▄
░███▀▒▒▒▒▒ДЯДЮ▒▒▒▒▒▒▀█████
░▐██▒▒▒▒▒БОГДАНА▒▒▒▒▒████▌
░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌
░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌
░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌
░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌
░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌
░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█
░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀
░░░░▄█████████████  █▒▒▐▌
░░░▀███▀▀████▀█████▀▒▌
░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐
░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐*/
#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
//#define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)
     
using namespace std;
      
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<ll> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<ll, ll, ll> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<ll> > vvi;
typedef vector<char> vc;
      
const ll INF = 1e9 + 228;
const ll INFLL = 1e18;
const ll MOD = 1e9 + 7;
static const int maxn = 2e5 + 228;;
const ld eps = 1e-7;
const ld eps2 = 1e-9;
const ll MOD2 = 998244353;
const ll dosz = 5e5;
const ll SZ = (1<<18);
const ld PI = atan2l(0, -1);
     
void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef DEBUG
//      freopen("haybales.in", "r", stdin);
//      freopen("haybales.out", "w", stdout);
    #endif
}

int a, b, c, d;
map<int, int> ans;

int calc(int cur){
	if(!cur)
		return 0;
	if(cur==1)
		return d;
	if(ans.count(cur))
		return ans[cur];
	int res = 1e18;
	if(cur < res/d)
		res = cur*d;
	res = min(res, abs((cur/2)*2 - cur)*d + a + calc(cur/2));
	res = min(res, abs(((cur+1)/2)*2 - cur) * d + a + calc((cur+1)/2));
	res = min(res, abs((cur/3)*3 - cur) * d + b + calc((cur)/3));
	res = min(res, abs(((cur+2)/3)*3 - cur) * d + b + calc((cur+2)/3));
	res = min(res, abs((cur/5)*5 - cur)*d + c + calc(cur/5));
	res = min(res, abs(((cur+4)/5)*5 - cur)*d + c + calc((cur+4)/5));
	return ans[cur] = res;
	
}

void solve(){
	int n;
	cin >> n;
	ans.clear();
//	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << calc(n) << endl;
}

signed main(){
        fast_io();
	srand(time(NULL));
//	cout << fixed << setprecision(12);
	int q = 1;
	cin >> q;
	while(q--)
		solve();
     
}





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

int main() {
  int n;
  cin >> n;
  vector<string> S(n);
  map<string, int> counter;
  for (auto& s : S) {
    cin >> s;
    counter[s]++;
  }
  vector<string> temp;
  int max = 0;
  for (auto& c : counter) {
    if (c.second > max) {
      temp.resize(1);
      temp[0] = c.first;
      max = c.second;
    } else if (c.second == max) {
      temp.emplace_back(c.first);
    }
  }
  sort(temp.begin(), temp.end());
  for (auto& t : temp) {
    cout << t << endl;
  }
  return 0;
}


Measured memory_bytes: 28404
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	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)];
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<pair<int, int> > A(N);
	int res = 0;
	map<int, vector<int> > X;
	map<int, vector<int> > Y;
	for (int i = 0; i < N; i++) {
		cin >> A[i].first >> A[i].second;
		X[A[i].first].push_back(i);
		Y[A[i].second].push_back(i);
	}

	UnionFind uf(N);
	for (auto v : X) {
		for (int i = 0; i < (int)v.second.size() - 1; i++) {
			uf.unionSet(v.second[i], v.second[i + 1]);
		}
	}

	for (auto v : Y) {
		for (int i = 0; i < (int)v.second.size() - 1; i++) {
			uf.unionSet(v.second[i], v.second[i + 1]);
		}
	}

	vector<set<int> > xs(N);
	vector<set<int> > ys(N);


	for (int i = 0; i < N; i++) {
		xs[uf.root(i)].insert(A[i].first);
		ys[uf.root(i)].insert(A[i].second);
	}
	res = -N;
	for (int i = 0; i < N; i++) {
		res += xs[i].size() * ys[i].size();
	}

	cout << res << endl;
}

Measured memory_bytes: 28160
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#define rep(i,j,k) for(register int i = j; i <= k; i++) 
#define dow(i,j,k) for(register int i = j; i >= k; i--)
#define fi first
#define se second
#define P pair<int,int>
#define PP pair<int,pair<int,int> >
#define mp(a,b) make_pair(a,b)
#define ll long long
#define ull unsigned long long
using namespace std;

inline int read() { 
	int s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;
}

const int N = 2005, p = 924844033;
inline void _(int &x) { if( x >= p ) x -= p; }
int f[N][N][4], g[N]; ll fac[N] = {1}; bool vis[N], lat[N], pre[N]; 

int main() {
	int n = read(), k = read(), x, ret = 0;
	rep(i,1,k) { 
		x = i, ret++;
		while( x + k <= n ) x += k, ret++; 
		lat[ret] = 1;
		pre[ret+1] = 1;
	}
	f[1][1][2] = 1, f[1][0][0] = 1;
	int f2, f1;
	rep(i,1,n-1) { 
		rep(j,0,i) { 
			rep(k,0,3) { 
				if( !f[i][j][k] ) continue;
				f2 = k & 2, f1 = k & 1; 
				if( !f1 && !pre[i+1] ) { 
					_(f[i+1][j+1][f2>>1] += f[i][j][k]);
				}
				if( !lat[i+1] ) { 
					_(f[i+1][j+1][f2>>1|2] += f[i][j][k]);
				}
				_(f[i+1][j][f2>>1] += f[i][j][k]);
			}
		} 
	}
	rep(i,0,n) { 
		rep(j,0,3) _(g[i] += f[n][i][j]);
	} 
	ll ans = 0;
	rep(i,1,n) fac[i] = fac[i-1] * i % p;
	for(register int i = 0, j = 1; i <= n; i++, j = -j) { 
		(ans += j * g[i] * fac[n-i]) %= p;
	}
	cout<<(ans + p) % p<<endl;
	return 0;
}

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

int main(){
    string str;
    cin>>str;
    string ans="";
    for(int i=0;i<str.length();i++){
        if(ans.length()%2&&str[i]=='Z')
            ans+='Z';
        if(ans.length()%2==0&&str[i]=='A')
            ans+='A';
    }
    if(ans[ans.length()-1]=='A')ans.erase(ans.length()-1);
    if(ans=="")cout<<-1<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 1192
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define MOD 1000000007

int L[300000],R[300000];
int counter = 0;
void merge_F(vector<int> &vec,int n,int left,int mid,int right)
{
  int n1 = mid - left;
  int n2 = right - mid;
  for (int i = 0; i < n1; i++)
  {
    L[i] = vec[left + i];
  }
  for (int i = 0; i < n2; i++)
  {
    R[i] = vec[mid + i];
  }
  L[n1] = I64_MAX;
  R[n2] = I64_MAX;
  int i = 0, j = 0;
  for (int k = left; k < right; k++)
  {
    counter++;
    if(L[i] <= R[j])
    {
      vec[k] = L[i++];
    }
    else
    {
      vec[k] = R[j++];
    }
    
  }
  
  

  return;
}
void mergeSort(vector<int> &vec,int n,int left,int right)
{
  if(left + 1 < right)//ここらへんの挙動わからん
  {
    int mid = (left + right)>>1;
    mergeSort(vec,n,left,mid);
    mergeSort(vec,n,mid,right);
    merge_F(vec,n,left,mid,right);
  }
}
void solve()
{
  int N;
  cin>>N;
  vector<int> vec(N,0);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  mergeSort(vec,N,0,N);

  for (int i = 0; i < N; i++)
  {
    if(i)
    {
      cout<<" ";
    }
    cout<<vec[i];
  }
  cout<<endl;
  cout<<counter<<endl;
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(8);

  solve();

 
  return 0;
}


Measured memory_bytes: 10720
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

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

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

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

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a,vector<vector<ll>> b,int n){
	int i,j,k,t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k]*b[k][j] % M)%M;
			c[i].push_back(t);
		}
	}
	return c;
}
int main() {
	ll n, i, k, a[111111], sum[111111], psum[111111], ans = 0,t=0;
	cin >> n >> k;
	for (i = 1; i <= n; i++)
		cin >> a[i];
	sum[0] = 0;
	psum[0] = 0;
	for (i = 1; i <= n; i++) {
		sum[i] = sum[i - 1] + a[i];
		if (a[i] > 0)
			psum[i] = psum[i - 1] + a[i];
		else
			psum[i] = psum[i - 1];
	}
	for (i = 1; i + k <= n + 1; i++)
		ans = max(ans, max(t,sum[i + k - 1] - sum[i - 1]) + psum[i - 1] + psum[n] - psum[i + k - 1]);
	cout << ans << endl;
}

Measured memory_bytes: 7680
if __name__ == '__main__':
    days = int(input())
    acts = []
    happiness = [[0, 0, 0] for _ in range(days)]
    for day in range(days):
        acts.append(list(map(int, input().split())))

    for day in range(days):
        if day == 0:
            happiness[day] = [acts[0][0], acts[0][1], acts[0][2]]
        else:
            for act in range(3):
                happiness[day][act] = max(happiness[day - 1][(act + 1) % 3] + acts[day][act],
                                          happiness[day - 1][(act + 2) % 3] + acts[day][act])
    print(max(happiness[days - 1]))


Measured memory_bytes: 50360
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int a = reader.nextInt();
		int b = reader.nextInt();

		if (b % a == 0) {
			System.out.print(a+b);
		} else {
			System.out.print(b-a);
		}
	}


}

Measured memory_bytes: 23764
#include<stdio.h>

int main(void){
    int i = 0, j = 0;
    for(i = 0; i < 9; i++){
        for(j = 0; j < 9; j++){
            printf("%dx%d=%d\n",i + 1,j + 1,(i + 1)*(j + 1));
        }
    }
    return 0;
}

Measured memory_bytes: 524
#include <stdio.h>
#include <stdlib.h>

#define int long long
#define datatype int

typedef struct edge_sub{
	int v;
	int w;
	struct edge_sub *next;
}edge;

typedef struct {
	int nearnum;
	edge *near;
}vertex_sub;

typedef struct {
	int num;
	datatype val;
	int parent;
	int pareweight;
	int chilnum;
	int *children;
	int *chilweight;
}vertex;

typedef struct {
	int N;
	int root;
	vertex_sub *v_s;
	vertex *v;
	int *sorted_v;
}tree;

tree *make_tree(int N, int root, datatype val){
	int i;
	tree *t = (tree *)malloc(sizeof(tree));
	t->N = N;
	t->root = root;
	t->v_s = (vertex_sub *)malloc(sizeof(vertex_sub) * N);
	t->v = (vertex *)malloc(sizeof(vertex) * N);
	t->sorted_v = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		(t->v_s)[i].nearnum = 0;
		(t->v_s)[i].near = NULL;
		(t->v)[i].num = i;
		(t->v)[i].val = val;
		(t->v)[i].parent = -1;
		(t->v)[i].pareweight = -1;
		(t->v)[i].chilnum = 0;
		(t->v)[i].children = NULL;
		(t->v)[i].chilweight = NULL;
		(t->sorted_v)[i] = -1;
	}
	return t;
}

void set_edge(tree *t, int a, int b, int w){
	edge *new1 = (edge *)malloc(sizeof(edge));
	new1->v = b;
	new1->w = w;
	new1->next = (t->v_s)[a].near;
	(t->v_s)[a].near = new1;
	(t->v_s)[a].nearnum++;
	edge *new2 = (edge *)malloc(sizeof(edge));
	new2->v = a;
	new2->w = w;
	new2->next = (t->v_s)[b].near;
	(t->v_s)[b].near = new2;
	(t->v_s)[b].nearnum++;
}

void build_tree(tree *t){
	vertex_sub *v_s = t->v_s;
	vertex *v = t->v;
	int *sorted_v = t->sorted_v;
	sorted_v[0] = t->root;
	if(t->N > 1){
		int i, j, nowv;
		edge *nowe;
		for(i = 0, j = 1; j - i > 0; i++){
			nowv = sorted_v[i];
			if(i == 0){
				v_s[nowv].nearnum++;
			}
			v[nowv].children = (int *)malloc(sizeof(int) * (v_s[nowv].nearnum - 1));
			v[nowv].chilweight = (int *)malloc(sizeof(int) * (v_s[nowv].nearnum - 1));
			if(i == 0){
				v_s[nowv].nearnum--;
			}
			for(nowe = v_s[nowv].near; nowe != NULL; nowe = nowe->next){
				if(nowe->v != v[nowv].parent){
					(v[nowv].children)[v[nowv].chilnum] = nowe->v;
					(v[nowv].chilweight)[v[nowv].chilnum] = nowe->w;
					v[nowv].chilnum++;
					v[nowe->v].parent = nowv;
					v[nowe->v].pareweight = nowe->w;
					sorted_v[j] = nowe->v;
					j++;
				}
			}
		}
	}
}

int main(){
	int N, a, b, c, i, j;
	scanf("%lld", &N);
	tree *t = make_tree(N, 0, 0);
	for(i = 1; i < N; i++){
		scanf("%lld%lld%lld", &a, &b, &c);
		set_edge(t, a - 1, b - 1, c);
	}
	int Q, K;
	scanf("%lld%lld", &Q, &K);
	t->root = K - 1;
	build_tree(t);
	for(i = 0; i < N; i++){
		for(j = 0; j < (t->v)[(t->sorted_v)[i]].chilnum; j++){
			(t->v)[((t->v)[(t->sorted_v)[i]].children)[j]].val = ((t->v)[(t->sorted_v)[i]].chilweight)[j] + (t->v)[(t->sorted_v)[i]].val;
		}
	}
	int *x = (int *)malloc(sizeof(int) * Q);
	int *y = (int *)malloc(sizeof(int) * Q);
	for(i = 0; i < Q; i++){
		scanf("%lld%lld", &x[i], &y[i]);
		x[i]--;
		y[i]--;
	}
	for(i = 0; i < Q; i++){
		printf("%lld\n", (t->v)[x[i]].val + (t->v)[y[i]].val);
	}
	return 0;
}

Measured memory_bytes: 24704
#include <iostream>
#include <climits>
#include <string>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int i,j,ans=0;
 
int ascSort(const void* v1, const void* v2) {
    const int _v1 = *((const int*)v1);
    const int _v2 = *((const int*)v2);
 
    if ( _v1 < _v2 ) {
        return 1;
    } else if ( _v1 > _v2 ) {
        return -1;
    } else {
        return 0;
    }
}
int INF = 1<<29;

int main(){
	int n,m,index=INF,x;
	cin>>n>>m;
	int a[50],b[50],c[50],d[50];
	for(i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	for(i=0;i<m;i++){
		cin>>c[i]>>d[i];
	}
	for(i=0;i<n;i++){
		index = INF;
		ans = 0;
		for(j=0;j<m;j++){
			x=abs(a[i]-c[j])+abs(b[i]-d[j]);
			if(x<index){
				index = x;
				ans = j;
			}
		}
		cout << ans+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
 public static void main(String args[]){
  boolean flag=false;
  Scanner scan=new Scanner(System.in);
  String s;

  s=scan.next();
  int a=Integer.parseInt(s);
  s=scan.next();
  int b=Integer.parseInt(s);
  s=scan.next();
  int c=Integer.parseInt(s);

  if(a==b&&b==c){
   if(a%2==0)System.out.println(-1);
   else System.out.println(0);
   return;
  }
  
  int t1,t2,t3,ans=0;
  while(a%2!=1&&b%2!=1&&c%2!=1){
   t1=(c+b)/2;
   t2=(a+c)/2;
   t3=(a+b)/2;
   a=t1;b=t2;c=t3;
   ans++;
  }
  System.out.println(ans);
 }

 ///////////////////////////////////////////////
 public static boolean prime(long a){
  if(a<=1)return false;
  for(int i=2;i*i<=a;i++){
   if(a%i==0)return false;
  }
  return true;
 }
 public static long llpow(long x,long n){
  long ans=1;
  for(int i=0;i<n;i++)ans*=x;
  return ans;
 }
 public static long max(long a,long b){
  if(a<b)return b;
  else return a;
 }
 public static long min(long a,long b){
  if(a>b)return b;
  else return a;
 }
 public static long cei(long x,long y){
  long ans=x/y;
  if(x%y!=0)ans++;
  return ans;
 }
 public static long gcd(long x,long y){
  return (y==1)?gcd(y,x%y):x;
 }
 public static long lcm(long x,long y){
  return x/gcd(x,y)*y;
 }
 public static long fact(long x){
  long ans=1;
  for(int i=0;i<x;i++)ans*=(x-i);
  return ans;
 }
 public static long ncr(long n,long r){
  long ans=1,l=2;
  for(int i=0;i<min(n-r,r);i++){
   ans*=(n-i);
   while(ans%l==0&&l<=min(r,n-r)){
    ans/=l;l++;
   }
  }
  return ans;
 }
 public static long npr(long n,long r){
  long ans=1;
  for(int i=0;i<r;i++)ans*=(n-i);
  return ans; 
 }
 public static long fib(int x){
  long fibo[]=new long[x+10];
  fibo[0]=1;fibo[1]=1;
  for(int i=2;i<x+1;i++)fibo[i]=fibo[i-1]+fibo[i-2];
  return fibo[x];
 }
 public static long dig(long n){
  long d=1,tmp=n;
  while(tmp/10>0){
   tmp/=10;d++;
  }
  return d;}
}



Measured memory_bytes: 35692
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int N)
        {
            int ans = 0;
            for (int i = 1; i <= N; i += 2)
            {
                int cnt = 0;
                for (int j = 1; j <= i; ++j)
                {
                    if (i % j == 0) { ++cnt; }
                }
                if (cnt == 8) { ++ans; }
            }
            return ans;
        }
        static void Main(string[] args)
        {
            Console.WriteLine(Solve(ReadInt()));
        }
    }
}


Measured memory_bytes: 11092
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N,M;
  cin >> N >> M;
  cout << (N-1)*(M-1) << endl;  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 998244353;

int main(void){
  ll n;
  cin >> n;
  ll res = 0LL;
  for(ll i = 1LL;i * i <= n;++i){
    if(n % i == 0){
      ll m = (n / i) - 1;
      if(m > i){
        res += m;
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
a = [input() for _ in range(h)]

mod = 10**9 + 7

dp = [[0] * (w+10) for _ in range(h+10)]

dp[0][0] = 1

for i in range(h):
    for j in range(w):
        if i + 1 < h and a[i+1][j] == ".":
            dp[i+1][j] += dp[i][j]
            dp[i+1][j] %= mod
        if j + 1 < w and a[i][j+1] == ".":
            dp[i][j+1] += dp[i][j]
            dp[i][j+1] %= mod

print(dp[h-1][w-1])

Measured memory_bytes: 53616
n = int(input())
d1 = []
d2 = []
for i in range(n):
	a,b = map(int,input().split())
	d1.append(a)
	d2.append(b)
for i in range(n-2):
	if d1[i] == d2[i]:
		if d1[i+1] == d2[i+1]:
			if d1[i+2] == d2[i+2]:
				print('Yes')
				exit()
			else:
				continue
		else:
			continue
	else:
		continue
print('No')

Measured memory_bytes: 9196
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int S,W;
  cin>>S>>W;
  cout<<(W>=S?"unsafe":"safe")<<endl;
  return 0;
}


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

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

		Scanner cin = new Scanner(System.in);

		int N = cin.nextInt();
		int M = cin.nextInt();
		int road[] = new int[N];
		Arrays.fill(road, 0);
		int tmp1,tmp2;
		for(int i=0;i<M;i++){
			tmp1 = cin.nextInt();
			tmp2 = cin.nextInt();
			road[tmp1-1] += 1;
			road[tmp2-1] += 1;
		}
		cin.close();

		for(int j=0;j<N;j++){
			System.out.println(road[j]);
		}
	}
}


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

long long dp[100010][3];

int main() {
    int n;
    cin >> n;
    vector<long long> a(n),b(n),c(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a.at(i) >> b.at(i) >> c.at(i);
    }
    for (int i = 0; i < 100010; i++) {
        for (int j = 0; j < 3; j++) {
            dp[i][j] = 0;
        }
    }
    dp[0][0] = a.at(0);
    dp[0][1] = b.at(0);
    dp[0][2] = c.at(0);

    for(int i = 1; i < n; i++)
    {
        dp[i][0] = max((dp[i - 1][1] + a.at(i)), (dp[i - 1][2] + a.at(i)));
        dp[i][1] = max((dp[i - 1][0] + b.at(i)), (dp[i - 1][2] + b.at(i)));
        dp[i][2] = max((dp[i - 1][0] + c.at(i)), (dp[i - 1][1] + c.at(i)));
    }
    long long ans = 0;
    for (int i = 0; i < 3; i++) {
        ans = max(ans, dp[n - 1][i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4992