akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  char S[N];
  cin >> S;
  
  int a[26];
  for(int i = 0; i< 26; i++){
    a[i] = 0;
  }
  long sum = 1;
  for(int i = 0; i < N; i++){
    a[S[i] - 'a']++;
  }

  for(int i = 0; i < 26; i++){
    sum *= (1 + a[i]);
    sum %= 1000000007;
  }
  cout << sum - 1;
  return 0;
}

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

int a[4];
bool ans;

int main(){
	scanf("%d%d%d%d", &a[0], &a[1], &a[2], &a[3]);
	sort(a, a+4);
	if(a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) ans = true;
	puts(ans ? "YES" : "NO");
}

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

using namespace std;

typedef long long ll;

int main(){
	ll n,x;
	cin >> n >> x;
	ll left=1;
	for(int i = 0; i < n; i++)left = left*2+3;
	ll ans=0;
	//cout << left << endl;
	left = left/2+1;
	while(1){
		if(x == left){
			ans+=left/2+1;
			break;
		}
		if(x == 1){
			break;
		}
		if(x == left*2-1){
			ans+=left;
			break;
		}
		if(x > left){
			ans+=left/2+1;
			x-=left;
			left = (left-2)/2+1;
		}
		else{
			x--;
			left = (left-2)/2+1;
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  map<string, ll> h;
  rep(i,n){
    string s;
    cin>>s;
    if (h.count(s)) {
      h[s]++;
    }
    else{
      h[s]=1;
    }
  }
  ll cu=0;
  for(auto p:h){
    cu=max(cu,p.S);
  }
  for(auto p:h){
    if(p.S==cu){
      COUT(p.F);
    }
  }
}
  

Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	ull x;
	cin >> x;
	ull cur = 100;
	int ans = 0;
	while(cur < x){
		++ans;
		cur += cur/100;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3612
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int s = sc.nextInt();
    int w = sc.nextInt();
    if(w >= s){
      System.out.println("unsafe");
    }else{
      System.out.println("safe");
    }
  }
}


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

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

    int n,x,t;
    cin>>n>>x>>t;
    int ans=(n/x)*t;
    if(n%x) ans+=t;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3608
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<int,int>
#define maxn 100005
using namespace std;
signed main()
{
    fast;
    
    ll r;
    cin>>r;
    cout<<r*r;
}

Measured memory_bytes: 256
from collections import Counter
from bisect import bisect_right as br
n,a,b = map(int,input().split())
v = list(map(int,input().split()))
count = Counter(v)
v.sort()
c = 0

ans = sum(v[-a:])

def pascla(low):
    list=[[1],[1,1]]
    if low==0 or low==1:
        return list
    while low-len(list):   
        for i in list[-1:]:
            counter = len(i)-1
            locallist = []
            for j in range(counter):
                locallist.append(i[counter-1] + i[counter])
                counter-=1
            locallist.append(1)
            locallist.insert(0,1)
            list.append(locallist)           

    return list

comb = pascla(51)
for i in range(a,b+1):
    if sum(v[-i:])*a == ans*i:
        m = v[-i]
        if count[m] == 1:
            c += 1
        else:
            index = br(v,m)
            c += comb[count[m]][index-(n-i)]
print(ans/a)
print(int(c))


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

int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}


int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    printf("%d",n*m);
}

Measured memory_bytes: 1736
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).
*/

f(0, [], []).
f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

main :-
    get_string(S),
    get_string(T),
    string_chars(S, S2),
    string_chars(T, T2),
    f(X, S2, T2),
    writeln(X).


Measured memory_bytes: 8196
import java.util.Scanner;
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
        try (Scanner scn = new Scanner(System.in)) {
            long h = scn.nextLong();
            long tekicount = 1;
            long total = h;
            while(true){
                if(h == 1){
                 tekicount = tekicount *2;
                    break;
                }
                h = h/2;
                tekicount = tekicount*2;
            }

            total = tekicount - 1 ;

            System.out.println(total);
        }
	}
	
}


Measured memory_bytes: 23252
#include <stdio.h>

int main () {
	int N;
	char str[100];
	scanf("%d", &N);
	scanf("%s", str);
	
	if(N%2==1) {
		printf("No");
		return 0;
	}
	
	for(int i=0;i<N/2;i++){
		if(str[i]==str[i+N/2]){
		continue;
		} else {
			printf("No");
			return 0;
		}
		
	}	
	printf("Yes");

	return 0;
}

Measured memory_bytes: 1716
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = Long.parseLong(sc.next());
        String b = sc.next();
        BigDecimal A = new BigDecimal(a);
        BigDecimal B = new BigDecimal(b);
        BigDecimal c = A.multiply(B);
        System.out.println(c.setScale(0, RoundingMode.DOWN));
    }
}

Measured memory_bytes: 36028
// # ======================================= #
// # Ilham Firdausi Putra, 23 Desember 2017  #
// # ======================================= #
#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
#define nl printf("\n");

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull; 


int main()
{
  ll X,Y, banyak=0;
  cin >> X >> Y;
  ll penambahX = X;
  for (ll i = X; i <= Y; i+=penambahX)
  {
    banyak++;
    if (i!=X)
    {
      penambahX*=2;
    }
  }

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


Measured memory_bytes: 256
def getlist():
	return list(map(int, input().split()))

N, K = getlist()
A = getlist()

x = 0
for i in range(N):
	for j in range(i + 1, N):
		if A[i] > A[j]:
			x += 1

s = 0
for i in range(N):
	for j in range(N):
		if i != j:
			if A[i] > A[j]:
				s += 1

ans1x = int(((K - 1) * K) // 2) % 1000000007
ans1 = ans1x * s % 1000000007
ans2 = K * x % 1000000007
print((ans1 + ans2) % 1000000007)

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

int main() {
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n) {
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  bool ex=false;
  rep(i,n){
    if(a[i]!=0){
      ex=true;
    }
  }
  if(!ex){
    cout<<"Yes"<<endl;
  }
  else{
    if(n%3!=0){
      cout<<"No"<<endl;
    }
    else{
      rep(i,3){
        rep(j,n/3){
          if(a[n/3*i+j]!=a[n/3*i]){
            ex=false;
          }
        }
      }
      if(ex){
        if((a[0]^a[n/3])!=a[n/3*2]){
          ex=false;
        }
      }
      if(ex){
        cout<<"Yes"<<endl;
      }
      else{
        cout<<"No"<<endl;
      }
    }
  }
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;
  ll a[n],b[n];
  memset(b,0,sizeof(b));
  for(ll i=0;i<n;i++) cin>>a[i],b[a[i]]++;
  ll ans=1LL,mod=1000000007;
  if(n%2){
    if(b[0]!=1) ans*=0;
    for(ll i=2;i<n;i+=2) if(b[i]==2) ans=(ans*2)%mod;else ans=0;
  }else{
    for(ll i=1;i<n;i+=2) if(b[i]==2) ans=(ans*2)%mod;else ans=0;
  }
  cout << ans%mod << endl;
  return 0;
}


Measured memory_bytes: 1792
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

A, B, H, M = In.ints()

hourstep = 360 / 12
minutestep = 360 / 60

hourX = 0
hourY = A

minuteX = 0
minuteY = B

hourX = hourY * sin(radians(hourstep*H) + radians(hourstep*(M/60)))
hourY = hourY * cos(radians(hourstep*H)+ radians(hourstep*(M/60)) )


minuteX = minuteY * sin(radians(minutestep*M))
minuteY = minuteY * cos(radians(minutestep*M))

res = sqrt((hourX-minuteX)**2+(hourY-minuteY)**2)
print(res)
    

######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Measured memory_bytes: 68604
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int a[3];
int main(){
    rep(i,3) cin >> a[i];
    sort(a,a+3);
    int sum = 0;
    rep(i,2) sum += a[i+1]-a[i];
    cout << sum << endl;
}

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

int main() {
	string sen;
	cin  >> sen;
	int count = 0;
	for (int i = 0; i < sen.size(); i++) {
		if (sen[i] == 'p')count--;
	}
	count += (sen.size()) / 2;
	printf("%d", count);
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////


int n,m;
const int MAX_N = 8;
vector<vector<bool>> v(MAX_N,vector<bool>(MAX_N,0));
int ans=0;

bool check(vector<bool> &c){
	bool f = true;
	rep(i,0,n)
		if(!c[i])
			f = false;

	ret f;
}

void solve( int now , vector<bool> c){
	if(check(c)){	
		ans++;
		ret;
	}
	
	rep(i,0,n){
		if(v[now][i]){
			if( !c[i] ){
				vector<bool> tmp = c;
				tmp[i] = 1;
				solve( i , tmp );
			}
		}
	}
	
	ret;
}

int main(){
	
	cin >> n >> m;
	rep(i,0,m){
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		v[a][b] = 1;
		v[b][a] = 1;
	}
	
	vector<bool> tmp(n,0);
	tmp[0]=1;
	solve(0,tmp);
	P(ans);
	ret 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int N[4];
	int one=0,seven=0,nine=0,four=0;
	int i;
	
	scanf("%d %d %d %d",&N[0],&N[1],&N[2],&N[3]);
	
	for(i=0;i<4;i++){
		if(N[i]==1)	one++;
		if(N[i]==9)	nine++;
		if(N[i]==7)	seven++;
		if(N[i]==4)	four++;
	}
	
	if(one==1 && nine==1 && seven==1 && four==1)	printf("YES");
	else	printf("NO");
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	string S;cin>>S;
	int a=0,b=0;
	for(int i=0;i<S.size();i++){
		if(S.at(i)=='0'){
			a++;
		}else{
			b++;
		}
	}cout<<2*min(a,b)<<endl;
}

Measured memory_bytes: 512
#include <iostream>

int main(void){
  	int Array[5];
	int min = 10;
  	int j = 0;
  	for(int i = 0; i < 5; ++i){
    	std::cin >> Array[i];
      	if(min > Array[i]%10 && Array[i]%10 != 0){
			j = i;
            min = Array[j]%10;
        }
    }
  
  	int count = 0;
  	for(int i = 0; i < 5; ++i){
    	if(i == j) count += Array[i];
      	else {
            int amari = Array[i]%10;
            amari == 0 ? count += Array[i] : count += Array[i] + 10 - amari;
        }
    }
  	
  	std::cout << count << std::endl;
  	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define INF 2147483647
using namespace std;
using Graph=vector<vector<int>>;

int main(){
  string s,t=""; cin>>s;
  ll n=s.length(),ans=0,cons=0;
  rep(i,n){
    if(i<n-1 && s[i]=='B' && s[i+1]=='C'){
      t=t+"D";
      i++;
    }else{
      t=t+s.substr(i,1);
    }
  }
  rep(i,t.length()){
    if(t[i]=='A'){
      cons++;
    }else if(t[i]=='D'){
      ans+=cons;
    }else{
      cons=0;
    }
  }
  cout<<ans;
}


Measured memory_bytes: 1292
/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#ifdef LOCAL
#include "debug.h"
#else
#include<bits/stdc++.h>
using namespace std;
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> 
using ordered_set= tree<T, null_type, 
		less<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
template<class T> 		
using ordered_mset= tree<T, null_type, 
		less_equal<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
		
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

void solve()
{
	int n;
	cin>>n;
	ll d;
	cin>>d;
	
	d*=d;
	
	int ans=0;
	
	for(int i=0;i<n;i++)
	{
		ll x,y;
		cin>>x>>y;
		
		x*=x;
		y*=y;
		
		if(x+y<=d) ans++;
	}
	
	cout<<ans;
}		

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int t=1;
	//cin>>t;
	
	for(int i=1;i<=t;i++)
	{
		//cout<<"Case "<<i<<": ";
		solve();
	}
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

long long N;
vector<int> A;

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

	cin >> N;
	for(int i=1; i<=N; i++){
		long long a;
		cin >> a;
		A.push_back(a);
	}
	long long ans = 0, v = 1, c = 0;
	int lastfound = 0;
	for(int i=0; i<A.size(); i++){
		c++;
		if(A[i] == v){
			lastfound = i + 1;
			ans += (c - 1);
			v++;
			c = 0;
		}
	}
	if(lastfound == 0){
		printf("-1\n");
		return 0;
	}
	if(lastfound != N){
		ans += (N - lastfound);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4248
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<deque>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<string>
#include<vector>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
typedef long long ll;

using namespace std;

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

	int N;
	int a[101] = { 0 };
	cin >> N;
	int ans = 0;
	REP(i, N) {
		cin >> a[i];
		if (a[i] % 2 == 1 && (i + 1) % 2 == 1)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3644
# _*_ coding:utf-8 _*_
#  Atcoder_Beginning_Contest057-C
#  TODO https://atcoder.jp/contests/abc057/tasks/abc057_c
import math,sys

def F(A,B):
	strA = str(A)
	strB = str(B)
	return len(strB) if len(strA) <= len(strB) else  len(strA)


def solveProblem(givenNumber):
	maxTimes = int(math.sqrt(givenNumber))
	maxInteger = sys.maxsize
	for x1 in range(1,maxTimes+1,+1):
		# TODO 余りと商をdivmodで求める。もし余りが0であれば上の関数Fで求める。最小値を出す。
		x2 , modX1 = divmod(givenNumber,x1)
		if modX1 == 0:
			x2int = int(x2)
			maxLength=F(x1,x2int)
			maxInteger = maxLength if maxLength <= maxInteger else maxInteger
	answer = maxInteger
	return answer


if __name__ == '__main__':
	N = int(input().strip())
	solution = solveProblem(N)
	print("{}".format(solution))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#ifdef JLOCAL
#include "stress.h"
#endif
using namespace std;

#define rep(i, z, n) for (int i = (z); i < int(n); ++i)
#define repr(i, n, z) for (int i = int(n) - 1; i >= (z); --i)
#define shl(n) (1 << (n))
#define hbit(n, i) (((n) >> (i)) & 1)

#define STRESS 0
using lint = long long;

int a[3];

void solve(istream& cin, ostream& cout) {
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    if (a[0] == a[1]) {
        cout << a[2];
    } else {
        cout << a[0];
    }
}

int main() {
#if !defined(JLOCAL) || !STRESS
#ifdef JLOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve(cin, cout);
#else
    srand();
    for (int ti = 0; ti < 100; ti++) {
        stress::gen();
        stress::stupid();
        ifstream in("input.txt");
        ofstream out("output.txt");
        solve(in, out);
        out.flush();
        stress::check();
    }
    cout << "ok" << endl;
#endif
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong x, y;

int main() {
    cin >> x >> y;

    llong ans = 0;
    while (x <= y) {
        x *= 2;
        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,c=0;
  cin>>N;
  vector<int> s(N);
  for(int i=0;i<N;i++){
    cin>>s[i];
    c+=s[i];
  }
  bool f=false;
  
  sort(s.begin(),s.end());
  for(int i=0;i<N;i++){
    if(c%10!=0){
      f=true;
      break;
 
    }
    if(s[i]%10 == 0) continue;
    else{
      c-=s[i];
      f=true;
    }
  }
  if(f) cout<<c<<endl;
  else cout<<0<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <sstream>

using namespace std;

string expand(string const& value, char ch) {
	stringstream s;
	for (size_t i = 0; i < value.size(); ) {
		auto pos = value.find(ch, i);
		auto substr = value.substr(i, pos - i);
		s << substr;
		if (pos == string::npos) {
			break;
		}
		s << "ABC";
		i = pos + 1;
	}
	return s.str();
}

bool dfs(string const& value) {
	if (value == "ABC") {
		return true;
	}

	for (char ch = 'A'; ch <= 'C'; ch++) {
		stringstream s;
		bool done = false;
		for (size_t i = 0; i < value.size(); ) {
			auto pos = value.find("ABC", i);
			auto substr = value.substr(i, pos - i);
			s << substr;
			if (pos == string::npos) {
				break;
			}
			done = true;
			s << ch;
			i = pos + 3;
		}
		auto prev = s.str();
		if (done && expand(prev, ch) == value && dfs(prev)) {
			return true;
		}
	}

	return false;
}

int main() {
	string line;
	cin >> line;
	if (dfs(line)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 33240
#include <stdio.h>
#define PI 3.14159265358979323846

int main(void);

int main(void){
    
    double r, S, C;
    
    scanf("%lf", &r);
    
    S = r * r * PI;
    C = 2 * r * PI;
    
    printf("%lf %lf", S, C);
    
    return 0;
}


Measured memory_bytes: 2036
N = int(input())
A = input().split()
A = [int(i) for i in A]

total = 0
amax = A[0]

for i in range(N-1):
  if A[i+1] < amax:
    total = total + (amax - A[i+1])
  if A[i+1] > amax:
    amax = A[i+1]

print(total)



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

int main(){
  ll n, k;
  cin >> n >> k;
  cout << min(n % k, k - (n % k)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long H,W,M;
    cin>>H>>W>>M;
    long long h[M],w[M];
    set<pair<long long,long long>>m;
    vector<long long> a(H,0);
    vector<long long> b(W,0);
    for(int i=0;i<M;i++){
        cin>>h[i]>>w[i];
        m.insert({h[i],w[i]});
        a[h[i]-1]++;
        b[w[i]-1]++;
    }
    vector<long long> c=a;
    vector<long long> d=b;
    sort(c.begin(), c.end());
    sort(d.begin(), d.end());
    long long maxa=c[H-1],maxb=d[W-1];
    vector<long long> e;
    vector<long long> f;
    for(int i=0;i<H;i++){
        if(a[i]==maxa){
            e.push_back(i);
        }
    }
    for(int i=0;i<W;i++){
        if(b[i]==maxb){
            f.push_back(i);
        }
    }
    long long ans=maxa+maxb-1;
    for(int i=0;i<e.size();i++){
        for(int j=0;j<f.size();j++){
            if(m.find({e[i]+1,f[j]+1}) == m.end()){
                ans=maxa+maxb;
                break;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

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


Measured memory_bytes: 384
/* To Kaise Hain Aaplog*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) (x).begin(), (x).end()

void shuru_krte_hai_bina_kisi_bakchodi_ke()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
const ll m = 998244353;

const ll s = 1e6 + 2;
ll a[s];

int main()
{
    //shuru_krte_hai_bina_kisi_bakchodi_ke();

/* long long yaad se daal de har jagah*/
#define int long long

    int mark = 1e18;
    int prod = 1;
    int n;
    cin >> n;
    int a[n];
    int z = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] == 0)
        {
            z++;
        }
    }
    if (z)
    {
        cout << 0;
        return 0;
    }
    for (int i = 0; i < n; i++)
    {
        if (a[i] <= mark / prod)
        {
            prod *= a[i];
        }
        else
        {
            cout<<-1;
            return 0;
        }
    }
    cout << prod;
    return 0;
}

Measured memory_bytes: 4404
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  if(s[k-1] == 'A'){
    s[k - 1] = 'a';
  }else if(s[k-1] == 'B'){
    s[k - 1] = 'b';
  }else{
    s[k - 1] = 'c';
  }
  cout << s << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10,mod=1e9+7;

int n,m,t[N],f[2][3],ans;

inline void ad(int &x,int y){x+=y;if(x>=mod) x-=mod;}

struct mat{
	int a[3][3];
	mat(){memset(a,0,sizeof(a));}
	inline void ori()
	{
		for(int j,i=0;i<3;++i)
		 for(j=0;j<3;++j)
		  a[i][j]=(i==j);
	}
	mat operator *(const mat & ky){
		mat R;int i,j,k,v;
		for(i=0;i<3;++i)
		 for(j=0;j<3;++j){
           for(v=k=0;k<3;++k) 
		     ad(v,(ll)a[k][j]*ky.a[i][k]%mod);
		   R.a[i][j]=v;
		 }
		return R;
	}
}A,B,C,re;

inline mat fp(mat x,int y)
{
	re.ori();
	for(;y;y>>=1,x=x*x)
	 if(y&1) re=re*x;
	return re;
}

int main(){
	int i,j;
    B.a[0][1]=B.a[0][2]=B.a[1][1]=A.a[0][0]=1;
	B.a[1][0]=B.a[0][0]=C.a[1][0]=2;
	for(i=0;i<3;++i) B.a[2][i]=C.a[2][i]=1;
	C.a[0][0]=C.a[1][1]=1;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;++i) scanf("%d",&t[i]);
	t[++m]=n;
	for(i=1;i<=m;++i){
		A=A*fp(B,t[i]-t[i-1]-1);
		A=A*C;
	}
	printf("%d",A.a[2][0]);
	return 0;
}

Measured memory_bytes: 640
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;

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

const int N = 1024;
void solve(){
	int n = rint;
	int[] ls = rint(n);
	
	long[N] lc;
	foreach(l; ls) lc[l] += 1;
	
	long ans;
	foreach(a; 0 .. N){
		foreach(b; a + 1 .. N){
			long m = lc[a] * lc[b];
			foreach(c; b + 1 .. N){
				if(a + b <= c) break;
				long x = m * lc[c];
				if(x > 0) log("a:", a, "b:", b, "c:", c, "x:", x);
				ans += x;
			}
		}
	}
	foreach(a; 0 .. N){
		int b = a;
		long m = lc[a] * (lc[b] - 1) / 2;
		foreach(c; b + 1 .. N){
			if(a + b <= c) break;
			long x = m * lc[c];
			if(x > 0) log("a:", a, "b:", b, "c:", c, "x:", x);
			ans += x;
		}
	}
	foreach(a; 0 .. N){
		foreach(b; a + 1 .. N){
			int c = b;
			long x = lc[a] * lc[b] * (lc[c] - 1) / 2;
			if(x > 0) log("a:", a, "b:", b, "c:", c, "x:", x);
			ans += x;
		}
	}
	foreach(a; 0 .. N){
		int b = a, c = b;
		long x = lc[a] * (lc[b] - 1) * (lc[c] - 2) / 6;
		if(x > 0) log("a:", a, "b:", b, "c:", c, "x:", x);
		ans += x;
	}
	
	ans.writeln;
	
}


Measured memory_bytes: 380
length = int(input())
eles = [int(i) for i in input().split()]

for i in range(length):
    val = eles[i]
    j = i - 1
    while j >= 0 and eles[j] > val:
        eles[j+1] = eles[j]
        j -= 1
    eles[j+1] = val
    print(*eles)

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

ll dp[101][100001] = {0};

ll helper(vector<int>& w, vector<int>& v, int index, int capacity) {
    if (dp[index][capacity] != 0) return dp[index][capacity];
    if (index == w.size()) return 0;
    if (capacity < w[index]) return helper(w, v, index + 1, capacity);
    ll notSelected = helper(w, v, index + 1, capacity);
    ll selected = helper(w, v, index + 1, capacity - w[index]) + v[index];
    dp[index][capacity] = max(notSelected, selected);
    return dp[index][capacity];
}

int main() {
    int n, capacity;
    cin >> n >> capacity;
    vector<int> w(n);
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> w[i] >> v[i];
    cout << helper(w, v, 0, capacity) << endl;
    return 0;
}

Measured memory_bytes: 76288
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val s = in.readLine
  val set = s.toSet
  val ans = if(set.size == 2 &&
   s.count(_ == set.head) == 2 &&
   s.count(_ == set.last) == 2) "Yes" else "No"

  println(ans)
}

Measured memory_bytes: 25532
K, A, B = [int(v) for v in input().split()]

if A + 2 >= B:
    print(K + 1)
elif K - 1 < A:
    print(K + 1)
else:
    ans = 1
    remained_op = K
    ans += A - 1
    remained_op -= A - 1
    if remained_op % 2 == 1:
        ans += 1
        remained_op -= 1
    ans += (remained_op // 2) * (B - A)
    print(ans)


Measured memory_bytes: 3060
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        if (s.length() < t.length()) {
            System.out.println("UNRESTORABLE");
        } else {
            int amari = s.length() - t.length();
            int clear = -1;
            for (int i = amari; i >= 0; i--) {
                boolean bre = false;
                for (int j = 0; j < t.length(); j++) {
                    if (s.charAt(j + i) != t.charAt(j) && s.charAt(j + i) != '?') {
                        bre = true;
                        break;
                    }
                }
                if (!bre) {
                    clear = i;
                    break;
                }
            }
            if (clear == -1) {
                System.out.println("UNRESTORABLE");
            } else {
                s = s.substring(0, clear) + t + s.substring(clear + t.length());
                s = s.replace('?', 'a');
                System.out.println(s);
            }
        }
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N;
  cin>>N;
  VI A(N);
  rep(i,N) cin>>A[i];
  sort(all(A));
  ll ans=A[N-1]/2;
  rep(i,N-1) ans+=A[i];
  cout<<ans<<endl;
}


Measured memory_bytes: 256
fun main(args:Array<String>):Unit{
    val abc = readLine()!!.split(' ').map(String::toInt)
    val k = readLine()!!.toInt()
    println(abc.sum() + abc.max()!! * exp(2, k) - abc.max()!!)
}
fun exp(base:Int, e:Int):Int{
    return when(e){
        0 -> 1
        1 -> base
        else -> exp(base, e / 2).let{it * it * exp(base, e % 2)}
    }
}

Measured memory_bytes: 38184
#include<cstdio>
#include<vector>
#include<string>
#include<iostream>
#include<iomanip>
#include<algorithm>

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N, tmpV;
  double RES=0.0;
  vector<int> V;
  
  cin>>N;
  cin.ignore(); //改行読み飛ばし
  for(int i=0;i<N;i++){
    cin>>tmpV;
    V.push_back(tmpV);
  }
  sort(V.begin(), V.end());
  
  RES=(double)V[0];
  for(int i=1;i<N;i++){
    RES=(RES+V[i])/2.0;
  }
  
  cout<<fixed<<setprecision(8)<<RES<<"\n";
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T>
vector<T> make_v(size_t size, const T& init){ return vector<T>(size, init); }

template<class... Ts>
auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }


int main() {
    int n, m, d;
    cin >> n >> m >> d;
    auto v = make_v(n, m, 0);
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < m; ++j) {
            v[i][j] = (s[j] == '.');
        }
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int k = 0;
        for (int j = 0; j < m; ++j) {
            if(v[i][j]) k++;
            else k = 0;
            if(k >= d) ans++;
        }
    }
    for (int i = 0; i < m; ++i) {
        int k = 0;
        for (int j = 0; j < n; ++j) {
            if(v[j][i]) k++;
            else k = 0;
            if(k >= d) ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3180
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;
using i64=long long int;

int main() {
    int N; cin >> N;
    vector<int> L(2 * N);

    for (auto &e: L) cin >> e;

    sort(L.begin(), L.end());
    
    int ans = 0;
    for (int i = 0; i < 2 * N; i += 2) {
        ans += L[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define I 700000
int x[99],z[99],y[99][20],h[99],a,b,c,d,e,f,i,j,k;string S;
main(){
while(true){
for(i=0;i<99;i++){x[i]=I;h[i]=0;}
memset(y,0,sizeof(y));
cin>>a>>b>>c;
if(!a){break;}
for(i=0;i<c;i++){
cin>>d>>e>>f>>S;
if(S[0]=='W'){
y[d][e]++;
}
else{
x[d]+=I;
x[d]-=f+1200*y[d][e];
}
}
for(i=1;i<=a;i++){z[i]=x[i];}
sort(x+1,x+a+1);
for(i=a;i>0;i--){
for(j=1;j<=a;j++){
if(z[j]==x[i]&&!h[j]){
printf("%d %d %d\n",j,(x[i]+I-1)/I-1,(99*I-x[i])%I);
h[j]=1;
}
}
}
}
}

Measured memory_bytes: 1224
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Y = sc.nextInt();
        int x = 0;
        int y = 0;
        int z = 0;

        int a = -1;
        int b = -1;
        int c = -1;

        for (x = 0; x <= N; x++) {
            for (y = 0; y <= N - x; y++) {
                if (10000 * x + 5000 * y + 1000 * (N - x - y) == Y) {
                    a = x;
                    b = y;
                    c = N - x - y;
                }
            }
        }

        System.out.println(a + " " + b + " " + c);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int t1, t2; cin >> t1 >> t2;
  ll a1, a2, b1, b2; cin >> a1 >> a2 >> b1 >> b2;
  ll d1 = a1-b1, d2 = a2-b2;
  if(d1<0) {
    swap(a1, b1);
    swap(a2, b2);
    d1 *= -1;
    d2 *= -1;
  }
  if(d1*t1+d2*t2==0) cout << "infinity" << endk;
  else if(d1*t1+d2*t2>0) cout << 0 << endk;
  else {
    ll dd = abs(d1*t1+d2*t2);
    ll n = ((d1*t1)+dd-1)/dd;
    ll cnt = n*2-1;
    if(dd*n==d1*t1) cnt++;
    cout << cnt << endk;
  }
  return 0;
}


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

int main(){
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if(s[0]==s[1] && s[1]!=s[2] && s[2]==s[3]){
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

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

int main(){
    vector<int> ss(5);
    for(int i = 0; i < 5; i++){
        cin >> ss[i];
        if(ss[i] == 0){
            cout << i+1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define REP(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;

map<int, int> map_compare(map<int, int> a, map<int, int> b){

    int a_size = 0;
    for(int i=9; i>=1; --i){
        a_size+=a[i];
    }

    int b_size = 0;
    for(int i=9; i>=1; --i){
        b_size+=b[i];
    }

    if(a_size > b_size){
        return a;
    } else if (b_size > a_size){
        return b;
    } else {
        for(int i=9; i>=1; --i){
            if(b[i] > a[i]) return b;
            else if (a[i] > b[i]) return a;
        }
    }

    return a;
}

string s(map<int, int> d){
    string str = "";

    for(int i=9; i>=1; --i){
        for(int j=0; j<d[i]; j++){
            str += to_string(i);
        }
    }

    return str;
}


int main(){
    std::ios_base::sync_with_stdio(false);

    int n,m; cin >> n >> m;
    std::vector<int> a(m); REP(i,m) cin >> a[i];
    std::vector<int> cost;

    cost.push_back(2);
    cost.push_back(5);
    cost.push_back(5);
    cost.push_back(4);
    cost.push_back(5);
    cost.push_back(6);
    cost.push_back(3);
    cost.push_back(7);
    cost.push_back(6);

    map<int, int> dp[10001];

    dp[0] = map<int, int>();

    std::vector<bool> dp_can_use(10001, false);
    dp_can_use[n] = true;

    for(int i=n; i>0; --i){

        //cout << "i: " << i << endl;

        if(!dp_can_use[i]) continue;

        REP(j,m){


            int c = cost[a[j]-1];

            if(i-c >= 0){

                //cout << a[j] << " " << c << endl;

                map<int, int> temp = dp[i];
                temp[a[j]]++;
                dp[i-c] = map_compare(dp[i-c], temp);
                dp_can_use[i-c] = true;
            }

        }

        //cout << '\n';

    }


    cout << s(dp[0]) << endl;


    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN
    ll n; cin>>n;
    cout<< n+ power(n,2) + power(n,3)<<endl;

    return 0;
}


Measured memory_bytes: 3648
#include<cctype>
#include<string>
#include<algorithm>
#include<iostream>
#include<set>
#include<regex>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<map>
#include<functional>
#include<unordered_map>
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    long long n;
    cin >> n;
    vector<long long> a(100001,1);
    for(long long i = 0; i < n; ++i) {
        cin >> a.at(i);
        if(a.at(i) == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    long long x = 1;
    for(long long i = 0; i < n; ++i) {
        
        if(a[i]<=1000000000000000000/x) {
            x*=a[i];
        }
        else{
            cout<<-1<<endl;
            return 0;
        } 
    }
    cout << (uli)x << endl;//*/
}

Measured memory_bytes: 3956
//
// Created by yamunaku on 2020/05/30.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 10000000000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    //CFS;
    int n;
    cin >> n;
    n++;
    vl a(n);
    rep(i, n) cin >> a[i];
    if(n == 1){
        if(a[0] == 1) cout << 1 << endl;
        else cout << -1 << endl;
        return 0;
    }
    ll kosu = 1;
    vl nokori(n);
    rep(i, n){
        if(kosu < a[i]){
            cout << -1 << endl;
            return 0;
        }
        kosu -= a[i];
        nokori[i] = kosu;
        kosu *= 2;
        if(kosu > IINF) kosu = IINF;
    }
    ll ans = 0;
    ll k = 0;
    perl(i, 1, n){
        ans += a[i];
        k += a[i];
        k = min(nokori[i - 1], k);
//        cout << a[i] SP nokori[i - 1] SP k << endl;
        ans += k;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4796
#include<iostream>
#include<cstring>
using namespace std;
char a[1000000],b[1000000];
int lena;
int main()
{
	cin>>a;
	lena=strlen(a);
	for(int i=lena-1;i>=0;i--)b[lena-i-1]=a[i];
	for(int i=0;i<lena;i++)
	{
		if(b[i]=='q')b[i]='p';
		else if(b[i]=='p')b[i]='q';
		if(b[i]=='b')b[i]='d';
		else if(b[i]=='d')b[i]='b';
	}
	for(int i=0;i<lena;i++)
	if(b[i]!=a[i])
	{
		cout<<"No";
		return 0;
	}
	cout<<"Yes";
}

Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().solve(new Scanner(System.in));
	}
	
	public void solve(Scanner sc) {
		int x1 = Integer.parseInt(sc.next());
		int y1 = Integer.parseInt(sc.next());
		int x2 = Integer.parseInt(sc.next());
		int y2 = Integer.parseInt(sc.next());
		
		int dx = x1 - x2;
		int dy = y1 - y2;
		
		int x3, x4, y3, y4;
		x3 = x2 + dy;
		y3 = y2 - dx;
		x4 = x1 + dy;
		y4 = y1 - dx;
		System.out.println(x3 + " " + y3 + " " + x4 + " " + y4);
	}
}


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

struct unionfind{
    vector<int> parent;
    vector<int> rank;
    vector<int> size;

    unionfind (int N) {
        parent = vector<int>(N);
        iota(parent.begin(), parent.end(), 0);
        rank = vector<int>(N, 0);
        size = vector<int>(N, 1);
    }
    int root(int x) {
        if (parent[x] == x) return x;
        parent[x] = root(parent[x]);
        return parent[x];
    }
    
    bool same(int x, int y){
        return root(x) == root(y);
    }
    
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] > rank[y]) {
            parent[y] = x;
            size[x] += size[y];
        }
        else {
            parent[x] = y;
            size[y] += size[x];
            if (rank[x] == rank[y]) rank[y] += 1;
        }
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    unionfind tree(N);
    vector<pair<int, int>> edge;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        edge.push_back({a-1, b-1});
    }
    
    ll cnt = (ll)N * (N-1) / 2;
    vector<ll> inconv(M);
    for (int i = M-1; i >= 0; i--) {
        inconv[i] = cnt;
        ll x = edge[i].first;
        ll y = edge[i].second;
        if (!tree.same(x, y)) {
            cnt -= tree.size[tree.root(x)] * tree.size[tree.root(y)];
            tree.unite(x, y);
        }
    }
    for (int i = 0; i < M; i++) cout << inconv[i] << "\n";
}

Measured memory_bytes: 4212
#include<iostream>
#include<algorithm>
#include<vector>
#include <iomanip>

using namespace std;

int main(){

	int a, b;
  	string op;
  	
    while(a>-1){
  		cin >> a >> op >> b;
      	if(op== "+"){
        	cout << a+b << endl;
        }
      	else if(op== "-"){
        	cout << a-b << endl;
        }
      	else if(op== "*"){
        	cout << a*b << endl;
        }
      	else if(op== "/"){
        	cout << a/b << endl;
        }
      	else break;
    }
  	

  
    return 0;
}


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

int main(){
    string S;
    cin>>S;
    long long K;
    cin>>K;
    for(int i=0;i<S.size();i++){
        if(S[i]=='1'){
            if(i+1>=K){
                cout<<1<<endl;
                break;
            }
        }else{
            cout<<S[i]<<endl;
            break;
        }
    }
}


Measured memory_bytes: 256