akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main( ){
  int N;
  int K;
  int x;
  x = 1;
  cin >> N >> K;
  
  for ( int i = 1; i <= N ; i++){
    if( x*2-x > K){
      
      x += K;
      continue;
    }
    
    else {
      
      x *= 2;
      continue;
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 3604
import sys
import numpy as np
buf = sys.stdin.buffer
mod = 10 ** 9 + 7

H, W = map(int, buf.readline().split())

grid = np.resize(np.frombuffer(buf.read(), dtype='S1') == b'.', (H, W + 1))[:, :-1] * 1

dp = np.zeros(W, np.int64)
dp[0] = 1

for i in grid:
    wall = (i == 0)
    dp[wall] = 0
    np.cumsum(dp, out=dp)
    dp -= np.maximum.accumulate(dp * wall)
    dp %= mod

print(dp[-1])

Measured memory_bytes: 23160
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>

#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,n) for(int i=0;i<(n); ++i)
#define rep2(i,n) for(int i=1;i<=(n);++i)

using namespace std;
typedef long long ll;
typedef vector<int> vi;
const int NMAX = 100000;
const int MMAX = 100000;
const int k = 200000;
static const int INF = 1<<21;
static const int NIL = -1;

int dp[3001][3001];
ll gcd(ll a, ll b){
if(a<b) swap(a,b);
    if(b==0) return a;
    return gcd(b, a%b);
}
vector<vi> pre(NMAX+1);
vi dist(NMAX+1);
vector<bool> visited(NMAX+1);

void dfs(int v){
    visited[v]=true; //bool値　訪れたらtrue
    for(int vp:pre[v]){
        if(!visited[vp]){
            dfs(vp);
        }
        dist[v] = max(dist[v],dist[vp]+1);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0); //この2行はより速度を向上させる


    int n,m,s,t,q;
    cin >> n >> m;
    int u,v;
    rep(i,m){
        cin >> u >> v;
        pre[v].push_back(u);
    }
    int ans=0;
    rep2(i,n){
        if(!visited[i]){
            dfs(i);
            ans=max(ans,dist[i]);
        }
    }
    cout << ans << endl;

return 0;
}

Measured memory_bytes: 10624
// eddy1021
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long ll;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<LD,LD> Pt;
typedef tuple<int,int,int> tiii;
typedef tuple<LL,LL,LL> tlll;
#define mod9 1000000009ll
#define mod7 1000000007ll
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define FI first
#define SE second
#define X FI
#define Y SE
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline ll getint(){
  ll _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline ll add( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x + _y;
  if( _ >= _mod ) _ -= _mod;
  return _;
}
inline ll sub( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x - _y;
  if( _ < 0 ) _ += _mod;
  return _;
}
inline ll mul( ll _x , ll _y , ll _mod = mod7 ){
  ll _ = _x * _y;
  if( _ >= _mod ) _ %= _mod;
  return _;
}
ll mypow( ll _a , ll _x , ll _mod ){
  if( _x == 0 ) return 1ll;
  ll _tmp = mypow( _a , _x / 2 , _mod );
  _tmp = mul( _tmp , _tmp , _mod );
  if( _x & 1 ) _tmp = mul( _tmp , _a , _mod );
  return _tmp;
}
ll mymul( ll _a , ll _x , ll _mod ){
  if( _x == 0 ) return 0ll;
  ll _tmp = mymul( _a , _x / 2 , _mod );
  _tmp = add( _tmp , _tmp , _mod );
  if( _x & 1 ) _tmp = add( _tmp , _a , _mod );
  return _tmp;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
int __ = 1 , _cs;
/*********default*********/
#define N 101010
void build(){

}
int n , a[ N ] , p[ N ];
void init(){
  n = getint();
  for( int i = 0 ; i < n ; i ++ )
    a[ i ] = getint();
}
void solve(){
  vector< PII > v;
  for( int i = 0 ; i < n ; i ++ )
    v.push_back( { a[ i ] , i } );
  sort( ALL( v ) );
  for( int i = 0 ; i < n ; i ++ )
    p[ v[ i ].SE ] = i;
  LL ans = 0;
  for( int i = 0 ; i < n ; i ++ )
    if( i % 2 != p[ i ] % 2 ){
      if( i % 2 ) ans ++;
    }
  printf( "%lld\n" , ans );
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 1908
#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() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  sort(h.begin(), h.end());
  k = min(n,k);
  ll ans = 0;
  rep(i,k) {
    h.pop_back();
  }
  rep(i,h.size()) ans += h[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
from itertools import accumulate
INF=1001001001001
n=int(input())
a=list(map(int,input().split()))
dp=[[INF for i in range(n+1)] for j in range(n+1)]
wa=[0]+list(accumulate(a))
for i in range(n):
  dp[i][i+1]=0
for gap in range(2,n+1):
  for l in range(n-gap+1):
    r=l+gap
    dp[l][r]=wa[r]-wa[l]+min(dp[l][k]+dp[k][r] for k in range(l+1,r))
print(dp[0][n])


Measured memory_bytes: 13952
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  ll starta, v, startb, w, t;
  cin >> starta >> v >> startb >> w >> t;

  ll dist = abs(starta - startb);
  bool ans = false;
  if (dist == 0) ans = true;
  if (v * t - w * t >= dist) ans = true;
  if (ans) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3612
import java.util.Arrays;

class Main {
    public static void main(String args[]) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());

        int[] coin = new int [M+1];
        for(int i=1; i<M+1; i++){
            coin[i] = Integer.parseInt(sc.next());
        }
        int[][] dp = new int[M+1][N+1];
        Arrays.fill(dp[0], Integer.MAX_VALUE/2);
        for(int mi=0; mi<M+1; mi++){
            dp[mi][0] = 0;
        }
        for(int mi=1; mi<M+1; mi++){
            for(int ni=0; ni<N+1; ni++){
                if(ni-coin[mi]>=0){
                    dp[mi][ni] = Math.min(dp[mi-1][ni], dp[mi][ni-coin[mi]]+1);
                } else {
                    dp[mi][ni] = dp[mi-1][ni];
                }
                //miのコインを使わなかったとき, miのコインを使ったとき
            }
        }
        System.out.println(dp[M][N]);
        sc.close();
    }
}


Measured memory_bytes: 30856
# coding: utf-8
# Your code here!

N=int(input())
A = list(map(int,input().split()))
A.append(0)
A.insert(0, 0)

#print(A)
B = [abs(A[i+1]-A[i]) for i in range(N+1)]
S = sum(B)
#print(B)
#print(S)
for i in range(N):
    print(S-B[i]-B[i+1]+abs(A[i+2]-A[i]))


Measured memory_bytes: 13944
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll N, M, ans;
    scanf("%lld %lld", &N, &M);
    if ( N == M ) printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<char> VC;
typedef vector<VC> VVC;

#define Y first
#define X second
#define RANGE(x, y, mX, mY) (0 <= (x) && 0 <= (y) && (x) < (mX) && (y) < (mY))
#define MP make_pair

const int INF = 0x3f3f3f3f;

struct State {
    State () {}
    State (PII p_, bool l, int c) :
        p(p_.Y, p_.X), leg(l), cost(c) {}
    PII p;
    bool leg;
    int cost;

    bool operator > (const State &s) const {
        return cost > s.cost;
    }
};

int W, H;

VVC ts;

const char WALL = 'X';
const char GOAL = 'T';
const char START = 'S';

const int DX[2][9] = {
    {1, 2, 3, 1, 2, 1, 1, 2, 1},
    {-1, -2, -3, -1, -2, -1, -1, -2, -1}
};
const int DY[2][9] = {
    {0, 0, 0, 1, 1, 2, -1, -1, -2},
    {0, 0, 0, 1, 1, 2, -1, -1, -2}
};


int solve() {
    // dist[y][x][leg] = min_cost;
    VVVI dist(H, VVI(W, VI(2, INF)));

    priority_queue<State, vector<State>, greater<State>> q;

    // ?????????
    for (int x = 0; x < W; x++) {
        int y = H - 1;
        if (ts[y][x] == START) {
            for (int i = 0; i < 2; i++) {
                q.push(State(MP(y, x), i, 0));
            }
        }
    }

    // ??????????????????
    while (q.size()) {
        State c = q.top();
        q.pop();

        // ????°?????????????
        if (c.cost > dist[c.p.Y][c.p.X][c.leg]) continue;

        // ?¬?
        for (int i = 0; i < 9; i++) {
            State n;
            n.leg = !c.leg;
            n.p.Y = c.p.Y + DY[n.leg][i];
            n.p.X = c.p.X + DX[n.leg][i];

            if (!RANGE(n.p.X, n.p.Y, W, H)) continue; // ??´???

            char t = ts[n.p.Y][n.p.X];
            if (t == WALL) continue; // ?£?

            n.cost = c.cost;
            if ('0' <= t && t <= '9') n.cost += t - '0';

            if (dist[n.p.Y][n.p.X][n.leg] > n.cost) {
                dist[n.p.Y][n.p.X][n.leg] = n.cost;
                q.push(n);
            }
        }
    }

    int ans = INF;
    for (int x = 0; x < W; x++) {
        for (int i = 0; i < 2; i++) {
            if (ts[0][x] == GOAL) {
                ans = min(ans, dist[0][x][i]);
            }
        }
    }

    return ans == INF ? -1 : ans;
}

int main(void) {
    while (cin >> W >> H, W) {
        ts = VVC(H, VC(W));

        for (int y = 0; y  <H; y++) {
            for (int x = 0; x < W; x++) {
                cin >> ts[y][x];
            }
        }

        cout << solve() << endl;
    }
}

Measured memory_bytes: 1344
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<String> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            set.add(sc.next());
        }

        System.out.println(set.size());
    }
}

Measured memory_bytes: 76972
#include <iostream>

using namespace std;

int main(void)
{
    int N, D, X[11][11], i, j, k, count=0;
    double sum;

    cin >> N >> D;

    for(i=1; i<=N; i++){
        for(j=1; j<=D; j++){
            cin >> X[i][j];
        }
    }

    for(i=1; i<=N-1; i++){
        for(j=i+1; j<=N; j++){
            sum = 0;

            for(k=1; k<=D; k++){
                sum += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
            }

            for(k=1; k<=200; k++){
                if(sum == k*k){
                    count++;
                }
            }
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int M = scan.nextInt();
    int[] s = new int[M];
    int[] c = new int[M];
    for(int i=0; i<M; i++) {
      s[i] = scan.nextInt();
      c[i] = scan.nextInt();
    }
    scan.close();

    int min = N==1 ? 0 : (int)Math.pow(10, N-1);
    int max = (int)Math.pow(10, N) - 1;
    for(int i=min; i<=max; i++) {
      boolean test = true;
      for(int j=0; j<M; j++) {
        if((i % (int)Math.pow(10, N-s[j]+1)) / (int)Math.pow(10, N-s[j]) != c[j]) {
          test = false;
        }
      }
      if(test == true) {
        System.out.println(i);
        return;
      }
    }
    System.out.println(-1);
  }
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;
#include <string>
typedef long long int ll;
#include <algorithm>
#include <stack>
#include <vector>
#include <array>
#include <queue>
#include <bitset>
#include <math.h>

int main(){

  ll a,b;
  cin >> a >> b;

  ll a_ = a;
  ll b_ = b;

  ll n = 2;
  while(a>1 && b>1 && n<=a && n<= b){
    //cout << a<<b<<n;
    if(a%n==0 && b%n==0){
      a /= n;
      b /= n;
    }else{
      n += 1;
    }
  }
  
  cout << a*b_ <<endl;

  return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a, b;
	scanf("%d %d", &a, &b);
	if(a == b){
		printf("a == b\n");
	}else if(a > b){
		printf("a > b\n");
	}else{
		printf("a < b\n");
	}
    return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ll n; cin >> n;
	ll a[2][n];
	for(ll j = 0; j < 2; j++)for(ll i = 0; i < n; i++) cin >> a[j][i];
	ll ue[n + 1] = {}, sita[n + 1] = {};
	for(ll i = 0; i < n; i++){
		ue[i + 1] = ue[i] + a[0][i];
		sita[i + 1] = sita[i] + a[1][i];
	}
	ll sum = 0;
	for(ll i = 0; i < n; i++) sum = max(sum, ue[i + 1] + sita[n] - sita[i]);
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let a: usize = iter.next().unwrap().parse().unwrap();
    let b: usize = iter.next().unwrap().parse().unwrap();

    println!("{}", std::cmp::min(a*n, b));
}


Measured memory_bytes: 4352
// Coded by Yash Pradhan
// bit.ly/yashpradhan

#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
typedef long long ll;

using namespace std;

void solve()
{
    ll a;
    string b;

    cin>>a;
    cin>>b;

    string bb = b.substr(0,1) + b.substr(2,4);
    ll ans = a * stoi(bb);

    string str_ans = to_string(ans);

    if(str_ans.length()<3) 
    {
        str_ans = "000";
    }

    cout<<str_ans.substr(0, str_ans.length()-2)<<endl; 
}


int main()
{
    solve();
    return 0;
}

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

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = Long.parseLong(sc.next());
    
    long n = (long)Math.ceil(Math.sqrt(N));

    for (long i = n; i > 0; i--) {
      if (N % i == 0) {
        System.out.println(i + (N/i) - 2);
        return;
      }
    }
  }
}

Measured memory_bytes: 23636
import sys
input = sys.stdin.readline
inputt = lambda: range(int(input()))
inputi = lambda: map(int, input().split())
inputl = lambda: list(inputi())
from math import *
from heapq import *
from bisect import *
from functools import reduce, lru_cache
from collections import Counter, defaultdict
from builtins import *

N, K = inputi()
print(min(N % K, -N % K))










Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll K;
  cin>>K;
  ll cnt=0;
  ll ans=100;
  while(true){
    ans=ans*1.01;
    cnt++;
    if(ans>=K){
      cout<<cnt<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define ll long long int 
#define ull unsigned long long int
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i)) 
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'
 
 
 
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
 map<ll,ll>m;
int main()
{
	_fastio
	ll n,q,a,b,sm=0;
	cin>>n;
	for1(i,n)
	{
		cin>>a;
		m[a]+=1;
		sm+=a;
	}
	cin>>q;
	for1(i,q)
	{
		cin>>a>>b;
		sm=sm-(m[a]*a);
		sm=sm+(m[a]*b);
		m[b]=m[b]+m[a];
		m[a]=0;
		cout<<sm<<en;
	}
}

Measured memory_bytes: 9500
#include<iostream>
using namespace std;
int main(){
long s[5],a,b,i,m,mm;
while(cin>>a>>b){
if(a==0&&b==0)break;
s[0]=a+b;
for(i=1;i<5;i++){
cin>>a>>b;
s[i]=a+b;
}
for(m=s[0],mm=0,i=1;i<5;i++)if(m<s[i]){m=s[i];mm=i;}
cout<<"ABCDE"[mm]<<" "<<m<<endl;
}
return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        StringBuilder ans = new StringBuilder();
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        int l = x - k + 1, r = x + k - 1;
        for(int i = l; i <= r; i++) ans.append(i + (i == r ? "" : " "));
        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
#include <stdio.h>

int main(void) {
	int i, a, b;
	for(i = 0; i < 10000; i ++)
	{
		scanf("%d%d", &a,&b);
		if (a == 0 && b == 0)
		{
			break;
		}
		else
		{
			if (a<b)
			{
				printf("%d %d\n", a, b);
			}
			else
			{
				printf("%d %d\n", b, a);
			}
		}
	}
	return 0;
}



Measured memory_bytes: 2060
from collections import deque
def m():
    S = input()
    N = len(S)

    q = deque(S)
    ans = 0
    while len(q) > 1:
        left,right = q[0], q[-1]
        if left == right:
            q.pop()
            q.popleft()
            continue
        if left == 'x':
            q.popleft()
            ans +=1
            continue
        if right == 'x':
            ans +=1
            q.pop()
            continue
        return -1
    return ans


print(m())

Measured memory_bytes: 72336
import java.util.Scanner

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	val k = scn.nextInt()
	val sfs = IntArray(n){scn.nextInt()}
	val dp = IntArray(n)
	for (j in 1 until n){
		dp[j] = ((j-k).coerceAtLeast(0) until j).map { i ->
			dp[i] + Math.abs(sfs[i]-sfs[j])
		}.min()!!
	}
	println(dp.last())
}

Measured memory_bytes: 116764
import java.util.Scanner;

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

        int a = scanner.nextInt();
        int b = scanner.nextInt();

        System.out.printf("%d %d %f", a/b, a%b, (double)a/b);

        scanner.close();
    }
}


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

class Operation {
    int l, r, d;
public:
    Operation() : l(0), r(1<<30), d(0) {};
    Operation(int l, int r, int d) : l(l), r(r), d(d) {}
    int apply(int a) {
        return max(l, min(r, a + d));
    };
    Operation append(Operation op) {
        if (r + op.d <= op.l) return Operation(op.l, op.l, d + op.d);
        else if (l + op.d >= op.r) return Operation(op.r, op.r, d + op.d);
        else return Operation(max(l + op.d, op.l), min(r + op.d, op.r), d + op.d);
    }
};

Operation operator*(Operation lhs, Operation rhs) {
    return lhs.append(rhs);
}

int main() {
    int x, k; cin >> x >> k;
    int r[k]; for (int i = 0; i < k; i++) cin >> r[i];
    vector<Operation> ops;
    ops.push_back(Operation(0, x, 0));
    for (int i = 1; i <= k; i++) {
        int r1 = i == 1 ? 0 : r[i-2], r2 = r[i-1];
        ops.push_back(ops[i-1] * Operation(0, x, (r2 - r1) * (i % 2 ? -1 : 1)));
    }
    int q; cin >> q;
    while (q--) {
        int t, a; cin >> t >> a;
        int i = upper_bound(r, r+k, t) - r;
        int a1 = ops[i].apply(a);
        cout << Operation(0, x, (t - (i > 0 ? r[i-1] : 0)) * (i % 2 ? 1 : -1)).apply(a1) << endl;
    }
}


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

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        final int MP = 999983;
        boolean[] prime = new boolean[MP * 2 + 1];
        Arrays.fill(prime, true);
        prime[0] = prime[1] = false;
        for (int i = 2; i * i <= MP; i++) {
            if (prime[i]) {
                for (int j = i + i; j <= MP; j += i)
                    prime[j] = false;
            }
        }
        int sums[] = new int[MP * 2 + 1];
        for (int i = 1; i <= MP; i++) {
            sums[i] = sums[i - 1] + (prime[i] ? 1 : 0);
        }
        for (int i = MP + 1; i <= MP * 2; i++) {
            sums[i] = sums[MP];
        }
        while (true) {
            int n = sc.nextInt();
            if (n == 0)
                break;
            int ans = 0;
            for (int i = 0; i < n; i++) {
                int p = sc.nextInt();
                int m = sc.nextInt();
                int x = sums[p + m] - (p > m ? sums[p - m - 1] : 0);
                if (x == 0)
                    ans--;
                else
                    ans += (x-1);
            }
            System.out.println(ans);
        }
    }
}

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

#define Max 105000
int IsPrime[Max];

int main()
{
	for (int i = 2; i < Max; i++) IsPrime[i] = true;
	for (int i = 2; i < Max; i++)
	{
		if (!IsPrime[i]) continue;
		for (int j = i + i; j < Max; j += i)
		{
			IsPrime[j] = false;
		}
	}

	int n;
	while (cin >> n, n)
	{
		int ans = 0;
		int i = 0;
		int count = 0;
		while (count < n)
		{
			if (IsPrime[i])
			{
				count++;
				ans += i;
			}
			i++;
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1564
#include <stdio.h>
#include <math.h>
#include <stdbool.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
int main(void){
  int n,i,j,ans=0;
  scanf("%d",&n);
  for(i=1;i<=n;i+=2){
    int cnt=0;
    for(j=1;j<=i;j++){
      if(i%j==0) cnt++;
    }
    if(cnt==8)ans++;
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,a[N],b[N],ra,rb,size[N];
vector<int> ea[N],eb[N],*e;
vector<int> E[N];
int last;
void dfs(int x){
    if ((e[x].size()^1)&1){
        if (!last) last=x;
        else{
            E[x].push_back(last);
            E[last].push_back(x);
            last=0;
        }
    }
    for (int i=0;i<e[x].size();i++) dfs(e[x][i]);
}
int tp[N];
void paint(int x,int C){
    if (tp[x]) return;
    tp[x]=C;
    for (int i=0;i<E[x].size();i++) paint(E[x][i],-C);
}
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        if (a[i]==-1) ra=i;else ea[a[i]].push_back(i);
    }
    for (int i=1;i<=n;i++){
        scanf("%d",&b[i]);
        if (b[i]==-1) rb=i;else eb[b[i]].push_back(i);
    }
    for (int i=1;i<=n;i++)
    if ((ea[i].size()^eb[i].size())&1)
        return puts("IMPOSSIBLE"),0;
    puts("POSSIBLE");
    e=ea;last=0;dfs(ra);
    e=eb;last=0;dfs(rb);
    for (int i=1;i<=n;i++)
        if (!tp[i]) paint(i,1);
    for (int i=1;i<=n;i++) printf("%d ",e[i].size()&1?0:tp[i]);
    puts("");
    return 0;
}


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

map<ll,ll>f;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,a,b,s=0,x;
    cin>>n>>a>>b;x=a;

    for(int i=1;i<=n;i++){
        ll s2=0,y;y=i;
        while(y>0){
            s2+=(y%10);y/=10;
        }
        if(s2>=a&&s2<=b){s+=i;}
    }
    cout<<s<<endl;
}


Measured memory_bytes: 3652
#include <iostream>

using namespace std;
#define FOR(i,n) for(i=0;i<=n;++i)
#define DEBG(s) cout<<s<<endl;
int i,j,a,b,c;

int main(void){
    int a,b;
    char op;
    cin>>a>>op>>b;
    cout<<(op=='+'?a+b:a-b);
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int a,b,t;
	cin>>a>>b>>t;
	cout<<(b*(t/a))<<endl;
}


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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	int p[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>p[i];
	}
	int dp[n+5]={};
	for (int i = 0; i < n; ++i)
	{
		dp[p[i]]=dp[p[i]-1]+1;
	}
	int ans=0;
	for (int i = 1; i <= n; ++i)
	{
		ans=max(ans,dp[i]);
	}
	cout<<n-ans<<endl;
	return 0;
}


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

def solve(k):
    ans = 1
    for i in range(1,k+1):
        ans = (ans*i)%(10**9+7)
    return ans


if n==m:
    print((2*solve(n)*solve(m))%(10**9+7))
elif abs(n-m)==1:
    print((solve(n)*solve(m))%(10**9+7))
else:
    print(0)


Measured memory_bytes: 38436
dishes = []
for _ in range(5):
  dishes.append(int(input()))
  
times = []
for _ in range(5):
  n = dishes.pop(0)
  time = n
  for dish in dishes:
    time += ((dish + 9) // 10) * 10
  times.append(time)
  dishes.append(n)
  
print(min(times))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
string a1,a2;
cin>>a1>>a2;
int s=0;
for(int i=0;i<a1.size();i++){
	if(a1[i]!=a2[i])s++;
}
cout<<s;
return 0;
}


Measured memory_bytes: 3832
require "prime"

q = gets.to_i
r_max = 0
queries = []
q.times do
  l, r = gets.split.map &:to_i
  queries << [l, r]
  r_max = r if r_max < r
end

sum = 0
prev = 0
is_prime = []
sums = []
Prime.each(r_max) do |p|
  (prev...p).each do |i| sums[i] = sum end
  is_prime[p] = true
  prev = p+1
  sum += 1 if is_prime[(p+1)/2]
  sums[p] = sum
end

(prev..r_max).each do |i| sums[i] = sum end

queries.each do |(l, r)|
  p sums[r] - sums[l-1]
end


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

int main(){
  int N, p, w, g, y;
  string S;
  p = w = g = y = 0;
  string result = "Three";
  cin >> N;
  
  for(int i=0; i<N; i++){
    cin >> S;
    if(S == "P"){
      p = 1;
    }else if(S == "W"){
      w = 1;
    }else if(S == "G"){
      g = 1;
    }else if(S == "Y"){
      y = 1;
    }
  }
  if(p == 1 && w == 1){
    if(g == 1 && y == 1){
      result = "Four";
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

vector<LL> go(vector<pair<int, int> > &order, vector<int> &a, vector<int> &b, int T){
    int n = order.size();
    vector<LL> res(n+1, 0);
    priority_queue<int> que;
    REP(i, n){
        int idx = order[i].second;
        res[i+1] = res[i] + a[idx];
        que.push(b[idx]-a[idx]);
        if((int)que.size()>T){
            res[i+1] += que.top();
            que.pop();
        }
    }
    return res;
}

int main(){
    int X, Y, Z;
    cin >> X >> Y >> Z;
    int N = X+Y+Z;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);
    vector<pair<int, int> > order(N);
    REP(i, N){
        cin >> A[i] >> B[i] >> C[i];
        int cost = A[i] - B[i];
        order[i] = make_pair(cost, i);
    }
    sort(ALL(order));

    vector<LL> sum1 = go(order, B, C, Y);
    reverse(ALL(order));
    vector<LL> sum2 = go(order, A, C, X);
    reverse(ALL(sum2));
    LL res = 0;
    for(int k=Y; k<=Y+Z; k++){
        res = max(res, sum1[k] + sum2[k]);
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 4476
N = int(input())
S = [input() for _ in range(N)]

cnt = 0
end_a = 0
sta_b = 0
a_b = 0
for s in S:
    cnt += s.count('AB')
    if s[-1]=='A' and s[0]=='B':
        a_b += 1
    elif s[-1]=='A':
        end_a += 1
    elif s[0]=='B':
        sta_b += 1
if a_b>=1:
    cnt += a_b-1
    if end_a>=1:
        end_a -= 1
        cnt += 1
    if sta_b>=1:
        sta_b -=1
        cnt+=1
cnt += min(end_a, sta_b)

print(cnt)

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


namespace ABC127_1
{
    class c
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int L = 0;
            int R = int.MaxValue;
            for (int i = 0; i < a[1]; i++)
            {
                var b = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (L < b[0]) L = b[0];
                if (b[1] < R) R = b[1];
            }
            if (R - L + 1 < 0) Console.WriteLine(0);
            else Console.WriteLine(R - L + 1);
        }
    }
}


Measured memory_bytes: 17476
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    s1, s2, s3 = s_map()

    print(s1[0].upper() + s2[0].upper() + s3[0].upper())

if __name__ == '__main__':
    main()


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

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

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


int main(){
    double r;
    cin >> r;
    cout << 2 * r * 3.1415926535 << endl;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int count = 0;

    int N_ctr = (N / 10) % (int)pow(10, (int)log10(N));
    // cout << N_ctr << endl;
    for (int x = 0; x < 6; x++)
    {
        for (int y = 0; y < 6; y++)
        {
            for (int j = 1; j < 10; j++)
            {
                for (int k = 1; k < 10; k++)
                {
                    if ((x == 0 || y == 0) && (j != k || j == 0))
                        continue;
                    int A, B;
                    if (x == 0)
                        A = j;
                    else
                        A = j * pow(10, x) + k;

                    if (y == 0)
                        B = j;
                    else
                        B = k * pow(10, y) + j;
                    if (A == 0 || B == 0)
                        continue;
                    if (A <= N && B <= N)
                    {
                        int a_count = 0;
                        if (x < 2)
                            a_count = 1;
                        else
                        {
                            for (int a = 0; a <= pow(10, x - 1) - 1; a++)
                            {
                                if (A + a * 10 <= N)
                                    a_count++;
                                else
                                    break;
                            }
                        }
                        int b_count = 0;
                        if (y < 2)
                            b_count = 1;
                        else
                        {
                            for (int b = 0; b <= pow(10, y - 1) - 1; b++)
                            {
                                if (B + b * 10 <= N)
                                    b_count++;
                            }
                        }
                        count += a_count * b_count;
                    }
                }
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

const double PI=acos(-1.0);

int N,P; string S;
void input()
{
    cin>>N>>P>>S;
}

void solve()
{
    vi count(P,0); 
    ll ans=0;
    if(P==2 || P==5){
        for(ll i=0;i<N;++i){
            if((S[i]-'0')%P==0) ans+=i+1ll;
        }
    }
    else{
        count[0]++;
        reverse(S.begin(), S.end());
        int k=1;
        int sum=0;
        for(int i=0;i<N;++i){
            // sum=(sum*10+S[i]-'0')%P;
            // ans+=count[sum];
            // count[sum]++;
            sum+=((S[i]-'0')*k)%P; sum%=P;
            count[sum]++;
            k*=10; k%=P;
        }
        
        for(int i=0;i<P;++i) {
            ans+=(ll)count[i]*(count[i]-1)/2;
            // cout<<"i:"<<i<<" "<<count[i]<<"\n";
        }
    }
    cout<<ans<<endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

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

using namespace std;
using ll = long long;

const int MAX = 1e6;
const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    ll ans = n - 1;
    for (ll i = 2; i <= sqrt(n); ++i) 
        if (n % i == 0) 
            ans = min(ans, i + n / i - 2);
    cout << ans;
    return 0;
}                                                               
    
                

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int x = stdIn.nextInt();
		call(x);
		stdIn.close();
	}
	static void call(int n){
		CHECK_NUM: for (int i = 1; i <= n; i++){
			int y = i;
			if ( y % 3 == 0 ){
				System.out.print(" " + i);
				continue CHECK_NUM;
			}
			if ( y % 10 == 3 ){
				System.out.print(" " + i);
				continue CHECK_NUM;
			}
			while((y/=10) > 0) {
				if ( y % 10 == 3 ){
					System.out.print(" " + i);
					continue CHECK_NUM;
				}
			}
		}
		System.out.println();
	}
}



Measured memory_bytes: 28836
a = input().split(" ")

if (a[0]=="5" and a[1]=="5" and a[2]=="7") or (a[0]=="5" and a[1]=="7" and a[2]=="5") or (a[0]=="7" and a[1]=="5" and a[2]=="5"):
  print("YES")
else:
  print("NO")

Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<=n;i++)
#define RIP(i,a,b) for(int i=a;i<b;i++)
#define all(V) V.begin(),V.end()
#define sec  setprecision;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops");
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using namespace std;
using ll = long long;
using ld = long double;
using Pa = pair<int, int>;
ll mod = 1000000007;
ll MOD = 998244353;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x) % mod, n / 2) % mod);
	else
		return (x * pow(x, n - 1)) % mod;
}
signed main() {
	int n, k; cin >> n >> k;
	vector<int>a(n);
	rip(i, n)cin >> a[i];
	for (int i = k; i < n; i++) {
		if (a[i] > a[i - k])cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
#define setbits(x) __builtin_popcountll(x)
#define f(i,l,r) for(ll i=l;i<r;i++)
#define d(i,n,m) for(ll i=n;i>=m;i--)
#define deb(x) cout<<#x<<" = "<<x<<endl;
#define clr(x) memset(x,0,sizeof(x));
//#define all(x) x.begin(),x.end()
#define P (ll)(1e9+7)
#define PI acosl(-1.0l)
#define mod 998244353
#define pb push_back
#define F first
#define S second
#define IP ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fixed(n) cout<<std::fixed<<std::setprecision(n) //use for n digits precision of decimal
/*  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);  */
using namespace std;
int offset[]={1,0,-1,0,1};
const int MXN=1e4+1;
int main()
{
    IP
    ll x,y;
    cin>>x>>y;
    bool found=0;
    f(i,0,x+1)
    {
        ll rem=x-i;
        if((2*i+4*rem)==y)
        {
            found=1;
            break;
        }
    }
    if(found)
        cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

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

int main() {
    int N;cin >> N;
    string W[N];
    for (int i = 0; i < N; i++) {
        cin >> W[i];
        if (i == 0) continue;
        if (W[i-1].substr(W[i-1].length()-1,1) != W[i].substr(0,1)) {
            cout << "No" << endl;
            return 0;
        }
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i == j) continue;
            if (W[i] == W[j]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;

using ll = long long;

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

    ll a, b; cin >> a >> b;
    if (a % 2 != b % 2) {
        cout << "IMPOSSIBLE\n";
    } else {
        cout << (a + b) / 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
 
 
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

int main()
{
    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a);
    vector<ll> q(b);
    vector<ll> r(c);
    rep(i,a){
        cin >> p[i];
    }
    rep(i,b){
        cin >> q[i];
    }
    rep(i,c){
        cin >> r[i];
    }
    sort(p.rbegin(),p.rend());
    sort(q.rbegin(),q.rend());
    sort(r.rbegin(),r.rend());
    vector<ll> z;
    rep(i,x){
        z.push_back(p[i]);
    }
    rep(i,y){
        z.push_back(q[i]);
    }
    rep(i,c){
        z.push_back(r[i]);
    }
    sort(z.rbegin(),z.rend());
    ll ans=0;
    rep(i,x+y){
        ans+=z[i];
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 8816
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if (s == u)a--;
    else b--;
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
mod = 10**9+7
M = 2*10**6

def main(K,S):
    fact = [1]*(M+1)
    factinv = [1]*(M+1)
    for n in range(1,M+1):
        fact[n] = n*fact[n-1]%mod
        factinv[n] = pow(fact[n],mod-2,mod)

    def comb(n,k):
        return fact[n]*factinv[k]*factinv[n-k]%mod
    n = len(S)
    ans = 0

    for k in range(K+1):
        ans += comb(n+k-1,k)*pow(25,k,mod)*pow(26,K-k,mod)
        ans %= mod
    print(ans)

if __name__ == '__main__':
    K = int(input())
    S = input()
    main(K,S)

Measured memory_bytes: 102124
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
namespace mp = boost::multiprecision;
// 任意長整数型
using bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;
// ついでに有理数型
using rat = boost::rational<bint>;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()

void solve(long long N, std::vector<long long> A){
  sort(all(A));
  bint x = 1;
  for (int i = 0; i < N; i++) {
    x *= A[i];
    if(x > 1000000000000000000){
      cout << -1 << endl;
      return;
    }
  }
  cout << x << endl;
}

int main(){
    long long N;
				scanf("%lld",&N);
				std::vector<long long> A(N);
				for(int i = 0 ; i < N ; i++){
								scanf("%lld",&A[i]);
				}
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4108
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    while(cin>>a>>b)
    {
        if(a>=9||b>=9)
        {
            cout<<":("<<endl;
        }
        else
        {
            cout<<"Yay!"<<endl;
        }
    }
    return 0;
}

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

int main()
{
  int a,b;
  cin >> a >> b;
  vector<vector<int> > A(b, vector<int>(a));
  vector<bool> F(a + 1);
  int d = 0;
  for(int i = 0; i < b; i++){
    cin >> d;
    for(int j = 0; j < d; j++){
      int q;
      cin >> q;
      A[i][j] = q;
      F[q] = true;
    }
  }
  int c = 0;
  cout << endl;
  for(int k = 1; k <= a; k++){
    //cout << F[k] << " ";
    if(F[k] == false){
      c++;
    }
  }
  cout << c;
  return 0;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
    long long n,a,b;
    cin>>n>>a>>b;
    if(a==0)
    {
        cout<<0;
    }
    else
    {
        long long t=(n/(a+b)),p=n-(t*(a+b));
        if(p>a)
        {
            cout<<t*a +  a;       
        }
        else
        {
            cout<<t*a + p;
        }
    }
    return 0;
}    

Measured memory_bytes: 256
#include<stdio.h>
int main() {
  double v, y;
  unsigned long long int n;
  while (scanf("%lf", &v) != EOF) {
    y = v / 19.6 * v;
    if (y - (int) y / 5 * 5) n = (int) (y / 5) + 2;
    else n = (int) (y / 5) + 1;
    printf("%llu\n", n);
  }
  return 0;
}

Measured memory_bytes: 632
n = int(input())

from collections import Counter

factors = []
i = 2
while n > 1:
   if n < i * i:
      factors.append(n)
      break
   while n % i == 0:
      factors.append(i)
      n //= i
   i += 1

ans = 0
for cnt in Counter(factors).values():
   i = 1
   while cnt >= i:
      cnt -= i
      i += 1
      ans += 1
print(ans)


Measured memory_bytes: 9448
#include<stdio.h>
int linearsearch(int t, int S[], int ns)
{
	int i;
	int tf = 0;
   for (i = 0; i < ns; ++i) {
      if (S[i] == t) {
         tf = 1;  break;
	   }
   }
   return tf;
}

int main()
{
   int ns, nt;
   int S[16384], T[512];
   int i = 0,
	   count = 0;
   int flag;

   scanf("%d", &ns);
   while (i < ns) {
      scanf("%d", &S[i]);
      i++;
   }
   i = 0;
   scanf("%d", &nt);
   while (i < nt) {
	   scanf("%d", &T[i]);
	   i++;
   }

   for (i = 0; i < nt; ++i) {
      count += linearsearch(T[i], S, ns);
   }

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

Measured memory_bytes: 1840
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define int ll
#define pb push_back
#define sz(i) (int)(i.size())
#define fi first
#define se second
#define ld long double
#define pii pair<int, int>
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = 1e9 + 7;
using namespace std;
#ifndef ONLINE_JUDGE
#define tr(...) {__l(__LINE__);__f(#__VA_ARGS__, __VA_ARGS__);}
inline void __l(int line) { cerr << "#" << line << ": "; }template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << std::endl;}template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define tr(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
const int N = 21;
// make sure N size is correctttt!!!!!!!!!

int a[N][N], dp[1<<N], n;
std::vector<int> v[N];
int total;

int f(int mask){
   return __builtin_popcount(mask);
}

int solve(int mask){
   if(f(mask) == n)
      return 1;
   int &ans = dp[mask];
   if(ans != -1)
      return ans;
   ans = 0;
   int idx = f(mask);
   for (int it = 0; it < n; ++it)
   {
      if(a[idx][it] and (mask&(1LL<<it)) == 0){
         ans += solve(mask|(1LL<<it));
         if(ans >= mod)ans -= mod;
      }
   }
   return ans;
}

int32_t main(){_
   cin>>n;

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

   total = (1<<n) - 1;
   memset(dp, -1, sizeof dp);
   cout<<solve(0);

   //make sure N size is correct!!!!!!!!!
   return 0;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
const int N =60 ;
char ch1[N][N];
char ch2[N][N];
int a,b,n,m,cnt;
string st,st1;
int main(){
    cin>>a>>b;
    n=b;
   while(n != 0)
    {
        n /= 10;
        ++cnt;
    }

    for(int i = 0 ; i<cnt; i++)
        a*=10;
    a+=b;
for(int i = 0 ; i<320 ; i++)
{
    if(i*i == a)
        return cout<< "Yes",0;
}
return cout<< "No",0;


    }








Measured memory_bytes: 256