akhauriyash/Code-Regression huggingface dataset:
#define REP(i, t, n)  for (int i = t; i < n; i++)
#define REPI(i, t, n)  for (int i = t; i >= n; i--)
#define ALL(n)        (n).begin(),(n).end()
#include <limits.h>
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <functional>
#include <algorithm>
#include <cstring>
#include <unordered_map>
#include <numeric>

using namespace std;

typedef bool               BOOL;
typedef short              WORD;
typedef unsigned short     U_WORD;
typedef long               DWORD;
typedef unsigned long      U_DWORD;
typedef long long          QWORD;
typedef unsigned long long U_QWORD;

#define N_MAX (100000)

QWORD N;
QWORD aqwMonster[N_MAX + 1];
QWORD aqwHero[N_MAX];
QWORD aqwCanDestroy[N_MAX];


void solve_main()
{
	cin >> N;
	REP (i, 0, N + 1) {
		cin >> aqwMonster[i];
	}
	REP (i, 0, N) {
		cin >> aqwHero[i];
	}

	REPI (i, (N - 1), 0) {
		if (aqwMonster[i + 1] >= aqwHero[i]) {
			//i + 1番目の敵を全部倒せない場合
			aqwCanDestroy[i] = aqwHero[i];
		} else {
			//i + 1番目の敵を全部倒せる場合
			QWORD qwDestroy;
			qwDestroy = aqwHero[i] - aqwMonster[i + 1];
			if (aqwMonster[i] >= qwDestroy) {
				//i 番目の敵を全部倒せない場合
				aqwCanDestroy[i] = aqwHero[i];
				aqwMonster[i] -= qwDestroy;
			} else {
				//i 番目の敵を全部倒せる場合
				aqwCanDestroy[i] = aqwMonster[i + 1] + aqwMonster[i];
				aqwMonster[i] = 0;
			}
		}
	}

	QWORD qwAns = 0;
	REP (i, 0, N) {
		qwAns += aqwCanDestroy[i];
	}
	cout << qwAns << endl;

}

int main()
{
#ifdef FOR_IDE
	ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
#endif

	solve_main();
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long n, k; cin >> n >> k;
	long long a[n], f[n];
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> f[i];
	sort(a, a + n);
	sort(f, f + n, greater<int>());

	long long l = -1, r = 1e15;
	while (abs(l - r) > 1)
	{
		long long mid = (l + r) / 2;
		long long tmp = 0;
		for (int i = 0; i < n; i++)
		{
			long long tra = ((a[i] + 1) * f[i] - mid - 1) / f[i];
			tmp += max(0ll, tra);
		}
		if(tmp <= k) r = mid;
		else l = mid;
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 6760
n,m = map(int,input().split())

drink = [list(map(int,input().split())) for _ in range(n)]
drink = sorted(drink, key=lambda x: x[0])

cost = 0

for i in range(n):
    value = drink[i][0]
    stock = drink[i][1]
    if m >= stock:
        cost += value*stock
        m -= stock
    else:
        cost += value*m
        m = 0
    if m == 0:
        break

print(cost)

Measured memory_bytes: 29796
// 文字の長さ
// 文字列
// 文字列がある文字列の繰り返しで生成されたものかを判断する

"use strict";

main(require("fs").readFileSync("/dev/stdin", "utf-8"));

function main(input) {
  input = input.split("\n");
  const length = parseInt(input.shift());
  let char = input[0].split("");
  let char1 = char.slice(0, length / 2).join("");
  let char2 = char.slice(length / 2, length).join("");
  console.log(char1 === char2 ? "Yes" : "No");
}


Measured memory_bytes: 7372
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	string c[3];
	for (int i = 0; i < 3;i++) {
			cin >> c[i];
	}
	for (int i = 0; i < 3;i++) {
		cout << c[i][i] ;
	}
}

Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
  int a,b;
  cin>>a>>b;

  cout<<max({a+b,a-b,a*b})<<endl;

}



Measured memory_bytes: 256
S = [60, 80, 100, 120, 140, 160]
W = [2, 5, 10, 15, 20, 25]
P = [600, 800, 1000, 1200, 1400, 1600]

while 1:
    n = int(input())
    if n == 0:
        break
    r = 0
    for i in range(n):
        x, y, h, w = map(int, input().split())
        s = x + y + h
        for j in range(6):
            if s <= S[j] and w <= W[j]:
                r += P[j]
                break
    print(r)

Measured memory_bytes: 7640
#include <cstdio>
using namespace std;

int main(){
    int a, b, cnt = 0, r[5];
    scanf("%d%d", &a, &b);
    for (int i = a; i <= b; i++){
        int t = i;
        int p = 0, mod = 10000;
        while (mod){
            r[p++] = t / mod;
            t %= mod;
            mod /= 10;
        }
        if (r[0] == r[4] && r[1] == r[3]) cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

void dfs(int v, int p, int now, vector<vector<int>> &G, vector<int> &counter,
         vector<int> &res) {
    now += counter[v];
    res[v] = now;
    for(auto nv : G[v]) {
        if(nv == p)
            continue;
        dfs(nv, v, now, G, counter, res);
    }
}

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<vector<int>> G(N, vector<int>());
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    vector<int> counter(N);
    rep(i, Q) {
        int p, x;
        cin >> p >> x;
        p--;
        counter[p] += x;
    }

    vector<int> res(N);
    dfs(0, -1, 0, G, counter, res);
    rep(i, N) { cout << res[i] << (i == N - 1 ? '\n' : ' '); }
    return 0;
}

Measured memory_bytes: 30464
import java.util.PriorityQueue

fun main(args: Array<String>) {
    val (H, W) = readInputLine().split(" ").map { it.toInt() }

    val cnt = IntArray('z' - 'a' + 1)
    
    for (i in 1..H) {
        readInputLine().forEach { cnt[it - 'a']++ }
    }

    val queue = PriorityQueue<Int>('z' - 'a' + 1) { x, y -> x.compareTo(y) * -1 }

    for (c in cnt) {
        queue.add(c)
    }

    // 4つ必要なところを見ていく
    for (i in 1..H / 2) {
        for (j in 1..W / 2) {
            val q = queue.poll()!!
            if (q < 4) {
                println("No")
                return
            }
            queue.add(q - 4)
        }
    }
    
    // 2つ必要なところを見ていく
    if (H % 2 == 1) {
        for (i in 1..W / 2) {
            val q = queue.poll()!!
            if (q < 2) {
                println("No")
                return
            }
            queue.add(q - 2)
        }
    }
    
    if (W % 2 == 1) {
        for (i in 1..H / 2) {
            val q = queue.poll()!!
            if (q < 2) {
                println("No")
                return
            }
            queue.add(q - 2)
        }
    }

    println("Yes")
}

fun readInputLine(): String {
    return readLine()!!
}


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

using namespace std;

int main(){

  int a, b, c;
  cin >> a >> b >> c;

  if ((a <= c) && (c <= b)){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


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

int main() {
    long long n;
    std::cin >> n;
    std::vector<long long> c(n), s(n), f(n);
    for (auto i = 0ll; i < n - 1; i++) {
        std::cin >> c[i] >> s[i] >> f[i];
    }

    for (auto i = 0ll; i < n - 1; i++) {
        long long ret = s[i] + c[i];
        for (auto j = i + 1; j < n - 1; j++) {
            if (ret >= s[j]) {
                if (ret % f[j] == 0) {
                    ret += c[j];
                } else {
                    ret = (ret - (ret % f[j]) + f[j]) + c[j];
                }
            } else {
                ret = s[j] + c[j];
            }
        }

        std::cout << ret << std::endl;
    }

    std::cout << 0 << std::endl;

    return 0;
}

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

using namespace std;

const int MAXN=2e5+1;

int n,k;
double p[MAXN],sum=0,ans=0;

int main() {
	scanf("%d %d",&n,&k);
	for(int i=1; i<=n; ++i) {
		scanf("%lf",&p[i]);
		p[i]=(1+p[i])/2;
		if(i<=k) sum+=p[i];
	}
	ans=sum;
	for(int i=2; i<=n-k+1; ++i) {
		sum=sum-p[i-1]+p[i+k-1];
		ans=max(ans,sum);
	}
	printf("%f\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t {}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 0xde0b6b43b9aca00;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  string ans = "";
  rep (i, 3)
  {
    string s;
    cin >> s;

    ans += toupper (s [0]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
grid = [input() for _ in range(H)]
A = [[0] * W for _ in range(H)]
B = [[0] * W for _ in range(H)]
L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
for i in range(H):
    L[i][0] = 1 if grid[i][0] == '.' else 0
    for j in range(1, W):
        L[i][j] = L[i][j - 1] + 1 if grid[i][j] == '.' else 0
for i in range(H):
    R[i][-1] = 1 if grid[i][-1] == '.' else 0
    for j in range(W - 2, 0, -1):
        R[i][j] = R[i][j + 1] + 1 if grid[i][j] == '.' else 0
for j in range(W):
    A[0][j] = 1 if grid[0][j] == '.' else 0
    for i in range(1, H):
        A[i][j] = A[i - 1][j] + 1 if grid[i][j] == '.' else 0
for j in range(W):
    B[-1][j] = 1 if grid[-1][j] == '.' else 0
    for i in range(H - 2, -1, -1):
        B[i][j] = B[i + 1][j] + 1 if grid[i][j] == '.' else 0



ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, A[i][j] + B[i][j] + L[i][j] + R[i][j])
print(ans - 3)


Measured memory_bytes: 180996
def bitcount(i): # i < 2^32
    i = i - ((i >> 1) & 0x55555555)
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333)
    return (((i + (i >> 4) & 0xF0F0F0F) * 0x1010101) & 0xffffffff) >> 24

MOD = 10**9+7
n = int(input())
can = [[int(i) for i in input().split()] for j in range(n)]
dp = [0] * (1 << n)
dp[0] = 1
for mask in range((1 << n) - 1):
    a = bin(mask).count('1')
    #a = bitcount(mask)
    for b in range(n):
        if can[a][b] and not (mask & (1 << b)):
            mask2 = mask ^ (1 << b)
            dp[mask2] += dp[mask]
            if dp[mask2] >= MOD:
                dp[mask2] -= MOD
print(dp[(1 << n) - 1])

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

using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long

int x[100001];

signed main(){
  int n;
  cin>>n;
  int a[100001];
  int check=0,mini;
  lp(i,n){
    cin>>a[i];
    if(i==0) mini=a[i];
    if(a[i]<mini&&a[i]!=mini-1){
      cout<<":("<<endl;
      return 0;
    }
    mini=min(mini,a[i]);
  }
  int bef=0;
  string s="";
  lp(i,n){
    if(i==0||bef<a[i]){
     lp(j,a[i]-bef){
        s.push_back('(');
      }
      bef=max(a[i],bef);
    }
    s.push_back(')');
  }
  string ans=s;
  //cout<<s<<endl;
  int stat=0;
  while(1){
    stat=0;
    lp(i,s.size()){
      if(i==0)continue;
      if(s[i]==')'&&s[i-1]=='('){
        s.erase(i-1,2);
        stat=1;
      }
    }
    if(stat==0)break;
    //cout<<s<<endl;
  }
  if(s.size()==0){
    cout<<ans<<endl;
  }
  else{
    cout<<":("<<endl;
  }
  return 0;
}


Measured memory_bytes: 4328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
const int mod =1000000007;
const int INF = 1e18;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,p,ecount=0;
    cin>>n>>p;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==0){ecount++;}
    }
    if(p==1&&ecount==n){cout<<0;return 0;}
    else if(p==0&&ecount==n){cout<<(int)pow(2,n);return 0;}
    else{cout<<(int)pow(2,n-1);}
}


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

int main(){

    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    int ans = 0;
    int t = a[2] - a[1];
    ans += t;
    
    a[0] += t;
    int s = a[2] - a[0];
    if(s % 2 == 0){
        ans += s / 2;
    }else{
        s--;
        ans += s / 2;
        ans += 2;
    }


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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using   namespace  std;
typedef  long long  ll;
typedef pair<ll,ll>pll;
typedef    double   db;

#define fi  first
#define se second
#define endl "\n"
#define pb(x)       push_back(x)
#define mp(a,b)  make_pair(a,b);
#define sz(a)  ((int)(a).size())
#define all(x) x.begin(),x.end()

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

#define de(a) cout << #a << " = " << a << endl;
#define dd(a) cout << #a << " = " << a << "  ";

#define mem(a,b)   memset(a,b,sizeof(a))
#define file freopen("in.txt","r",stdin)
#define jkl ios::sync_with_stdio(false);cin.tie(0);
#define list list2

const ll INF     =    0x3f3f3f3f;
const ll LINF=0x3f3f3f3f3f3f3f3f;
const ll MOD     =   1e9+7;
const double eps =    1e-8;
const double PI=acos(-1.0);
/*************************************************/
const int N=1e5+5;
int a[N];
int main() {
	int n;cin >> n;
	ff(i,1,n) cin>> a[i];
	bool yes=true;
	for(int i=n-1;i>=1;i--) {
		if(a[i]<=a[i+1]) continue;
		else if(a[i]-1<=a[i+1]) {
			a[i]--;
			continue;
		}else yes=false;
	}
	if(yes) cout << "Yes\n";
	else cout << "No\n";
}


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

int main(){
  ll n;
  cin >> n;
  bool ans = true;
  ll border = -1;
  rep(i,n){
    ll h;
    cin >> h;
    if(border>h){
      ans = false;
      break;
    }
    h--;
    chmax(border, h);
  }
  if(ans){
    print("Yes");
  }
  else{
    print("No");
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int N;
	string S;
	cin >> N >> S;

	// char moji = 65;
	// cout << moji << endl;

	for (int ii = 0; ii < S.size(); ++ii){
		char s = S[ii];
		int num = s - 'A';
		int ans = (num + N) % 26;
		char moji = ans + 65;
		cout << moji;
	}

	cout << "\n";

	return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

#define sz(a) static_cast<int>((a).size())
#define f first
#define s second
#define els(v) for (auto &el : (v))


#ifdef KIRYA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h << "\n";
}

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;

    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;

    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> vec(n);
    for (int i = 0; i < n; ++i) {
        cin >> vec[i];
    }
    sort(vec.begin(), vec.end());
    int64_t ans = 0;
    for (int i = 0; i < n - k; ++i) {
        ans += vec[i];
    }
    cout << ans << '\n';
}

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

    int q = 1;

    for (int i = 0; i < q; ++i) {
        solve();
    }
}

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

int main(){
    int n,ans=0;
    string s;
    cin>>n>>s;
    for(int i=0;i<n-2;i++){
        if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
            ans++;
        }
    }
    cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,a,b;
  scanf("%d %d %d",&n,&a,&b);
  if(n<=20&&n>=1&&a<=100&&a>=1&&b>=1&&b<=2000){
    if(n*a<b)
      printf("%d\n",n*a);
    else
      printf("%d\n",b);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 
int n;
long long a[100010];
long long ans;

int main(){
    cin >> n;
    a[0] = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    a[n+1] = 0;

    for(int i = 1; i <= n+1; i++){
        ans += abs(a[i] - a[i-1]);
    }

    for(int i = 1; i <= n; i++){
        cout << ans - abs(a[i]-a[i-1]) - abs(a[i+1] - a[i]) + abs(a[i+1] - a[i-1]) << endl;
    }
}

Measured memory_bytes: 2048
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"




int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    map<ll,ll> mp;
    ll ans=0;
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        ++mp[2];
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            ++mp[i]; 
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        ++mp[n];
        for(auto itr=mp.begin();itr!=mp.end();itr++)
        {
        	ans=ans+(-1+sqrt(1+8*itr->second))/2;
        }
        cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3680
//بِسْمِ ٱللَّٰهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;

#define endl "\n"

const int MOD = 1000000007;


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

    int a;
    cin >> a;

    char x[a], y[a];
    for(int i = 0 ; i < a ; i++) cin >> x[i];
    for(int i = 0 ; i < a ; i++) cin >> y[i];
    for(int i = 0 ; i < a ; i++){
        cout << x[i] << y[i];
    }

    cout << endl;

    return 0;
}


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

typedef long long ll;

int main() {
    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    if ((V - W) * T >= abs(A - B)) {
        cout << "YES\n";
    } else {
        cout << "NO\n";
    }
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<assert.h>
using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}

#define MAX 1000005


long long beki(long long a,int n)
{
  long long s=1LL;
  while(n){
    if(n%2)s=s*a;
    a=a*a;
    n/=2;
  }
  return s;
}

signed main(void) {
    int i,j;
    int n,p;
    cin >> n >> p;
    if(n == 1){
        cout << p << endl;
        return 0;
    }
    vi prime(MAX,1),pr;
    loop(i,2,MAX)if(prime[i]){
        pr.push_back(i);
        for(j = 2; i*j < MAX; j++)prime[i*j] = 0;
    }
    int ans = 1;
    rep(i,pr.size()){
        //if(p < pr[i])break;
        if(p%pr[i] == 0){
            int cnt = 0;
            while(p % pr[i] == 0){
                cnt++;
                p /= pr[i];
            }
            //cout << pr[i] << " " << cnt << endl;
            ans *= beki(pr[i],(cnt/n));
        }
    }
    //assert(p==1);
    cout << ans << endl;

}


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

int cmp(int x,int y){
	return x>y;
}

int main(){
	long long sum=0;
	int n,a[100010]={0},len,rin;
	cin>>n;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+1+n,cmp);
	len=1;rin=n;
	sum+=a[len]-a[rin];
	while(1){
		if(rin-len>2) sum+=a[len]+a[len+1]-a[rin]-a[rin-1],len++,rin--;
		else{
			if(rin-len==2) sum+=max(a[len]-a[len+1],a[len+1]-a[rin]);
			break;
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数
using namespace std;

signed main() {
  int x, a;
  cin >> x >> a;
  if(x<a) cout << 0 << endl;
  else cout << 10 << endl;
}


Measured memory_bytes: 256
#include<cstring>
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int n,sum=0;;
	char str1[100],str2[100],str3[100];
	cin>>str1;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>str2;
		strcpy(str3,str2);
		strcat(str2,str3);
		if(strstr(str2,str1)==NULL) {sum+=0;}
		 else sum+=1;
	}
	cout<<sum<<endl;
	return 0;
	
}

Measured memory_bytes: 1188
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
int n;
long long a[1000];
double MAX(double b,double c){
	if(b>c)return b;
	return c;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	sort(a,a+n);
	double ans=0;
	for(int i=0;i<n-3;i++){
		ans=MAX((a[n-1]+a[n-2])/(a[i+1]-a[i]+0.0),ans);
	}
	ans=MAX((a[n-1]+a[n-4])/(a[n-2]-a[n-3]+0.0),ans);
	ans=MAX((a[n-3]+a[n-4])/(a[n-1]-a[n-2]+0.0),ans);
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}

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

#define oo 1000000000000000000LL
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define In insert
#define mod 1000000007
#define File(s) ifstream fin ((string)s + ".in", ios::in), ofstream fout ((string)s + ".out", ios::out);
#define cl const long long

using namespace std;

typedef long long int ll;
typedef long double ld;

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

	ll n, m, k;

	cin>> n >> m >> k;

	n = max (n, m);

	m = ceil (1.0 * k / n);

	cout<< m << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <functional>
#include <stdio.h>
#include <array>
#include <algorithm>
#include <string>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <queue>
#include<iomanip>
#include<bitset>
#include<stack>
#include<set>
#include<limits>
#include <complex>
using namespace std;

int N;
long long int memo[101][101][101][3];
long long int getans(vector<int>usenums,int now) {
	long long int *nmemo = &memo[usenums[0]][usenums[1]][usenums[2]][now];
	if (*nmemo >= 0) {
		return *nmemo;
	}
	else {
		if (now == 0) {
			if (usenums[0] == N) {
				return *nmemo = usenums[0] - max(usenums[1], usenums[2]) + 1;
			}
			else {
				long long int ans = 0;
				vector<int>nusenums(usenums);
				nusenums[0]++;
				ans += getans(nusenums, 0);
				nusenums[1] = nusenums[0];
				ans += getans(nusenums, 1);
				nusenums[2] = nusenums[0];
				ans+=(usenums[0] - max(usenums[1], usenums[2]) + 1)*getans(nusenums,2);
				ans %= 1000000;
				return *nmemo = ans;
			}
		}
		else if (now == 2) {
			if (usenums[2] == N) {
				return *nmemo = 1;
			}
			else {
				long long int ans = 0;
				vector<int>nusenums(usenums);
				nusenums[2]++;
				ans += getans(nusenums, 2);
				nusenums[1] = nusenums[2];
				ans += getans(nusenums, 1);
				nusenums[0] = nusenums[2];
				ans += (usenums[2] - max(usenums[1], usenums[0]) + 1)*getans(nusenums, 0);
				ans %= 1000000;
				return *nmemo = ans;
			}
		}
		else if(now==1){
			if (usenums[1] == N) {
				return *nmemo = 1;
			}
			else {
				long long int ans = 0;
				vector<int>nusenums(usenums);
				nusenums[1]++;
				ans += getans(nusenums, 1);
				nusenums[2] = nusenums[1];
				ans += getans(nusenums, 2);
				nusenums[2] = usenums[2];
				nusenums[0] = nusenums[1];
				ans +=getans(nusenums, 0);
				ans %= 1000000;
				return *nmemo = ans;
			}
		}
		else {
			assert(false);
		}
	}
}
int main() {
	memset(memo, -1, sizeof(memo));
	int  M; cin >> N >> M;
	long long int ans=0;
	if (M == 1) {
		ans = 1;
		while (N) {
			ans *= 2;
			ans %= 1000000;
			N--;
		}
		cout << ans << endl;
		return 0;
	}
	else {
		ans += getans(vector<int>({ 1, 0, 0 }), 0);
		ans += getans(vector<int>({ 1,1,0 }), 1);
		ans += getans(vector<int>({ 1,1,1, }), 2);
	}
	ans %= 1000000;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 27320
N,M = map(int,input().split())

SwitchCond=[]
for i in range(M):
    k_i = list(map(int,input().split()))
    k_i = k_i[1:]
    SwitchCond.append(k_i)

Lights = list(map(int,input().split()))


cnt=0

for i in range(2**N):
    Ans=[0]*M
    i = format(i,'0{}b'.format(N))

    for k in range(M):
        light_num=0
        for n in SwitchCond[k]:
            if i[n-1]=='1':
                light_num+=1
        
        if light_num%2==Lights[k]:
            Ans[k]=1
    
    if sum(Ans)==M:
        cnt+=1

print(cnt)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    for(auto& x: a) cin >> x;

    const ll MOD = 1e9+7;
    vector<ll> dp(K+1), sdp(K+2, 1);
    sdp[0] = 0;
    for(int i=0; i<N; i++){
        for(int j=0; j<=K; j++){
            dp[j] = sdp[j+1] - sdp[max(j-a[i], 0)];
            if(dp[j]<0) dp[j] += MOD;
            dp[j] %= MOD;
        }
        for(int j=0; j<=K; j++){
            sdp[j+1] = sdp[j] + dp[j];
            sdp[j+1] %= MOD;
        }
    }

    cout << dp[K] << endl;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	static long bignum = 1000000000+7;

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		if(s.equals("ARC"))System.out.println("ABC");
		if(s.equals("ABC"))System.out.println("ARC");
		


	}

	static long divn(int target, int times) {//10_9+7のあまり累乗版
		int sqtimes = (int)Math.sqrt(times);
		long ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		long holder = ans;
		ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans*holder)%(1000000000+7);
		}
		for(int i=0;i<times - sqtimes*sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		return ans;
	}

	static long div(long a) {//10_9+7のあまり
		if(a<0)a+=1000000000+7;
		return a%(1000000000+7);
	}

}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 35636
#include<iostream>
using namespace std;
int main()
{
    int n,count=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        if(s[i]==65&&s[i+1]==66&&s[i+2]==67)
        {
            count++;
        }
    }
    cout<<count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = 1e+14;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define _GLIBCXX_DEBUG

int main(){
    int N,K;
    cin>>N>>K;
    vector<int> P(N), C(N);
    rep(i,N) cin>>P[i] , --P[i];//１始まりが想定されているので1下げとく。
    rep(i,N) cin>>C[i];

    ll ans=-INF;

    rep(i,N){
        int v=i;
        ll cycle_sum=0;
        ll cycle_cnt=0;

        while(true){   //動いてから得点足し始めるからまずcnt++しとく
            cycle_cnt++;
            cycle_sum+=C[v];
            v=P[v];
            if(v==i) break;
        }
        ll path=0;
        ll cnt=0;
        while(true){
            cnt++;
            path+=C[v];
            if(cnt>K) break;
            int num=(K-cnt)/cycle_cnt;
            ll score =path+max(0ll,cycle_sum)*num;
            ans =max(ans, score);
            v=P[v];
            if(v==i) break;


        }
    }

    cout<<ans<<endl;

}

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

int main(){
  int a, b;
  cin >> a >> b;
  int cnt = a;
  int i = 1;
  if (b == 1)
    i = 0;
  else if (cnt < b){
    while(true){
      i++;
      cnt += a - 1;
      if (cnt >= b)
        break;
    }
  }
  cout << i << endl;

  return 0;
}


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

ll combi(ll n, ll k){
    if(n==k || k==0) return 1;
    else return combi(n-1, k-1) + combi(n-1, k);
}

int main(){
    int n, p; cin >> n >> p;
    vector<int> a(n);
    ll odd=0, even=0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(a[i]%2==0) even++;
        if(a[i]%2!=0) odd++;
    }
    ll odd_count=0;
    if(odd>0)
        odd_count  = pow(2, odd-1);
    else
        odd_count = 0;
    ll even_count=0;
    even_count = pow(2, even);
    unsigned long long ans=0;
    if(p==0){
        if(odd>0)
            ans = odd_count*even_count;
        else
            ans = even_count;
    }else if(p==1) ans = odd_count*even_count;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3988
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int n;
    cin >> n;

    int s = 0;
    bitset<2000 * 2000 + 1> bs;
    bs.set(0);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        s += a;
        bs |= bs << a;
    }

    for (int i = (s + 1) / 2;; i++) {
        if (bs[i]) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 1792
while True:
    a=[int(x) for x in input().split()]
    if a[0]==a[1]==0:
        break
    else:
        print("#"*a[1])
        for i in range(a[0]-2):
            print("#"+"."*(a[1]-2)+"#")
        print("#"*a[1])
    print("")

Measured memory_bytes: 7588
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int A=stdIn.nextInt();
		int B=stdIn.nextInt();
		if(A>B)
			System.out.print(B+" ");
		else
			System.out.print(A+" ");
		if((A+B)-N<0)
			System.out.print(0);
		else
			System.out.print((A+B)-N);
	}

}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

ll a[100001]={},b[100001]={};
int main() {

	int n;
	cin>>n;

	ll t=0;
	rep(i,n)cin>>a[i]>>b[i];
	for(int i=n-1; i>=0; i--){
		a[i]+=t;
		if(a[i]%b[i]>0)t+=(a[i]/b[i]+1)*b[i]-a[i];
	}
	cout<<t<<endl;
	return 0;

}


Measured memory_bytes: 1792
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  int t = sc.nextInt();
  int min = 10000;
  int cost = 10000;
  for(int i = 0;i < n;i++){
    int c = sc.nextInt();
    int s = sc.nextInt();
    if(s <= t){
      min = Math.min(min,s);
      cost = Math.min(cost,c);
    }
  }
  System.out.println(min == 10000 ? "TLE":cost);
}}


Measured memory_bytes: 21716
#include<stdio.h>

int main(){
	
	int i,a,b,c,d;
	
	scanf("%d",&i);
	
	a = (i%3600);
	b = (i/3600);
	
	c=(a%60);
	d=(a/60);
	
	printf("%d:%d:%d\n",b,d,c);
	return 0;
	
}

Measured memory_bytes: 592
N=int(input())
alist=list(map(int,input().split()))
a2list=[0]+alist+[0]
#print(a2list)

alldist=0
for i in range(1,N+2):
  alldist+=abs(a2list[i]-a2list[i-1])
#print(alldist)

for i in range(N):
  if a2list[i+1]-a2list[i]>=0 and a2list[i+2]-a2list[i+1]>=0:
    print(alldist)
  elif a2list[i+1]-a2list[i]<=0 and a2list[i+2]-a2list[i+1]<=0:
    print(alldist)
  else:
    dist=alldist-abs(a2list[i+1]-a2list[i])-abs(a2list[i+2]-a2list[i+1])+abs(a2list[i+2]-a2list[i])
    print(dist)

Measured memory_bytes: 14048
#abc_151_f

#utilize the characeristic of l(x,y) being convex
#Thus, 3bun search is available

n = int(input())
l = []
for i in range(n):
    x,y = [int(j) for j in input().split()]
    l.append((x,y))
    
#determine the fuction representing the longest distance ^2 from the center point to designated N points.
def loss(x,y):
    maxi = 0
    for i,j in l:
        maxi = max(maxi, (i-x)**2 + (j-y)**2)
    return maxi

def f(x):
    #return min l(x,y)
    left = 0
    right = 1000
    num = 100

    for i in range(num):
        c1 = (2*left + right)/3
        c2 = (left + 2*right)/3    
        if(loss(x,c1)<loss(x,c2)):
            right = c2
        else:
            left = c1
            
    return loss(x,left)

        
    

left = 0
right = 1000
num = 100

for i in range(num):
    c1 = (2*left + right)/3
    c2 = (left + 2*right)/3    
    if(f(c1)<f(c2)):
        right = c2
    else:
        left = c1
        
ans = f(left)**0.5
print(ans)

Measured memory_bytes: 3064
n,*a=gets.split.map &:to_i
l=(1..n).map{gets.to_i}
m=9000
for x in 0...4**n
    s=[0,0,0]
    q=0
    x.to_s(4).rjust(n,"0").split("").map(&:to_i).each_with_index{|e,i|
        next if e>2
        q+=10 if s[e]>0
        s[e]+=l[i]
    }
    m=[m,(0..2).inject(q){|i,j|i+(a[j]-s[j]).abs}].min if s.none?{|i|i<1}
end
p m

Measured memory_bytes: 3964
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	int n;
	double ans=0;
	vector<double> v;

	cin>> n;
	v.resize(n);
	for(int i=0;i<n;i++) cin>> v[i];

	sort(v.begin(), v.end());

	for(int i=1;i<n;i++){
		v[i]=(v[i]+v[i-1])/2.0;
	}

	cout<< v[n-1] << endl;

}

Measured memory_bytes: 256
/*My CSP has exploded*/
/*ABC146*/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<stack>
#include<vector>
#include<queue>
#include<map>
using namespace std;

#define LL long long
#define DB double
#define MAXN 200000
#define Pr pair<int,int>
#define X first
#define Y second
#define mem(x,p) memset(x,p,sizeof(x))

LL read(){
  LL x=0,F=1;char c=getchar();
  while(c<'0'||c>'9'){if(c=='-')F=-1;c=getchar();}
  while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
  return x*F;
}

int n,m;
char s[MAXN+5];
int Q[MAXN+5],pre[MAXN+5],dp[MAXN+5],l,r;
int main()
{
    l=1,r=1;
    n=read(),m=read();
    scanf("%s",s);
    Q[r]=n;
    for(int i=n-1;i>=0;i--){
        if(s[i]=='1')continue;
        while(l<=r&&Q[l]>i+m)l++;
        if(l>r)break;
        dp[i]=dp[Q[l]]+1,pre[i]=Q[l];
        while(l<=r&&dp[Q[r]]>=dp[i])r--;
        Q[++r]=i;
    }
    if(!dp[0]){printf("-1\n");return 0;}
    int x=0;
    while(x!=n){
        printf("%d ",pre[x]-x);
        x=pre[x];
    }
}


Measured memory_bytes: 1664
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left
import heapq
import numpy as np

def input(): return sys.stdin.readline().strip()
def INt(): return int(input())
def MAP(): return map(int, input().split())
def LISt(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
	s = input()
	t = input()
	
	if not set(s) >= set(t):
		print(-1)
		exit()

	dic = defaultdict(list)
	for i, char in enumerate(s):  # 文字列が出現する位置のリスト
		dic[char].append(i)
	
	loop = 0
	index = -1
	for i in range(len(t)):
		idx = bisect_left(dic[t[i]], index)  # リストの何個目とヒットするか
		if idx != len(dic[t[i]]):
			index = dic[t[i]][idx] + 1
		else:  # idx = |dic[t[i]]| -> もうヒットする箇所がないので次のループ
			loop += 1
			index = -1
			idx = bisect_left(dic[t[i]], index)
			index = dic[t[i]][idx] + 1

	print(len(s)*loop+index)

if __name__ == '__main__':
	main()


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

const int N = 1e5 + 5;

int n;
int a[N];

int32_t main()
{
	IOS;
	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	int ans = a[n / 2 + 1];
	ans -= a[n / 2];
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc162
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
			solve_abc162C();
			Console.Out.Flush();

        }
        public static void solve_abc162C()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int sum = 0;
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                {
                    for (int k = 1; k <= n; k++)
                    {
                        sum += gcd(i, gcd(j, k));
                    }
                }
            }

            Console.WriteLine(sum);
        }
        public static int gcd(int a, int b)
        {
            if (b == 0)
            {
                return a;
            }
            else
            {
                return gcd(b, a % b);
            }
        }

        public static void solve_abc162B()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int sum = 0;
            for (int i = 1; i <= n; i++)
            {
                if (i % 3 != 0 && i % 5 != 0)
                {
                    sum += i;
                }
            }
            Console.WriteLine(sum);
        }

        public static void solve_abc162A()
        {
            string s = Console.ReadLine();
            Console.WriteLine(s.Contains("7") ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 28444
#include<iostream>
#include<vector>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<set>
#include<map>
#include<stack>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define stop char nyaa;cin>>nyaa;

int n; ll p;
vector<ll> x, y;

ll cost[100][101];
ll dp[102][102];
void solve() {
	cin >> n >> p;
	x.resize(n); y.resize(n);
	rep(i, n) {
		cin >> x[i] >> y[i];
	}
	rep(i, n) {
		Rep(j, i+1, n+1) {
			//[i,j)
			ll sum = 0;
			ll r = 0;
			Rep(k, i, j) {
				ll t = max((ll)0, x[k] - r);
				ll dif = max((ll)0, y[k] - t);
				sum += dif; r = dif;
			}
			cost[i][j] = sum;
		}
	}
	rep(i, n + 2)rep(j, n + 2)dp[i][j] = mod;
	dp[0][0] = 0;
	rep(i, n) {
		//take
		rep(j, i + 1) {
			Rep(k, i + 1, n+1) {
				dp[k + 1][j + k - i] = min(dp[k + 1][j + k - i], dp[i][j] + cost[i][k]);
			}
		}
		//non_take
		rep(j, i + 1) {
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
		}
	}
	int ans = 0;
	rep(i, n + 1) {
		if (dp[n][i] <= p || dp[n + 1][i] <= p)ans = i;
		//cout << dp[n][i] << " " << dp[n + 1][i] << endl;
	}
	cout << ans << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(6);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 3372
X=gets.chomp.split('')
dai = ("A".."Z").to_a
if X[0] == "A"
  cj = dai & X[2..-2]
  om = dai & X[1..-1]
  if om.length < 2 && cj.include?("C") && X[1..-1].count("C") < 2
    puts 'AC'
  else
    puts 'WA'
  end
else
  puts 'WA'
end

Measured memory_bytes: 1788
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let n=read::<i32>();
    let d=read::<f32>();
    let mut x=read::<i32>();
    for _i in 0..n{
        let a=read::<f32>();
        x+=(d/a).ceil()as i32;
    }
    println!("{}",x);
}


Measured memory_bytes: 4352
import sys

X,N=map(int,input().split())
if N==0:
	print(X)
	sys.exit()

p=list(map(int,input().split()))
n=[0]*(103)
for i in range(len(p)):
	n[p[i]+1]=1

d_min=1000
for j in range(103):
	if n[j]!=1:
		d=abs((X+1)-j)
		if d_min>d:
			d_min=d
			ans=j-1
print(ans)

Measured memory_bytes: 9212
import numpy as np

N = int(input())
H = np.array(list(map(int, input().split())))

ans_1 = min(H[np.where(H==H.max())[0].min():]) > max(H)-2
ans_2 = all((H[1:] - H[:-1]) > -2)

print("Yes") if ans_1 & ans_2 else print("No")

Measured memory_bytes: 23120
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;

int main(int argc, char* argv[])
{

	string S;

	cin >> S;

	cout << ((S[0]!=S[1] && S[1]!=S[2] && S[0]!=S[2]) ? "Yes" : "No") << endl;

	return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<k;i++)
    {
        int d;
        cin>>d;
        for(int j=0;j<d;j++)
        {
            int x;
            cin>>x;
            a[x-1]++;
        }
    }
    int count=0;
    for(int i=0;i<n;i++)
        count+=a[i]==0;
    cout<<count;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define F first
#define S second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int Inf = 1e9;
const double EPS = 1e-9;



int main()
{
  int w, a, b ;
  cin >> w >> a >> b ;
  int small, big ;
  
  if(a<=b){
    small = a ;
    big = b ;
  }
  else{
    small = b ;
    big = a ;
  }
  
  cout <<max(0,big-w-small)<<endl ;

  return 0 ;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
int data[101][101], ks;
vector<int>k;
vector<int>m;
bool judge(int x){
  int j;
  rep(i, ks){
    for(j = 0; j < m[x]; ++j) if(k[i] == data[x][j]) break;
    if(j == m[x]) return false;
  }
  return true;
}

int main(){
  int n, in;
  while(scanf("%d", &n) && n){
    k.clear(); m.clear();
    rep(i, n){
      scanf("%d", &in);
      m.push_back(in);
      rep(j, m[i]) scanf("%d", &data[i][j]);
      sort(data[i], data[i]+m[i]);
    }
    //    printf("member");
    scanf("%d", &ks);
    rep(i, ks){ scanf("%d", &in); k.push_back(in);}
    sort(k.begin(), k.end());
    int f = 0, res;
    rep(i, n)
      if(judge(i)){ f++; res = i;}
    /*    rep(i, n){
      rep(j, m[i]) printf("%d ", data[i][j]);
      puts("");
    }
    printf("%d %d\n", f, res);
    rep(i, ks) printf("%d ", k[i]);
    puts(""); */    
    if(f == 1) printf("%d\n", res+1);
    else puts("-1");
    //    puts("end");
  }
  return 0;
}

Measured memory_bytes: 1260
#include <vector>
#include <iostream>
#include <set>
#include <cstdio>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <algorithm>
#include <limits>
#include <map>

using namespace std;

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

int n;
int g[110];
int dp[110];

int solve(int i, int k) {
    if (i >= n) return 0;
    if (dp[i] != -1) return dp[i];
    if (k > 1000) return 1000000;
    int r = min(solve(g[i], k+1), solve(i+1, k+1)+1);
    dp[i] = r;
    return r;
}

int main() {
    cin >> n;
    map<string, int> m;
    bool F[110];
    string S[110];
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        F[i] = (s == "goto");
        if (F[i]) {
            cin >> s;
            S[i] = s.substr(0, s.size()-1);
        } else {
            S[i] = s.substr(0, s.size()-1);
            m[S[i]] = i;
        }
    }
    vector<int> v[110];
    for (int i = 0; i < n; i++) {
        if (F[i]) {
            assert(m.find(S[i]) != m.end());
            v[m[S[i]]].push_back(i);
            g[i] = m[S[i]];
        } else {
            v[i+1].push_back(i);
            g[i] = i+1;
        }
    }
    priority_queue<P, vector<P>, greater<P>> q;
    q.push(P(0, n));
    bool used[110] = {};
    int r = 10000;
    while (!q.empty()) {
        int a, b;
        tie(a, b) = q.top(); q.pop();
        if (used[b]) continue;
        used[b] = true;
        if (!b) {
            r = a;
            break;
        }
        q.push(P(a+1, b-1));
        for (int d: v[b]) {
            q.push(P(a, d));
        }
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 1256
import scala.io.StdIn

object Main extends App {
  val j = Array(0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0)
  val a = StdIn.readLine().split(" ").map(_.toInt - 1)

  println(if(j(a(0)) == j(a(1))) "Yes" else "No")

}


Measured memory_bytes: 27068