akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(N: int, H: "List[int]"):

    H[0] = H[0]-1
    for i in range(1, N):
        if H[i-1]+1 == H[i]:
            H[i] -= 1
        elif H[i-1] == H[i]:
            H[i] = H[i]
        elif H[i-1] > H[i]:
            no()
            return
        else:
            H[i] -= 1
    yes()

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    H = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, H)


if __name__ == '__main__':
    main()


Measured memory_bytes: 15876
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <map>

using namespace std;

int n,m;

int kx,ky;
int field[11][11];
int home;
const int INF=1000000000;

int cnt=0;

void dfs(int x,int y){
	if(home==0){
		if(x==kx||y==ky){
			cnt++;
			return;
		}
	}
	else{
		for(int i = y-1; i >= 0; i--){
			if(field[i][x]==1){
				field[i][x]=0;
				home--;
				dfs(x,i);
				home++;
				field[i][x]=1;
				break;
			}
		}
		for(int i = y+1; i < n; i++){
			if(field[i][x]==1){
				field[i][x]=0;
				home--;
				dfs(x,i);
				home++;
				field[i][x]=1;
				break;
			}
		}

		for(int i = x-1; i >= 0; i--){
			if(field[y][i]==1){
				field[y][i]=0;
				home--;
				dfs(i,y);
				home++;
				field[y][i]=1;
				break;
			}
		}
		for(int i = x+1; i < m; i++){
			if(field[y][i]==1){
				field[y][i]=0;
				home--;
				dfs(i,y);
				home++;
				field[y][i]=1;
				break;
			}
		}
	}

}

int main(){

	while(cin>>m>>n&&!(n==0&&m==0)){
		home=0;
		cnt=0;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				cin>>field[i][j];
				if(field[i][j]==2){
					kx=j;
					ky=i;
				}
				else if(field[i][j]==1)
					home++;
			}
		}
		dfs(kx,ky);
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 868
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
using namespace std;

int get(int N,int K){
    int res = 0;
    int point = N;
    for(;;){
        if(point >= K ) return res;
        point *= 2;
        res++;
    }
}


//累乗を高速に（MODとってないよ！！！！！！）
double my_pow(double a,int b){
  double res;
  if(b==0) return 1;
  if(b==1) return a;
  if(b % 2 == 0){
    res = my_pow(a,b/2);
    return res * res;
  } else {
    res = my_pow(a,b/2);
    return res * res * a;
  }
}




int main(){
     double N;
  int K;cin>>N>>K;

   double ans = 0;
  for(int i=1;i<=int(N);i++){
      int num = get(i,K);
      //cout<<num<<" "<<my_pow(0.50,num)<<endl;
      ans += my_pow(0.50,num);
      //cout<<ans<<endl;

  }
  printf("%.16f",ans * (1.00)/N);
  cout<<endl;

    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

// 素因数分解
set<ll> prime_factorize(ll N) {
    set<ll> res;
    for (ll i = 2; i * i <= N; ++i) {
        while (N % i == 0) {
            if (res.find(i) == res.end()){res.insert(i);}
            N /= i;
        }
    }
    if (N != 1 && res.find(N) == res.end()){res.insert(N);}
    return res;
}

void Main() {
    ll N; cin >> N;
    vector<ll> A(N); rep(i, N){cin >> A.at(i);}

    set<ll> res = prime_factorize(A.at(0));
    set<ll> pw_set = res;
    set<ll> sw_set = res;

    bool is_pw = true, is_sw = true;
    rep(i, N - 1){
        ll a = A.at(i + 1);
        set<ll> res = prime_factorize(a);
        set<ll> tmp;
        for (auto r: res){
            if (pw_set.find(r) == pw_set.end()){
                pw_set.insert(r);
            } else {
                is_pw = false;
            }
            if (sw_set.find(r) != sw_set.end()){tmp.insert(r);}
        }
        sw_set = tmp;
    }
    if (is_pw){
        cout << "pairwise coprime" << endl;
    } else if (sw_set.size() == 0){
        cout << "setwise coprime" << endl;
    } else {
        cout << "not coprime" << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 14692
#include<iostream> 
#include<fstream>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<vector> 
#include<array>
#include<deque>
#include<list>
#include<forward_list>
#include<stack>
#include<queue>
#include<algorithm>
#include<numeric>
#include<iterator>
#include<functional>
#include<map>
#include<unordered_map>
#include<set>
#include<utility>
#include<unordered_set>
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define sort_all(v) sort(v.begin(), v.end())
#define fill(a) memset(a, 0, sizeof(a))

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


void test() {
    int x;
    cin >> x;
    printf("%d", x ? 0 : 1);
}   
 
int main ()     
{
    // int t;
    // cin >> t;
    // while(t--) 
        test();
}


Measured memory_bytes: 3688
// #include <bits/stdc++.h>
#include <iostream>
// #include <cmath>
// #include <iomanip>
#include <string>
using namespace std;
 
int main() {
    int h, w;
    while (true) {
        cin >> h >> w;
        if ( h== 0 && w == 0) {
            break;
        }
        string line = string(w, '#');
        for (int i=0;i<h;i++) {
            cout << line << endl;
        }
        cout << endl;
    }
    return 0;
}



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

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

    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200) {
        cout << s << endl;
    }
    else {
        cout << "red" << endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;

using namespace std;

typedef long long ll;
typedef pair<int,int> PII;

template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int n;
int ans;
string s[111];
bool r[111],c[111];
int main()
{
    //~ freopen("file.in", "r", stdin);
    int m;
    scanf("%d",&n);scanf("%d",&m);
	for(int i=0;i<n;i++){
		cin>>s[i];
		for(int j=0;j<m;j++)
			if(s[i][j]=='#'){
				r[i]++;
				c[j]++;
			}
	}
//	for(int i=0;i<n;i++){
//		cerr << r[i] << ' ' << c[i] << endl;
//	}
	for(int i=0;i<n;i++){
		if(!r[i])
			continue;
		for(int j=0;j<m;j++)
			if(c[j]>0)
				cout << s[i][j];
		puts("");
	}			
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; 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>;
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; }

int a[3005][3005];
ll dp[3005][3005][4];

int main(){
    int R, C, n;
    cin >> R >> C >> n;
    rep(i,n){
        int r, c, v;
        cin >> r >> c >> v;
        a[r-1][c-1] = v;
    }

    rep(i,R) rep(j,C){
        for(int k = 2; k >= 0; k--){
            chmax(dp[i][j][k+1], dp[i][j][k] + a[i][j]);
        }

        rep(k, 4){
            chmax(dp[i+1][j][0], dp[i][j][k]);
            chmax(dp[i][j+1][k], dp[i][j][k]);
        }
    }

    ll ans = 0;
    rep(k, 4){
        chmax(ans, dp[R-1][C-1][k]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 320552
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,a[10000];
    cin>>n>>k;
    for(int i=0;i<n;i++){cin>>a[i];}
    sort(a,a+n);
    int sum=0;
    for(int i=0;i<k;i++){sum=sum+a[i];}
    cout<<sum<<endl;
    return 0;
}


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

using namespace std;

int dp[9][102];

int main(void)
{

  ios_base::sync_with_stdio(0);

  cin.tie(0);
  cout.tie(0);

  int n;
  cin >> n;

  int x = n / 100;
  int y = n % 100;

  dp[0][0] = 0;

  for(int i = 1;i<=y;i++)
    dp[0][i] = INT_MAX;

  for(int i=1;i<=5;i++)
    for(int j=0;j<=y;j++)
      if( j < i )
        dp[i][j] = dp[i-1][j];
      else
        dp[i][j] = min( dp[i-1][j], dp[i][j-i] + 1 );

  if( dp[5][y] <= x )
    cout << 1;
  else
    cout << 0;

  return(0);

}


Measured memory_bytes: 384
/** 
If comrades that you trust gather around you, hope can take physical form and become visible. That’s what I believe.
*/
#include <bits/stdc++.h>
using namespace std;
/**
(▀̿Ĺ̯▀̿ ̿) (ง ͠° ͟ل͜ ͡°)ง
*/
using ll = long long;


auto get(ll a, ll b, ll x) -> ll {
    return (x * a)/ b - a * (x / b);
}
auto main() -> int {
	ios_base::sync_with_stdio(false); cin.tie(0);
    ll a, b, n; cin >> a >> b >> n;
    ll ans = 0;
    if (n < b) {
        cout << a * n  / b << '\n';
        return 0;
    }
    if (n <= 1'000'000) {
        for (int i = 1; i <= n; ++i) {
            ans = max(ans, get(a, b, i));
        }
        cout << ans << '\n';
        return 0;
    }
    if (b >= 1'000'000) {
        for (ll i = b; i <= n; i += b) {
            ans = max(ans, get(a, b, i));
            ans = max(ans, get(a, b, i - 1));
        }
        cout << ans << "\n";
        return 0;
    }
    // b < 1e6
    for (ll i = 1; i <= max(a, b); ++i) {
        ans = max(ans, get(a, b, i));
    }
    cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	int n;
	cin>>n;
	if(n<=81){
		int temp;
		bool cond =false;
		for(int i =1;i<10;i++){
			temp = n/i;
			if(temp < 10 && i * temp == n)
				cond = true;
		}
		if(cond){
			cout<<"Yes";
		}
		else
		{
			cout<<"No";
		}
	}
	else
	{
		cout<<"No";
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  set<int> s;
  rep(i,n){
    int a;
    cin >> a;
    s.insert(a);
  }
  if(s.size()==n)cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int n,i,j,k;
	scanf("%d",&n);
	int cnt[10001];
	for(i=1;i<=10000;i++){
		cnt[i] = 0;
	}
	for(i=1;i<=100;i++){
		for(j=1;j<=100;j++){
			for(k=1;k<=100;k++){
				int tot = i*i + j*j + k*k + i*j + i*k + j*k;
				if(tot <= 10000){
					cnt[tot]++;
				}
			}
		}
	}

	for(i=1;i<=n;i++){
		printf("%d\n",cnt[i]);
	}
	
	return 0;
};

Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <cmath>
#include <typeinfo>


using namespace std;

//  ||
// \

int main() {
	int x = 0, a = 0, b = 0;
	cin >> x >> a >> b;
	int ds = abs(a - x);
	int dsA = abs(b - x);
	if(ds < dsA) {
		cout << "A" << endl;
	}
	else {
		cout << "B" << endl;
	}

    return 0;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] k = line.split(" ");

		Double[] d = new Double[k.length];
		for (int i = 0; i < d.length; i++) {
			d[i] = Double.parseDouble(k[i]);
		}
		double sin = Math.sin(Math.toRadians(d[2]));
		double cos = Math.cos(Math.toRadians(d[2]));

		Double c = Math.sqrt((Math.pow(d[0], 2) + Math.pow(d[1], 2)) - 2 * d[0]
				* d[1] * cos);

		Double men = (sin * d[0] * d[1]) / 2;

		Double shuu = d[0] + d[1] + c;
		Double high = men*2/d[0];

		BigDecimal bighigh = new BigDecimal(high);
		BigDecimal bigshuu = new BigDecimal(shuu);
		BigDecimal bigmen = new BigDecimal(men);
		bighigh.setScale(5, BigDecimal.ROUND_DOWN);
		bigshuu.setScale(5, BigDecimal.ROUND_DOWN);
		bigmen.setScale(5, BigDecimal.ROUND_DOWN);
		System.out.println(bigmen);
		System.out.println(bigshuu);
		System.out.println(bighigh);

	}
}

Measured memory_bytes: 26520
#!/usr/bin/env python3

def main():
    N = int(input())
    S = input()
    # mod = 10**9+7
    # base = 1234
    # power = [1]*(N+1)
    # for i in range(1, N+1):
    #     power[i] = power[i-1]*base%mod
    def check(m):
        dic = {}
        for i in range(N-m+1):
            s = S[i:i+m]
            if s in dic.keys():
                if dic[s]+m<=i:
                    return True
            else:
                dic[s] = i
        return False
    ok = 0
    ng = N+1
    while ng-ok>1:
        mid = (ok+ng)//2

        if check(mid):
            ok = mid
        else:
            ng = mid
    print(ok)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9516
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};


int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int N, L; cin >> N >> L;
    vector<string> vec(N);
    for(int i = 0; i < N; i++) cin >> vec[i];
    sort(vec.begin(), vec.end());
    
    for(auto s : vec)
        cout << s;
    
    return 0;
}


Measured memory_bytes: 256
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    S = input()[:-1]
    
    if S[:1]!="A":
        print("WA")
        return
    if S[2:len(S)-1].count("C")!=1:
        print("WA")
        return
    for i in range(1, len(S)):
        if S[i:i+1].isupper() and S[i:i+1] not in "AC":
            print("WA")
            return
    
    print("AC")


if __name__ == '__main__':
    main()

Measured memory_bytes: 65336
#include <iostream>
#include <stdio.h>
#include <cstring>
using namespace std;

 unsigned long long factorial(int n){
    unsigned long long fact=1;
    const unsigned int M =1000000007;
    for(int counter=1;counter<=n;counter++){
        fact=(fact*counter)%M;
    }
    return fact;

 }
int main (){
     int n; cin>>n;
     cout<<factorial(n);

     return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll              long long
#define rep(i,a,N)      for(ll i=(a);i<(N);i++)
#define INF             ((1LL<<62)-(1LL<<31))
#define max(p,q)        ((p)>(q)?(p):(q))
#define min(p,q)        ((p)<(q)?(p):(q))

int n;
int x[20],y[20],p[20];
ll ans[20];
ll dist[20];

void dfs(int k,int cnt){
	if(k==n){//集落数N=K
		ll sum=0;
		rep(i,0,n)sum+=dist[i]*p[i];//最短距離*人数の和
		ans[cnt]=min(ans[cnt],sum);
		return;
	}
	//素通り
	int temp[20];
	rep(i,0,n)temp[i]=dist[i];
	//memcpy(temp,dist,sizeof(dist))
	dfs(k+1,cnt);
	//x座標
	rep(i,0,n)dist[i]=min(temp[i],abs(x[i]-x[k]));
	dfs(k+1,cnt+1);
	//y座標
	rep(i,0,n)dist[i]=min(temp[i],abs(y[i]-y[k]));
	dfs(k+1,cnt+1);
}
 
 
int main(){
	scanf("%d",&n);
	rep(i,0,n)scanf("%d%d%d",x+i,y+i,p+i);
	rep(i,0,n)dist[i]=min(abs(x[i]),abs(y[i]));//各集落からX軸、Y軸どちらかまでの距離のうち最短距離をdist[]に格納
	rep(i,0,n)ans[i]=INF;//ans[]に極大値を格納
	dfs(0,0);
	rep(i,0,n+1)printf("%lld\n",ans[i]);
}

Measured memory_bytes: 1728
//pragma GCC optimize("Ofast")
//pragma GCC optimize("unroint-loops")
//pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(int i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( int i = a; i >= b ; i-= k)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sz(a) (int) a.size()
#define aint(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
//#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
using namespace std;

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


const int MAX = 1e5+6;
const ll inf = 5e18;
ll mod=998244353;


int main(){
	fastio;
	ll n,m;
	cin>>n>>m;
	cout<<(n*(n-1))/2+(m*(m-1))/2<<endl;
}

Measured memory_bytes: 256
using System;
using System.IO;
using static Scanner;

class Program
{
    static void Main(string[] args) {
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        var thread = new System.Threading.Thread(Solve, 50000000);
        thread.Start();
        thread.Join();
        Console.Out.Flush();
    }
    static void Solve() {
        var N = ScanInt();
        Span<int> T = stackalloc int[N];
        var sum = 0;
        for (int i = 0; i < N; i++) {
            T[i] = ScanInt();
            sum += T[i];
        }
        var M = ScanInt();
        for (int i = 0; i < M; i++) {
            var p = ScanInt() - 1;
            var x = ScanInt();
            Console.WriteLine(sum - T[p] + x);
        }
    }
}

public static class Scanner
{
    private static string[] s = new string[0];
    private static int index;
    public static string Scan() {
        while (true) {
            if (index < s.Length) return s[index++];
            var str = Console.ReadLine();
            while (str == "") str = Console.ReadLine();
            s = str.Split(' ', StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) continue;
            index = 0;
            return s[index++];
        }
    }
    public static int ScanInt() {
        var str = Scan();
        var temp = 0;
        foreach (var let in str) {
            temp = temp * 10 + (let - '0');
        }
        return temp;
    }
}

Measured memory_bytes: 26224
#include <iostream>
#include <cmath>
#include <string>
#include <map>
#include <queue>

using namespace std;

#define N 3
#define N2 9

struct Puzzle
{
  int f[N2];
  int space;
  string path;

  bool operator<(const Puzzle &p)
    const
  {
    for(int i=0;i<N2;i++)
      {
	if(f[i]==p.f[i])
	  {
	    continue;
	  }
      
	return f[i]>p.f[i];
      }
    
    return false;
  }
};

static const int dx[4] = {-1,0,1,0};
static const int dy[4] = {0,-1,0,1};
static const char dir[4] = {'u','l','d','r'};

bool isTarget(Puzzle p)
{
  for(int i=0;i<N2;i++)
    {
      if(p.f[i]!=(i+1))
	{
	  return false;
	}
    }
  return true;
}

string bfs(Puzzle s)
{
  queue<Puzzle> Q;
  map<Puzzle, bool>V;
  Puzzle u,v;
  s.path="";
  Q.push(s);
  V[s]=true;

  while(!Q.empty())
    {
      u=Q.front();
      Q.pop();
      if(isTarget(u))
	{
	  return u.path;
	}
    
      int sx=u.space/N;
      int sy=u.space%N;
    
      for(int r=0;r<4;r++)
	{
	  int tx=sx+dx[r];
	  int ty=sy+dy[r];
      
	  if(tx<0||ty<0||tx>=N||ty>=N)
	    {
	      continue;
	    }
	  v=u;
      
	  swap(v.f[u.space],v.f[tx * N + ty]);
      
	  v.space=tx*N+ty;
      
	  if(!V[v])
	    {
	      V[v]=true;
	      v.path+=dir[r];
	      Q.push(v);
	    }
	}
    }

  return "unsolvable";
}

int main(void)
{
  Puzzle in;

  for(int i=0;i<N2;i++)
    {
      cin>>in.f[i];
      if(in.f[i]==0)
	{
	  in.f[i]=N2;
	  in.space=i;
	}
    }
  
  string ans=bfs(in);
  
  cout<<ans.size()<<endl;

  return 0;
}




Measured memory_bytes: 30476
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
	    String input = Io.read();

	    Searcher searcher = new Searcher();
	    int[] result = searcher.search(input);

        String ans = String.format("%d %d", result[0], result[1]);

        Io.write(ans);
    }
}

class Searcher {
    public int[] search(String input) {
        int[] result = {-1, -1};

        char startStr;
        char nextStr;
        char endStr = 'Z';

        if (input.length() > 2) {
            for (int i = 0; i <= input.length() - 3; i++) {
                startStr = input.charAt(i);
                nextStr = input.charAt(i + 1);
                endStr = input.charAt(i + 2);

                int checkRes = checkSame(startStr, nextStr, endStr);

                if (checkRes != 0) {
                    result[0] = i + 1;
                    result[1] = i + checkRes + 1;
                    break;
                }
            }
        } else {
            startStr = input.charAt(0);
            nextStr = input.charAt(1);
            int checkRes = checkSame(startStr, nextStr, endStr);

            if (checkRes != 0) {
                result[0] = 1;
                result[1] = 2;
            }
        }


        return result;
    }

    private int checkSame(char a, char b, char c) {
        if (a == b) {
            return 1;
        } else if (a == c) {
            return 2;
        } else {
            return 0;
        }
    }
}

class Io {

    /**
     * 標準入力から1行ずつ受け取る
     * @return
     * @throws IOException
     */
    public static String read() throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();

        br.close();
        return line;
    }

    /**
     * 標準出力
     * @param line
     */
    public static void write(String line)
    {
        System.out.println(line);
    }
}


Measured memory_bytes: 24916
use std::io::{stdin, Read};
use std::str::FromStr;

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

#[allow(dead_code)]
fn main() {
    let a = read::<usize>();
    let b = read::<usize>();
    let ab = read::<usize>();
    let x = read::<usize>();
    let y = read::<usize>();

    let end = std::cmp::max(x, y);

    let mut ans = usize::max_value();
    for i in 0..end + 1 {
        let abc = i * 2;
        let ac = if x >= i { x - i } else { 0 };
        let bc = if y >= i { y - i } else { 0 };
        ans = std::cmp::min(ans, ac * a + bc * b + abc * ab)
    }
    println!("{}", ans)
}


Measured memory_bytes: 4352
/// Kazuki Hoshino


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple


int n, k, a[201010], mp[202020], ans=0;
set<int> s;
vi v;

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


cin >> n >> k;

rep(i, 1, n){
cin >> a[i];
mp[a[i]]++;
s.insert(a[i]);
}

for(auto t: s){
    v.pb(mp[t]);
}

sort(all(v));


k = (int)v.size() - k;
int i = 0;
while(k>0){
    ans+=v[i];
    i++;
    k--;
}

cout << ans << endl;


return 0;}
///.... Maria Otonashi


Measured memory_bytes: 12408
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

s = sum(a)

for i in range(N):
    if a[i] >= b[i]:
        a[i] -= b[i]
    else:
        if b[i] - a[i] <= a[i+1]:
            a[i+1] -= b[i] - a[i]
        else:
            a[i+1] = 0
        a[i] = 0



print(s - sum(a))



Measured memory_bytes: 18624
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

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

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

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

#define MOD 1000000007
#define INF (1 << 30)

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

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
    int a = ri();
    int b = ri();
    int c = ri();
    int x = ri();
    int y = ri();
    int res;
    if (x == y) {
        if (a+b <= c+c) res = (a+b)*x;
        else res = c*x*2;
    } else if (x < y) {
        if (b > c+c) res = c*2*y;
        else if (b+a > c+c) res = c*2*x+(y-x)*b;
        else res = x*a+y*b;
    } else if (y<x) {
        if (a > c+c) res = c*2*x;
        else if (a+b>c+c) res = c*2*y+(x-y)*a;
        else res = x*a+y*b;
    }
    cout << res << endl;
 return 0;
}


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

const int INF = 0x3f3f3f3f;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector< vector<int> > a(n, vector<int>(3));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> a[i][j];
    }
  }
  vector< vector<int> > dp(n, vector<int>(3, -INF));
  for (int i = 0; i < 3; i++) {
    dp[0][i] = a[0][i];
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (k != j) {
          dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i][j]);
        }
      }
    }
  }
  cout << *max_element(dp[n - 1].begin(), dp[n - 1].end()) << '\n';
  return 0;
}

Measured memory_bytes: 11136
#include <iostream>

using namespace std;

#define min(a, b) ((a)<(b)? (a):(b))
#define max(a, b) ((a)>(b)? (a):(b))

int main() {
	while(true) {
        int n; cin >> n;
        if(n == 0) break;
	    int sum = 0, s_min = 1024, s_max = -1;
	    for(int i=0; i<n; i++) {
	        int s; cin >> s;
	        sum += s;
	        s_min = min(s_min, s);
	        s_max = max(s_max, s);
	    }
	    cout << (sum - s_min - s_max) / (n - 2) << endl;
	}
}



Measured memory_bytes: 3020
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: i32,
  }

  puts!("{}\n", (n - 1) / 2);
}


Measured memory_bytes: 4352
h = int(input())

div_count = 0
add = 0
total_count = 0

while True:
    if h == 1:
        break
    h = h // 2
    if add == 0:
        div_count += 1
        add += 1
    else:
        div_count += add * 2
        add *= 2

if div_count == 0:
    total_count = 1
else:
    total_count = div_count + (add * 2)

print(total_count)

Measured memory_bytes: 3060
use proconio::*;

// /// create loop_to
// fn dfs(idx: usize, depth: usize, edge: &Vec<usize>, loop_to: &mut Vec<(i32, i32)>) -> (i32, i32) {
//     if loop_to[idx].0 >= 0 {
//         return loop_to[idx];
//     }
//     if loop_to[idx].0 == -1 && loop_to[idx].1 >= 0 {
//         loop_to[idx] = (idx as i32, depth as i32 - loop_to[idx].1);
//         return loop_to[idx];
//     }
//     loop_to[idx] = (-1, depth as i32);
//     let ret = dfs(edge[idx], depth+1, edge, loop_to);
//     if (-1, depth as i32) != loop_to[idx] {
//         loop_to[idx] = (idx as i32, ret.1);
//     } else {
//         if loop_to[edge[idx]].0 == edge[idx] as i32 {
//             loop_to[idx] = (edge[idx] as i32, 1);
//         }
//         else {
//             loop_to[idx] = (ret.0, ret.1 + 1);
//         }
//     }
//
//     loop_to[idx].clone()
// }

fn main() {
    input!{
        n: usize,
        mut k: usize,
        a: [usize; n],
    }

    let mut doubling = vec![vec![0usize; n]; 70];
    for i in 0..n {
        doubling[0][i] = a[i]-1;
    }
    for i in 0..69 {
        for j in 0..n {
            doubling[i+1][j] = doubling[i][doubling[i][j]];
        }
    }

    let mut idx = 0;
    for i in (0..64).rev() {
        if (1usize << i) <= k {
            k -= (1usize<<i);
            idx = doubling[i][idx];
        }
    }
    assert_eq!(k, 0);
    println!("{}", idx+1);
}


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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

ll gcd(ll a, ll b){
  if (a % b == 0)return b;
  return gcd(b, a % b);
}

ll lsm(ll a, ll b){
  return a / gcd(a, b) * b;
}

int main(){
  int N;
  cin >> N;
  ll T[N];
  for (int i = 0; i < N; ++i)cin >> T[i];

  ll ans = T[0];
  for (int i = 1; i < N; ++i){
    if (ans > T[i]){
      ans = lsm(ans, T[i]);
    }else{
      ans = lsm(T[i], ans);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;
struct activity{
  ll W,V;
};
ll knapsack(vector<activity> arr,ll n,ll w,ll i,vector<vector<ll>> &dp){
  if(i>=n || w==0) return 0;
  if(dp[i][w]!=-1) return dp[i][w];

  ll left,right;
  left=right=INT_MIN;
  if(w-arr[i].W>=0){
    left=arr[i].V+knapsack(arr,n,w-arr[i].W,i+1,dp);
  }
  right=knapsack(arr,n,w,i+1,dp);
  return dp[i][w]=max(left,right);
}
int main(){

    ll n,w;
    cin>>n>>w;
    vector<activity> arr(n);
    for(ll i=0;i<n;i++){
      cin>>arr[i].W;
      cin>>arr[i].V;
    }
    vector<vector<ll>> dp(n,vector<ll>(w+1,-1));
    cout<<knapsack(arr,n,w,0,dp)<<endl;
}

Measured memory_bytes: 82376
import sys
input=sys.stdin.readline

h,w=map(int,input().split())

B,ans,cnt=[],[],0
Bappend=B.append
ansappend=ans.append
fflag=False

for i in range(h):
    A=list(map(int,input().split()))
    flag=False
    for j in range(w-1):
        if flag:
            if A[j]%2==0:
                ansappend((i+1,j+1,i+1,j+2))
                flag=True
                cnt+=1
            else:
                flag=False
        else:
            if A[j]%2==1:
                ansappend((i+1,j+1,i+1,j+2))
                flag=True
                cnt+=1
    if i!=h-1:
        if flag+fflag==1:
            if A[w-1]%2==0:
                ansappend((i+1,w,i+2,w))
                fflag=True
                cnt+=1
            else:
                fflag=False
        else:
            if A[w-1]%2==0:
                fflag=False
            else:
                ansappend((i+1,w,i+2,w))
                fflag=True
                cnt+=1
                
print(cnt)
for a in ans:
    print(*a)

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

int main(){
  int N, M; cin >> N >> M;

  if(M == 0){
    if(N == 1) cout << 0;
    else {
      cout << '1';
      for(int i = 1; i < N; i++)
        cout << '0';
    }
    cout << endl;
    return 0;
  }

  int ans = 0;

  vector<int> k = vector<int>(N, -1);
  
  for(int i = 0; i < M; i++){
    int s, c; cin >> s >> c;
    s--;
    if(k[s] == -1 || k[s] == c) k[s] = c;
    else {
      cout << -1 << endl;
      return 0;
    }
  }

  if(k[0] == 0){
    if(N == 1) cout << 0 << endl;
    else cout << -1 << endl;
    return 0;
  }else if(k[0] == -1){
    cout << 1;
  }else{
    cout << k[0];
  }

  for(int i = 1; i < N; i++){
    if(k[i] == -1) cout << 0;
    else cout << k[i];
  }

  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long dp[3][200];
long long mat[3][200];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i = 1 ; i <= 2 ; i++)
	{
		for(int j = 1; j <= n ; j++)
		{
			scanf("%lld",&mat[i][j]);
		}
	}
	dp[1][1] = mat[1][1];
	for(int i = 1; i <= 2; i++)
	{
		for(int j = 1; j <= n ; j++)
		{
			if(i == 1 && j == 1)
				continue;
			if(i == 1)
			{
				dp[i][j] += dp[i][j-1] + mat[i][j];
			}
			else if(j == 1)
			{
				dp[i][j] += dp[i-1][j] + mat[i][j];
			}
			else
			{
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]) + mat[i][j];
			}
		}
	}
	printf("%lld\n",dp[2][n]);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
//ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
 ll gcd( ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}

int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
    ll n;
    cin>>n;
     ll a[n];
    for(int i=0;i<n;i++)
    {
      cin>>a[i];
    }
    ll ans=a[0];
    for(int i=1;i<n;i++)
    {
     // ans=(1ll*ans*a[i])///gcd(1ll*ans,1ll*a[i]);
      ll temp=gcd(1ll*ans,a[i]);
      ans=ans/temp*a[i];
     //ans=ans/temp;
      //cout<<"Ans = "<<ans<<endl;
    }
   cout<<ans<<endl;
}
return 0;
}

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

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

    static class DIHateFactorization {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int x = in.nextInt();

            HashMap<Long, Integer> root = new HashMap<>();
            for (int i = -200; i < 200; i++) {
                root.put(NumberTheory.pow(i, 5), i);
            }
            for (int a = 1; ; a++) {
                long d = NumberTheory.pow(a, 5) - x;
                if (root.containsKey(d)) {
                    out.println(Util.join(a, root.get(d)));
                    return;
                }
            }
        }

    }

    static class Util {
        public static String join(int... i) {
            StringBuilder sb = new StringBuilder();
            for (int o : i) {
                sb.append(o);
                sb.append(" ");
            }
            if (sb.length() > 0) {
                sb.deleteCharAt(sb.length() - 1);
            }
            return sb.toString();
        }

        private Util() {
        }

    }

    static class NumberTheory {
        public static long pow(long x, long e) {
            if (e == 0)
                return 1;
            if ((e & 1) > 0)
                return x * pow(x, e - 1);
            return pow(x * x, e / 2);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



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

int pri[1000000+1];
bool is_prime[1000000+1];
int prime(int n){
	int p=0;
	for(int i=0;i<n+1;i++){
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for(int i=2;i<n+1;i++){
		if(is_prime[i]==true){
			pri[p++] = i;
			for(int j=i+i;j<n+1;j+=i){
				is_prime[j] = false;
			}
		}
	}
	return p;
}

int main()
{
	int max_p = prime(1000000);
	int n;
	while(cin >> n){
		if(!n)
			break;
		int p,m;
		int money = 0;
		for(int i=0;i<n;i++){
			cin >> p >> m;
			int sum = 0;
			for(int j=0;j<max_p;j++){
				if(p-m <= pri[j] && pri[j] <= p+m)
					sum++;
			}
			money += sum;
		}
		money -= n;
		cout << money << endl;
	}	
	return 0;
}

Measured memory_bytes: 2148
N = int(input())
A = list(map(int,input().split()))
gcd1 = [0] * (N - 1)
gcd1[0] = A[0]
gcd2 = [0] * (N - 1)
gcd2[-1] = A[-1]
for i in range(N - 2):
    a, b = gcd1[i], A[i + 1]
    while b:
        a, b = b, a % b
    gcd1[i + 1] = a
    a, b = gcd2[-i-1], A[-i-2]
    while b:
        a, b = b, a % b
    gcd2[-i-2] = a
ans = max(gcd1[-1], gcd2[0])
for i in range(N - 2):
    a, b = gcd1[i], gcd2[i + 1]
    while b:
        a, b = b, a % b
    ans = max(a, ans)
print(ans)

Measured memory_bytes: 14528
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int ans=0;
  int x;
  x=min(a,k);
  ans+=x;
  k-=x;
  if(k<=0){
    cout << ans;
    return 0;
  }
  x=min(b,k);
  k-=x;
  if(k<=0){
    cout << ans;
    return 0;
  }
  x=min(c,k);
  ans-=x;
  cout << ans;
}

Measured memory_bytes: 3632
n = int(input())
w = [input() for _ in range(n)]

flag = 1
if len(set(w)) == n:
    f = w[0][-1]
    for i in range(1, len(w)):
        if f != w[i][0]:
            flag = 0
        f = w[i][-1]
else:
    flag = 0

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vb vector<bool>
#define vpli vector<pair<long long,int>>
#define deb(x) cout<<x<<endl;
ll MOD = 1e9+7;
void solve()
{
    ll n;
    cin>>n;
    int temp;
    string ans ="";
    while(n)
    {
        temp = n%26;
        if(temp !=0)
            ans = (char)(temp+'a'-1)+ans;
        else
        {
            ans = 'z'+ans ;
        }
        n = n/26;
        if(temp == 0)
            n--;
    }
    cout<<ans;
}
int main()
{
    solve();
    return 0;
}

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

int main(){
	int d, t, s;
	cin >> d >> t >> s;
	
	float f_dis = d;
	float temp = f_dis / s;
	
	
	if(temp <= t)
		cout << "Yes";
	else
		cout << "No";
		
		
}


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

ll solve() {
    ll M = 51;
    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    for ( int i = 0; i < N; i++ ) cin >> A[i];
    for ( int i = 0; i < N; i++ ) cin >> B[i];
    for ( int i = 0; i < N; i++ ) {
        if ( A[i] < B[i] ) return -1;
    }
    vector<ll> ks;
    auto check = [&](ll x) {
        vector<vector<ll>> g(M, vector<ll>());
        for ( ll m = 0; m < M; m++ ) {
            vector<ll> d(M);
            d[m] = 1;
            for ( ll k : ks ) {
                d[m % k] = 1;
            }
            for ( ll k = 1; k <= x; k++ ) {
                d[m % k] = 1;
            }
            for ( ll v = 0; v < M; v++ ) {
                if ( d[v] > 0 ) g[m].push_back(v);
            }
        }
        int i;
        for ( i = 0; i < N; i++ ) {
            if ( A[i] == B[i] ) continue;
            vector<ll> used(M);
            queue<ll> q;
            q.push(A[i]);
            used[A[i]] = 1;
            bool ok = false;
            while ( !q.empty() ) {
                ll v = q.front();
                q.pop();
                for ( ll u : g[v] ) {
                    if ( used[u] > 0 ) continue;
                    if ( u == B[i] ) {
                        ok = true;
                        break;
                    } else {
                        q.push(u);
                        used[u] = 1;
                    }
                }
                if ( ok ) break;
            }
            if ( !ok ) return false;
        }
        return true;
    };

    if ( !check(M) ) return -1;

    ll r_sup = M;
    for(;;) {
        ll l = -1, r = r_sup;
        while ( r - l > 1 ) {
            ll m = (l + r) / 2;
            if ( check(m) ) r = m;
            else l = m;
        }
        if ( r == 0 ) break;
        ks.push_back(r);
        r_sup = r;
    }

    ll ans = 0;
    for ( ll k : ks ) {
        ans += 1LL << k;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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 (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);
    string s;
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22){
        cout<<"bust"<<endl;

    }else{
        cout<<"win"<<endl;

    }
    return  0;
}


Measured memory_bytes: 256