akhauriyash/Code-Regression huggingface dataset:
#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;

#define MAX 200002
long long MOD = 1000000007;
long long MODPOW2[MAX] = {0};

void initModPow2(){
	MODPOW2[0] = 1;
	for(int i=1; i<MAX; i++){
		MODPOW2[i] = (MODPOW2[i-1]*2)%MOD;
	}
}

long long GCD(long long x, long long y){
        long long r=0;
        if( x<y ) swap(x, y);
        r = x % y;
        while(r!=0){
                x = y;
                y = r;
                r = x % y;
        }
        return y;
}

// U(u個)とV(v個)が直交しているとき、どの2つも内積が0にならない選び方の数
// 余事象で考えて、2**(u+v)から内積が0になりうる選び方の数を引く
long long countUV(long long u, long long v){
	long long a=0, b=0, c=0, ret=0;
	a = MODPOW2[u+v] % MOD;
	b = (MODPOW2[u] - 1) % MOD;
	b = (b*(MODPOW2[v] - 1)) % MOD;
	ret = (a - b) % MOD;
	if(ret<0) ret += MOD;
	return ret;
}

class Tilt{
public:
	long long x;
	long long y;
	Tilt(){x = 0, y = 0;}
	Tilt(long long x, long long y){
		if(x == 0){
			this->x = 0; this->y = 1;
		}
		else if(y == 0){
			this->x = 1; this->y = 0;
		}
		else{
			long p, a, b;
			p = GCD(x, y);
			a = x / p; b = y / p;
			if(a > 0){
				this->x = a; this->y = b;
			}
			else{
				this->x = 0 - a; this->y = 0 - b;
			}
		}
	}
	inline bool operator==(const Tilt &t) const{
		if(x == t.x && y == t.y){
			return true;
		}
		else{
			return false;
		}
	}
	inline bool operator!=(const Tilt &t) const{
		return !(this->operator==(t)) ;
	}
};

//ハッシュ関数定義
class MyHash {
public:
	std::size_t operator() (const Tilt& t) const {
		return (std::size_t) abs(t.x);
	}
};

unordered_map<Tilt, long long, MyHash> m1;

int main(int argc, char* argv[]){
	int N, M;
	long long zero = 0;

	cin >> N;
	m1.reserve(N);

	initModPow2();
	long long ans=1; 
	for(int i=1; i<=N; i++){
		long long a, b;
		cin >> a >> b;

		if(a == 0 && b == 0){
			zero++;
			continue; //(0, 0)は除外するが、数えておく
		}
		Tilt t =Tilt(a, b);
		if(m1.count(t)==0){
			m1[t] = 1;
		}
		else{
			long long v = m1[t];
			m1[t] = v+1;
		}
	}
	for(auto itr = m1.begin(); itr != m1.end(); itr++){
		long long x, y, u, v;
		Tilt t = itr->first;
		if(m1[t] == -1){
			continue;
		}
		u = itr->second;
		if(u == -1) continue;
		x = t.x;
		y = t.y;
		Tilt w = Tilt(0 - y, x); //法線ベクトル
		auto tmpitr2 = m1.find(w);
		if( tmpitr2 != m1.end()){
			v = m1[w];
			m1[w] = -1;
		}
		else{
			v = 0;
		}
		long long uvcnt = countUV(u, v);
		ans = (ans * uvcnt) % MOD;
		m1[t] = -1;
	}
	ans = ans + (zero % MOD) -1 ; //(0, 0)は他のどの要素とも直交するので足す。まったく選ばないを引く。
	ans = ans % MOD;
	if(ans < 0) ans += MOD;
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 15504
H, W, M = map(int, input().split())
targets = [list(map(int, input().split())) for _ in range(M)]
x_counter = [0 for _ in range(W + 1)]
y_counter = [0 for _ in range(H + 1)]
y_index = []
x_index = []
check = 0

for i in range(M):
    x, y = targets[i]
    y_counter[x] += 1
    x_counter[y] += 1

y_max, x_max = max(y_counter), max(x_counter)

for i in range(H + 1):
    if y_counter[i] == y_max:
        y_index.append(i)

for j in range(W + 1):
    if x_counter[j] == x_max:
        x_index.append(j)

y_index = set(y_index)
x_index = set(x_index)

check = len(y_index) * len(x_index)
for k in range(M):
    r, c = targets[k]
    if r in y_index and c in x_index:
        check -= 1

print(y_max + x_max if check > 0 else y_max + x_max -1)


Measured memory_bytes: 112896
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<ll(n); i++)

int main(){
    int N;
    int i, j;
    int flag_1 = 0;
    int flag_2 = 0;
    int ai, bi;
    cin >> N;
    for(i=0;i<N;i++){
        cin >> ai >> bi;
        if(ai == bi){flag_1 += 1;}
        else{flag_1 = 0;}
        if(flag_1 == 3){flag_2 = 1;}
    }
    if(flag_2 == 1){cout << "Yes" << endl;return 0;}
    else{cout << "No" << endl;}

    return 0;
}


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

typedef vector<int, int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long int ll;

int n, m, t, ans;
string s;
int main() {
	cin >> s;
	ans = 0;
	for(auto e: s) {
		if(e == '1') ans++;
	}
	cout << ans << endl;
	return 0;
}

// v[v.size()-1].first

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<long, long> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
const double EPS=1e-10;

LL fc(vector<LL>&B,LL num){
    LL res=0;
    REP(i,SZ(B))res+=num^B[i];
    return res;
}
int main(){
    int N,M;
    cin>>N>>M;
    if(N/2+N%2>=M){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#define llint long long
#define inf 1e18

using namespace std;
typedef pair<llint, llint> P;

llint n, k, s;
llint a[100005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k >> s;
	
	if(s < 1000000000) {
		for(int i = 1; i <= n; i++){
			if(i <= k) a[i] = s;
			else a[i] = 1000000000;
		}
	}
	else{
		for(int i = 1; i <= n; i++){
			if(i <= k) a[i] = s;
			else a[i] = 1;
		}
	}
	
	for(int i = 1; i <= n; i++) cout << a[i] << " "; cout << endl;
	
	return 0;
}

Measured memory_bytes: 2176
def solve():
    A, B = map(int,input().split())
    A_res = func(max(A-1,0))
    B_res = func(B)
    ans = 0
    two_factor = 1
    for i in range(60):
        if not A_res[i] == B_res[i]:
            ans += two_factor
        two_factor *= 2
    
    print(ans)

def func(N):
    res = [0] * 60
    for i in range(60):
        if i == 0 and not (N % 4 == 0 or N % 4 == 3):
            res[i] = 1
        elif N & (1<<i):
            if (N+1) % 2 != 0:
                res[i] = 1

    return res

if __name__ == '__main__':
    solve()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 1e5 + 5;
const ll LINF = 1e18 + 5;
constexpr int mod = 1e9 + 7;
int d, a[N];
char s[N];
ll dp[N][105]; 
ll dfs(int pos,int limit, int state) 
{
	if(pos==-1) return state==0;
	if(!limit&&dp[pos][state]!=-1) return dp[pos][state];
	int up = limit ? a[pos] : 9;
	ll ans = 0;
	for(int i=0;i<=up;i++)
	{
		ans = (ans + dfs(pos-1,limit&&i==a[pos], (state+i)%d))%mod;
	}
	if(!limit) dp[pos][state] = ans;
	return ans;	
}
ll solve() 
{
	memset(dp, -1, sizeof(dp));
	int pos = strlen(s);
	reverse(s, s+pos);
	for(int i=0; i<pos; i++) a[i] = s[i] - '0';
	return (dfs(pos-1, 1, 0)-1+mod)%mod;
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> s >> d;
 	cout << solve();
	return 0;
}


Measured memory_bytes: 83072
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define pb push_back
#define pii pair<int,int>
#define SZ(x) (int)x.size()
#ifdef __linux__
#define getchar getchar_unlocked
#endif
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int inf=0x3f3f3f3f;
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<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int len,a[20],ans;
LL x;
int main()
{
	file();
	read(x);
	while(x){a[++len]=x%10;x/=10;}
	reverse(a+1,a+len+1);
	int ret=0;
	For(i,1,len)
	{
		if(a[i]!=0)chkmax(ans,ret+a[i]-1+(len-i)*9);
		ret+=a[i];
	}
	chkmax(ans,ret);
	printf("%d\n",ans);
	return 0;
}


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

string FILENAME = "filename";
#define io ifstream fin(FILENAME + ".in"); ofstream fout(FILENAME + ".out")
#define fwrite(X) fout << X;
#define fwriteln(X) fout << X << endl;

#define forl(V, N) for(int V = 0; V < N; V++)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
#define rem(X) X.top(); X.pop()
#define setmin(A, B) A = min(A, B)
#define setmax(A, B) A = max(A, B)
#define graph unordered_map<int, unordered_set<int>>
#define vi vector<int>
#define pb push_back
#define ll long long

int amount[4];
double prob[305][305][305];

int main() {
    int N;
    cin >> N;
    forl(i, N) {
        int sushi;
        cin >> sushi;
        amount[sushi]++;
    }
    for(int three = 0; three < 305; three++) {
        for(int two = 0; two < 305; two++) {
            for(int one = 0; one < 305; one++) {
                if(three+two+one == 0) continue;
                double tev = (double)N / (three + two + one);
                if(three) {
                    prob[three][two][one] += ((double)three / (three + two + one)) * prob[three-1][two+1][one];
                }
                if(two) {
                    prob[three][two][one] += ((double)two / (three + two + one)) * prob[three][two-1][one+1 ];
                }
                if(one) {
                    prob[three][two][one] += ((double)one / (three + two + one)) * prob[three][two][one-1];
                }
                prob[three][two][one] += tev;
            }
        }
    }
    cout << setprecision(20) << prob[amount[3]][amount[2]][amount[1]] << endl;
}

Measured memory_bytes: 221952
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(long long A, long long B){
    lint res = A + B;
    if (res >= 10) {
        cout << "error" << endl;
    } else {
        cout << res << endl;
    }

}

int main(){

    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}



Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let today: String = read();

    let mut tommorow = String::new();

    if today == "Sunny" {
        tommorow = "Cloudy".to_string();
    } else if today == "Cloudy" {
        tommorow = "Rainy".to_string();
    } else if today == "Rainy" {
        tommorow = "Sunny".to_string();
    }

    println!("{}", tommorow);
}

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

int main() {
  int N;
  cin >> N;
  double sum = 0;
  for (int i=0; i<N; i++){
    int a;
    cin >> a;
    sum += 1.0/a;
  }
  double ans = 1/sum;
  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import Counter

def prime_factor(n):
    res = Counter()
    for i in range(2, int(n**.5) + 1):
        while n % i == 0:
            res[i] += 1
            n //= i
    if n != 1:
        res[n] += 1
    return res

N = int(input())

C = Counter()
for x in range(1, N + 1):
    C += prime_factor(x)

res = [C[k] for k in sorted(C)]
cnt = 0

# 5 * 5 * 3
for i in range(len(res)):
    if res[i] < 2:
        continue
    for j in range(len(res)):
        if j == i or res[j] < 4:
            continue
        for k in range(j + 1, len(res)):
            if k == i or res[k] < 4:
                continue
            cnt += 1
# 25 * 3
for i in range(len(res)):
    if res[i] < 24:
        continue
    for j in range(len(res)):
        if i == j or res[j] < 2:
            continue
        cnt += 1
# 15 * 5
for i in range(len(res)):
    if res[i] < 14:
        continue
    for j in range(len(res)):
        if i == j or res[j] < 4:
            continue
        cnt += 1
# 75
for i in range(len(res)):
    if res[i] < 74:
        continue
    cnt += 1

print(cnt)

Measured memory_bytes: 3444
#include <stdio.h>
int main()
{
	int num, r, i;
	char alfa[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
	
	char s[10000];
	for(r = 0; r < 10000; r++){
		s[r] = 'u';
	}
	
	scanf("%d", &num);
	scanf("%s", s);
	
	for(r = 0; r < 10000; r++){
		for(i = 0; i < 26; i++){
			if(s[r] == alfa[i]){
				if(i <= 25 - num){
					printf("%c", alfa[i+num]);
				}else{
					printf("%c", alfa[i+num-26]);
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
n = input()
k = int(input())
l = len(n)

def k2(l, n):
    ans = 81 * (l - 1) * (l - 2) // 2
    ans += (int(n[0]) - 1) * 9 * (l - 1)
    for i, s in enumerate(n[1:]):
        if s == "0":
            continue
        ans += int(s)
        ans += max((l - i - 2), 0) * 9
        break
    return ans

if k == 1:
    ans = (l - 1) * 9 + int(n[0])
elif k == 2:
    if l == 1:
        print(0)
        exit()
    ans = k2(l, n)
else:
    if l < 3:
        print(0)
        exit()
    ans = 9 ** 3 * (l - 1) * (l - 2) * (l - 3) // 6
    ans += (int(n[0]) - 1) * 81 * (l - 1) * (l - 2) // 2
    n = n[1:]
    n = str(int(n))
    ans += k2(len(n), n)
print(ans)

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

int main()
{
  long long n;
  double sum = 0;
  cin >> n;

  for (int i = 0; i < n; i++) {
    double x;
    string u;
    cin >> x >> u;
    if (u == "JPY") sum += (float)x;
    else if (u == "BTC") sum += (x * 380000.0);
  }

  cout << (double)sum << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Hello
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        int[] a = new int[n];

        var s = Console.ReadLine().Split();

        for (int i = 0; i < n; i++)
        {
            a[i] = int.Parse(s[i]);
        }
        int a_min = a.Min();
        int a_max = a.Max();

        Console.WriteLine(a_max - a_min);


    }
}

Measured memory_bytes: 13268
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,sum=0; cin>>n;
    vector<vector<int>> path(n);
    vector<int> ans(n,0),c(n,0);
    rep(i,n-1){
        int a,b; cin>>a>>b;
        a--; b--;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    rep(i,n){
        cin>>c[i];
        sum+=c[i];
    }
    sort(al(c)); reverse(al(c));
    sum-=c[0];
    int cnt=0;
    queue<int> que;
    que.push(0);
    while(!(que.empty())){
        int s=que.front();
        que.pop();
        ans[s]=c[cnt]; 
        cnt++;
        for(auto to:path[s]){
            if(ans[to]==0) que.push(to);
        }
    }
    cout<<sum<<endl;
    rep(i,n-1) cout<<ans[i]<<" ";
    cout<<ans[n-1]<<endl;
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    vector<pair<ll, ll>> xy[N];
    REP(i, N)
    {
        cin >> A[i];
        REP(j, A[i])
        {
            ll x, y;
            cin >> x >> y;
            x--;
            xy[i].push_back(make_pair(x, y));
        }
    }

    ll ans = 0;
    for (ll i = 1; i <= (1 << N) - 1; ++i)
    {
        bool flag = true;
        vector<bool> isHonest(N, false);
        ll countHonest = 0;
        REP(j, N)
        {
            if ((i >> j) & 1 == 1)
            {
                isHonest[j] = true;
                countHonest++;
            }
        }
        REP(j, N)
        {
            if (isHonest[j])
            {
                REP(k, A[j])
                {
                    ll x, y;
                    x = xy[j][k].first;
                    y = xy[j][k].second;
                    if (y == 0)
                    {
                        if (isHonest[x])
                        {
                            flag = false;
                            break;
                        }
                    }
                    else
                    {
                        if (!isHonest[x])
                        {
                            flag = false;
                            break;
                        }
                    }
                    
                }
            }
            if (!flag) break;
        }
        if (flag) ans = max(ans, countHonest);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
N=input()
I=list(map(int,input().split()))
E=list(filter(lambda x:x%2==0,I))
if len(E)==0:
    print('APPROVED')
else:
    O=list(filter(lambda r:r%3!=0 and r%5!=0,E))
    if len(O)==0:
        print('APPROVED')
    else:
        print('DENIED')

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

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi std::vector<int>
#define vvi std::vector<std::vector<int> >
#define vpi std::vector<pi >
#define pi std::pair<int,int>
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (int var = (from); var <= ((int)(to)); var++)
#define DOWNTO(var, from, to) for (int var = (from); var >= ((int)(to)); var--)
#define FOR(var, to)		  UPTO(var, 0, (to)-1)
#define DOWN(var, from)	   DOWNTO(var, (from)-1, 0)

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static const int MOD = 1000000007;
static const int INF = ((1<<30)-1);
static const s64 LINF = ((1LL << 62)-1);

struct Comb {
	std::vector<std::vector<s64> > a;
	Comb(int n) { // O(n^2)
		a.resize(n+1);
		FOR(i,n+1) {
			a[i].resize(i+1, 1);
			UPTO(j,1,i-1) a[i][j] = a[i-1][j] + a[i-1][j];
		}
	}
	s64 ncr(int n, int r) {
		assert(n >= 0);
		assert(n <= (int)a.size());
		assert(r >= 0);
		assert(r <= n);
		return a[n][r];
	}
};

#define gc(c) (c)=getchar()
int ri() {
	int c,s=0,r=0;
	for(;;){gc(c);if(c=='-'){s=1;break;}if(c>='0'&&c<='9'){r=c-'0';break;}}
	for(;;){gc(c);if(c<'0'||c>'9')break;r*=10;r+=c-'0';}
	if(s)r=-r;
	return r;
}
s64 rs64() {
	s64 r;
	int c,s;
	for(;;){gc(c);if(c=='-'){s=1;break;}if(c>='0'&&c<='9'){r=c-'0';break;}}
	for(;;){gc(c);if(c<'0'||c>'9')break;r*=10;r+=c-'0';}
	if(s)r=-r;
	return r;
}

int int_less(const void *a, const void *b) {
	return (*(const int*)a - *(const int*)b);
}
int int_greater(const void *a, const void *b) {
	return (*(const int*)b - *(const int*)a);
}
std::string operator*(const std::string &s, int n){ std::string res; FOR(i,n) res += s; return res; }

template<class T> std::ostream& operator<<(std::ostream& os, std::vector<T> a) { for (auto i : a) os << i << " "; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, std::set<T> a) { for (auto i : a) os << i << " "; return os; }
template<class A, class B> std::ostream& operator<<(std::ostream&os, std::pair<A,B> a) { os << a.fi << "," << a.se; return os; }


int main() {
	s64 n;std::cin>>n;
	s64 min = LINF;
	FOR(i,5) {
		s64 a;
		std::cin >> a;
		min = std::min(min, a);
	}
	
	std::cout << 5 + (n - 1) / min << std::endl;
	
	return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	nextReader = newScanner()
	h := nextInt()
	fmt.Println(int(math.Pow(2, 1+math.Floor(math.Log2(float64(h)))) - 1))
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;

int main(){
    ll n, a, b; cin >> n >> a >> b;
    vector<ll> x(n);
    for(int i = 0; i < n; ++i){
    	cin >> x[i];
    }
    ll ans = 0;
    for(int i = 1; i < n; ++i){
    	  ans += min( (x[i] - x[i-1])*a, b);
    }

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

Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int main(){
	long long a,b;
	scanf("%lld%lld",&a,&b);
	a=min(a,b/2);
	long long ret=0;
	ret+=a;
	b-=a*2;
	ret+=b/4;
	printf("%lld\n",ret);
}

Measured memory_bytes: 128
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),* $(,)*) => {
        #[cfg(debug_assertions)]
        eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
    };
}

fn main() {
    input! {
        n: usize,
        d: [(usize, usize); n],
    }
    for i in 2..n {
        if (0..3).all(|j| d[i - j].0 == d[i - j].1) {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 2152
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)){
            while(true){
                int x,y;
                x = sc.nextInt();
                y = sc.nextInt();
                if(x == 0 && y == 0){
                    break;
                }
                if(x > y){
                    System.out.println(y + " " + x);
                }else{
                    System.out.println(x + " " + y);
                }
            }
        }
    }
}


Measured memory_bytes: 34924
ans = 0
n = gets.to_i
(1..9).each do |m|
  [?3,?5,?7].repeated_permutation(m).each do |a|
    s = a*''
    next unless s =~ /3/
    next unless s =~ /5/
    next unless s =~ /7/
    next if s.to_i > n
    ans += 1
  end
end
p ans

Measured memory_bytes: 2044
class UnionFind:
    def __init__(self, size):
        #非負なら親ノード，負ならグループの要素数
        self.parent = [-1 for i in range(size)]

    def root(self, x): # xの根ノードを返す．
        if self.parent[x] < 0: return x
        else:
            self.parent[x] = self.root(self.parent[x]) # xをxの根に直接つなぐ
            return self.parent[x]

    def union(self, x, y): # xのいるグループと$y$のいるグループをまとめる
        x = self.root(x)
        y = self.root(y)
        if x == y: return False
        if self.size(x) < self.size(y): x, y = y, x
        self.parent[x] += self.parent[y] # xの要素数を更新
        self.parent[y] = x  # yをxにつなぐ
        return True

    def same(self, x, y): # xとyが同じグループにあるならTrue
        return self.root(x) == self.root(y)

    def size(self,x): # xのいるグループの要素数を返す
        return - self.parent[self.root(x)]

def solve():
    N, M = map(int, input().split())
    bridges = [[int(i) - 1 for i in input().split()] for i in range(M)]
    ans = [N * (N - 1) // 2]

    uf = UnionFind(N)
    for bridge in reversed(bridges):
        A, B = bridge
        if uf.same(A, B):
            ans.append(ans[-1])
        else:
            ans.append(ans[-1] - uf.size(A) * uf.size(B))
            uf.union(A, B)
    ans.pop(-1)
    return '\n'.join(map(str, reversed(ans)))

print(solve())


Measured memory_bytes: 34272
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())

    res = 0

    for i in range(1,N):
        res += (N-1) // i

    print(res)



main()


Measured memory_bytes: 9152
#include<iostream>
#include<string>
using namespace std;
 
int main(void)
{
	string s;
	cin >> s;

	for ( int i = 0; i < s.size()-1; ++i ) {
      	for(int j = 1; j < s.size() - i; ++j ) {
    		if ( s[i] == s[i+j] ) {
        		cout << "no" << endl;
          		return 0;
        	}
        }
    }
  	cout<< "yes" <<endl;
  	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int loop = 1, n;
  for(int i=0;i<10;i++) loop *= 3;

  cin >> n;

  set<ll> ss;
  int p[3] = {7, 5, 3};
  
  for(int i=0;i<loop;i++){
    int t = i;
    ll num = 0;

    int use[3] = {};
    
    for(int j=0;j<10;j++){
      num = num * 10 + p[t%3];
      use[t%3] = true;
      if(n >= num && use[0] && use[1] && use[2]) ss.insert(num);
      t/=3;
    }
  }
  
  cout << ss.size() << endl;
  
  return 0;
}




Measured memory_bytes: 1536
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int sum=a+b,ans=b+c,num=c+a;
    int temp;
    if(sum<ans)
    {
        temp=sum;
        sum=ans;
        ans=temp;
    }
    if(num<ans)
    {
        temp=num;
        num=ans;
        ans=temp;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 128
#include <cstddef>
#include <cstdint>
#include <vector>

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

template <typename T>
std::vector<T> make_v(usize a) { return std::vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(usize a, Ts... ts) {
  return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename std::enable_if<std::is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename std ::enable_if<std::is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

template <typename T, typename V>
inline void chmin(T &a, V b) {
  if (a > b) a = b;
}
template <typename T, typename V>
inline void chmax(T &a, V b) {
  if (a < b) a = b;
}

} // namespace null_null

#include <algorithm>
#include <iostream>
#include <utility>

namespace null_null {

void main_() {
  usize N, K;
  std::cin >> N >> K;

  std::vector<std::pair<i64, i64>> v;
  for (usize i = 0; i < N; i++) {
    u64 w, d;
    std::cin >> w >> d;
    v.push_back({w, d});
  }

  i64 ok = 2 * 1e18, ng = 0;
  while (abs(ok - ng) / 2) {
    i64 mid = (ok + ng) / 2;

    auto C = [&](i64 mid) {
      i64 sum = 0;
      for (usize i = 0; i < N; i++) {
        sum += std::max(static_cast<i64>(0), (mid - v[i].first + v[i].second - 1) / v[i].second);
      }

      if (sum >= K) {
        return true;
      } else {
        return false;
      }
    };

    if (C(mid)) {
      ok = mid;
    } else {
      ng = mid;
    }
  }

  std::cout << ng << std::endl;
}

} // namespace null_null

int main() {
  null_null::main_();
  return 0;
}


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

int main() {
	string a,b;
	cin >> a >> b;
	int ans = 0;
	for (int i=0; i<(int)a.size(); i++) {
		ans += a[i] != b[i];
	}
	cout << ans << '\n';
	return 0;
}


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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    string s;
    cin >> s;

    int mx=0,cc=0;

    FOR(i,0,(int)s.sz()){
        if(s[i]=='A' || s[i]=='T' || s[i]=='G' || s[i]=='C'){
            cc++;
        }else{
            mx=max(mx,cc);
            cc=0;
        }
    }
    mx=max(mx,cc);

    cout << mx << endl;

    return 0;
}


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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;

int main(){
    int N;
    lint A[10000];

    lint count=0;
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];

    for(int i=0;i<N;i++){
        while(A[i]%2==0){
            A[i]>>=1;
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    double r; cin >> r;
    cout << 2 * r * 3.14159265358979 << endl;
}


Measured memory_bytes: 3772
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int MAX =1e5+6;
const long long inf=1e18;
const int mod=1e9+7;
vector<int>adj[MAX];

int main(){
    long long n;
    cin>>n;
    long long ans=inf;
    for(long long i=1;i*i<=n;i++){
        if(n%i==0){
            //cout<<i<<"\n";
            ans=min(ans, abs(i-(long long)1)+abs(n/i-(long long)1));
        }
    }
    cout<<ans;
}

Measured memory_bytes: 2688
#include<stdio.h>
#define N 100000
#define Q 50000

int main(){
  int i,n,q,Sawa[N],Hira[Q],f=0,a,b,c;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&Sawa[i]);
  }
  
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&Hira[i]);
  }
  for(i=0;i<q;i++){
    a=0;
    b=n;
    while(a<b){
      c=(a+b)/2;
      if(Hira[i]==Sawa[c]){
    f++;
    break;
      }
      if(Hira[i]>Sawa[c])
    a=c+1;
      else if(Hira[i]<Sawa[c])
    b=c;
    }
  }
  printf("%d\n",f);
    
    
  return 0;
}

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

int main() {
	int n;
	string s,a,b;
	cin>>n;
	cin>>s;
	
	if(n%2==0){
		a=s.substr(0,n/2);
		b=s.substr(n/2,n/2);
		if(a==b){
			cout<<"Yes"<<endl;
		}else cout<<"No"<<endl;
		
	}else{
		cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
N, Ma, Mb = map(int, input().split())
D = []
atotal, btotal = 0, 0
for i in range(N):
    a, b, c = map(int, input().split())
    D.append((a, b, c))
    atotal += a
    btotal += b
Inf = 10**4

def DP(i, a, b, memo = {}):
    if i == 0 and a == b == 0:
        return 0
    elif i == 0:
        return Inf
    try:
        return memo[(i, a, b)]
    except KeyError:
        if a - D[i-1][0] >= 0 and b - D[i-1][1] >= 0:
            ret = min(DP(i-1, a, b, memo), DP(i-1, a-D[i-1][0], b-D[i-1][1], memo) + D[i-1][2])
        else:
            ret = DP(i-1, a, b, memo)
        memo[(i, a, b)] = ret
        return ret

memo = {}
ans = Inf
for a in range(1, atotal+1):
    for b in range(1, btotal+1):
        if a*Mb == b*Ma:
            ans = min(ans, DP(N, a, b, memo))

print(ans if ans < Inf else -1)


Measured memory_bytes: 65972
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
	int a, b, c;
	int K;
	cin >> a >> b >> c;
	cin >> K;
	int ma = max(max(a, b), c);
	cout << a + b + c - ma + ma * pow(2, K) << endl;
	//system("pause");
}

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


//powMod
ll powMod(ll k, ll n, ll mod) {
    ll x = 1;
    while (n > 0) {
        if (n & 1) {
            x = x * k % mod;
        }
        k = k * k % mod;
        n >>= 1;
    }
    return x;
}

int main() {
    constexpr int MOD = 2019;
    string s; cin >> s;
    vector<int> a(2019, 0);
    a[0]++;
    ll sum = 0;
    for (int i = s.size() - 1; i >= 0; i--) {
        sum += (s[i] - '0') * powMod(10, s.size() - 1 - i, MOD);
        sum %= MOD;
        a[sum]++;
    }
    ll ans = 0;
    for (int i = 0; i < 2019; i++) {
        ans += (ll)a[i] * (a[i] - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin >> n;
  vl a(n);
  vll x(20, vl(20));
  vll y(20, vl(20));
  rep(i,n){
    cin >> a[i];
    rep(j,a[i]){
      cin >> x[i][j] >> y[i][j];
    }
  }
  ll max = 0;
  for (int tmp = 0; tmp < (1 << n); tmp++){
    bitset<15> s(tmp);
    bool OK = true;
    ll count = 0;
    rep(i,n){
      if (s[i]){
        rep(j,a[i]){
          if(y[i][j]!=s[x[i][j]-1]){
            OK = false;
          }
        }
        count++;
      }
    }
    if(OK){
      chmax(max, count);
    }
  }
  print(max);
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
  ll x;
  cin>>x;
  ll n=1;
  while(true){
    if(n*(n+1)/2>=abs(x))break;
    else n++; 
  }
  if(abs(x)== n*(n+1)/2-3)n++;
  cout<<n;
  return 0;
}

Measured memory_bytes: 256
import sys

cnt = 0
g = []

def insertion_sort(a, n, g):
    global cnt
    
    for i in range(g, n):
        v = a[i]
        j = i - g

        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j -= g
            cnt += 1

        a[j+g] = v

def shell_sort(a, n):
    global g

    h = 1
    while True:
        if h > n:
            break

        g.append(h)
        h = h * 3 + 1

    for i in range(len(g)-1, -1, -1):
        insertion_sort(a, n, g[i])
    
def main():
    n = int(sys.stdin.readline().strip())
    a = []

    for i in range(n):
        a.append(int(sys.stdin.readline().strip()))

    shell_sort(a, n)

    print(len(g))

    for i in range(len(g)-1, -1, -1):
        print(g[i], end='')
        if i:
            print(' ', end='')

    print('')
    print(cnt)

    for i in range(n):
        print(a[i])

if __name__ == '__main__':
    main()

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

int main(){
	int n,count=0;
	bool kondisi=false;
	cin>>n;
	while(n--){
		int d1,d2;
		cin>>d1>>d2;
		if(d1==d2) count++;
		else count=0;
		if(count==3) kondisi=true;
	}
	if(kondisi) cout<<"Yes\n";
	else cout<<"No\n";
	
	
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
int main(){

    int N;
    scanf("%d", &N);

    float v[N];
    for(int i=0; i<N; i++){
        scanf("%f", &v[i]);

    }

    int swap;

    bool isEnd = false;
        while (!isEnd)
        {
            bool loopSwap = false;
            for (int i = 0; i<N-1; i++)
            {
                if (v[i] > v[i + 1])
                {
                    swap = v[i];
                    v[i] = v[i+1];
                    v[i+1] = swap;
                    loopSwap = true;
                }
            }
            if (!loopSwap) // Swapが一度も実行されなかった場合はソート終了
            {
                isEnd = true;
            }
        }

    // for(int i=0; i<N; i++){
    //     printf("%f", v[i]);
    // }

    float sum = (v[0] + v[1])/2;
    for(int i=2; i<N; i++){
        sum = (sum + v[i])/2;
    }
    printf("%f", sum);


    return 0;
}


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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<Int> A(N), B(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i] >> B[i];
	}

	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	auto tapu = [&](Int x) -> pair<Int, Int> {
		return { A[x - 1], B[x - 1] };
	};

	Int ans = 0;
	if (N % 2) {
		auto p = tapu((N + 1) / 2);
		ans = p.second - p.first + 1;
	} else {
		auto p1 = tapu(N / 2);
		auto p2 = tapu(N / 2 + 1);
		ans = (p2.second + p1.second) - (p2.first + p1.first) + 1;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6432
import bisect
N = int(input())
L = [int(i) for i in input().split()]
L.sort()
ans = 0

for i in range(N):
  for j in range(i+1,N):    
    A = L[i]+L[j]
    tmp = bisect.bisect_left(L,A)
    ans += tmp-j-1
print(ans)

Measured memory_bytes: 3188
n = list(input())
op = len(n) - 1
total = 0
for i in range(2 ** op):
    op_l = [''] * op
    for j in range(op):
        if (i >> j) & 1:
            op_l[j] = '+'
    
    formula = '' 
    for s, k in zip(n, op_l + ['']):
        formula += s + k
    
    total += eval(formula)
print(total)

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

ll solve() {
    ll A, B;
    cin >> A >> B;
    if ( A + B == 15 ) cout << "+";
    else if ( A * B == 15 ) cout << "*";
    else cout << "x";
    cout << "\n";
    return 0;
}

int main() {
    solve();
    return 0;
}

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

int main(){
    int n;
    string s;
    cin>>n>>s;
    ll ans=0;
    for(int i=0;i<1000;i++){
        ostringstream ss;
        ss << setw(3) << setfill('0')<<i<<endl;
        string p(ss.str());
        int cnt=0;
        for(int j=0;j<n;j++){
            if(p[cnt]==s[j]){
                cnt++;
                if(cnt==3){
                    ans++;
                    break;
                }
            }
        }
    }
    cout<<ans<<endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)

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

  int k, x; cin >> k >> x;
  for(int i = max(x-(k-1), -1000000); i <= min(x+(k-1), 1000000); i++) {
    cout << i << " ";
  }
  cout << '\n';
  return 0;
}


Measured memory_bytes: 256
//   __      __       .__           .____________                   __________        __ ________   __                 
//  /  \    /  \ ____ |_________  __| _\______   \__ __  ____  _____\______   \__ ___/  |\_____  \ |  | ______  ___.__.
//  \   \/\/   _/ __ \|  \_  __ \/ __ | |    |  _|  |  \/ ___\/  ___/|    |  _|  |  \   __/   |   \|  |/ \__  \<   |  |
//   \        /\  ___/|  ||  | \/ /_/ | |    |   |  |  / /_/  \___ \ |    |   |  |  /|  |/    |    |    < / __ \\___  |
//    \__/\  /  \___  |__||__|  \____ | |______  |____/\___  /____  >|______  |____/ |__|\_______  |__|_ (____  / ____|
//         \/       \/               \/        \/     /_____/     \/        \/                   \/     \/    \/\/     

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second

using namespace std;

void solve()
{
    ll lim = 100000;
    ll x;
    cin >> x;
    for(ll b = -118; b < 120; b++)
        for(ll a = b + 1; a < 120; a++)
        {
            ll t1 = a * a * a * a * a - b * b * b * b * b;
            if(t1 == x)
            {
                cout << a << " " << b << endl;
                return;
            }
        }
}

int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int q = 1;
	//cin >> q;
	for(int i = 1; i <= q; i++)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3608
a,b,c = map(int,input().split())

if a % 2 == 0 or b % 2 == 0 or c % 2 == 0:
    print(0)
else:
    l = [a,b,c]
    l.sort()
    print(l[0] * l[1] * (l[2] // 2 + 1) - l[0] * l[1] * (l[2] // 2))

Measured memory_bytes: 3060
import sys

for i in sys.stdin:
    h,w = map(int,i.strip().split())

    if h==0 and w==0:
        break

    for i in range(h):
        str = ''
        for j in range(w):
            if (i+j) % 2 == 0:
                str += '#'
            else:
                str += '.'
        print(str)
    print()

Measured memory_bytes: 7560
N = int(input())
D,X = map(int,input().split())
A = []
for n in range(N):
    A.append(int(input()))

sum = 0
for n in range(N):    #ここで人数
    sum += 1
    for d in range(1,D+1):#ここで日数
        result = A[n] * d + 1
        if result <= D:
            sum += 1

sum = X + sum

print(sum)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() { 
	int h, m, s; 
	cin >> s; 

	h = s / 3600; s %= 3600;
	m = s / 60; s  %= 60;

	cout << h << ":" << m << ":" << s << endl;

	return 0;
}

Measured memory_bytes: 3100
MAX_N = 50
MAX_DAY = 30

def solve(n, f):
    dp = [{i} for i in range(n)]

    for d in range(1, MAX_DAY + 1):
        for i in range(n):
            for j in range(n):
                if f[d][i] and f[d][j]:
                    dp[i] |= dp[j]

            if len(dp[i]) == n:
                return d

    return -1

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

while True:
    n = int(input())
    if n == 0:
        exit()

    f = [[False] * n for i in range(MAX_DAY + 1)]
    for i in range(n):
        _, *li = map(int, input().split())
        for x in li:
            f[x][i] = True

    print(solve(n, f))

Measured memory_bytes: 7976
import java.util.*;
public class Main {

    public static void main(String[] args)
    {
        Scanner in=new Scanner(System.in);
        int n = in.nextInt();
        int[] ans = new int[10050];

        for (int i = 1; i < 105; i++) {
           for (int j= 1; j < 105; j++) {
               for (int k = 1; k < 105; k++) {
                   int v = i*i+j*j+k*k+i*j+j*k+k*i;
                   if (v<10050)
                       ans[v]+=1;
        }
        }
        }
        for (int i = 0; i < n; i++) {
            System.out.println(ans[i+1]);
        }
    }
}


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

dic = dict()
for i in A:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] =1
dic_sort = sorted(dic.items(), key = lambda x: x[1])

ans = 0
for i in range(len(dic_sort)-K):
    ans += dic_sort[i][1]

print (ans)


# print (dic_sort)

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

int N;
string S;
bool isSheep[100100];

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

    std::cin >> N;
    string S;
    std::cin >> S;
    S += S[0];

    for(int i=0;i<2;++i){
        for(int j=0;j<2;++j){
            isSheep[0] = i;
            isSheep[1] = j;
            
            for(int k=1;k<N+1;++k){
                if(isSheep[k]){ // sheep
                    isSheep[k+1] = S[k] == 'o' ? isSheep[k-1] : !isSheep[k-1];
                }else{ // wolf
                    isSheep[k+1] = S[k] == 'x' ? isSheep[k-1] : !isSheep[k-1];
                }
            }

            // for(int k=0;k<N+1;++k){
            //     std::cout << isSheep[k] << std::endl;
            // }
            // std::cout << "----------" << std::endl;
            
            if(isSheep[0] == isSheep[N] && isSheep[1] == isSheep[N+1]){
                for(int k=0;k<N;++k){
                    std::cout << (isSheep[k] ? "S" : "W");
                }
                std::cout << std::endl;
                return 0;
            }
        }
    }

    std::cout << -1 << std::endl;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
int main() {
	int l,r;
	cin>>l>>r;
	int m=r-l;
	l=l%2019,r=r%2019;
	if(r<l&&m>=2019) r+=4038;
	if(r<l&&m<2019) r+=2019;
	if(r-l<2019&&m>=2019) r+=2019;
	int MIN=2000000000;
	for(int i=l;i<=r;i++)
		for(int j=i+1;j<=r;j++)
			MIN=min(MIN,(i*j)%2019);
	cout<<MIN<<endl;
	return 0;
}

Measured memory_bytes: 256