akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <map>
#define enter putchar('\n')
#define space putchar(' ')
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define eps 1e-7
#define MAXN 250005
#define MOD 999999137
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
typedef vector<int> poly;

template<class T>
void read(T &res) {
	res = 0;char c = getchar();T f = 1;
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {putchar('-');x = -x;}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
int B[] = {0,823,727,401,271,571};
int InvB[10];
int f[8][MAXN],g[8][MAXN],N,h[8][MAXN];
char s[MAXN];
map<int,int> MK[8];


int mul(int a,int b) {
	return 1LL * a * b % MOD;
}
int inc(int a,int b) {
	return a + b >= MOD ? a + b - MOD : a + b;
}
void update(int &x,char c,int id) {
	if(c == '<') x = mul(x,InvB[id]);
	else if(c == '>') x = mul(x,B[id]);
	else if(c == '+') x = inc(x,1);
	else x = inc(x,MOD - 1);
}
int fpow(int x,int c) {
	int res = 1,t = x;
	while(c) {
		if(c & 1) res = mul(res,t);
		t = mul(t,t);
		c >>= 1;
	}
	return res;
}
void Solve() {
	for(int i = 1 ; i <= 5 ; ++i) InvB[i] = fpow(B[i],MOD - 2);
	read(N);
	scanf("%s",s + 1);
	int c[10] = {0};
	for(int k = 1 ; k <= 5 ; ++k) {
		for(int i = N ; i >= 1 ; --i) {
			update(c[k],s[i],k);
		}
	}
	for(int k = 1 ; k <= 5 ; ++k) h[k][N + 1] = 1,g[k][N + 1] = c[k],MK[k][0] += 1;
	int64 ans = 0;
	for(int i = N ; i >= 1 ; --i) {
		int add = N - i + 1;
		for(int k = 1 ; k <= 5 ; ++k) {
			if(s[i] == '<') {
				g[k][i] = inc(g[k][i + 1],MOD - mul(h[k][i + 1],c[k]));
				h[k][i] = mul(h[k][i + 1],B[k]);
				g[k][i] = inc(g[k][i],mul(h[k][i],c[k]));
				f[k][i] = f[k][i + 1];		
			}
			else if(s[i] == '>') {
				g[k][i] = inc(g[k][i + 1],MOD - mul(h[k][i + 1],c[k]));
				h[k][i] = mul(h[k][i + 1],InvB[k]);
				g[k][i] = inc(g[k][i],mul(h[k][i],c[k]));
				f[k][i] = f[k][i + 1];
			}
			else if(s[i] == '+') {
				h[k][i] = h[k][i + 1];
				g[k][i] = inc(g[k][i + 1],MOD - h[k][i]);
				f[k][i] = inc(f[k][i + 1],MOD - h[k][i]);
			}
			else {
				h[k][i] = h[k][i + 1];
				g[k][i] = inc(g[k][i + 1],h[k][i]);
				f[k][i] = inc(f[k][i + 1],h[k][i]);
			}
			add = min(add,MK[k][g[k][i]]);
			MK[k][f[k][i]] += 1;
		}
		ans += add;
	}
	out(ans);enter;	
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
	return 0;
}

Measured memory_bytes: 136960
#include <stdio.h>
  
int main(void){
    int i,j,k,dice[2][7];
      
    for(i=0;i<2;i++)
      for(j=1;j<7;j++)
        scanf("%d", &dice[i][j]);
     
    for(i=0;i<6;i++){
      if(dice[0][1]==dice[1][1])
        for(j=0;j<4;j++){
 
  //一致判定
          for(k=1;k<7;k++)
            if(dice[0][k]!=dice[1][k]) break;
  
          if(k==7){
            printf("Yes\n");
            return 0;
          }
 
  //スピン
          dice[1][0] = dice[1][2];
          dice[1][2] = dice[1][3];
          dice[1][3] = dice[1][5];
          dice[1][5] = dice[1][4]; 
          dice[1][4] = dice[1][0]; 
 
       
      }
          
       //回転  
      
      dice[1][0] = dice[1][1];
          
      switch(i){
                  
          case 2:
              dice[1][1] = dice[1][3];
              dice[1][3] = dice[1][6];
              dice[1][6] = dice[1][4];
              dice[1][4] = dice[1][0]; 
              break;
              
          default:
              dice[1][1] = dice[1][2];
              dice[1][2] = dice[1][6];
              dice[1][6] = dice[1][5];
              dice[1][5] = dice[1][0]; 
              break;
         
          }
    }
 
    printf("No\n");
    return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    int n, k;
    cin >> n >> k;
    ll x1 = n / k;
    ll x2 = (k % 2 == 0) ? n / (k / 2) - x1 : 0;
    ll ans = x1 * x1 * x1 + x2 * x2 * x2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = int64_t;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1'001'001'001;
const ll INFL = (1LL<<60);
const double eps = (1e-9);

const ll mod = 1e9 + 7;

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

  string o, e;
  cin >> o >> e;
  if (o.size() == e.size()) {
    rep(i, o.size()) {
      printf("%c%c", o[i], e[i]);
    }
  } else {
    rep(i, e.size()) {
      printf("%c%c", o[i], e[i]);
    }
    printf("%c", o[o.size() -1]);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>

int main() {
    int N;
    std::cin >> N;

    std::map<std::string, long> m;
    for (int i = 0; i < N; i += 1) {
        std::string si;
        std::cin >> si;
        std::sort(si.begin(), si.end());
        if (m.find(si) == m.end()) {
            m[si] = 0;
        } else {
            m[si] += 1;
        }
    }

    long sum = 0;
    for (auto & it : m) {
        sum += it.second * (it.second + 1) / 2;
    }

    std::cout << sum << std::endl;
}


Measured memory_bytes: 11136
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

using type = pair<int, long long>; // 1: query, 0; delete, -1: insert
using event = pair<long long, type>;

int main() {
    int N, Q; cin >> N >> Q;
    vector<event> v;
    for (int i = 0; i < N; ++i) {
        int s, t, x; cin >> s >> t >> x;
        v.push_back({s-x, type(-1, x)});
        v.push_back({t-x, type(0, x)});
    }
    for (int i = 0; i < Q; ++i) {
        int d; cin >> d;
        v.push_back({d, type(1, i)});
    }
    sort(v.begin(), v.end());

    vector<long long> res(Q);
    multiset<long long> se;
    for (auto p : v) {
        long long x = p.first;
        int type = p.second.first;
        long long val = p.second.second;
        if (type == -1) se.insert(val);
        else if (type == 0) se.erase(se.lower_bound(val));
        else res[val] = (se.empty() ? -1 : *(se.begin()));
    }
    for (auto v : res) cout << v << endl;
    return 0;
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

H, W, K = MAP()

# あみだくじとして妥当かの判定
def check(S):
    for i in range(W-1):
        # 1つでも隣り合う場所に横棒があればNG
        if S & 1<<i and S & 1<<(i+1):
            return False
    return True

# dp[i][S][j] := i段目まで見て、今の段の横棒の状態がSで、j本目の縦棒に行く通り数
dp = list3d(H+1, 1<<W, W+1, 0)
dp[0][0][1] = 1
for i in range(H):
    for S1 in range(1<<W):
        # 左端はただの番兵なので、立っていたらスキップ
        if S1 & 1:
            continue
        # あみだくじとして妥当でない集合は全てスキップ
        if not check(S1):
            continue
        for S2 in range(1<<W):
            if S2 & 1:
                continue
            if not check(S2):
                continue
            for j in range(1, W+1):
                # 左に棒があれば左に遷移
                if S2 & 1<<(j-1):
                    dp[i+1][S2][j-1] += dp[i][S1][j]
                    dp[i+1][S2][j-1] %= MOD
                # 右に棒があれば右に遷移
                elif S2 & 1<<j:
                    dp[i+1][S2][j+1] += dp[i][S1][j]
                    dp[i+1][S2][j+1] %= MOD
                # 棒がなければ真下に遷移
                else:
                    dp[i+1][S2][j] += dp[i][S1][j]
                    dp[i+1][S2][j] %= MOD
ans = 0
for S in range(1<<W):
    ans += dp[H][S][K]
    ans %= MOD
print(ans)


Measured memory_bytes: 8692
#include<iostream>
using namespace std;
int n,v,j,A[100];

void trace(){
    for ( int i = 0;i < n; i++ ){
        if ( i ) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

int main(){
    cin >> n;
    for ( int i = 0; i < n; i++)cin >>A[i];
    trace();
    
    for ( int i = 0; i < n; i++){
        v=A[i];
        j = i - 1;
        while ((j >= 0) && (A[j] > v)){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        if(i>0)trace();
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include<cstring>
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    string s;
    int h,w;
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
        {
            cin>>s;
            if(s=="snuke"){printf("%c%d\n",j+'A',i+1);return 0;}
        }
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List

f :: [(Int, Bool)] -> Int
f xs = sum ys
  where
    (_, ys) = mapAccumL g 0 xs
    g acc (k, True)
        | acc + k > 0  = (acc + k, 0)
        | otherwise    = (1, abs $ k - (1 - acc))
    g acc (k, False)
        | acc + k < 0  = (acc + k, 0)
        | otherwise    = (-1, abs $ k - (-1 - acc))

main :: IO ()
main = do
    getLine
    as <- fmap read . words <$> getLine :: IO [Int]
    let bs = zip as (cycle [True, False])
    let cs = zip as (cycle [False, True])
    print $ min (f bs) (f cs)

Measured memory_bytes: 54652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
double x[10010],y[10010];
double ans;
int pd;
int n;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x[i]>>y[i];
		x[i+n]=x[i],y[i+n]=y[i];
	}
	for(int j=1;j<=n-1;j++){
		double xx=x[j],yy=y[j];
		for(int i=1;i<=2*n;i++){
			x[i]-=xx,y[i]-=yy;
		}
		for(int i=3+j-1;i<=n+j-1;i++){
			if(x[i-1]*y[i]-x[i]*y[i-1]<0) pd=1;
		}
		for(int i=1;i<=2*n;i++){
			x[i]-=xx,y[i]-=yy;
		}
	}
	cout<<(pd^1)<<endl; 
	return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;


int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    vector<int> v(n);
    for(auto &a : v) cin>>a;
    int pre  =v[0];
    ll sum = 0;
    for(int i=1;i<n;++i){
        if(pre > v[i]){
            sum += pre - v[i];
        }else pre = v[i];
    }
    cout << sum << endl;
    return 0;
    
}

Measured memory_bytes: 3984
import sys
while(True):
    x, y =  map(lambda x: (int, int)[x.isdigit()](x) ,sys.stdin.readline().split(None, 1))
    if x == 0 and y == 0:
        break
    if x < y:
        print("%d %d" % (x, y))
    else:
        print("%d %d" % (y, x))

Measured memory_bytes: 7660
#include<iostream>
using namespace std;
int main(){
  int h,w;
  while(1){
    cin>>h>>w;
  if(h==0&&w==0)break;
    for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cout<<"#";
    }
    cout<<"\n";
    }
    cout<<"\n";
  }
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

void solve(){
  LL h, a; cin >> h >> a;
  cout << (h + a - 1) / a << endl;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  
 int a[110]={0};
  
  for(int i=2;i<=n;i++){
    
    int sum=i;
    for(int j=2;j<=i;j++){
      
      while(sum%j==0){
        a[j]++;
        
        sum/=j;
      }
      
    }
  }
  
 int p[100]={0};
  
  for(int i=2;i<=n;i++){
    
    if(a[i]>=74){//75*1 = 74と0 = 同じ数が74 あとは同様に
      
      p[75]++;
    }
    
    if(a[i]>=24){
      p[25]++;
    }
    
    if(a[i]>=14){
      
      p[15]++;
    }
    
    if(a[i]>=4){
      p[5]++;
    }
    
    if(a[i]>=2){
      p[3]++;
    }
  }
  //全部合わせる
  //同じ素数が多いほう(25個ある方など)から先に選択すると少ないほうは必ず一つ要素が減っている。
  cout << p[75]+p[25]*(p[3]-1)+p[15]*(p[5]-1)+p[5]*(p[5]-1)/2*(p[3]-2) << endl;
  
}


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

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ').Select(str => int.Parse(str)).ToArray();
            var result = 0;
            for (var a = line[0]; a <= line[1]; a++)
            {
                if (line[2] % a == 0)
                {
                    result++;
                }
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 18428
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    int N;
    cin>>N;
    vector<int>P(N);
    int ans=0;
    int ma=0;
    rep(i,N){
        cin>>P[i];
        ans+=P[i];
         if(ma<P[i]){
            ma=P[i];
        }
    }
    cout<<ans-ma/2<<endl;
}

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

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

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	int ca = 0;
	int cw = 0;
	int ct = 0;
	int cr = 0;
	F0R(i, N) {
		string S; cin >> S;
		if (S == "AC") ++ca;
		if (S == "WA") ++cw;
		if (S == "TLE") ++ct;
		if (S == "RE") ++cr;
	}
	print("AC x", ca);
	print("WA x", cw);
	print("TLE x", ct);
	print("RE x", cr);

}

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

int main() {
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < 3; i++) {
		if (s.at(i) == t.at(i)) {
			ans++;
		}
	}
	cout << ans << endl;
}

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

#define ll              long long
#define LMx             LLONG_MAX
#define LMn             LLONG_MIN
#define PI              3.14159265
#define endl            '\n'
#define cd              cout << '\n';
#define ys              cout << "YES"; return;
#define no              cout << "NO"; return;
#define pii             pair<int,int>
#define IOS             ios::sync_with_stdio(0);
#define vi              vector<int>
#define vll             vector<long long>
#define vpii            vector<pair<int,int>>
#define vpll            vector<pair<long long, long long>>
#define pb              push_back
#define in              insert
#define mp              make_pair
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define fr              first
#define sc              second
#define sz(a)           a.size()
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define buga(i,n,a)     for(i = 0; i < n; ++i) cout << a[i] << " ";
#define bugv(i,n,v)     cout << endl; for(i = 0; i < n; ++i) cout << v[i].first << " " << v[i].second << endl; cout << endl;

//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

/*ll myceil(ll a, ll b)
{
	return ((a+b-1)/b);
}

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


void solve()
{
	ll c, d, i, j, k, l, m, n, x, y, z, r, sum = 0, ans = 0, tmp, cnt = 0;
	//string s, t;
	cin >> n;
	vll t(n);
	for(auto &it : t) {
		cin >> it;
		sum+= it;
	}
	cin >> m;
	ll p;
	for(i = 0; i < m; i++) {
		cin >> p >> x;
		cout << sum - t[p-1] + x << endl;
	}
}


int main()
{
    IOS;
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3648
import copy
        
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

class UnionFindPathCompression():
    def __init__(self, n:int):
        self.parents = list(range(n))
        self.rank = [1]*n
        self.size = [1]*n
        

    def find(self, x:int) -> int:
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x:int, y:int):
        px = self.find(x)
        py = self.find(y)

        if px == py:
            return
        else:
            if self.rank[px] < self.rank[py]:
                self.parents[px] = py
                self.size[py] += self.size[px]
            else:
                self.parents[py] = px
                self.size[px] += self.size[py]
                #ランクの更新
                if self.rank[px] == self.rank[py]:
                    self.rank[px] += 1


n,m = map(int,input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
ans = 0
for i in range(m):
    ufpc = UnionFindPathCompression(n)
    ab_copy = copy.deepcopy(ab)
    ab_copy.pop(i)
    for a,b in ab_copy:
        a,b = a-1,b-1
        ufpc.union(a,b)
    for i in range(n):
        ufpc.find(i)
    check = set(ufpc.parents)
    if len(check) != 1:
        ans += 1
print(ans)
        

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


int main() {
    unsigned long long	 h, w;
    cin >> h >> w;

    if (h==1 || w==1) {
        cout << 1 << endl;
    } else {
        cout << (h*w+1) / 2 << endl;
    }



    return 0;
}



Measured memory_bytes: 256
import bisect
import copy

n = int(input())
list1 = list(map(int,input().split()))
list1.sort()

cout = 0
m,k = 0,0

for i in range(n-2):
	o = list1.pop(0)
	for j in range(n-i-1):
		p = list1[j]

		a = abs(o-p) +1
		b = o+p -1 #<= ではなく<条件に揃える

		d = bisect.bisect_right(list1[j+1:],b)
		
		cout += d

print(cout)


Measured memory_bytes: 54620
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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



	string s;
	cin >> s;
	REP(i, 2){
		if (s[i] == '9') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}



Measured memory_bytes: 256
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

ll a,mod = 1e9+7;
vec<vec<ll>> l, dp;

void dfs(int v, int p){
    for(int h : l[v]){
        if(h==p) continue;
        dfs(h, v);
        ll p0 = (dp[h][0]+dp[h][1])%mod;
        ll p1 = dp[h][0];
        dp[v][0] *= p0;
        dp[v][1] *= p1;
        dp[v][0]%=mod;
        dp[v][1]%=mod;
    }
}

int main() {
    fast;
    cin>>a;
    l = vec<vec<ll>>(a, vec<ll>());
    dp = vec<vec<ll>>(a, {1,1});
    for(int q=0; q<a-1; q++){
        ll x,y; cin>>x>>y; x--, y--;
        l[x].pb(y);
        l[y].pb(x);
    }
    dfs(0, -1);
    cout<<(dp[0][0]+dp[0][1])%mod;
}

Measured memory_bytes: 14848
// ABC174C
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
const ll INF=1000000000000001;
int main() {
	int k;
	cin >>k;
	int n=7;
	int ans=-1;
	for(int i=1;i<=k;i++){
		if ((n%k)==0){
			ans=i;
			break;
		}
		n=(n%k)*10+7;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3640
/*  -*- coding: utf-8 -*-
 *
 * a.cc: C: Together
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_A = 100000;

/* typedef */

/* global variables */

int acs[MAX_A + 1];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    if (ai > 0) acs[ai - 1]++;
    acs[ai]++;
    acs[ai + 1]++;
  }

  int maxac = 0;
  for (int a = 0; a <= MAX_A; a++)
    if (maxac < acs[a]) maxac = acs[a];

  printf("%d\n", maxac);
  return 0;
}


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

struct node
{
	int f,t;
} t[1000000];

long long a[1000000],size[1000000],id[1000000],hh[1000000],h,tot;
map<long long,int>mp;

void make(long long x,long long y)
{
	t[++h].f=hh[x],t[h].t=y,hh[x]=h;
}

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

void dfs(int x,int y,int z)
{
	tot+=z;
	for(int i=hh[x]; i; i=t[i].f)
	{
		int j=t[i].t;
		if(j==y) 
			continue;
		dfs(j,x,z+1);
	}
}

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1; i<=n; i++) 
	{
		scanf("%lld",a+i);
		mp[a[i]]=i;
		size[i]=1;
		id[i]=i;
	}
	sort(id+1,id+1+n,cmp);
	for(int i=1; i<n; i++)
	{
		long long x=id[i],y=a[x]-(n-size[x])+size[x];
		if(!mp[y]||y>=a[x]) 
		{
			printf("-1\n");
			return 0;
		}
		y=mp[y];
		make(x,y);
		make(y,x);
		size[y]+=size[x];
	}
	dfs(id[n],0,0);
	if(tot!=a[id[n]]) 
	{
		printf("-1\n");
		return 0;
	}
	for(int i=1; i<=n; i++)
		for(int j=hh[i]; j; j=t[j].f)
			if(t[j].t>i) 
				printf("%d %d\n",i,t[j].t);
	return 0;
}


Measured memory_bytes: 25088
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)
int H,A[MAX+1];
void maxHeapify(int i){
 int l,r,largest;
 l=2*i;
 r=2*i+1;
 if(l<=H&&A[l]>A[i])largest=l;
 else largest=i;
 if(r<=H&&A[r]>A[largest])largest=r;
 if(largest!=i){
  swap(A[i],A[largest]);
  maxHeapify(largest);
 }
}
int extract(){
 int maxv;
 if(H<1)return -INFTY;
 maxv=A[1];
 A[1]=A[H--];
 maxHeapify(1);
 return maxv;
}
void increaseKey(int i,int key){
 if(key<A[i])return;
 A[i]=key;
 while(i>1&&A[i/2]<A[i]){
  swap(A[i],A[i/2]);
  i=i/2;
 }
}
void insert(int key){
 H++;
 A[H]=-INFTY;
 increaseKey(H,key);
}
int main(){
 int key;
 char com[10];
 while(1){
  scanf("%s",com);
  if(com[0]=='e'&&com[1]=='n')break;
  if(com[0]=='i'){
   scanf("%d",&key);
   insert(key);
  }else printf("%d\n",extract());
 }
 return 0;
}


Measured memory_bytes: 6588
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, a, res;

int main() {
	cin >> N;
	for (int i = 0; i != N; ++i) {
		cin >> a;
		res += a - 1;
	}
	cout << res << endl;
}

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

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

    vector<int> sum_W(N + 1, 0);
    int count_W = 0;
    for (int i = 1; i < N; i++) {
        if (S.at(i - 1) == 'W') {
            count_W++;
        }
        sum_W.at(i) = count_W;
    }
    vector<int> sum_E(N + 1, 0);
    int count_E = 0;
    for (int i = N - 2; i >= 0; i--) {
        if (S.at(i + 1) == 'E') {
            count_E++;
        }
        sum_E.at(i) = count_E;
    }
    int ans1 = 300001, ans2;
    for (int i = 0; i < N; i++) {
        ans2 = sum_W.at(i) + sum_E.at(i);
        ans1 = min(ans1, ans2);
    }

    cout << ans1 << endl;
}

Measured memory_bytes: 3076
#include <stdio.h>
int main (){
    int num,x,i,j,flag=0,cnt=0;
    scanf("%d",&num);
    for(i=0;i<num;i++){
        scanf("%d",&x);
        for(j=2;j<=10000;j++){
            if(x%j==0&&x!=j){
                flag=1;
                break;
            }
        }
        if(flag==0){
            cnt++;
        }
        flag=0;
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a,a+n);
    reverse(a,a+n);
    long ans= a[0];
    for(int i=1;i<n/2;i++){
        ans += 2*a[i];
    }
    if(n%2) ans += a[n/2];
    cout << ans << endl;
}


Measured memory_bytes: 4412
import java.util.Scanner;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        while (sc.hasNext()) {
            int h = sc.nextInt();
            int w = sc.nextInt();
            if (h == 0 && w == 0) break;
            for (int i = 0; i < h; i++) {
                StringBuilder sb = new StringBuilder();
                for (int j = 0; j < w; j++) {
                    if (i == 0 || i == h-1 || j == 0 || j == w-1) {
                        sb.append("#");
                    } else {
                        sb.append(".");
                    }
                }
                System.out.println(sb.toString());
            }
            System.out.println("");
        }
    }
}

Measured memory_bytes: 28672
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);


int main(){
  FAST_IO  
  
  int sum, one; cin >> sum >> one;
  sum %= 500;
  if(sum <= one) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, A):
    A = [-1] + A
    B = [0] * (N + 1)
    for i in range(N, 0, -1):
        xor = 0
        for j in range(i * 2, N + 1, i):
            xor ^= B[j]
        B[i] = xor ^ A[i]
    print(sum(B))
    print(*[i for i, b in enumerate(B) if b == 1])

if __name__ == '__main__':
    input = sys.stdin.readline
    N = int(input())
    *A, = map(int, input().split())
    main(N, A)


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

const int MAX=1e9;
int main(){
    int x;
    cin >> x;
    int ans;
    for(int i=0;i<=x;i++){
        if((i*(i+1)/2)>=x){
            ans=i;
            break;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

template <class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')
    cerr<<*sdbg++;
  cerr<<"="<<h<<","; 
  _dbg(sdbg+1, a...);
}

template<class T> ostream & operator<<(ostream & os, vector<T> V){
  os<<"[";
  for(auto vv: V) os << vv <<",";
  return os << "]";
}
template<class L, class R> ostream & operator <<(ostream & os, pair<L,R> P){
  return os <<"("<<P.first <<","<<P.second <<")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int n;
string s[3];
int G[2005][5][5];

bool git(int a, int b, int startPos) {
    if (startPos >= s[a].size()) return true;
    return G[startPos][a][b];
}

bool bad(char a, char b) {
    if (a == '?' || b == '?') return false;
    return a != b;
}

bool solve(string a, string b, int startPos) {
    if (startPos >= a.size()) {
        return 1;
    }
    for (int i = startPos; i - startPos < b.size() && i < a.size(); i++) {
        if (bad(a[i], b[i - startPos])) {
            return 0;
        }
    }
    return 1;
}

int main() {
    
    cin >> s[0] >> s[1] >> s[2];
    n = max(s[0].size(), max(s[1].size(), s[2].size()));
    
    for (int k = 0; k <= n; k++) {
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (i == j) continue;
                G[k][i][j] = solve(s[i], s[j], k);
//                 debug(k, i, j, G[k][i][j]);
            }
        }
    }
    
    vector<int> per;
    for (int i = 0; i < 3; i++) {
        per.push_back(i);
    }
    int ans = 3 * n;
    do {
        
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n; j++) {
                if (git(per[0], per[1], i) && git(per[1], per[2], j) && git(per[0], per[2], i + j)) {
                    ans = min(ans, max((int)s[per[0]].size(), max(i + (int)s[per[1]].size(), i + j + (int)s[per[2]].size())));
                }
            }
        }
    } while (next_permutation(per.begin(), per.end()));
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 512
nums = []

for i in range(3):
    nums.append([int(n) for n in input().split(" ")])

bingo_list = []

bingo_list.extend(nums)
for i in range(3):
    bingo_list.append([nums[0][i], nums[1][i], nums[2][i]])
bingo_list.append([nums[0][0], nums[1][1], nums[2][2]])
bingo_list.append([nums[2][0], nums[1][1], nums[0][2]])

is_bingo = False
n = int(input())
for i in range(n):
    num = int(input())
    for bingo in bingo_list:
        if num in bingo:
            bingo.remove(num)
            if not bingo:
                is_bingo = True

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

Measured memory_bytes: 3064
"use strict";

const main = arg => {
    const input = arg.trim().split("\n");

    const n = parseInt(input[0]);
    const s = input[1];
    let rs = []
    let gs = []
    let bs = []
    for(let i = 0; i<s.length;i++){
        if(s[i] === "R") rs.push(i)
        else if(s[i] === "G") gs.push(i) 
        else if(s[i] === "B") bs.push(i)
    }
    let num = rs.length * gs.length * bs.length
    for(let i = 0; i< n; i++){
        for(let j = i+1; j<n; j++){
            let k = j + j - i
            if (k >= n) break
            if( s[i] !== s[j] && s[j] !== s[k] && s[k] !== s[i]){
                num--
            }
        }
    }
    console.log(num)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 35280
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val l = scanner.nextInt()

    val result =
        mutableListOf<String>().apply {
            repeat(n + 1) {
                add(scanner.nextLine())
            }
            sort()
        }.joinToString(separator = "")
    print(result)
}

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

int main() {
   int n, k;
   string s;
   cin >> n >> k >> s;
  
  s[k-1] += 32;

   cout << s << endl;
}

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

int main() {
    string s;
    ll k;
    cin >> s >> k;
    for (int i = 0; i < k; i++) {
        if (s[i] != '1') {
            cout << s[i] << endl;
            return 0;
        }
        if (i + 1 == s.size()) break;
    }
    cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::{Read, Write};

fn run() {
    let m = 1_000_000;
    let mut dp = vec![m; m + 1];
    let mut dp1 = vec![m; m + 1];
    dp[0] = 0;
    dp1[0] = 0;
    for i in 1.. {
        let k = i * (i + 1) * (i + 2) / 6;
        if k > m {
            break;
        }
        for j in k..(m + 1) {
            dp[j] = std::cmp::min(dp[j], dp[j - k] + 1);
            if k % 2 == 1 {
                dp1[j] = std::cmp::min(dp1[j], dp1[j - k] + 1);
            }
        }
    }
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    while let Some(s) = it.next() {
        let n: usize = s.parse().unwrap();
        if n == 0 {
            break;
        }
        writeln!(out, "{} {}", dp[n], dp1[n]).ok();
    }
}

fn main() {
    run();
}



Measured memory_bytes: 21300
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>


using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)


using namespace std;


int main() {
	string s;

	cin >> s;
	int n = s.size();
	for(int i = 0; i < n / 2; i ++) {
		if (s[i] != s[n - i - 1]) {
			cout << "No" << endl;
			return 0;
		}
	}

	for (int i = 0; i < (n - 1) / 2; i++) {
		if (s[i] != s[(n - 1) / 2 - i - 1]) {
			cout << "No" << endl;
			return 0;

		}
	}
	int count = 0;
	for (int i = (n + 3) / 2 - 1; i < n; i++) {
		if (s[i] != s[n - count - 1]) {
			cout << "No" << endl;
			//cout << s[i] << ":" << s[n - count - 1] << endl;
			return 0;

		}
		count ++;
	}	

	cout << "Yes" << endl;
	return 0;

}

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

const int N=3010;
struct Edge{int to,next;} e[N<<1];
int h[N],sum=0;
int a[N],n;
bool sg[N];

void add_edge(int u,int v)
{
	e[++sum].to=v;
	e[sum].next=h[u];
	h[u]=sum;
}

void dfs(int u,int fa)
{
	for(int tmp=h[u];tmp;tmp=e[tmp].next)
	{
		int v=e[tmp].to;
		if(v==fa) continue;dfs(v,u);
		if(sg[v]==0&&a[u]>a[v]) sg[u]=1;
	}
}

int main()
{
	int u,v;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",a+i);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		add_edge(u,v);
		add_edge(v,u);
	}
	for(int i=1;i<=n;i++)
	{
		memset(sg,0,sizeof(sg));
		dfs(i,0);
		if(sg[i]) printf("%d ",i);
	}
	return 0;
}

Measured memory_bytes: 512
# https://atcoder.jp/contests/agc014/tasks/agc014_b

n, m = map(int, input().split())
edges = [0] * n
ab = []
for _ in range(m):
    a, b = map(int, input().split())
    ab.append((a, b))

for a, b in ab:
    edges[a - 1] += 1
    edges[b - 1] += 1

for e in edges:
    if e % 2 == 1:
        print('NO')
        break
else:
    print('YES')

Measured memory_bytes: 83476
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d,x,cnt=0;
  int a[109];
  cin>>n>>d>>x;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++){
    for(int j=1;j<=d;j+=a[i]){
      cnt++;
    }
  }
  cout<<cnt+x<<endl;
  return(0);
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  map<int,int> m;
  priority_queue<int> pq;
  for(int i=0;i<N;i++){
    cin >> a.at(i);
    for(int j=-1;j<2;j++){
      if(m.count(a.at(i)+j)){
        m.at(a.at(i)+j)++;
      }else{
        m[a.at(i)+j]=1;
      }
      pq.push(m.at(a.at(i)+j));
    }
  }
  cout << pq.top() << endl;
  return 0;
}


Measured memory_bytes: 7028
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt(), m = sc.nextInt();
			if( (n|m) == 0 ) break;
			String[] t = new String[n]; int[] v = new int[n];
			String[] b = new String[m];
			for(int i=0;i<n;i++) {
				t[i] = sc.next(); v[i] = sc.nextInt();
			}
			for(int i=0;i<m;i++) b[i] = sc.next();
			
			int sum = 0;
			for(int i=0;i<n;i++) for(int h=0;h<m;h++){
				boolean flg = true;
				for(int j=0;j<8;j++) if(t[i].charAt(j) != '*' && t[i].charAt(j) != b[h].charAt(j))
					flg = false;
				if(flg) sum += v[i];
			}
			System.out.println(sum);
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 35892
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
 
struct c{
  int a;
  int b;
  
  bool operator<( const c& right ) const {
        return b == right.b ? a < right.a : b < right.b;
    }
  
};

int main(){
  int n,i,wa=0,kotae=0;
  cin>>n;
  vector<c> d(n);
  for(i=0;i<n;i++){
    cin>>d[i].a>>d[i].b;
  }
  sort(d.begin(), d.end());
  for(i=0;i<n;i++){
    wa+=d[i].a;
    if(wa>d[i].b){
      kotae=1;
    }
  }
  if(kotae==0){
    cout<<"Yes";
  }else{
    cout<<"No";
  } 
}
  

Measured memory_bytes: 1792
#include<iostream>

using namespace std;

	
long long bin(long long table[],long long value,long long low,long long high){
		
		long long upper_bound = high;
	
		while(low<=high){
			long long mid = (low+high)/2;
			if(table[mid]>value){
				high = mid-1;
				
			}
			else if(table[mid]<value){
				low = mid+1;
				
			}
			else{
				return mid;
			}
			//printf("%d %d\n",checker1,checker2);

			
		}
		
		if(low>=upper_bound)return upper_bound-1;
		else return low-1;

		
		
return -1;
}


int main(){
	long long n,m,k; 
	scanf("%lli %lli %lli",&n,&m,&k);

	long long *table1 = new long long [n+1];
	long long *table2 = new long long [m+1];

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

	table2[0] = 0;
	for(int i=1;i<=m;i++){
		cin >> table2[i];
		table2[i] += table2[i-1];
	}


	long long count = 0;
	for(int i=0;i<n+1;i++){
		long long rem = k - table1[i];

		if(rem<0)continue;
		long long j = bin(table2,rem,0,m);
		
	//	printf("%lli %lli %d\n",rem,j,i);
		count = max(count,(i+j));
	}

printf("%lli\n",count);


	return 0;
}

Measured memory_bytes: 6924
#include <algorithm>
#include <cmath>
#include <ctype.h>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define ENDL '\n'
#define FOR(i, n) for (int i = 0; i < n; ++i)
#define FOR_EACH(i, v) for (auto&& i : v)

int N;

struct Edge {
	int to;
	int length;

	Edge(int to_, int length_)
	{
		to = to_;
		length = length_;
	}
};

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

	cin >> N;
	vector<list<Edge>> edge(N);
	vector<bool> ans(N);
	vector<bool> visited(N);
	FOR(i, N) {
		ans[i] = false;
		visited[i] = false;
	}

	FOR(i, N - 1) {
		int u;
		int v;
		int w;
		cin >> u >> v >> w;

		edge[u - 1].push_back(Edge(v - 1, w));
		edge[v - 1].push_back(Edge(u - 1, w));
	}

	queue<int> q;
	q.push(0);
	while (!q.empty()) {
		int from = q.front();
		q.pop();
		visited[from] = true;
		for (list<Edge>::iterator it = edge[from].begin(); it != edge[from].end(); it++) {
			if (!visited[it->to]) {
				q.push(it->to);
			}

			if (it->length & 0x1) {
				ans[it->to] = !ans[from];
			}
			else {
				ans[it->to] = ans[from];
			}
		}
	}

	FOR(i, N) {
		cout << (ans[i] ? 1 : 0) << ENDL;
	}

	return 0;
}

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

int main() {
	int n, max_pos = 0;
	vector <int> v, c;
	cin >> n;
	v.resize(n);
	c.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	for (int i = 0; i < n; i++) {
		int dif = v[i] - c[i];
		if (dif > 0) max_pos += dif;
	}
	cout << max_pos << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>

int main(){
	char ch;
	while(1) {
		scanf("%c",&ch);
		if(ch == '\n'){
			break;	
		}
		
		if(islower(ch)){
			ch = toupper(ch);
		}
		else if(isupper(ch)){
			ch = tolower(ch);
		}
		else{}
		printf("%c",ch);
	}
	printf("\n");
		
 return 0 ;
}

Measured memory_bytes: 940
N,T = map(int, input().split())
t = list(map(int, input().split()))

ans = 0

for i in range(N-1):
    if t[i+1] - t[i] > T:
        ans += T
        
    else:
        ans += (t[i+1]-t[i])
        
print(ans+T)

Measured memory_bytes: 26708
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int main(void) {
    int n;
    cin >> n;
    while (n--) {
        int y, m, d;
        cin >> y >> m >> d;
        // year
        int year = 0;
        for (int i = y+1; i < 1000; i++) {
            if (i % 3 == 0) {
                year += 200;
            } else {
                year += 195;
            }
        }
        // month
        int month = 0;
        for (int i = m+1; i <= 10; i++) {
            if (y % 3 == 0 || i % 2 == 1) {
                month += 20;
            } else {
                month += 19;
            }
        }
        // day
        int day = 0;
        if (m % 2 == 1 || y % 3 == 0) day = 20-d;
        else day = 19-d;
        cout << year+month+day+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

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

    
    return 0;
}

Measured memory_bytes: 256
N = input()



can = True
for i in range(len(N)-1):
  if N[i+1] != '9':
    can = False

if len(N) == 1:
  print(int(N))
elif can:
  ans = 0
  for i in N:
    ans += int(i)
  print(ans)
else:
  ans = int(N[0])-1 + (len(N)-1)*9
  print(ans)


Measured memory_bytes: 3060
// https://atcoder.jp/contests/

#include <iostream>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  int r, g, b;

  cin >> r >> g >> b;

  if ((10 * g + b) % 4 == 0)
    cout << "YES" << '\n';
  else
    cout << "NO" << '\n';

  return 0;
}


Measured memory_bytes: 384
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))

a = 0
b = 0
c = 0
for i in range(len(P)):
    if P[i] <= A:
        a += 1
    elif A < P[i] <= B:
        b += 1
    elif P[i] > B:
        c += 1

print(min(a, b, c))


Measured memory_bytes: 38384
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define szz 200009
#define mx 10000000000
ll n,m,t[3*szz],ini[3*szz],lini[3*szz],mn[3*szz];
bool marked[3*szz];
void koro(ll node,ll l,ll r)
{
    if(marked[node]==true)
    {
        ll mid=(l+r)/2;
        marked[node]=false;
        marked[2*node]=marked[2*node+1]=true;
        mn[2*node]=t[2*node]=t[node];
        ini[2*node]=ini[2*node+1]=ini[node];
        t[2*node+1]=mn[2*node+1]=t[node]+(mid-l+1)*ini[node];
    }
    return;
}
ll update(ll node,ll l,ll r,ll le,ll ri,ll val,ll dif)
{
    if(le>ri || l>ri || le>r)
        return 0;
    if(l>=le && r<=ri)
    {
        marked[node]=true;
        mn[node]=val;
        t[node]=val;
        ini[node]=dif;
        return r-l+1;
    }
    koro(node,l,r);
    ll mid=(l+r)/2;
    ll a,b;
    a=update(2*node,l,mid,le,ri,val,dif);
    b=update(2*node+1,mid+1,r,le,ri,val+(dif)*a,dif);
    mn[node]=min(mn[2*node],mn[2*node+1]);
    return a+b;
}
ll query(ll node,ll l,ll r,ll ind)
{
    if(ind>r || ind<l)
        return 0;
    if(l==r)
        return mn[node];
    koro(node,l,r);
    ll mid=(l+r)/2;
    ll a,b;
    a=query(2*node,l,mid,ind);
    b=query(2*node+1,mid+1,r,ind);
    return a+b;
}
int main()
{
    ll n,m;
    scanf("%lld %lld",&n,&m);
    ll la=0,j,k;
    for(int i=1;i<=n;i++){
        scanf("%lld %lld",&j,&k);
        if(j<=(la+1))
            la=max(k,la);
          //  printf("     %lld\n",la);
           if(j>(la+1))
           {
               ll a=query(1,1,m,j-1);
            //   printf("     %lld %d\n",a,i);
               update(1,1,m,j,k,a+1,1);
           }
           else
           {
               update(1,1,m,1,la,mx,0);
           }
        //   printf("   %lld\n",query(1,1,m,2));
           if(mn[1]>=mx)
           printf("-1\n");
           else
            printf("%lld\n",mn[1]+i);
        }
    return 0;
}


Measured memory_bytes: 16512
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;

#define rp(i,t) for(int i=0;i<(t);i++)
#define rep(i,s,t) for(int i=(s);i<=(t);i++)
#define rsp(i,s,t) for(int i=(s);i<(t);i++)
#define rrp(i,t,s) for(int i=(t);i>=(s);i--)
#define rcp(i,s,b,d) for(int i=(s);b;d)
#define mst(a,x) memset(a,x,sizeof(a))
#define INF 0x3f3f3f3f

#define Dp puts("")
#define Dw printf
#define Ds printf("#")

typedef long long ll;
char ch;
ll T,x,ans=1;

inline void read(ll &x){x=0;do{ch=getchar();}while(ch<'0'||'9'<ch);do{x=x*10+ch-'0';ch=getchar();}while('0'<=ch&&ch<='9');}

ll gcd(const ll &a,const ll &b)
{
	if(!b)return a;
	return gcd(b,a%b);
}

inline ll lcm(const ll &a,const ll &b)
{
	return a/gcd(a,b)*b;
}

int main(void)
{
	read(T);
	while(T--)
	{
		read(x);
		ans=lcm(x,ans);
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 256