akhauriyash/Code-Regression huggingface dataset:
import bisect
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def solve():
    N, M = map(int, input().split())
    if N*M == 0:
        return False
    P = [0]+[int(input()) for _ in range(N)]
    # solve
    k = [P[i]+P[j] for i in range(N) for j in range(i, N)]
    k = sorted(k)

    ret = 0
    for tmp in k:
        if tmp > M:
            break
        else:
            r = M-tmp
            l = bisect.bisect_right(k, r)
            tmp += k[l-1]
            ret = max(ret, tmp)
    return ret


ans = []
while True:
    ret = solve()
    if ret:
        ans.append(ret)
    else:
        break
print("\n".join(map(str, ans)))



Measured memory_bytes: 31728
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,ans;
signed main(){
	string s,t;
	cin>>s>>t;
	rep(i,3){
		if(s[i]==t[i])ans++;;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int data[10];

void myScan(){
	int i;
	for(i=0;i<10;i++){
		scanf("%d",&data[i]);
	}
	return;
}

int check(int bTop,int cTop,int i){
	int result=0;
	
	if(i==9){
		return (data[9]>bTop || data[9]>cTop);
	}
	
	if(data[i]>bTop){
		result+=check(data[i],cTop,i+1);
	}else{
		result+=0;
	}
	
	if(data[i]>cTop){
		result+=check(bTop,data[i],i+1);
	}else{
		result+=0;
	}
	return result;
}

int slove(void){
	myScan();
	
	return check(0,0,0);
}

int main(void){
	int i,datasetNum;
	scanf("%d",&datasetNum);
	for(i=0;i<datasetNum;i++){
		printf(slove()? "YES\n" : "NO\n");
	}
	
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[] a = {0,100001};
        boolean flag = true;
        while(m>0){
            int l = Integer.parseInt(sc.next());
            int r = Integer.parseInt(sc.next());
            if(r < a[0] || a[1] < l){
                System.out.println(0);
                flag = false;
                break;
            }
            if(a[0] < l){
                a[0] = l;
            }
            if(r < a[1]){
                a[1] = r;
            }
            m--;
        }
        sc.close();
        if(flag){
            System.out.println(a[1]-a[0]+1);
        }
    }
}

Measured memory_bytes: 51024
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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; }

int main(void){
    int N; cin >> N;
    int d[N]; REP(i,N) cin >> d[i];
    set<int> s; REP(i,N) s.insert(d[i]);
    cout << s.size() << endl;
    return 0;
}

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

int main()
{
    char s[100];
    scanf("%s",s);
    for(int i=0;s[i];i++)
        if(i==5||i==13)
            s[i]=' ';
    printf("%s",s);
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
      cin >> vec.at(i);
  }
  vector<int> backet(101);
  for(int i =0 ; i < N; i++){
  	backet.at(vec.at(i))++;
  }
  int res = 0;
  for(int i = 1; i < 101; i++){
  	if(backet.at(i)) res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
def resolve():
    K = ir()
    A, B = lr()
    for i in range(A, B+1):
        if i%K == 0:
            print('OK')
            return
    print('NG')
resolve()

Measured memory_bytes: 61684
n = int(input())
A = list(map(int,input().split()))

def seq(a,t):
    ans = 0
    x = 0
    for i in a:
        x+=i
        if t==True and x<1:
            ans+=1-x
            x=1
        elif t==False and x>-1:
            ans+=x+1
            x=-1
        t = not t
    return ans
print(min(seq(A,True),seq(A,False)))

Measured memory_bytes: 14332
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define pii pair<int, int>
#define keep_calm_and_become_orange ios_base::sync_with_stdio(0)
#define utochka_po_imeni_jonathan_livingston cin.tie(0)
 
using namespace std;
 
void yes() {
    cout << "YES" << endl;
}
 
void no() {
    cout << "NO" << endl;
}
 
long long bp(long long a, long long p, long long mod) {
    if (p == 0) {
        return 1ll;
    } else if (p % 2 == 1) {
        return bp(a, p - 1, mod) * a % mod;
    } else {
        long long res = bp(a, p / 2, mod);
        return res * res % mod;
    }
}

const long long mod = 1e9 + 7;

void solve(int qq) { 
    string s; int d;
    cin >> s >> d;
    int n = int(s.size());
    vector<vector<long long> > dp(d, vector<long long>(2));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        vector<vector<long long> > dp_new(d, vector<long long>(2));
        for (int sum = 0; sum < d; sum++) {
            for (int j = 0; j < 2; j++) {
                for (int last = 0; last < 10; last++) {
                    int here = s[i] - '0';
                    if (last > here and !j) break;
                    else if (last < here or j) {
                        dp_new[(sum + last) % d][1] += dp[sum][j];
                        dp_new[(sum + last) % d][1] %= mod;
                    } else {
                        dp_new[(sum + last) % d][0] += dp[sum][j];
                        dp_new[(sum + last) % d][0] %= mod;
                    }
                }
            }
        }
        for (int sum = 0; sum < d; sum++) {
            for (int j = 0; j < 2; j++) {
                dp[sum][j] = dp_new[sum][j];
            }
        }
    }
    cout << (dp[0][0] + dp[0][1] + mod - 1) % mod << endl;
}   
 
int main()
{
    keep_calm_and_become_orange;
    utochka_po_imeni_jonathan_livingston;
 
    int t; t = 1;
    for (int i = 1; i <= t; i++) {
        solve(i);
    }
    return 0;
}

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

ans = 0
for i in range(1, n):
    for j in range(i):
        dist = 0
        for k in range(d):
            dist += (x[i][k] - x[j][k]) ** 2
        if abs(int(dist ** 0.5) ** 2 - dist) < 1e-6: 
            ans += 1
print(ans)

Measured memory_bytes: 38384
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
    return divisors


def solve():
    N = int(rl())
    
    divisors1 = set(make_divisors(N - 1)[1:])
    divisors2 = set(make_divisors(N)[1:])
    
    for divisor in divisors2:
        tmp = N
        while tmp % divisor == 0:
            tmp //= divisor
        if tmp % divisor == 1:
            divisors1.add(divisor)
    print(len(divisors1))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 39536
N = int(input())
A = list(map(int, input().split()))

dp = [int(n*(n-1)/2) for n in range(N+1)]
cnt_org = [0]*(N+1)

for a in A:
  key = a
  cnt_org[a] += 1 

base = sum([dp[c] for c in cnt_org])

for k in range(N):
  diff = dp[cnt_org[A[k]]] - dp[cnt_org[A[k]]-1]
  print(base - diff)



Measured memory_bytes: 26140
#include <stdio.h>

int main(void){
	int N;
	int a[20000],b[20000];
	int p[20000];

	int i;
	
	scanf("%d",&N);
	for(i=0;i<N;i++){scanf("%d",&p[i]);}

	
	for(i=0;i<N;i++){
		a[i] = 20000*(i+1);
		b[N-1-i] = 20000*(i+1);
	}

	for(i=0;i<N;i++){
		a[p[i]-1] += i;
	}

	for(i=0;i<N-1;i++){printf("%d ",a[i]);}
	printf("%d\n",a[N-1]);
	for(i=0;i<N-1;i++){printf("%d ",b[i]);}
	printf("%d\n",b[N-1]);

	return 0;
}

Measured memory_bytes: 768
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n, m, k = LI()
    for i in range(n):
        unit = n-2*i

        if unit == 0:
            if k == i*m:
                print("Yes")
                break
        else:
            j = (k-i*m)//(n-2*i)
            jr = (k-i*m)%(n-2*i)

            if 0 <= j <= m and jr == 0:
                print("Yes")
                break
    else:
        print("No")
main()


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

int main(void){
    int a;
    int b;
    int c;
    
    std::cin >> a >> b >> c;
    
    if(a < b && b < c) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
    
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<long long, long long>
#define ff first
#define ss second

main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s, t; cin >> s >> t;
    int N = s.size(), M = t.size();
    if(N > M){swap(N, M), swap(s, t);}
    int DP[N+1][M+1];
    memset(DP, 0, sizeof(DP));
    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= M; j++){
            if(s[i-1] == t[j-1]){
                DP[i][j] = DP[i-1][j-1] + 1;
            }
            else{
                DP[i][j] = max(DP[i-1][j], DP[i][j-1]);
            }
        }
    }
    pii pos = {N, M};
    string ans = "";
    while(true){
        if(!DP[pos.ff][pos.ss]) break;
        if(s[pos.ff-1] == t[pos.ss-1]) ans += s[pos.ff-1], pos.ff--, pos.ss--;
        else (DP[pos.ff-1][pos.ss] > DP[pos.ff][pos.ss-1]) ? pos.ff-- : pos.ss--;
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
}

Measured memory_bytes: 38796
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 998244353
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 5000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(){
    string s; cin>>s;
    if(s.front()==s.back()){
        if(s.size()%2==1)cout<<"Second"<<endl;
        else cout<<"First"<<endl;
    }else{
        if(s.size()%2==0)cout<<"Second"<<endl;
        else cout<<"First"<<endl;
    }
}

Measured memory_bytes: 512
/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>

typedef long long LL;
typedef unsigned long long ULL;
using namespace std;

const LL MOD = 998244353, maxN = 1000000 + 24;
int N, a, b;
LL K, ans;
LL f[maxN], inv[maxN];

LL Pow(LL x, LL y)
{
	LL res = 1;
	while (y) {
		if (y&1) res = res % MOD * x % MOD;
		x *= x; x %= MOD; y >>= 1;
	}
	return res;
}

LL Com(LL x, LL y)
{
	if (x < y) return 0;
	return f[x] % MOD * inv[y] % MOD * inv[x-y] % MOD;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	f[0] = 1;
	for (int i = 1; i < maxN; i++) f[i] = f[i-1] % MOD * i % MOD ;
	inv[maxN-1] = Pow(f[maxN-1], MOD-2);
	for (int i = maxN - 2; i >= 0; i--) inv[i] = inv[i+1] % MOD * (i+1) % MOD;
		 // printf("%lld\n", Pow(2, 4));
	// for (int i = 0; i < 10; i++) printf("f = %lld, inv = %lld\n", f[i], inv[i]);
	while (scanf("%d%d%d%lld", &N, &a, &b, &K) == 4) {
		ans = 0;
		if (!K) { puts("1"); continue; }
		for (int i = 1; i <= N; i++) {
			LL t = K - a*i;
			if (t < 0 || (t % b)) continue;
			LL j = t / b;
			ans = (ans + Com(N, i) * Com(N, j) + MOD) % MOD;
		}
		printf("%lld\n", ans);
	}

	return 0;
}
/*
    input:
    output:
    modeling:
    methods:
    complexity:
    summary:
*/

Measured memory_bytes: 16000
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  string s,t;
  int a=0;
  cin>>s>>t;
  rep(i,s.size()){
    if(s[i]!=t[i]){
      a++;
    }
  }
  
  cout<<a<<endl;
}

Measured memory_bytes: 3912
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll int
#define N 305
#define rep(i,j,k) for (ll i=j;i<=k;++i)
#define per(i,j,k) for (ll i=j;i>=k;--i)
using namespace std;
inline ll read(){
	char ch=getchar(); ll x=0,f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}
ll n,m,ans,a[N][N],now[N],flag[N],tmp[N];
int main(){
	n=ans=read(); m=read();
	rep(i,1,n) rep(j,1,m) a[i][j]=read();
	rep(i,1,n) now[i]=1;
	rep(T,1,m-1){
		rep(i,1,n) while (flag[a[i][now[i]]]) ++now[i];
		ll num=0; memset(tmp,0,sizeof tmp);
		memset(tmp,0,sizeof tmp);
		rep(i,1,n) ++tmp[a[i][now[i]]];
		rep(i,1,m) if (tmp[i]>tmp[num]) num=i;
		ans=min(ans,tmp[num]); flag[num]=1;
	}
	printf("%d",ans);
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	int data[5];
	int i, j, swap;
	
	for (i = 0; i < 5; i++){
		scanf("%d", &data[i]);
	}
	
	for (i = 0; i < 4; i++){
		for (j = i + 1; j < 5; j++){
			if (data[i] < data[j]){
				swap = data[i];
				data[i] = data[j];
				data[j] = swap;
			}
		}
	}
	
	for (i = 0; i < 5; i++){
		printf("%d", data[i]);
		if (i == 4){
			printf("\n");
		}
		else {
			printf(" ");
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,p;
    string s;
    vector<pair<pair<string,int>,int>>vec;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s>>p;
        vec.push_back(make_pair(make_pair(s,-p),i+1));
    }
    sort(vec.begin(),vec.end());
    for(int i=0;i<n;i++)
        cout<<vec[i].second<<endl;
}


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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

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

  ll n; cin >> n;
  ll ga, sa, ba; cin >> ga >> sa >> ba;
  ll gb, sb, bb; cin >> gb >> sb >> bb;

  ll maxn = 0;
  for(int i=0; i<=n/ga; i++) {
    for(int j=0; j<=n/sa; j++) {
      ll rem = n-ga*i-sa*j;
      if (rem < 0) continue;
      ll k = 0;
      if (bb > ba) {
        k = rem/ba;
        rem -= ba*k;
      }
      chmax(maxn, rem+gb*i+sb*j+bb*k);
    }
  }

  n = maxn;

  vector<P> vec;
  if (ga > gb) {
    vec.emplace_back(ga, gb);
  }
  if (sa > sb) {
    vec.emplace_back(sa, sb);
  }
  if (ba > bb) {
    vec.emplace_back(ba, bb);
  }

  ll ans = 0;
  if (vec.size() == 3) {
    for(int i=0; i<=n/gb; i++) {
      for(int j=0; j<=n/sb; j++) {
        ll rem = n-gb*i-sb*j;
        if (rem < 0) continue;
        ll k = rem/bb;
        rem -= bb*k;
        chmax(ans, rem+ga*i+sa*j+ba*k);
      }
    }
    cout << ans << endl;
    return 0;
  }

  if (vec.size() == 2) {
    ll a = vec[0].first;
    ll b = vec[0].second;
    ll c = vec[1].first;
    ll d = vec[1].second;
    for(int i=0; i<=n/b; i++) {
      ll rem = n-b*i;
      ll k = rem/d;
      rem -= d*k;
      chmax(ans, rem+a*i+c*k);
    }
    cout << ans << endl;
    return 0;
  }

  if (vec.size() == 1) {
    ll a = vec[0].first;
    ll b = vec[0].second;
    ll k = n/b;
    ll rem = n-b*k;
    cout << rem+a*k << endl;
    return 0;
  }

  cout << n << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] line = sc.nextLine().split(" ");
        int n = Integer.parseInt(line[0]);
        int m = Integer.parseInt(line[1]);
        boolean[] done = new boolean[n];
        int ac = 0, penalty = 0;
        int[] wa = new int[n];
        for(int i = 0; i < m; i++) {
            line = sc.nextLine().split(" ");
            int p = Integer.parseInt(line[0]);
            if(done[p-1]) continue;
            if(line[1].equals("AC")) {
                ac++;
                done[p-1] = true;
                penalty+=wa[p-1];
            } else if(line[1].equals("WA")) {
                wa[p-1]++;
            }
        }
        System.out.println(ac + " " + penalty);
    }
}

Measured memory_bytes: 103168
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e9

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll n, a, b, c, ans, cur, lo, mid, hi, h[100000];

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> a >> b;
	c = a-b;
	for(int i = 0; i < n; i++){
		cin >> h[i];
	}
	lo = 0;
	hi = 1e9;
	while(lo <= hi){
		mid = lo+(hi-lo)/2;
		cur = 0;
		for(int i = 0; i < n; i++){
			cur+=max(ll(0),(h[i]-mid*b+c-1)/c);
		}
		if(cur<=mid){
			ans=mid;
			hi=mid-1;
		}
		else{
			lo=mid+1;
		}
	}
	cout << ans;
	return 0;
}


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

using namespace std;

int main()
{
    long long n,d,a;
    cin>>n>>d>>a;
    vector<pair<long long,long long>> v(n);
    vector<long long> separate(n);
    for(int i =0;i<n;i++)
    {
        cin>>v[i].first>>v[i].second;
        separate[i] = v[i].first;
    }

    sort(v.begin(),v.end());
    sort(separate.begin(),separate.end());
    long long rsum = 0;
    vector<long long> baggage(n);
    long long bombs = 0;
    for(int i = 0;i<n;i++)
    {
        long long x = v[i].first;
        rsum += baggage[i];
        long long y = v[i].second;
        y -= rsum;
        if(y <= 0)
        {
            continue;
        }
        long long curr;
        if(y % a == 0)
        { 
            curr = y/a;
            bombs += curr;
        }
        else
        {
            curr = y/a + 1;
            bombs += curr;
        }

        rsum += curr*a;
        
        long long temp;
        temp = x + 2*d;
        auto it = upper_bound(separate.begin(),separate.end(),temp);
        if(it != separate.end())
        {
            int j = it-separate.begin();
            baggage[j] -= curr*a;
        }
    }

    cout<<bombs;

    return 0;
}

Measured memory_bytes: 9512
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#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 Per(i,sta,n) for(int i=n-1;i>=sta;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++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int h,w;
int a[200010],b[200010];
set<P> se1,se2;

void solve(){
    cin >> h >> w;
    rep(i,h){
        cin >> a[i] >> b[i];
    }
    se1.insert(P(0,-mod));
    se2.insert(P(mod,0));
    rep(i,w){
        se1.insert(P(i+1,i+1));
        se2.insert(P(0,i+1));
    }
    se1.insert(P(w+1,0));
    rep(i,h){
        //cout << i << endl;
        auto it1=se1.lower_bound(P(a[i],0));
        P p=P(-1,-1);
        while((*it1).first<=b[i]){
            p=(*it1);
            int idx=p.first,pos=p.second;
            //cout << idx << " " << pos << endl;
            se2.erase(P(idx-pos,idx));
            it1=se1.erase(it1);
        }
        if(p.first!=-1) if(b[i]+1<(*it1).first){
            se1.insert(P(b[i]+1,p.second));
            se2.insert(P(b[i]+1-p.second,b[i]+1));
        }
        auto it=se2.begin();
        if((*it).first>=w+5) cout << -1 << endl;
        else cout << i+1+(*it).first << endl;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 23896
import sys

N = int(input())

if N == 4:
	print('Yes')
	sys.exit()
p = N//7
q = N%7
if p < 1:
	print('No')
	sys.exit()
for i in range(p):
	if q % 4 == 0:
		print('Yes')
		sys.exit()
	else:
		q = (q+7)%4
		if q == 0:
			print('Yes')
			sys.exit()
print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;


lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

lli A[100000] = {};

lli B[100000] = {};

int main(void) {

	lli N;
	cin >> N;

	for (int i = 0; i < N; i++)
		cin >> A[i];

	lli B0 = 0;
	
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			B0 += A[i];
		}
		else {
			B0 -= A[i];
		}
	}

	for (int i = 0; i < N - 1; i++) {
		B[i] = B0;
		B0 = (A[(i) % N] - B0 / 2) * 2;
	}

	B[N - 1] = B0;

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

	return 0;
}

Measured memory_bytes: 2816
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<int, int>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

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

const int mod = 1000000007;

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

  int n, m;
  cin >> n >> m;

  vector<P> bridges(m);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    bridges[i] = {b, a};
  }
  sortv(bridges);

  int last = 0;
  int idx = 0;
  int res = 0;
  while(idx < m) {
    while(idx < m && bridges[idx].second < last) idx++;
    if (idx == m) break;
    res++;
    last = bridges[idx].first;
  }

  cout << res << endl;
}


Measured memory_bytes: 1024
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    a,b,c = map(int, sys.stdin.readline().split())
    #a,b,c → x,x,xになる過程を求める問題
    #上の過程は(3x-(a+b+c))/2回
    #m=max{a,b,c}とするとx=m or m+1。条件分岐:和とmaxの偶奇が一致してればx=m
    wa = a+b+c
    m=max(a,b,c)

    if wa % 2== m %2:
        print((3*m-wa)//2)
    else:
        print((3*(m+1)-wa)//2)

Measured memory_bytes: 5200
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
					/*多倍長整数/cpp_intで宣言
					#include <boost/multiprecision/cpp_int.hpp>
					using namespace boost::multiprecision;
					*/

#pragma gcc target ("avx2")
#pragma gcc optimization ("o3")
#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2.0)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}
#define nof(T) [](T a){return a;}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if ((a == b && a != c) || (a == c && a != b) || (b == c && a != b))printyn(true);
	else printyn(false);

	Please AC;
}


Measured memory_bytes: 888
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define N 1005
#define rep(i, l, r) for(int i=l; i<=r; ++i)
using namespace std;
int t;
int n;
int a[N], b[N];    
int main(){
	scanf("%d", &n);
	int tmp=0, ans=0;
	rep(i, 1, n){
		scanf("%d%d", &a[i], &b[i]);
		if(a[i]==b[i]) ++tmp;
		else tmp=0;
		if(tmp==3) ans=1;
	}
	printf(ans ? "Yes" : "No");
	return 0;
}
	

Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
  string s; cin >> s;
  s.at(3) = '8';
  cout << s << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <climits>
using namespace std;
 
long long gcd(long long a, long long b) {
    if (a == 0) return b;
    return gcd(b % a, a);
}
 
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<long long> T(N);
    for(int i=0; i<N; i++) cin >> T[i];
    long long ans = 1;
    long long g;
    for(int i=0; i<N; i++) {
        g = gcd(ans, T[i]);
        ans *= T[i] / g;
    }
    cout << ans << endl;
 
    return 0;
}


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

using namespace std;

bool dfs(int& depth, int& ans, set<int>& L);

int N, K;
size_t n_digits;
string s_N;

int main()
{
	cin >> N >> K;
	s_N = to_string(N);
	n_digits = s_N.length();
	int ans = 0;
	int depth = 0;
	set<int> L{ 0,1,2,3,4,5,6,7,8,9 };
	priority_queue<int, vector<int>, greater<int>> pq_L;
	for (int i = 0; i < K; i++)
	{
		int d;
		cin >> d;
		L.erase(d);
	}
	for (auto itr = L.begin(); itr != L.end(); itr++)
	{
		pq_L.push(*itr);
	}
	if (!dfs(depth, ans, L))
	{
		if (pq_L.top() != 0)
		{
			for (int i = 0; i <= n_digits; i++)
			{
				cout << pq_L.top();
			}
			cout << endl;
		}
		else
		{
			pq_L.pop(); cout << pq_L.top();
			for (int i = 1; i <= n_digits; i++)
			{
				cout << 0;
			}
			cout << endl;
		}
	}
	else cout << ans << endl;
	return 0;
}

bool dfs(int& depth, int& ans, set<int>& L)
{
	depth++;
	for (auto itr = L.begin(); itr != L.end(); itr++)
	{
		ans += *itr * (int)pow(10, n_digits - depth);
		if (n_digits > depth)
		{
			if (dfs(depth, ans, L) == true) return true;
		}
		else
		{
			if (ans >= N) return true;
		}
		ans -= *itr * (int)pow(10, n_digits - depth);
	}
	depth--;
	return false;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <iomanip> //cout << fixed << setprecision(12) << ans << endl;
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define loop(i, l, r) for(int i = l; i < r; i++)
#define rloop(i, l, r) for(int i = l; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vec_i;

const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
const int INF = 1e9;
const int MOD = 1e9+7;

int main()
{
	int n,k,q;
	cin >> n >> k >> q;
	vec_i v(n, k-q);
	int a;
	rep(i, q){
		cin >> a;
		v[a-1]++;
	}
	rep(i, n){
		if(v[i] > 0){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
int cnt[3];
void solve()
{
	string a[3];
	rep(i, 3) cin >> a[i];
  	int x = 0;
  	char ans[] = {'A', 'B', 'C'};
	while(true){
		if(cnt[x] == sz(a[x])) {
			cout << ans[x];
			return;
		}
		cnt[x]++;
		x = a[x][cnt[x] - 1] - 'a';
	}
	
}


 // a b c a b c a b c a b c
 
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    Red;
  	int T = 1;
  //	cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 256
class Tree
	def initialize(key)
		@key = key
		@left = nil
		@right = nil
	end

	def insert(k)
		if @key > k
			if !@left
				@left = Tree.new(k)
			else
				@left.insert(k)
			end

		else
			if !@right
				@right = Tree.new(k)
			else
				@right.insert(k)
			end
		end
	end

	def inorder(list)
		if @left
			list = @left.inorder(list)
		end
		list << @key
		if @right
			list = @right.inorder(list)
		end
		list
	end

	def preorder(list)
		list << @key
		if @left
			list = @left.preorder(list)
		end
		if @right
			list = @right.preorder(list)
		end
		list
	end
end

n = gets.to_i
head = nil

n.times do
	num = gets.to_s.chomp!
	if num == "print"
		puts " #{head.inorder([]).join(" ")}"
		puts " #{head.preorder([]).join(" ")}"
	else
		num = num.split
		if head
			head.insert(num[1].to_i)
		else
			head = Tree.new(num[1].to_i)
		end


	end

end

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

using namespace std;

int main() {
  #ifdef _OFFLINE_
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int n, p;
  cin >> n >> p;
  long long c0 = 0, c1 = 0;
  for(int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    long long t0 = c0, t1 = c1;
    if(x & 1) {
      c0 = t0 + t1;
      c1 = t0 + t1 + 1;
    }
    else {
      c0 = t0 + t0 + 1;
      c1 = t1 + t1;
    }
  }  

  if(p == 0) {
    cout << c0 + 1;
  }
  else {
    cout << c1;
  }
}

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

t = [[0] * (N + 1) for _ in range(N + 1)]
for _ in range(M):
    L, R = map(int, input().split())
    t[L][R] += 1

for i in range(N + 1):
    for j in range(N):
        t[i][j + 1] += t[i][j]

for i in range(N):
    for j in range(N + 1):
        t[i + 1][j] += t[i][j]

result = []
for _ in range(Q):
    p, q = map(int, input().split())
    result.append(t[q][q] + t[p - 1][p - 1] - t[p - 1][q] - t[q][p - 1])
print('\n'.join(str(v) for v in result))


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

int main() {
  int N, K, i;
  int  sum = 1;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
    
    if (sum < K)
      sum *=2;
  
    else
      sum += K;
  }
  
  cout << sum << endl;
}


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

using namespace std;

int main() {
  string S;
  cin >> S;
  stack<char> T;
  for (char c : S) {
    if (!T.empty() && T.top() != c) {
      T.pop();
    } else {
      T.push(c);
    }
  }

  cout << S.size() - T.size() << endl;

  return 0;
}


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

int		main(void)
{
	int		a;
	cin >> a;
	cout << (a % 2 ? (a / 2) * (a / 2 + 1) : (a / 2) * (a / 2)) << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int tlim = ni();
		int minc = Integer.MAX_VALUE;
		for(int i = 0; i < n ; i++) {
			int c = ni();
			int t = ni();
			if(t > tlim) {
				continue;
			}else {
				minc = Math.min(minc, c);
			}
		}
		if(minc == Integer.MAX_VALUE) {
			System.out.println("TLE");
		}else {
			System.out.println(minc);
		}
	}
	
	private static int dfs(int dig, int cur, int max) {
		int result = 0;	
		if(dig >= 3) {
			if(dig <= Integer.toString(max).length()) {
				if(cur <= max) {
					if(is753(cur))result++;
				} else {
					return 0;
				}
			} else {
				return 0;
			}
		}	
		dig++;
		result += dfs(dig, cur * 10 + 3, max) + dfs(dig, cur * 10 + 5, max) + dfs(dig, cur * 10 + 7, max);
		return result;
	}

	private static boolean is753(int in) {
		boolean[] flags = new boolean[3];
		char[] inca = Integer.toString(in).toCharArray();
		for(char c:inca) {
			if(c == '3')flags[0] = true;
			if(c == '5')flags[1] = true;
			if(c == '7')flags[2] = true;
		}
		
		return flags[0] && flags[1] && flags[2];
	}
	//Switch input source (stdin/file)
	private static Scanner scanner = new Scanner(System.in);
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				scanner = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath)))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(scanner.nextLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    string S; cin >> S;
    map<char,int> A;
    REP(i,4){
        A[S[i]]++;
    }

    int cnt = 0;
    for(auto a:A){
        if(a.second == 2)cnt++;
    }
    
    cout << (cnt==2?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdio>
#include <set>
using namespace std;

set<string> u;

int main()
{
    char s[5005],k;
    scanf("%s%d",s,&k);
    int len = strlen(s);
    for(int i = 0; i < len; i++)
    {
        string tem = "";
        for(int j = 0; j < k; j++)
        {
            if(i+j<len)
            {
                tem += s[i+j];
                if(u.find(tem) == u.end())
                {
                    u.insert(tem);
                    //printf("%s\n",tem.c_str());
                }
            }
        }
    }
    set<string>::iterator it = u.begin();
    for(int i = 1; i < k; it++,i++)
        ;
    printf("%s\n",it->c_str());
    return 0;
}


Measured memory_bytes: 1664
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

#define maxn 200000+5

using namespace std;

struct Data{
	int val,pos;
	bool operator <(const Data &T)const{
		return val<T.val;
	}
}a[maxn];

int ans[maxn],ori[maxn];
int n;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i].val);
		ori[i]=a[i].val;
		a[i].pos=i;
	}
	sort(a+1,a+1+n);
	for(int i=1;i<=n;i++){
		ans[a[i].pos]=n/2;
		if(ans[a[i].pos]>=i) ans[a[i].pos]++;
	}
	for(int i=1;i<=n;i++){
		printf("%d\n",a[ans[i]].val);	
	}
	return 0;
}

Measured memory_bytes: 5248
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

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

int main() {
	int x, y, xin, yin;
	cin >> x >> y;
	int g[] = {1,3,5,7,8,10,12}, h[] = {4,6,9,11}, i[] = {2};
	for(int i = 0; i < 7; i++){
		if(x == g[i]){
			xin = 1;
		}
		if(y == g[i]){
			yin = 1;
		}
	}
	for(int i = 0; i < 4; i++){
		if(x == h[i]){
			xin = 2;
		}
		if(y == h[i]){
			yin = 2;
		}
	}
	if(x == 2){
		xin = 3;
	}
	if(y == 2){
		yin = 3;
	}
	if(xin == yin){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  for (int i = 0; a > 0 && c > 0; ++i) {
    if (i % 2 == 0) {
      c -= b;
    } else {
      a -= d;
    }
  }
  puts(a > 0 ? "Yes" : "No");
}


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

using namespace std;

#define ll long long int
#define get(a) ll a; cin >> a;
#define show(a) cout << a << endl;
#define full(p) p.begin(), p.end()
#define sz(a) (ll)(a.size())
#define pb push_back

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout<<fixed;
	////////////////////////////////
	string s;
	cin >> s;
	int n = sz(s);
	stack<char> final;
	for (int i = 0; i < n; ++i)
		{
			if(s[i] == 'B')
			{
				if(!final.empty())
				{
					final.pop();
				}
			}
			else
				final.push(s[i]);
		}
	string ans;
	while(!final.empty())
	{
		ans += final.top();
		final.pop();
	}
	reverse(full(ans));
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3616
def i1str():
    return input()


def istrs(n=None):
    if n is None:
        return input().split()
    a = []
    for _ in range(n):
        a.append(istrs())
    return a


def i1num():
    return int(input())


def inums(n=None):
    if n is None:
        return list(map(int, input().split()))
    a = []
    for _ in range(n):
        a.append(inums())
    return a


def ostrs(l, sp=" "):
    print(sp.join(l))


def onums(l, sp=" "):
    print(sp.join(map(str, l)))


def solve(n):
    pi = 3.14159
    return 2*pi*n


if __name__ == "__main__":
    n = i1num()
    print(solve(n))


Measured memory_bytes: 9076
#include <bits/stdc++.h>
#define ms(a,b)         memset(a, b, sizeof(a))
#define pb(a)           push_back(a)
#define db              double
#define ll              long long
#define loop(i,e,n)      for(int i=e;i<=n;i++)
#define TEST_CASE(t)    for(int z=1;z<=t;z++)
ll PowFun(ll base, ll power){ll ans = 1;for(int i = 1; i <= power; i++){ans *= base;}return ans;}
double phi = acos(-1);
using namespace std;



    int main()
    {
        int a; cin>>a;
        cout<<a+a*a+a*a*a<<endl;
    }



Measured memory_bytes: 3636
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        final String ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        int n;
        
        Scanner scan = new Scanner(System.in);
        int ch = scan.nextInt();
        String str = scan.next();
        scan.close();
        StringBuilder r = new StringBuilder();

        for(int i = 0;i < str.length();i++){
            char c = str.charAt(i);
            n = ALPHA.indexOf(c) + ch;
            if(n >= 26) n = n - 26;
            r.append(ALPHA.charAt(n));
        }
            String result = new String(r);   
            System.out.println(result);
    }
}

Measured memory_bytes: 23764
#include <stdio.h>

int main()
{
	int i, j, n, k, cnt;
	long ans = 0;
	
	scanf("%d %d", &n, &k);		
	
	if(k % 2 == 0){
		cnt = 0;
		for(i = k / 2; i <= n; i += k){
			cnt++;
		}
		if(cnt >= 1){
			ans += (long)cnt * cnt * cnt;
		}
	}
	
	cnt = n / k;
	if(cnt >= 1){
		ans += (long)cnt * cnt * cnt;
	}
	
	printf("%ld", ans);


	return 0;
}

Measured memory_bytes: 128
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> sss(m);
    for(auto& ss : sss){
        int k; cin >> k;
        ss.resize(k); cin >> ss;
    }
    vector<int> ps(m); cin >> ps;
    int ans = 0;
    for(int i = 0; i < (1 << n); i++){
        bool ok = true;
        for(auto& ss : sss){
            int cnt = 0;
            for(auto& s : ss){
                cnt += i >> (s - 1) & 1;
            }
            if(cnt % 2 != ps[&ss - &sss[0]]){
                ok = false;
                break;
            }
        }
        ans += ok;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 888