akhauriyash/Code-Regression huggingface dataset:
#!usr/bin/env python3

import sys
import operator
from math import floor


def string_to_list_spliter():
    lst = [i for i in sys.stdin.readline().split()]
    return lst


def main():
    ops = {'+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.truediv}

    # TODO Refactor the ugly code below into the function above.
    while True:
        lst = string_to_list_spliter()
        if lst[1] == '?':
            break
        elif lst[1] == '+':
            print(ops[lst[1]](int(lst[0]), int(lst[2])))
        elif lst[1] == '-':
            print(ops[lst[1]](int(lst[0]), int(lst[2])))
        elif lst[1] == '*':
            print(ops[lst[1]](int(lst[0]), int(lst[2])))
        elif lst[1] == '/':
            print(floor(ops[lst[1]](int(lst[0]), int(lst[2]))))


if __name__ == '__main__':
    main()

Measured memory_bytes: 7780
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext())
		{
			String str = sc.next();
			int nums[] = new int[str.length()];
			for (int i = 0; i < str.length(); i++)
			{
				nums[i] = (int) (str.charAt(i) - '0');
			}
			down(nums);
		}
	}
	private static void down(int nums[])
	{
		if (nums.length == 1)
		{
			System.out.println(nums[0]);
		}
		else
		{
			int next[] = new int[nums.length - 1];
			for (int i = 0; i < next.length; i++)
			{
				next[i] = (nums[i] + nums[i+1]) % 10;
			}
			down(next);
		}
	}
}

Measured memory_bytes: 11000
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

//const long long int MOD = 1000000007;
const long long int MOD = 1000003;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

//long long int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;




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

	string s;
	cin >> s;
	long long int ans = 0;
	int bef = -MOD;
	int bnum = 0;
	N = s.size();
	for (int i = 1; i < N - 1; i++) {
		if (s[i] == 'B'&&s[i + 1] == 'C') {
			//cout << i << endl;
			int ast = i;
			int num = 0;
			while (ast&&s[ast - 1]=='A') {
				ast--;
				num++;
			}
			if (i - num - 2 == bef) {
				num += bnum;
			}
			ans += num;
			bef = i;
			bnum = num;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 720
#include <iostream>

using namespace std;

int main(){
    int a,b,c,sum = 0,count = 0;
    cin >> a >> b >> c;
    while(sum < c){
        ++count;
        sum += a;
        if((count % 7) == 0) sum += b;
    }
    cout << count << endl;
}


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

#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define FORN(i, m, n) for(int (i) = (m); (i) <= (n); (i)++)
#define FORR(i, m, n) for(int (i) = (m); (i) >= (n); (i)--)
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> Vec;

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll m;
	cin >> m;
	Vec d(m), c(m);
	rep(i, m) cin >> d[i] >> c[i];

	ll sum = 0, sum_c = 0;
	rep(i, m){
		sum += d[i]*c[i];
		sum_c += c[i];
	}

	ll ans = sum_c-1+(sum-1)/9;
	co(ans);

	return 0;
}


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

using namespace std;
#define MAX  1000000000


int main()
{
	int n, k;
	vector<int> l;
	int temp;
	int sum = 0;

	cin >> n >> k;

	for (int i = 0; i < n; i++) {
		cin >> temp;
		l.push_back(temp);
	}

	sort(l.rbegin(), l.rend());

	for (int i = 0; i < k; i++) {
		sum += l[i];
	}
	cout << sum << endl;
	return (0);
}

Measured memory_bytes: 256
s = input()
t = input()

lens = len(s)
lent = len(t)

kotae = 1000
for i in range(lens-lent+1):
    temp = 0
    for j in range(lent):
        if(s[i+j] == t[j]):
            temp += 1
    kotae = min(kotae,lent-temp)

print(kotae)

Measured memory_bytes: 72964
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll x;cin>>x;
    for(int i=1;i<=1000;i++){
        if(x>=100*i&&x<=105*i)
        { cout<<1<<endl;
            return 0;}
        
    }
    cout<<0<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 384
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 998244353
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int x,a,b;cin>>x>>a>>b;
    cout<<x-a-(x-a)/b*b<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






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

#define ll long long int
#define loop(i,s,e) for(ll i=s; i<e; i++)
#define endl '\n'
#define vll vector<ll>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX
#define minusinf INT_MIN

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

ll n;
ll swim[100001], bugs[100001], homework[100001];

ll dp[100001][4];

ll util(ll i, ll prev){

	if(i>=n) return 0;

	if(dp[i][prev]!=-1) return dp[i][prev];

	ll a=minusinf, b=minusinf, c=minusinf;

	if(prev!=1) a = swim[i] + util(i+1, 1);
	if(prev!=2) b = bugs[i] + util(i+1, 2);
	if(prev!=3) c = homework[i] + util(i+1, 3);

	return dp[i][prev] = max(a, max(b, c));

}

void alpha(){

	cin>>n;
	loop(i,0,n) cin>>swim[i]>>bugs[i]>>homework[i];

	memset(dp, -1, sizeof(dp));

	cout<<util(0, 0)<<endl;

	
	return;

}

int main(){

	ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    ll t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}

Measured memory_bytes: 12032
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
using namespace std;
int main() {
	int n;
	string s[200010];
	int max = 0, co = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	sort(s, s + n);
	for (int j = 0; j < n - 1; j++) {
		if (s[j] == s[j + 1]) {
			co++;
		}
		else {
			if (max < co + 1) {
				max = co + 1;
			}
          co=0;
		}
	}
	if (max < co + 1) {
		max = co + 1;
	}
	co = 0;
	for (int k = 0; k < n-1; k++) {
		if (s[k] == s[k + 1]) {
			co++;
		}
		else {
			if (max == co + 1) {
				cout << s[k] << endl;
			}
			co = 0;
		}
	}
	if (max == co + 1) {
		cout<<s[n-1]<<endl;
	}
	return 0;
}




Measured memory_bytes: 14208
def factoring(M,n=2):
    if M==1: return {}
    for i in range(n,int(M**0.5)+1):
        if M%i==0:
            ret = factoring(M//i,i)
            ret[i] = ret.get(i,0)+1
            return ret
    return {M:1}

N = int(input())
*A, = map(int,input().split())

mod = 10**9+7

fac = {}

for a in A:
    tmp = factoring(a)
    for b,n in tmp.items():
        fac[b] = max(fac.get(b,1),n)
lcm = 1
for b,n in fac.items():
    lcm *= pow(b,n,mod)
    lcm %= mod
        
ans = 0
for a in A:
    ans += (lcm*pow(a,mod-2,mod))%mod
    ans %= mod
print(ans)

Measured memory_bytes: 69464
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  String s = sc.next();
	  String t = sc.next();
	  String ans = "No";
	  for(int i = 0; i < s.length(); i++) {
		  String a = s.substring(0,1);
		  s = s.substring(1);
		  s += a;
		  if(s.equals(t)) {
			  ans = "Yes";
			  break;
		  }
	  }
	  System.out.println(ans);
	}
}

Measured memory_bytes: 39320
using System;

public class Hello
{
    public const long SS = 1000000007;
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var x = Array.ConvertAll(line, long.Parse);
        line = Console.ReadLine().Trim().Split(' ');
        var y = Array.ConvertAll(line, long.Parse);
        var r1 = getAns(x);
        var r2 = getAns(y);
        Console.WriteLine((r1 * r2) % SS);
    }
    public static long getAns (long[] a )
    {
        var n = a.Length;
        var rsum = 0L;
        for (int i = 0; i < n; i++)
            rsum += (i * a[i] - (n - i - 1) * a[i]) % SS;
        return rsum % SS;
    }
}

Measured memory_bytes: 33804
participant_num, initial_point, ans_num = gets.split.map(&:to_i)
# 初期点数を initial_point - ans_num としておき、正解したら加算する
participants = Array.new(participant_num, initial_point - ans_num)
ans_num.times do |i|
  index = gets.to_i - 1
  participants[index] += 1
end

participants.each do |point|
  puts(point > 0 ? "Yes" : "No")
end


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

using namespace std;

int fun(int x){
  int ret = 0;
  while(x){
    ret += x % 10;
    x /= 10;
  }
  return ret;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  if(n % fun(n)  == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
/*
  kadai3_3 Digits
  unomi
*/
#include <stdio.h>
#include <math.h>

double log_K(double N, double K){
  // 底の変換公式を用いて、log_K(N)を計算
  return log(N)/log(K);
}

int main(void){
  double N=0, K=0;

  // N,K の入力を取得
  scanf("%lf %lf",&N, &K);

  // N = K^log_K(N) < K^(log_K(N)の次の整数) 
  // → K進数において、Nは(log_K(N)の次の整数)桁
  printf("%d\n",(int)floor(log_K(N,K))+1);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main()
{
  int a, b;
  cin >> a >> b;
  if (a <= b)
    cout << a << endl;
  else
    cout << a - 1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1073741824
#define ll long long
#define PI (2*acos(0.0))
#define p1(n) printf("showing %d\n",n)
#define p2(m,n) printf("showing %d %d\n",m,n)
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define on(val,pos) val|(1<<pos)
#define off(val,pos) val&(~(1<<pos))
#define check(val,pos) (val&(1<<pos))

//first four adjacent,second four corner
//int row[8]={0,-1,0,1,1,-1,-1,1};
//int col[8]={-1,0,1,0,-1,-1,1,1};
using namespace std;

int main(){
    ll i,j,k,n,m,t=0,cnt,test;
    //freopen("000input.txt","r",stdin);
    cin>>n;
    double dp[n+5],head;
    memset(dp,0,sizeof dp);
    dp[0]=1;
    for(i=0;i<n;i++){
        scanf("%lf",&head);
        for(int j=i+1;j>=0;j--){
            dp[j]=(j==0?0:dp[j-1]*head)+dp[j]*(1-head);
        }
    }
    double ans=0;
    for(i=n/2+1;i<=n;i++){
        ans+=dp[i];
    }
    printf("%.9lf",ans);
    //free();   //if pointer array
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+100,M=1e6+100;
int n,num;
int a[N],mark[M];
inline void solve(int x)
{
	mark[x]--;
	for (int i=1;i*i<=x;i++)
	if (x%i==0)
	if (mark[i]||mark[x/i])
	{
		mark[x]++;
		return ;
	}
	num++;
	mark[x]++;
	return ;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",a+i);
		mark[a[i]]++;
	}
	for (int i=1;i<=n;i++) solve(a[i]);
	printf("%d\n",num);
	return 0;
}

Measured memory_bytes: 8408
cards = [[False for j in range(14)]for i in range(4)]
n = int(input())
for i in range(n):
	suit,rank = input().split()
	r = int(rank)
	if suit == "S":
		s = 0
	elif suit == "H":
		s = 1
	elif suit == "C":
		s = 2
	else:
		s = 3
	cards[s][r] = True
  	
name = ["S","H","C","D"]
for s in range(4):
	for r in range(1,14):
		if not cards[s][r]:
			print(name[s],r)

Measured memory_bytes: 7648
N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i)
B = gets.chomp.split(" ").map(&:to_i)
max = 0
N.times do |i|
  sum = 0
  for j in 0..i
    sum += A[j]
  end
  for j in i..(N-1)
    sum += B[j]
  end
  max = [max,sum].max
end
puts max


Measured memory_bytes: 14280
#include<iostream>
#include<queue>
#include<stack>
#include<algorithm>
#include<map>
#include<set>

using namespace std;

int main()
{
    int n,k,ans=0;
    cin>>n>>k;
    while(n>0)
    {
        ans++;
        n/=k;
    }
    cout<<ans<<endl;
    return 0;
    
}


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

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

int main()
{
    using vi = vector<int>;
    using vvi = vector<vi>;
    using vvvi = vector<vvi>;
    using ll = long long;

    int N;
    string S;
    cin >> N >> S;

    int ans = 0;
    char now = -1;
    rep(i, N)
    {
        if(now == S[i])
            continue;
        else
        {
            now = S[i];
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}
	
	// for prime mod
	mint inv() const {
		return pow(mod-2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res/=a;
	}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
	int n, m;
	cin >> n >> m;
	mint ans = 0;
	if (n < m) swap(n, m);
	if (n - m == 1) {
		mint now1 = 1, now2 = 1;
		rep(i, n) now1 *= i+1;
		rep(i, m) now2 *= i+1;
		ans = now1 * now2;
	} else if (n == m) {
		mint now1 = 1, now2 = 1;
		rep(i, n) now1 *= i+1;
		rep(i, m) now2 *= i+1;
		ans = now1 * now2 * 2;
	}
	cout << ans << endl;
	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/01/27  Problem: nikkei_2019_qual A / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL ans = 0LL;

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

	LL N, A, B; cin >> N >> A >> B;

	LL z = min(A, B);

	ans = max(0LL,A + B - N);
	cout << z << " " << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} 
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
#define sort(v) sort(v.begin(), v.end())
#define sortr(v) sort(v.rbegin(), v.rend())
void chmin(int &a, int b) {if(a > b) a = b;}
void chmax(int &a, int b) {if(a < b) a = b;}

const int mod = 1000000007;
const int inf = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};


int main(){
    int a, b;
    cin >> a >> b;
    printf("%d", (a+b>=24?a+b-24:a+b));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define Q int tc; scanf("%d",&tc); for(int test=1;test<=tc;test++)
typedef long long int ll;
#define pi pair<int,int>
int main()
{
  int ar[6];
  int ans;
  for(int i=1;i<=5;i++){
     cin>>ar[i];
  }
  for(int i=1;i<=5;i++){
    if(ar[i]==0){
        ans=i;
        break;
    }
  }
  cout<<ans;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#define rep(xx,yy) for(int xx=0;xx<yy;xx++)
const int N=203;
using namespace std;
int n,m,x,S,T,t,q[N],b[N][N],d[N];
stack<int>a[N][N];
bool e[N][N];
inline bool bfs(){
	rep(i,T+1)d[i]=0;
	d[q[0]=S]=t=1;
	rep(h,t){
		x=q[h];
		rep(i,T+1)
		if(e[x][i]&&!d[i])d[q[t++]=i]=d[x]+1;
	}
	return d[T];
}
bool dfs(int x,int f){
	if(x==T)return f;
	bool c,re=0;
	rep(i,T+1)
	if(f&&e[x][i]&&d[i]==d[x]+1)
	c=dfs(i,1),re|=c,f-=c,
	e[x][i]^=c,e[i][x]^=c;
	return re;
}
int main(){
	scanf("%d%d",&n,&m);S=n<<1,T=S|1;
	rep(i,n)rep(j,m)
	scanf("%d",&x),a[i][(x-1)/m].push(x);
	rep(i,m){
		memset(e,0,sizeof e);
		rep(j,n){
			e[S][j]=e[n+j][T]=1;
			rep(k,n)e[j][n+k]=a[j][k].size();
		}
		for(;bfs();dfs(S,N));
		rep(j,n)rep(k,n)
		if(e[k+n][j])b[i][j]=a[j][k].top(),a[j][k].pop();
	}
	rep(i,n)rep(j,m)
	printf("%d%c",b[j][i],j<m-1?' ':'\n');
	rep(i,m)sort(b[i],b[i]+n);
	rep(i,n)rep(j,m)
	printf("%d%c",b[j][i],j<m-1?' ':'\n');
}

Measured memory_bytes: 28160
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

struct ProbState {
  bool uresii = false;
  int kanasii = 0;
  int penalty;

  ProbState() {
  }
};

struct Team {
  vector<ProbState> states;
  int id;
  int solved  = 0;
  int penalty = 0;

  Team(int probs, int id)
    : states(probs), id(id) {
  }
};

bool operator<(const Team &a, const Team &b) {
  if (a.solved != b.solved) return a.solved > b.solved;
  return a.penalty < b.penalty;
}

void solve() {
  int t, p, r;
  while (cin >> t >> p >> r, t) {
    vector<Team> ts;
    ts.reserve(t);
    rep(i, t) ts.emplace_back(p, i + 1);
    while (r--) {
      int tid, pid, tm;
      string msg;
      cin >> tid >> pid >> tm >> msg;
      --tid, --pid;
      if (ts[tid].states[pid].uresii) continue;
      if (msg == "CORRECT") {
        ts[tid].states[pid].uresii = true;
        ts[tid].solved++;
        ts[tid].states[pid].penalty = ts[tid].states[pid].kanasii * 1200 + tm;
        ts[tid].penalty += ts[tid].states[pid].penalty;
      }
      if (msg == "WRONG") ts[tid].states[pid].kanasii++;
    }
    stable_sort(all(ts));
    for (Team x : ts) cout << x.id << ' ' << x.solved << ' ' << x.penalty << endl;
  }
}

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

using namespace std;
int main() {
	string S;
	int w;

	int count = 0;

	cin >> S >> w;

	for (char c : S) {
		if (count == 0) {
			cout << c;
			count = w;
		}
		count--;
	}


	cout << endl;


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i=0,l,j,s;
  int A[100];
  int key;
  scanf("%d",&l);
  for(i=0;i<l;i++)scanf("%d",&A[i]);
  for(s=0;s<l;s++)if(s==l-1)printf("%d",A[s]);else printf("%d ",A[s]);
  printf("\n");
  
  for(i=1;i<l;i++){
    key=A[i];
    j=i-1;
    while(j>=0&&A[j]>key){//keyがあるべき位置に来るまでループする
      A[j+1]=A[j];
      j--;
      A[j+1]=key;
    }
    for(s=0;s<l;s++)if(s==l-1)printf("%d",A[s]);else printf("%d ",A[s]);
    printf("\n");
  }
  return 0;
}



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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	ll k; string s;
	cin >>s >>k;
	
	rep(i, sz(s)){
		if(s[i]=='1'){
			k--;
			if(k==0) {puts("1"); return 0;}
		}else{
			cout << s[i] <<"\n";
			return 0;
		}
	}
	
	return 0;
}


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

int main()
{
    int n;
    cin>>n;
    int dp[n+1];
    int h[n];
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);

    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include<bits/stdc++.h>
#include<cmath>
 
 
using namespace std;
 
int main()
{
  int a,b,c;
  cin>>a>>b;
  c=a+b;
  if(c<24)
  {
  cout<<c;
  }
 else
 {

   cout<<c-24;
 }
  return 0;
}

Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
struct WORK{
    int needTime;
    int shimekiri;
};
bool cmp(WORK a, WORK b){
    return a.shimekiri < b.shimekiri;
}
int main(){
    int N;
    cin >> N;
    vector<WORK> work(N);
    long long nowTime=0;
    string ans = "Yes";
    for(int i=0; i<N; i++){
        cin >> work.at(i).needTime >> work.at(i).shimekiri;
    }
    sort(work.begin(),work.end(),cmp);
    for(int i=0; i<N; i++){
        nowTime+=work.at(i).needTime;
        if(nowTime>work.at(i).shimekiri){
            ans = "No";
            break;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) (((a%MOD+MOD)%MOD+(b%MOD+MOD)%MOD)%MOD)
#define MUL(a, b) ((((a%MOD+MOD)%MOD)*((b%MOD+MOD)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#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 fcout cout << fixed << setprecision(10)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b){ if(a<b){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b){ if(a>b){ a=b; return true; } return false; }
template<typename I> int ACC(I f, I l, int i){ return accumulate(f, l, i); }


int N, M;
PQ<int> pq;


signed main(){
    cin >> N >> M;
    rep(i, 0, N){
        int A;
        cin >> A;
        pq.push(A);
    }

    rep(i, 0, M){
        int x = pq.top();
        pq.pop();
        pq.push(x/2);
    }

    int ans = 0;
    while(!pq.empty()) ans += pq.top(), pq.pop();

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1400
import java.io.IOException;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int cnt = 0;
		for (int i = 1; i <= n; i++) {
			if (i % 2 != 0) {
				cnt++;
			}
		}

		System.out.println((double)cnt / n);
	}
	
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

int vis[100010] = {};
V<int> XX[100010], YY[100010];
V<int> X, Y;

ll pts;
unordered_set<int> xx, yy;

void rec(int i) {
    if (vis[i]) return;
    vis[i] = 1;
    xx.emplace(X[i]);
    yy.emplace(Y[i]);
    pts++;

    for (int j : XX[X[i]]) {
        rec(j);
    }
    for (int j : YY[Y[i]]) {
        rec(j);
    }
} 

int main() {
    int n; cin >> n;
    X = V<int>(n);
    Y = V<int>(n);
    loop (n, i) cin >> X[i] >> Y[i];

    loop (n, i) {
        XX[X[i]].push_back(i);
        YY[Y[i]].push_back(i);
    }

    V<int> vis(n);

    ll ans = 0;
    loop (n, i) {
        if (XX[X[i]].size() >= 2 && YY[Y[i]].size() >= 2) {
            xx = unordered_set<int>();
            yy = unordered_set<int>();
            pts = 0;
            rec(i);
            ans += xx.size() * yy.size() - pts;
        }
    }

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



Measured memory_bytes: 16792
# -*- coding: utf-8 -*-
"""
AtCoder B
"""

def main():
    N=input()
    S=list(map(str,input().split()))[0]
    K=int(input())

    trg= S[K-1]
    out=""
    for s in S:
        if s!=trg:
            out+="*"
        else:
            out+=s
    print(out)

if __name__ == "__main__":
    main()

Measured memory_bytes: 38256
M=10**6+10
c=[0]*M
n=int(input())
a=sorted(list(map(int,input().split())))
for k in a:
    if c[k]:
        c[k]=2
        continue
    for i in range(k,M,k):
        c[i]+=1
ans=0
for i in a:
    if c[i]==1:
        ans+=1
print(ans)

Measured memory_bytes: 129588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

ll solve(ll n, ll x, ll m){
    VL r(m);
    deque<ll> dq;
    for(ll i = 0; i < n; i++) {
        r[x]++;
        dq.push_back(x);
        x *= x;
        x %= m;

        // 巡回検出
        if (r[x] != 0) break;
    }

    // 残りの数
    n -= dq.size();

    if (n != 0){
        // ループサイズ
        while(dq.front() != x) dq.pop_front();
        ll loop_sz = dq.size();

        // 何回ループするかを計算し、ループする数に対して加算する
        ll nq = n / loop_sz;
        while(!dq.empty()){
            ll y = dq.front(); dq.pop_front();
            r[y] += nq;
        }

        // 残りは普通に計算する
        ll nr = n % loop_sz;
        while(nr--){
            r[x]++;
            x *= x;
            x %= m;
        }
    }

    ll ans = 0;
    rep(i,m) ans += (ll)i * r[i];
    return ans;
}

int main(){

    random_device seed_gen;
    mt19937_64 engine(seed_gen());
    // rep(i, 100){
        ll n, x, m;

        // n = engine() % (ll) 1e10 + 1;
        // x = engine() % (ll) 1e5 + 1;
        // m = engine() % (ll) 1e5 + 1;
        // printf("input %lld %lld %lld\n", n, x, m);
        // if (x >= m) continue;
        cin >> n >> x >> m;
        cout << solve(n, x, m) << endl;
    // }
    
    return 0;
}

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

using namespace std;

void solve()
{
    int n, m;
    cin >> n >> m;

    vector <vector <int> > adj(n + 1);

    for(; m; --m)
    {
        int x, y;
        cin >> x >> y;

        adj[x].emplace_back(y);
        adj[y].emplace_back(x);
    }

    vector <int> ans(n + 1);

    ans[1] = 1;
    queue <int> q;
    q.push(1);
    int cnt = 1;

    while(!q.empty())
    {
        int nod = q.front();
        q.pop();

        for(auto i : adj[nod])
            if(ans[i] == 0)
            {
                ans[i] = nod;
                q.push(i);
                ++cnt;
            }
    }

    if(cnt != n)
    {
        cout << "No\n";
        return ;
    }

    cout << "Yes\n";

    for(int i = 2; i <= n; ++i)
        cout << ans[i] << '\n';
}

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

    int t;
    t = 1;

    //cin >> t;

    for(; t; --t)
        solve();
}


Measured memory_bytes: 10216
#include <cstdio>
#include <vector>
#include <cmath>

using namespace std;

int main() {
    int n, d, cnt = 0;
    scanf("%d%d", &n, &d);
    vector< vector<int> > x(n, vector<int>(d));
    for (int i = 0; i < n; ++i) for (int j = 0; j < d; ++j) scanf("%d", &x.at(i).at(j));
    for (int i = 0; i < n; ++i) for (int j = i + 1; j < n; ++j) {
        double sum = 0;
        for (int k = 0; k < d; ++k) sum += pow(x.at(i).at(k) - x.at(j).at(k), 2);
        if (pow(int(round(sqrt(sum))), 2) == sum) ++cnt;
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 256
// 剰余がゼロになるまで演算を繰り返すことで計算を早くする
#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
    int x, y, r;
    cin >> x >> y;
    if (x < y)
    {
         swap(x, y); //小さい方をyとする
    }
    r = x % y;
    while( r != 0 )
    {
        x = y;
        y = r;
        r = x % y;
    }
    cout << y << endl;
    return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}


int N;
vector<string> ans;

void dfs(int d, string& s, char c) {
  if (d == N) {
    ans.push_back(s);
    return;
  }
  if (s[d] == '?') {
    vector<int> is;
    REP(i, N) if (s[i] == '?') is.push_back(i);

    REP(st, 1 << is.size()) if (st >> 0 & 1) {
      REP(i, N) if (st >> i & 1) s[ is[i] ] = c;
      dfs(d + 1, s, c + 1);
      REP(i, N) if (st >> i & 1) s[ is[i] ] = '?';
    }

  } else {
    dfs(d + 1, s, c);
  }
}

int main2() {
  N = nextInt();

  string s(N, '?');
  dfs(0, s, 'a');

  sort(ALL(ans));
  REP(i, ans.size()) cout << ans[i] << endl;

  return 0;
}

int main() {

#ifdef LOCAL
  // for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 7796
using System;
using System.Linq;

namespace Lower
{
    class Program
    {
        static void Main(string[] args)
        {
            var length = int.Parse(Console.ReadLine());
            var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var max = 0;

            var dp = new int[arr.Length];

            for(int i = 1; i < arr.Length; i++)
            {
                if (arr[i] <= arr[i - 1]) dp[i] = dp[i - 1] + 1;
                max = Math.Max(max, dp[i]);
            }

            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 30684
"""
Nが奇数のとき、明らかに掛け算で10の倍数が出来上がらないので、答えは0になる。
Nが偶数のとき、掛け算に巻き込まれる5の素因数の数だけ0ができる。
5^x(1 <= x)ごとに、Nを割る。すると、0~Nに含まれる5^xの数がわかる。
そのうち半分は奇数で半分は偶数である。偶数のカウントだけを加算する。
"""

N = int(input())
if N%2 == 1:
    print(0)
else:
    ans = 0
    x = 1
    while 5**x <= N:
        ans += (N//(5**x))//2
        x += 1
    print(ans)

Measured memory_bytes: 61408
#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <climits>

#include <cfloat>

#include <map>

#include <utility>

#include <set>

#include <iostream>

#include <memory>

#include <string>

#include <vector>

#include <algorithm>

#include <functional>

#include <sstream>

#include <complex>

#include <stack>

#include <queue>

#include <numeric>

#include <cstring>



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

#define pb push_back



using namespace std;



typedef long long ll;

typedef pair<int, int> P;

typedef vector<int> vi;



const int INF = 1 << 29;

const double EPS = 1e-9;

const int MAX_N = 100;



int field[1000][1000];



int bfs(int sx, int sy, int t){

		P p;

		queue<P> q;

		queue<int> qt;

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

		int mx, my, count = 0;



		q.push(P(sx, sy));

		count++;

		field[sx][sy] = -1;

		qt.push(t);



		while(q.size()){

				p = q.front(), q.pop();

				t = qt.front(), qt.pop();

				if(t == 0) break;

				t--;

				sx = p.first, sy = p.second;



				rep(i, 6){

						mx = sx + dx[i], my = sy + dy[i];

						if(mx >= 0 && my >= 0 && mx < 1000 && my < 1000 && field[mx][my] == 0){

								field[mx][my] = -1;

								count++;

								q.push(P(mx, my));

								qt.push(t);

						}

				}

		}

		return count;

}





int main(){

		int n, sx, sy, t, x, y, ans;

		while(1){

				memset(field, 0, sizeof(field));



				cin >> t >> n;

				if(t == 0 && n == 0) break;



				rep(i, n){

						cin >> x >> y;

						x += 500, y += 500;

						field[x][y] = INF;

				}



				cin >> sx >> sy;

				sx += 500, sy += 500;

				ans = bfs(sx, sy, t);

				cout << ans << endl;

		}

}

Measured memory_bytes: 4832
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

template<typename T>
struct BIT{
  int n;
  vector<T> bit;
  BIT(int n_=0):n(n_),bit(n+1){}
  void add(int i,T x=1){
    for(i++;i<=n;i+=i&-i){
      bit[i]+=x;
    }
  }
  T sum(int i){
    T x=0;
    for(i++;i;i-=i&-i){
      x+=bit[i];
    }
    return x;
  }
  T sum(int l, int r){
    return sum(r-1) - sum(l-1);
  }
};

int main(){
  int N,Q;cin>>N>>Q;
  BIT<int> b(N);
  rep(q,Q){
    int c, x, y; cin >> c >> x >> y;
    if(c==0){
      x--;
      b.add(x,y);
    }
    else{
      x--;
      cout << b.sum(x,y) << '\n';
    }
  }
  return 0;
}



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


int main() {
  int n;
  cin>>n;
  int a[n];

  for (int i=0; i<n; i++) cin>>a[i];
  if (a[0] != 0) {
    cout<<-1<<endl;
    return 0;
  }
  for (int i=0; i<n-1; i++) {
    if (a[i] + 1 < a[i+1]) {
      cout<<-1<<endl;
      return 0;
    }
  }
  int i = 0;
  long long cnt = 0;
  while (i < n) {
    while (i < n - 1 && a[i] < a[i+1]) {
      ++i;
      ++cnt;
    }
    ++i;
    if (i != n) {
      cnt += a[i];
    }
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 1024
n = gets.chomp.to_i

def divisor(num)
  result = []
  i = 1
  while i <= num do
    remainder = num % i
    if remainder == 0
      result << i
    end
    i += 1
  end
  return result
end

res = 0

1.upto(n) do |i|
  res += 1 if i.odd? && divisor(i).length == 8
end

puts res


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

int main(void) {
	int N;
	int *P;
	int i;
	int min_till_i;
	int answer;
	char buf_N[16];
	char *buffer;
	char *ch;

	fgets(buf_N, sizeof(buf_N), stdin);
	ch = strtok(buf_N, " ");
	N = atoi(ch);

	P = (int *)calloc(N, sizeof(int));
	buffer = (char *)calloc(N * N + 1, sizeof(char));

	fgets(buffer, N * N + 1, stdin);
	ch = strtok(buffer, " ");
	P[0] = atoi(ch);
	for(i = 1; i < N; i += 1) {
		ch = strtok(NULL, " ");
		if(NULL == ch) {
			printf("sth wrong:%d\n", i);
			break;
		}
		P[i] = atoi(ch);
	}
	
	min_till_i = N;
	answer = 0;
	for(i = 0; i < N; i += 1) {
		if(min_till_i >= P[i]) {
			min_till_i = P[i];
		}
		if(P[i] <= min_till_i) {
			answer += 1;
		}
	}

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

	free(P);
	free(buffer);
	return 0;
}


Measured memory_bytes: 4096
mod = 10 ** 9 + 7
n = int(input())

import sys
sys.setrecursionlimit(100000)

memo = {}
def ok(last4):
    if 'AGC' in last4:
        return False
    if last4[:3] == 'ACG' or last4[:3] == 'GAC':
        return False
    if last4[1:] == 'ACG' or last4[1:] == 'GAC':
        return False
    if last4[0] == 'A' and last4[2:] == 'GC':
        return False
    if last4[:2] == 'AG' and last4[3] == 'C':
        return False
    return True

def dfs(h, last3):
    if (h, last3) in memo:
        return memo[h, last3]
    # 停止条件
    if h == n:
        return 1
    ret = 0
    for c in 'ACGT':
        if ok(last3+c):
            ret = (ret + dfs(h+1, last3[1:]+c)) % mod
    memo[h, last3] = ret
    return ret

print(dfs(0, 'TTT'))

Measured memory_bytes: 51032
s = list(input())
for i in range(int(input())):
    cmd, a, b, *c = input().split()
    a = int(a); b = int(b)
    if cmd == "print":
        print(*s[a:b+1], sep='')
    elif cmd == "reverse":
        s[a:b+1] = reversed(s[a:b+1])
    else:
        s[a:b+1] = c[0]



Measured memory_bytes: 5740
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class C {
        static long MOD = (long) (1e9 + 7);
        int N;
        int[] A;

        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            N = in.Int();
            A = in.Int(N);

//        long ans1 = calc1();
//        out.println(ans1);
            long ans2 = calc2();
            out.println(ans2);
        }

        public long calc2() {
            long[] as = new long[N + 1];
            for (int i = 0; i < N; i++) {
                as[i + 1] = (as[i] + A[i]) % MOD;
            }
            long ret = 0;
            for (int i = 0; i < N - 1; i++) {
                long l = (as[N] - as[i + 1] + MOD) % MOD;
                ret += (A[i] * l) % MOD;
                ret %= MOD;
            }
            return ret;
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    return null;
                }
            }
            return st.nextToken();
        }

        public int Int() {
            return Integer.parseInt(next());
        }

        public int[] Int(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Int();
            }
            return a;
        }

    }
}



Measured memory_bytes: 54968
from functools import reduce

n, a, b = map(int, input().split(" "))

MOD = 10**9 + 7


def comb(n, r, mod=float("inf")):
    c = 1
    m = 1
    r = min(n - r, r)
    for i in range(r):
        c = c * (n - i) % mod
        m = m * (i + 1) % mod
    return c * pow(m, mod - 2, mod) % mod


print((pow(2, n, MOD) - comb(n, a, MOD) - comb(n, b, MOD) - 1) % MOD)


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

int main()
{
    ll n, h;
    cin >> n >> h;
    ll ans = INF;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end(), greater<ll>());
    sort(b.begin(), b.end(), greater<ll>());
    for (int i = 0; i < n; i++)
    {
        ll tmp;
        h -= b[i];
        tmp = i + 1;

        if (h > 0)
        {
            tmp += (h + (a[0] - 1)) / a[0];
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#-*- coding:utf-8 -*-

#素数リストの生成
M = 10001
primes = [1]*M
primes[0], primes[1] = 0,0
for i in range(2,101):
    if primes[i]:
        j = 2
        while j*i < M:
            primes[j*i] = 0
            j += 1


#入力されたデータに関して2つとも素数の組の数を返す
def both_prime(num):

    #各データについて偶数奇数で場合分け
    #偶数
    if num%2 == 0:
        if primes[num-1]:
            return 2
        else:
            return 0
    #奇数
    else:
        c = 0 #カウント
        for i in range(num/2):
            if (i+1)%2==0:
                continue
            else:
                if primes[i+1] and primes[num-i]:
                    c += 1
        c *= 2
        if primes[num/2+1]:
            c += 1
        return c

if __name__=="__main__":
    while 1:
        try:
            n = int(raw_input())
            print both_prime(n)
        except:
            break

Measured memory_bytes: 4492