akhauriyash/Code-Regression huggingface dataset:
//Never stop trying
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;
typedef pair<int, int> pi;
#define fi first
#define se second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<str> vs;
typedef vector<ld> vd;
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

const int MOD = 1e9 + 7; //998244353
const ll INF = 1e18;
const int MX = 2e5 + 10;
const int nx[4] = {0, 0, 1, -1}, ny[4] = {1, -1, 0, 0}; //right left down up

template<class T> using V = vector<T>;
template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); } // divide a by b rounded up
constexpr int log2(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))

#define dbg(x) cerr << " - " << #x << " : " << x << endl;
#define dbgs(x,y) cerr << " - " << #x << " : " << x << " / " << #y << " : " << y << endl;
#define dbgv(v) cerr << " - " << #v << " : " << endl << "[ "; for(auto it : v) cerr << it << ' '; cerr << ']' << endl;

void IO() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int K;
str s;
int C[2000005];

int modpow(int x, int p){
	if(p==0) return 1;
	int v=modpow(x,p/2); v*=v; v%=MOD;
	if(p%2) v*=x; v%=MOD;
	return v;
}

int modinv(int x){
	return modpow(x,MOD-2);
}


int32_t main() {
	boost; IO();

	cin>>K>>s;
	int N=sz(s);
	C[N-1]=1;
	FOR(i,N,N+K){
		C[i]=(C[i-1]*i)%MOD; C[i]*=modinv(i-(N-1)); C[i]%=MOD;
	}
	int ans=0;
	FOR(i,N-1,N+K){
		ans+=(((C[i]*modpow(25,i-(N-1)))%MOD)*(modpow(26,N+K-i-1)))%MOD;
		ans%=MOD;
	}
	cout << ans << endl;

	return 0;
}

//575111451

/* Careful!!!
	.Array bounds
	.Infinite loops
	.Uninitialized variables / empty containers
	.Order of input

   Some insights:
	.Binary search
	.Graph representation
	.Write brute force code
	.Change your approach
*/


Measured memory_bytes: 12164
#include<bits/stdc++.h>
using namespace std;
long long f[2000001];
int main()
{
	long long n,a,b;
	long long ans=0;
	cin>>n>>a>>b;
	long long x[n];

	for(int i=1;i<=n;i++)
	{
		cin>>x[i];
	}
	for(int j=1;j<n;j++)
	{
		f[j]+=min((x[j+1]-x[j])*a,b);
	} 
	for(int k=1;k<n;k++)
	{
		ans+=f[k];
	}
	cout<<ans;
 	return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Grouping 2
            int N = int.Parse(Console.ReadLine());
            var arare = ReadLine();

            int count = 0;
            var colors = new char[4] { 'P', 'W', 'G', 'Y' };

            foreach(var c in colors)
            {
                if (arare.Contains(c))
                {
                    count++;
                }
            }

            if (count > 3)
            {
                Console.WriteLine("Four");
            }
            else
            {
                Console.WriteLine("Three");
            }
        }

        static List<char> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => Convert.ToChar(x)).ToList();
        }
    }
}

Measured memory_bytes: 13396
a, b, c = map(int, input().split())
L = [a, b, c]
L.sort()
ans = L[2]-L[1]
L[0] += ans
if L[0]%2 == L[2]%2:
    ans += (L[2]-L[0])//2
else:
    ans += 1
    ans += (L[2]+1-L[0])//2
print(ans)


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

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int a, b;
	cin >> a >> b;
	int c = b - a;
	cout << (c * (c + 1) / 2 - b) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
   int N;
  scanf("%d",&N);
  int split;
  split=N%10;
  switch(split){
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      printf("hon\n");
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      printf("pon\n");
      break;
    case 3:
      printf("bon\n");
        break;
  }
  return 0;
}

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

using namespace std;

typedef long long llint;

llint gcd(llint a, llint b)
{
	while (b)
	{
		tie(a, b) = make_pair(b, a % b);
	}
	
	return a;
}

bool solve()
{
	llint a, b, c, d, x;
	
	cin>>a>>b>>c>>d;
	
	if (a < b)
		return false;
	
	a %= b;
	
	if (a > c)
		return false;
	
	x = gcd(b, d);
	
	if (a % x + d < b)
		return false;
	
	return b - x + a % x <= c;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int t;
	
	cin>>t;
	
	while (t--)
	{
		cout<<(solve() ? "Yes\n" : "No\n");
	}
}


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

int main(void) {
  long long N;
  long long r;
  cin >> N;
  string ans = "";
  do {
    r = N % (-2);
    N /= -2;
    if (r == -1) {
      r = 1;
      N++;
    }
    ans = to_string(r) + ans;
  } while (N != 0);
  cout << ans << endl;
  return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int V = sc.nextInt();
		int E = sc.nextInt();
		int r = sc.nextInt();
		Edge[] edges = new Edge[E];
		for (int i = 0; i < E; i++) {
			edges[i] = new Edge(sc.nextInt(), sc.nextInt(), sc.nextInt());
		}
		solve(V, E, r, edges);
	}
	
	public static void solve(int V, int E, int r, Edge[] edges) {
		int[] cost = new int[V];
		Arrays.fill(cost, Integer.MAX_VALUE);
		cost[r] = 0;
		
		for (int i = 0; i < V; i++) {
			boolean update = false;
			for (int j = 0; j < E; j++) {
				Edge edge = edges[j];
				if (cost[edge.src] == Integer.MAX_VALUE) {
					continue;
				}
				
				if (cost[edge.src] + edge.cost < cost[edge.dest]) {
					update = true;
					cost[edge.dest] = cost[edge.src] + edge.cost;  
				}
			}
			
			if (i == V-1) {
				if (update) {
					System.out.println("NEGATIVE CYCLE");
				} else {
					for (int k = 0; k < V; k++) {
						if (cost[k] == Integer.MAX_VALUE) {
							System.out.println("INF");
						} else {
							System.out.println(cost[k]);
						}
					}
				}
			}
			update = false;
		}
	}
}

class Edge {
	int src;
	int dest;
	int cost;
	public Edge(int s, int d, int c) {
		src = s;
		dest = d;
		cost = c;
	}
}

Measured memory_bytes: 29376
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	ll X;
	cin >> X;
	
	using pll = pair<ll, ll>;
	set<pll> ss;
	for (ll i = 0;; ++i) {
		ll p5 = i;
		REP(j, 4) p5 *= i;
		
		ll p6 = (i + 1);
		REP(j, 4) p6 *= (i + 1);
		
		if (p5 > 10000000000000000ll) break;
		ss.insert(pll(p5, i));
		ss.insert(pll(-p5, -i));
	}
	
	
	for (pll c : ss) {
		auto it = ss.lower_bound(pll(c.fi - X, -longINF));
		if (it == ss.end()) continue;
		
		if (c.fi - it->fi == X) {
			printf("%lld %lld\n", c.se, it->se);
			return 0;
		}
	}
	
	return 0;
}


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

int cus(int p[], int c[], int j){
	int count = 0;
	for(int i = 0; i < 8; i++){
		count += min(p[i],c[(i+j)%8]);
	}
	return count;
}

void printc(int p[],int i){
	for(int j = 0; j < 8; j++){
		if(j != 0) cout << " ";
		cout << p[(i+j)%8];
	} 
	cout << endl;
}

int main(){
	int c[] = {
		1, 2, 1, 2, 
		1, 4, 1, 4
	};
	int p[8];
	while(cin >> p[0] >> p[1] >> p[2] >> p[3]
			>> p[4] >> p[5] >> p[6] >> p[7])
	{
		int count_max = 0;
		for(int i = 0; i < 8; i++){
			count_max = max(count_max, cus(p,c,i));
		}
		if(cus(p,c,0) == count_max){
			printc(c,0);
		}else if(cus(p,c,2) == count_max){
			printc(c,2);
		}else if(cus(p,c,6) == count_max){
			printc(c,6);
		}else if(cus(p,c,4) == count_max){
			printc(c,4);
		}else if(cus(p,c,1) == count_max){
			printc(c,1);
		}else if(cus(p,c,3) == count_max){
			printc(c,3);
		}else if(cus(p,c,7) == count_max){
			printc(c,7);
		}else{
			printc(c,5);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define il inline
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define rep0(i, n) for(int i = 0; i < (n); i ++)
#define per0(i, n) for(int i = (n) - 1; i >= 0; i --)
#define ept 1e-9
#define INF 0x3f3f3f3f
#define sz(x) (x).size()
#define ALL(x) (x).begin(), (x).end()
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int N = 3e5 + 10, mod = 998244353;

ll fac[N], inv[N];
ll k, a, b;
int n;

ll C(int n,int k)
{
	return fac[n] * inv[k] % mod * inv[n - k] % mod;
}

int main()
{
	fac[0] = inv[0] = inv[1] = 1;
	rep(i, 2, 300000)
		inv[i] = mod - (mod / i) * inv[mod % i] % mod;
	rep(i, 1, N - 1)
	{
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = inv[i - 1] * inv[i] % mod;
	}
	scanf("%d%lld%lld%lld",&n,&a,&b,&k);
	ll ans = 0;
	rep(i, 0, n)
	{
		if(a * i > k) break;
		if((k - a * i) % b || (k - a * i) / b > n) continue;
		ans += C(n, i) * C(n, (k - a * i) / b) % mod;
	}
	printf("%lld\n", ans % mod);
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> P(N);
  for (int i = 1; i <= N; i++) {
    int p;
    cin >> p;
    P[i - 1] = make_pair(p, i);
  }
  sort(P.begin(), P.end(), greater<pair<int, int>>());

  ll ans = 0;
  multiset<ll> S = {0, 0, N + 1, N + 1};
  S.insert(P[0].second);
  for (int i = 1; i < N; i++) {
    int p = P[i].second;
    S.insert(p);
    auto it = S.find(p);
    ll r1 = *next(it);
    ll r2 = *next(it, 2);
    ll l1 = *prev(it);
    ll l2 = *prev(it, 2);
    ans += ((r2 - r1) * (p - l1) + (l1 - l2) * (r1 - p)) * P[i].first;
  }
  cout << ans << endl;
}


Measured memory_bytes: 5760
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import Text.Printf

readInt = ( readLn :: IO Int )
getInts = map ( read :: String -> Int ) . words <$> getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ a, b, x ] :: [ Integer ] <- map read . words <$> getLine
	print $ ( b `div` x ) - ( ( a - 1 ) `div` x )


Measured memory_bytes: 508
#include <iostream>
#include <vector>
using namespace std;

void output(vector<int> a, int n){
    for(int i = 0; i < n-1; i++) cout << a.at(i) << " ";
    cout << a.at(n-1) << endl;
}

void isort(vector<int> a, int n){
    for(int i = 1; i < n; i++){
        int tmp = a.at(i);
        int j = i-1;
        for(; j >= 0 && a.at(j) > tmp; j--) a.at(j+1) = a.at(j);
        a.at(j+1) = tmp;
        output(a, n);
    }
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a.at(i);

    output(a, n);
    isort(a, n);
    
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c, a*d, b*c, b*d});   
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<20;
const ll INF=1LL<<60;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N,X;cin>>N>>X;
    vector<ll> S(N+1);
    for(int i=0;i<N;i++){
        cin>>S[i+1];
        S[i+1]+=S[i];
    }
    
    ll ans=INF;
    
    for(int k=1;k<=N;k++){
        ll sum=X*(N+k);
        sum+=2*(S[N]-S[N-k]);
        ll now=N;
        for(ll j=1;j<=(N+k-1)/k;j++){
            sum+=(2*j+1)*(S[now]-S[max(0LL,now-k)]);
            now-=k;
            
            if(sum>ans) break;
        }
        
        ans=min(ans,sum);
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 1920
#include <stdio.h>
#include <math.h>

int main(void)          
{
	long long int n, s[10001];
	double a, sum = 0;
	int i;
	while (1 > 0) 
	{
		a = 0;
		sum = 0;
		scanf("%lli", &n);
		if (n == 0) break;

		for (i = 0; i < n; i++) 
		{
			scanf("%lli", &s[i]);
			sum += s[i];
		}
		for (i = 0; i < n; i++)
		{
			a += (s[i] - sum / n) * (s[i] - sum / n);
			s[i] = 0;
		}
		printf("%f\n", sqrt(a / n));
	}

	return 0;
}

Measured memory_bytes: 648
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long

long long powerexp(long long base, long long exp) {
   long long res = 1;
   while (exp > 0) {
      if (exp % 2 == 1)
         res= (res * base) ;
      exp = exp >> 1;
      base = (base * base) ;
   }
   return res;
}
map<int,int> get_Factors(int n)
{
    int count = 0; 
    map<int,int>temp;
    while (!(n % 2)) { 
        n >>= 1; // equivalent to n=n/2; 
        count++; 
    } 
  
    if (count) 
        temp[2]=count;
  
    for (long long i = 3; i <= sqrt(n); i += 2) { 
        count = 0; 
        while (n % i == 0) { 
            count++; 
            n = n / i; 
        } 
        if (count) 
            temp[i]=count; 
    } 
  
    if (n > 2) 
       temp[n]=1;
   return temp;
}
signed main() 
{
    IOS;    
    int n,p;
    cin>>n>>p;
    
    if(n==1)cout<<p;
    else{
        int ans=1;
        map<int,int>mp=get_Factors(p);
        for(auto it=mp.begin();it!=mp.end();it++){
            if((it->second)>=n)ans*=powerexp(it->first,it->second/n);
        }
        cout<<ans;
    }
    
    return 0; 
} 

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    int a, b, c; cin >> a >> b >> c;
    if(a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3176
#include <stdio.h>

int main()
{
    int n,x;
    int w;
    int i,j,k;
    
    while(1){
        scanf("%d %d",&n,&x);
        if(n==0 && x==0)break;
    w = 0;
    for(i=1; i<=n-2;i++){
        for(j=i+1;j<=n-1;j++ ){
            for(k=j+1;k<=n;k++){
                if((i+j+k) == x){
                    w ++; 
                }
            }            
        }
    }
    printf("%d\n",w);
    }
    return 0;
}


Measured memory_bytes: 2064
//https://atcoder.jp/contests/abl/tasks/abl_c
//查并集
#include <bits/stdc++.h>

using namespace std;

const int MAXM=1e5+4;
int f[MAXM];

int find(int x) {
    if (x==f[x]) {
        return x;
    } else {
        f[x]=find(f[x]);
        return f[x];
    }
}

int main() {
    int now=0;
    int n,m;
    cin>>n>>m;
    for (int i=1; i<=n; i++) {
        f[i]=i;
    }
    
    for (int i=1; i<=m; i++) {
        int a,b;
        cin>>a>>b;
        
        a=find(a);
        b=find(b);

        if (a==b) {
            continue;
        }

        f[b]=a;
        now++;
    }

    cout<<n-1-now<<"\n";
    
    return 0;
}

Measured memory_bytes: 3912
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    if(a1+a2+a3 >= 22){
        cout << "bust" << endl;
    }
    else{
        cout << "win" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]

si, sj = 0, 0
c = 0
while si <= n - m:
    ni, nj = si, sj
    rest = m ** 2
    for i in range(m):
        nj = sj
        for j in range(m):
            # print(ni, nj, i, j)
            if a[ni][nj] != b[i][j]:
                break
            nj +=1
            rest -= 1
        ni += 1
        # print()
    if rest == 0:
        print("Yes")
        exit()
    sj += 1
    if sj > n - m:
        si += 1
        sj = 0

print("No")
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
using ll = long long;

double n,m,a,b,h;
string s,t;

int main() {
  cin >> a >> b >> h >> m;
  printf("%.10f\n",sqrt(a*a+b*b-2*a*b*cos(((60*h+m)/720-m/60)*2*M_PI)));
}

Measured memory_bytes: 4180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<int,int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,t;
    cin>>a>>b>>t;
    int now=a;
    int ans=0;
    while(now<t+1){
      ans+=b;
      now+=a;
      //cout<<now<<'\n';
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
while True:
    h,w = map(int,input().split())
    
    if h == 0 and w == 0:
        break
    for i in range(h):
        for j in range(w):
            if i == 0 or i == h-1 or j == 0 or j == w-1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 7008
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = gets.to_i

print a[K-1]

Measured memory_bytes: 1788
function gets(str){
  this._s = str.split("\n");
  this._y = 0;
};
gets.prototype = {
  a: function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y] = s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  },
  l: function(f){
    var s = this._s[this._y++].split(" ");
    return f?s:s.map(a=>+a);
  },
  m: function(n,f){
    var s = this._s, y = this._y, r = [], i = 0;
    if(f)for(;i < n; i++)r[i] = s[y+i].split(" ");
    else for(;i < n; i++)r[i] = s[y+i].split(" ").map(a=>+a);
    this._y += n;
    return r;
  },
};
var o=new gets(require("fs").readFileSync("/dev/stdin","utf8"));
var mod = 1e9 + 7;
var fact=[1,1];
function factmod(n){for(var i=fact.length;i<=n;)fact[i]=abmod(fact[i-1],i++);return fact[n];}
function modinv(a){var b=mod,u=1,v=0,t;while(b){t=a/b|0;a-=t*b;u-=t*v;t=a;a=b;b=t;t=u;u=v;v=t;}u%=mod;return u<0?u+mod:u;}
function nCrmod(n,r){return abmod(factmod(n),modinv(factmod(r)),modinv(factmod(n-r)));}
function abmod(){var a=arguments,r=a[0],i=1;for(;i<a.length;)r=((r>>16)*a[i]%mod*65536+(r&65535)*a[i++])%mod;return r;}

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  if(m === 1)return 1;
  var a = {};
  while(m % 2 === 0){
    if(a[2])a[2]++;
    else a[2] = 1;
    m /= 2;
  }
  for(var i = 3; i <= Math.sqrt(m); i += 2){
    while(m % i === 0){
      if(a[i])a[i]++;
      else a[i] = 1;
      m /= i;
    }
  }
  if(m !== 1) a[m] = 1;
  var ans = 1;
  for(i in a){
    ans = abmod(ans, nCrmod(a[i] + n - 1, a[i]));
  }
  return ans;
}

Measured memory_bytes: 14156
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>

using namespace std;
using ll = long long int;

int main()
{
  int a1, a2, a3, b1, b2, b3;
  cin >> a1 >> a2 >> a3 >> b1 >> b2 >> b3;
  vector<int> town(4, 0);
  town[a1 - 1]++;
  town[a2 - 1]++;
  town[a3 - 1]++;
  town[b1 - 1]++;
  town[b2 - 1]++;
  town[b3 - 1]++;
  bool can = true;
  for(auto e : town)
  {
    if(e >= 3)
    {
      can = false;
    }
  }
  if(can)
  {
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 888
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <bitset>
#include <queue>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define sqr(x) (x)*(x)
typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;
    cout << t << s;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define em emplace_back
#define test ll t;cin>>t;while(t--)
#define M 1000000007
#define input ll x;cin >> x
ll gcd(ll a, ll b) { return (b == 0) ? a : gcd(b, a % b); }

int main () {
	ios_base::sync_with_stdio(false); 
    cin.tie(nullptr);
	int count = 0;
	int maxi = INT_MIN;
	test {
		pair<int, int> p;
		cin >> p.first >> p.second;
		if(p.first == p.second){
			count++;
		}
		else {
			if(count > maxi) maxi = count;
			count = 0;
		}
	}
	if(count>maxi)
		maxi = count;
	if(maxi >= 3)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>
using namespace std;
int main()
{
	int  k, x;
	cin >> k >> x;

	int counter = k*2 - 1;

	for (int i = x - k + 1; i <= x + k -1; i++) {
		cout << i << " ";
	}
}

Measured memory_bytes: 256
// atcoder/abc157/E/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr lli mod = 1e9 + 7;

template<typename T>
struct SegTree {
  int n;
  vector<T> dat;
  using F = function<T(T, T)>;
  F fn;
  T e;
  SegTree(int n_, T e_, F fn_) {
    e = e_;
    fn = fn_;
    n = 1;
    while (n < n_) n *= 2;
    dat.resize(2 * n - 1, e);
  }

  void update(size_t k, T a) {
    k += n - 1;
    dat[k] = a;
    while (k > 0) {
      k = (k - 1) / 2;
      dat[k] = fn(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
    return ;
  }

  T operator [] (size_t idx) const {
    return dat[idx + n - 1];
  }

  T query(size_t a, size_t b) {
    return query(a, b, 0, 0, n);
  }

  T query(size_t a, size_t b, size_t k, size_t l, size_t r) {
    if (r <= a || b <= l) return e;
    if (a <= l && r <= b) return dat.at(k);

    T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);

    return fn(vl,vr);
  }
};
// SegTree<int> rmq(a.size(), -(1 << 29), [] (int a, int b) { return max(a, b); });
// SegTree<int> rmq(a.size(), +(1 << 29), [] (int a, int b) { return min(a, b); });

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

  int n, q;
  str s;
  while (cin >> n >> s >> q) {
    const int N = 500000 + 5;

    SegTree<int> freq(N, 0, [] (int a, int b) { return a | b; });

    for (int i = 0; i < s.size(); ++i) {
      freq.update(i, 1 << (s[i] - 'a'));
    }

    for (int _ = 0; _ < q; ++_) {
      int t;
      cin >> t;
      if (t == 1) {
        int i;
        char c;
        cin >> i >> c;
        --i;
        freq.update(i, 1 << (c - 'a'));
      }
      if (t == 2) {
        int begin, end;
        cin >> begin >> end;
        --begin;
        cout << __builtin_popcount(freq.query(begin, end)) << endl;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 5020
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<algorithm>
#include<set>
#include <stdexcept>
#include<queue>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
typedef long long ll;
typedef pair<int,int> P;
int ceil(int a,int b){// a以上でbの倍数の最小値を出力//
    return (a+b-1)/b*b;
}
int stoii(string s){//stoi関数の代用 文字列を数値として読み取りint型に変換//
    return atoi(s.c_str());
}

int R,C;
int sy,sx;
int gy,gx;
string c[51];
void solve(){
	queue<P> qp;
	qp.push({sy,sx});
}
int main(){
	int n;
	cin>>n;
	if(n>=1000) cout<<"ABD"<<endl;
	else cout<<"ABC"<<endl;
	return 0;
}	

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
	unsigned int n;
	string s;
	cin >> n >> s;
	
	vector<unsigned int> er(n);
	vector<unsigned int> wr(n);
	wr[0] = (s[0] == 'W');
	er[0] = (s[0] == 'E');
	for (unsigned int i = 1; i < n; ++i) {
		wr[i] = wr[i - 1] + (s[i] == 'W');
		er[i] = er[i - 1] + (s[i] == 'E');
	}
	
	unsigned int result = n;
	for (unsigned int i = 0; i < n; ++i) {
		unsigned int count = 0;
		if (i > 0) {
			count += wr[i - 1];
		}
		
		count += er[n - 1] - er[i];
		
		if (result > count) {
			result = count;
		}
	}
	
	cout << result << endl;
}

Measured memory_bytes: 3076
#include<iostream>
#include<utility>
#include<cstring>
#include<set>
using namespace std;

int cnt;
set<string> ans;
int tmp;

int rec(string s,int pos,bool u[26]){
  if(pos==s.length()){
    ans.insert(s);
    if(ans.size()>10){
      set<string>::iterator ite=ans.begin();
      for(int i=0;i<5;i++)ite++;
      ans.erase(ite);
    }
    tmp++;
    return 0;
  }
  bool *used;
  used = new bool[26];
  for(int i=0;i<26;i++) used[i]=u[i];
  if(s[pos]=='a'){
    used[0]=true;
    rec(s,pos+1,used);
    used[0]=false;
    if(used[1]!=true){
      used[1]=true;
      s[pos]++;
      rec(s,pos+1,used);
    }
  }else if(s[pos]=='z'){
    if(used[25]==false){
      return 0;
    }else{
      rec(s,pos+1,used);
    }
  }else if(used[s[pos]-'a']==true){
    rec(s,pos+1,used);
    if(used[s[pos]-'a'+1]!=true){
      used[s[pos]-'a'+1]=true;
      s[pos]++;
      rec(s,pos+1,used);
    }
  }else{
    if(used[s[pos]-'a'+1]!=true){
      used[s[pos]-'a'+1]=true;
      s[pos]++;
      rec(s,pos+1,used);
    }
  }
  delete[] used;
  return 0;
}

int main(){
  string s;
  while(cin>>s){
    ans.clear();
    cnt = 0;
    tmp = 0;
    if(s=="#")break;
    bool used[26];
    memset(used,0,sizeof(used));
    rec(s,0,used);
    cout << tmp << endl;
    for(string i : ans){
      if(cnt<5){
	cout << i << endl;
      }else if(cnt>ans.size()-6){
	cout << i << endl;
      }
      cnt++;
    }
  }
  return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int INF=1010101001;
queue<int> q;
void push(int,int,vector<int>&);

int main(){
    int n,x,y;
    cin>>n>>x>>y;
    x--; y--;
    vector<int> ans(n);
    int r;
    
    for(int i=0;i<n;i++){
        vector<int>v(n,INF);
        q.push(i);
        v[i]=0;
        while(!q.empty()){
          r=q.front();q.pop();
          int d=v[r];
          if(r-1>=0) push(r-1,d+1,v);
          if(r+1<n) push(r+1,d+1,v);
          if(r==x) push(y,d+1,v);
          if(r==y) push(x,d+1,v);
        }
        for(int j=0;j<n;j++){
            ans[v[j]]++;
        }
    }
    for(int i=1;i<n;i++){
        cout<<ans[i]/2<<endl;
    }
    return 0;
}

void push(int i,int d,vector<int>& v){
    if(v[i]!=INF){
        return;
    }else{
        q.push(i);
        v[i]=d;
        return;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();

		int ans = 0;
		for (int i = 0; i < n; i++) {
			char charA = a.charAt(i);
			char charB = b.charAt(i);
			char charC = c.charAt(i);

			if (charA != charB && charB != charC && charC != charA) {
				ans += 2;
			} else if (charA != charB || charB != charC || charC != charA) {
				ans++;
			}
		}

		System.out.println(ans);

		sc.close();
	}

}


Measured memory_bytes: 21844
import sys
input = sys.stdin.readline
def main():
    N = int( input())
    A, B = [], []
    for _ in range(N):
        a, b = map( int, input().split())
        A.append(a)
        B.append(b)
    A.reverse()
    B.reverse()
    cnt = 0
    for i in range(N):
        if (A[i]+cnt)%B[i] == 0:
            continue
        cnt += B[i] - (A[i]+cnt)%B[i]
    print(cnt)
if __name__ == '__main__':
    main()


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define fi first
#define se second

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    ll n,m;
    cin>>n>>m;
    vi d(100000+1,0);
    ll a=0,w=0;
    vi ww(100000+1,0);
    rep(i,m){
        ll q;
        cin>>q;
        string s;
        cin>>s;
        if (s=="AC"){
            if (d[q]==1)continue;
            else{
                d[q]=1;
                a+=1;
                w+=ww[q];
            }
        }
        else{
            if (d[q]==1)continue;
            else ww[q]+=1;
        }
    }
    cout<<a<<" "<<w<<endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int>> t(n);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    t.at(a).push_back(b);
    t.at(b).push_back(a);
  }
  vector<int> l(n,n+1);
  l[0]=0;
  set<vector<int>> s;
  for(int i=0;i<n;i++)
    s.insert({l[i],i});
  vector<int> g(n,n+1);
  while(!s.empty()){
    vector<int> p=*begin(s);
    s.erase(p);
    for(int x:t.at(p.at(1))){
      if(s.count({l[x],x})){
        s.erase({l[x],x});
        if(p.at(0)+1<l[x]){
          l[x]=p.at(0)+1;
          g[x]=p.at(1);
        }
        s.insert({l[x],x});
      }
    }
  }
  cout<<"Yes"<<endl;
  for(int i=1;i<n;i++)
    cout<<g[i]+1<<endl;
}

Measured memory_bytes: 19248
n = int(input())
p = list(map(float,input().split()))

dp = [[0]*3100 for _ in range(3100)]

dp[0][0] = 1

# dp[i][j] := 最初の i 枚のコインを投げたときに、表が j 枚となる確率

for i in range(n):
    for j in range(i+1):
        dp[i+1][j+1] += dp[i][j] * p[i]
        dp[i+1][j] += dp[i][j] * (1-p[i])

res = 0
for j in range(n//2+1,n+1):
    res += dp[n][j]
print(res)

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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()
#define what_is(x) #x << " is " << (x)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

int a, b, c;

int main() {
	megaRandom();
	cin >> a >> b >> c;
	if(a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << 0;
	} else {
		cout << min({1ll * a * b, 1ll * a * c, 1ll * b * c});
	}
	return 0;  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int n, a; cin >> n >> a;
	cout << n * n - a << endl;
}


Measured memory_bytes: 256
w,h,n = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(n)]
 
xmin,xmax,ymin,ymax = 0,w,0,h
 
for a in A:
  if a[2] == 1:
    xmin = max(xmin, a[0])
  if a[2] == 2:
    xmax = min(xmax, a[0])
  if a[2] == 3:
    ymin = max(ymin, a[1])
  if a[2] == 4:
    ymax = min(ymax, a[1])
    
S = (xmax-xmin) * (ymax-ymin)
if S < 0 or xmin > xmax or ymin > ymax:
  S = 0
print(S)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep(i,n) FOR(i,0,n-1)
 
int d[105];

int main(){
	
	string a,b;cin>>a>>b;
	string c = a+b;
	int num = stoi(c);
	
	rep(i,1000)
	{
		if(i*i == num)
		{
			cout << "Yes"<<endl;
			return 0;
		}
	}
	
	cout << "No" << endl;
}

//cout << ans << endl;

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip>

using namespace std;

int main(int argc, char const* argv[])
{
	double r;
	cin >> r;

	cout << fixed << setprecision(6) << M_PI * r * r
		<< " "
		<< fixed << setprecision(6) << M_PI * r * 2
		<< endl;
	return 0;
}


Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()


struct SegmentTree{
    private:
        int n;
        vector<map<char,int>> node;
    
    public:
        SegmentTree(string v){
            int sz = v.size();
            n = 1; while(n < sz) n *= 2;
            node.resize(2 * n - 1);
            for(int i = 0; i < sz; i++) node[i+n-1][v[i]]++;
            for(int i = n - 2; i >= 0; i--){
                for(auto e: node[2*i+1]) node[i][e.first]+=e.second;
                for(auto e: node[2*i+2]) node[i][e.first]+=e.second;
            }
        }

        void update(int x, char val){
            x += n - 1;
            if(node[x][val] == 1) return;
            char E = '0';
            for(auto e: node[x])if(e.second > 0){
                E = e.first;
                node[x][E]--;
            }
            node[x][val]++;
            while(x > 0){
                x = (x - 1) / 2;
                node[x][E]--;
                node[x][val]++;
            }
        }

        map<char, int> get(int a, int b, int k = 0, int l = 0, int r = -1){
            if(r < 0) r = n;
            map<char,int> MP;
            if(r <= a || b <= l) return MP;
            if(a <= l && r <= b) return node[k];

            auto vl = get(a, b, 2*k+1, l, (l+r)/2);
            auto vr = get(a, b, 2*k+2, (l+r)/2, r);
            for(auto e: vl) MP[e.first] += e.second;
            for(auto e: vr) MP[e.first] += e.second;
            return MP;
        }
};

int main(){
    int N; cin >> N;
    string S; cin >> S;
    int Q; cin >> Q;
    SegmentTree seg(S);
    while(Q--){
        int q; cin >> q;
        if(q == 1){
            int i;
            char c; cin >> i >> c; i--;
            seg.update(i, c);
        }else{
            int l, r; cin >> l >> r; l--, r--;
            auto M = seg.get(l, r + 1);
            int cnt =0;
            for(auto e: M) if(e.second > 0) cnt++;
            cout << cnt << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 192664
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

#include<unistd.h>
struct Buffer{
    int idx;
    enum { chunk = 1 << 16 };
    char buf[chunk];
    Buffer(){ init(); }
    void init(){ idx = 0; read(0, buf, chunk); }
    void check(){ if(idx == chunk){ init(); } }
    int next(){
        static char notDigits[256] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1, 0,0,0,0,0,0,0,0,0,0,};
        int ret = 0, sign = 1;
        while(check(), notDigits[(int)buf[idx]]){ idx++; }
        if(check(), buf[idx] == '-'){ sign = -1; idx++; }
        while(check(), !notDigits[(int)buf[idx]]){ ret = ret * 10 + buf[idx++] - '0'; }
        return sign * ret;
    }
};

int main(){
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    Buffer buf;
    const int lim = 1e5;
    vector<int> prime(lim + 1, true);
    prime[0] = prime[1] = false;
    for(int i = 2; i <= lim; i++){
        if(prime[i]){
            for(int j = i + i; j <= lim; j += i){
                prime[j] = false;
            }
        }
    }
    vector<int> accs(lim + 1);
    for(int i = 1; i <= lim; i++){
        accs[i] = accs[i - 1] + (i & 1 && prime[i] && prime[(i + 1) / 2]);
    }
    // int q; cin >> q;
    int q = buf.next();
    for(int i = 0; i < q; i++){
        // int l, r;
        // cin >> l >> r;
        int l = buf.next(), r = buf.next();
        cout << accs[r] - accs[l - 1] << '\n';
    }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
 
#define rep(i, n)      for (int i = 0; i < (n); i++)
#define repr(i, n)     for (int i = (n) - 1; i >= 0; i--)
#define repe(i, l, r)  for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r) - 1; i >= (l); i--)
#define repi(i, l, r)  for (int i = (l); i <= (r); i++)
#define repir(i, l, r) for (int i = (r); i >= (l); i--)
#define range(a) a.begin(), a.end()
void init_io() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(15); }
 
using namespace std;
using ll = long long;

int main() { init_io();
  int N; cin >> N;
  vector<int> L(N), R(N);
  rep(i, N) cin >> L[i] >> R[i], R[i]++;
  int p = max_element(range(L)) - L.begin();
  int q = min_element(range(R)) - R.begin();
  vector<pair<int, int>> ab(N);
  rep(i, N) {
    ab[i].first  =  max(0, R[i] - L[p]);
    ab[i].second = -max(0, R[q] - L[i]);
  }
  sort(range(ab));
  vector<int> pref(N + 1, INT_MAX);
  rep(i, N) {
    pref[i + 1] = min(pref[i], -ab[i].second);
  }
  vector<int> suff(N + 1, INT_MAX);
  repr(i, N) {
    suff[i] = min(suff[i + 1], ab[i].first);
  }
  int ans = 0;
  {
    int cnt = max(0, R[q] - L[p]);
    int mx = 0;
    rep(i, N) if (i != p && i != q) {
      mx = max(mx, R[i] - L[i]);
    }
    ans = max(ans, cnt + mx);
  }
  repe(i, 1, N) {
    ans = max(ans, pref[i] + suff[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
const ll INF = 1E+18;


int main(){
    ll h, w;
    cin >> h >> w;
    ll ans = INF;
    rep(i, h) {
        ll ih = h - i;
        ll iw = w;
        vector<ll> v;
        v.push_back(w*i);
        if (ih%2==0 || iw%2==0) {
            v.push_back(ih*iw/2);
        }
        else {
            ll x = min(ih, iw);
            v.push_back((ih*iw-x)/2);
            v.push_back((ih*iw+x)/2);
        }
        sort(whole(v));
        ll res = v.back() - v[0];
        chmin(ans, res);        
    }
    swap(h, w);
    rep(i, h) {
        ll ih = h - i;
        ll iw = w;
        vector<ll> v;
        v.push_back(w*i);
        if (ih%2==0 || iw%2==0) {
            v.push_back(ih*iw/2);
        }
        else {
            ll x = min(ih, iw);
            v.push_back((ih*iw-x)/2);
            v.push_back((ih*iw+x)/2);
        }
        sort(whole(v));
        ll res = v.back() - v[0];
        chmin(ans, res);        
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
//

fun main() {
    abc171c()
}

fun abc171c() {
    val n = readLine()!!.toLong()
    var tmp = n
    var name = ""
    val nameTable = ('a'..'z').toList()
    while (tmp > 0L) {
        tmp -= 1
        val r = tmp % 26
        name = "${nameTable[r.toInt()]}$name"
        tmp /= 26
    }
    println(name)
}


Measured memory_bytes: 35548
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<pair<string,int>> S;
  set<string> S2;
  for (int i = 0; i < N; i++){
    string s;
    cin >> s;
    if (S2.count(s)){
      for (int j = 0; j < S.size(); j++){
        if (S[j].first == s) S[j].second++;
      }
    } else {
      S.push_back(make_pair(s,1));
      S2.insert(s);
    }
  }
  int M;
  cin >> M;
  for (int i = 0; i < M; i++){
    string t;
    cin >> t;
    if (S2.count(t)){
      for (int j = 0; j < S.size(); j++){
        if (S[j].first == t) S[j].second--;
      }
    }
  }
  int res = 0;
  for (int i = 0; i < S.size(); i++) res = max(res,S[i].second);
  cout << res;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)

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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////

ll dp[310][310];

int main() {
    while (1) {
        int n;
        cin >> n;
        if (!n) break;
        vector<int> w(n);
        rep(i,n) cin >> w[i];
        memset(dp, 0, sizeof(dp));

        repf(width, 2, n+1) rep(left,n) {
            int right = left + width - 1;
            if (right >= n) continue;

            if (dp[left+1][right-1] == width-2 && abs(w[left]-w[right]) <= 1) {
                dp[left][right] = width;
            }

            repf(mid, left, right) {
                chmax(dp[left][right], dp[left][mid]+dp[mid+1][right]);
            }
        }
        cout << dp[0][n-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3856
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,k,x,ans=0,i;
    cin>>n>>k;
    for (i=0;i<n;i++)
    {
        cin>>x;
        ans+=2*min(x,k-x);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
let sum a b n =
  let rec iter c s m =
    if m = 0 then s
    else iter ((10 * c) mod b) ((10 * c) / b + s) (m - 1) in
  iter (a mod b) 0 n
  
let _ =
  try
    while true do
      let s = Scanf.scanf "%d %d %d\n" sum in
      Printf.printf "%d\n" s
    done
  with
    End_of_file -> ()

Measured memory_bytes: 2392