akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline

# from collections import deque

def linput(_t=int):
    return list(map(_t, input().split()))

def gcd(n,m):
    while m: n,m = m, n%m
    return n

def lcm(n,m): return n*m//gcd(n,m)

def main():

    S = input().rstrip()
    if S == "ABC":
        res = "ARC"
    else:
        res = "ABC"
    print(res)

    # print(("No","Yes")[res%2])


main()


Measured memory_bytes: 9124
function getLines(input){
	return input.split("\n").map((s)=>s.trim())
}
function parseLine(line){
	return line.split(" ").map((s)=>s.trim());
}
function parseLineToInt(line){
	return line.split(" ").map((s)=>parseInt(s.trim()));
}

// parameter "input" gets all data
function Main(input) {
	// the first line is assigned to input[0], the second line is assigned to input[1] similarly.	
	input = getLines(input).map(parseLineToInt);
	var N = input[0][0];
	var X = input[0][1]-1;
	var Y = input[0][2]-1;
	var ans = [];	
	for (var i = 0; i < N; i++) {
		ans.push(0);
	}
	for (var i = 0; i < N-1; i++) {
		for (var j = i+1; j < N; j++) {
			if(i<=X){
				if(j<=X){
					ans[j-i]++;
				}else if(j<=Y){
					ans[X-i+Math.min(1+Y-j,j-X)]++;
				}else{
					ans[X-i+1+j-Y]++;
				}
			}else if(i>X && i<=Y){
				if(j<=Y){
					ans[Math.min(j-i,i-X+1+Y-j)]++;
				}else{
					ans[Math.min(Y-i,i-X+1)+j-Y]++;
				}
			}else if(i>=Y){
				ans[j-i]++;			
			}
		}
	}
	for (var i = 1; i < N; i++) {
		console.log(ans[i]);
	}
	
}

// Don't edit this line!
//Main(require("fs").readFileSync(__dirname+'/in.txt', "utf8"));
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

// vector<vector<uint64_t> > v(n+1, vector<uint64_t>(n+1, 0))
// v[n][k]に組み合わせ数が入る。
void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// フェルマーの小定理
// mod. m での a の逆元 a^{-1} を計算する
// (a/b)%m = a*movinv(b,m)%m  
int64_t modinv(int64_t a, int64_t m) {
    int64_t b = m, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;


signed main() {
  string s;
  cin >> s;
  for(auto c:s){
    cout << "x";
  }
  cout << endl;
  return 0;
}




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

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

    for (int i = 1; i <= S.size(); ++i) {
        if (i % 2 != 0 && S[i - 1] == 'L' || i % 2 == 0 && S[i - 1] == 'R') {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


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

#define FOR(i, a, b) for(int i = a; i<b; ++i)
#define FR(a, b) for(int i = a; i>=b;--i)
#define _upgrade cin.tie(0); ios_base::sync_with_stdio(0)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define INF 1e9

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef pair<int, int> iPair;

const int MAX = 2e5+2;
const int M = 1e9+7;

double dp[301][301][301];
int main()
{
    _upgrade;
    int n, c1 = 0, c2 = 0, c3 = 0;
    cin>>n;
    FOR(i, 0, n)
    {
        int x;
        cin>>x;
        if(x == 1)
            c1++;
        else if(x == 2)
            c2++;
        else
            c3++;
    }
    FOR(i, 0, 301)
        FOR(j, 0, 301)
            FOR(k, 0, 301)
            {
                if(i+j+k > n || i+j+k == 0)
                    continue;
                db a, b, c;
                a = 1.0*k/(i+j+k);
                b = 1.0*j/(i+j+k);
                c = 1.0*i/(i+j+k);
                if(k)
                    dp[k][j][i] += dp[k-1][j][i]*a;
                if(j)
                    dp[k][j][i] += dp[k+1][j-1][i]*b;
                if(i)
                    dp[k][j][i] += dp[k][j+1][i-1]*c;

                dp[k][j][i] += 1.0*n/(i+j+k);
            }
    cout<<setprecision(10)<<dp[c1][c2][c3];
}



Measured memory_bytes: 213248
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N;

int main() {

	cin >> N;

	if (N >= 30) cout << "Yes" << endl;
	else

		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int k,s;

int main(){
    cin >> k >> s;
    int count = 0;
    for(int i = 0; i <= k; i++){
        for(int j = 0; j <= k; j++){
            int l = s - i - j;
            if(0 <= l && l <= k) count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
from collections import defaultdict as dd
import math

def ri():
    return int(input())

def rl():
    return map(int, input().split())

def rl2():
    return list(rl())

A, B, H, M = rl()
minutes = 60 * H + M
full1 = 60 * 12
full2 = 60

theta1 = 2 * math.pi * (minutes / full1)
theta2 = 2 * math.pi * (minutes / full2)

x1, y1 = A * math.cos(theta1), A * math.sin(theta1)
x2, y2 = B * math.cos(theta2), B * math.sin(theta2)

d = math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
print (d)


Measured memory_bytes: 65896
from math import sqrt, ceil, factorial
def is_prime(num):
  for i in range(2, ceil(sqrt(num))+1):
    if num%i==0:
      return False
  return True

def permcnt(n, r):
  return factorial(n) // factorial(n-r)

def combcnt(n, r):
  return factorial(n) // (factorial(n-r)*factorial(r))

n = int(input())
pls = [2]
i=3
while i<=n:
  if is_prime(i):
    pls.append(i)
  i+=1

def factoring(num):
  return _factoring(num, dict())
  
def _factoring(num, p):
  for i in pls:
    if num % i == 0:
      if i in p:
        p[i] += 1
      else:
        p[i] = 1
      return _factoring(num//i, p)
  return p

factors = dict()
for i in range(1,n+1):
  for k, v in factoring(i).items():
    if k in factors:
      factors[k] += v
    else:
      factors[k] = v

cnt = 0

# 七五数がx^74の形となるケース
cnt += len(list(filter(lambda x:x[1]>=74, factors.items())))

# 七五数がx^2*y^24の形となるケース
xs = {k for k,v in factors.items() if 2<=v and v<24}
ys = {k for k,v in factors.items() if v>=24}
cnt += len(xs)*len(ys)
cnt += permcnt(len(ys), 2) if len(ys)>=2 else 0

# 七五数がx^4*y^14の形となるケース
xs = {k for k,v in factors.items() if 4<=v and v<14}
ys = {k for k,v in factors.items() if v>=14}
cnt += len(xs)*len(ys)
cnt += permcnt(len(ys), 2) if len(ys)>=2 else 0

# 七五数がx^2*y^5*z^5の形となるケース
xs = {k for k,v in factors.items() if 2<=v and v<4}
ys = {k for k,v in factors.items() if v>=4}
cnt += len(xs)*combcnt(len(ys),2) if len(ys)>=2 else 0
cnt += 3*combcnt(len(ys), 3) if len(ys)>=3 else 0

print(cnt)

Measured memory_bytes: 3192
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
now = A[0]
ans = 0
s = 1
for i in range(1,N):
    if now == A[i]:
        s += 1
    else:
        if s % 2 == 0:
            pass
        else:
            ans += 1
        s = 1
    now = A[i]
if s % 2 == 1:
    ans += 1
print(ans)



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

int main(){
  int a = -1, m, k; scanf("%d %d", &m, &k);
  v1i v;
  if(k == 0) rep(i, 1 << m) rep(j, 2) v.push_back(i);
  else if(m > 1 && k < (1 << m)){
    v.push_back(k);
    rep(i, (1 << m)) if(i != k) v.push_back(i);
    v.push_back(k);
    rrep(i, (1 << m)) if(i != k) v.push_back(i);
  }
  if(v.size() == 0) printf("%d\n", a);
  else{
    rep(i, v.size()){
      printf("%d", v[i]);
      if(i == v.size()-1) printf("\n");
      else printf(" ");
    }
  }
  return 0;
}

Measured memory_bytes: 2932
#include <bits/stdc++.h>
using namespace std;
using llong = long long;

void fnInput(llong& rnNumA, double& rnNumB)
{
  cin >> rnNumA >> rnNumB;
}

llong fnMultiple(llong nNumA, double nNumB)
{
  int nNumIB = nNumB * 100 + 0.5;
  return nNumA * nNumIB / 100;
}
  
int main()
{
  llong nNumA;
  double nNumB;

  fnInput(nNumA, nNumB);
  cout << fnMultiple(nNumA, nNumB) << endl;

  return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    ll a[n];
    rep(i, 0, n) cin >> a[i];
    ll sum[n + 1] = {};
    rep(i, 0, n) {
        sum[i + 1] = sum[i] + a[i];
    }
    ll ans = 1e18;
    rep(i, 1, n + 1) {
        ll a = sum[i], b = sum[n] - sum[i];
        ans = min(ans, abs(a - b));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(void){
    ll a,b,c;
    a = 0;
    cin >> b >> c;
    a =(b/2) * (c/2) + ((b+1)/2) * ((c+1)/2);
  	if(b==1||c==1)a = 1;
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "vector"
#include "string"
#include "map"
#include "algorithm"
#include "functional"
#include "set"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;



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

	vector<vector<int>>v(3, vector<int>(3));
	for (auto &i : v) {
		for (auto &j : i)cin >> j;
	}
	for (int i = 0; i < 2; i++) {
		if (v[i][0] - v[i + 1][0] == v[i][1] - v[i + 1][1] && v[i][2] - v[i + 1][2] == v[i][0] - v[i + 1][0])continue;
		cout << "No\n";
		return 0;
	}
	for (int i = 0; i < 2; i++) {
		if (v[0][i] - v[0][i + 1] == v[1][i] - v[1][i + 1] && v[2][i] - v[2][i + 1] == v[0][i] - v[0][i + 1])continue;
		cout << "No\n";
		return 0;
	}
	cout << "Yes\n";
	return 0;
}


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

#define mod 1000000007

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()
#define ll long long int
#define vi vector<int>
#define vli vector<long int>
#define vlli vector<long long int >
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll>>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define cnl cout<<"\n";

#define fr(i, a, b) for(i=a; i<=b; i++)
#define frr(i,a,b) for(i=a;i<b;i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define fbb(i,a,b) for(i=a;i>b;i--)

#define pr_vec(i,a,b,v) for(i=a;i<b;i++) cout<<v[i]<<" ";
#define in_arr(i,n,v) for(i=0;i<n;i++) cin>>v[i];
int main(){
	ll n,i,j;
	cin>>n;
	ll ans=(n-2)*180;
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
v = list(map(int, input().split()))

kisu = [0]*(10**6)
gusu = [0]*(10**6)
for i in range(n):
    if i % 2 == 0:
        gusu[v[i]] += 1
    else:
        kisu[v[i]] += 1

count = 0
gusu_m = gusu.index(max(gusu))
kisu_m = kisu.index(max(kisu))

if gusu_m == kisu_m:

    gusu[gusu_m] = 0
    kisu[kisu_m] = 0
    if max(gusu) > max(kisu):
        gusu_m = gusu.index(max(gusu))
    else:
        kisu_m = kisu.index(max(kisu))

for i in range(n):
    if i % 2 == 0 and gusu_m != v[i]:
        count += 1
    if i % 2 != 0 and kisu_m != v[i]:
        count += 1

print(count)


Measured memory_bytes: 99736
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (a) - 1; (i) >= (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main(){
    ll n,c;
    cin >> n >> c;
    vector<vector<int>> cnt(1e5 + 1,vector<int>(c + 1,0));
    rep0(i, n){
        ll s,t,c;
        cin >> s >> t >> c;
        ++cnt[s - 1][c];
        --cnt[t][c];
    }
    rep1(i, c){
        rep1(j, 1e5){
            cnt[j][i] += cnt[j - 1][i];
        }
    }
    int ans = 0;
    rep1(i, 1e5){
        int t = 0;
        rep1(j, c){
            if(cnt[i][j] >= 1)++t;
        }
        ans = max(ans,t);
    }
    pf(ans);
    return 0;
}


Measured memory_bytes: 16640
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
  	cin>>n;
  	cout<<(n+1)/2<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n;
  scanf("%d", &n);
  if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
    printf("pon");
  else if (n % 10 == 3)
    printf("bon");
  else
    printf("hon");
}

Measured memory_bytes: 1732
_=gets.to_i
a=gets.split.map(&:to_i)
h=Hash.new(0)
a.each{|i|h[i]+=1}
total=0
h.each{|k,ci|total+=ci*(ci-1)/2}
a.each{|i|puts total - h[i]*(h[i]-1)/2 + ((h[i]-1)*(h[i]-2)/2)}


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

int main(){
  
  int N;
  cin >>N;
  
  //int A[N];
  vector<int> A(N);
  for (int i=0; i<N; i++){
    cin >>A.at(i);
  }
  
  int r;
  int ans = 0;
  bool flag = true;
  while (flag){
    r = 0;
    for (int i=0; i<N; i++){
      r += A.at(i) % 2;
      A.at(i) /= 2;
    }
    if(r != 0){
      flag = false;
    }else{
      ans++;
    }
  }
  cout << ans <<endl;

}

Measured memory_bytes: 256
using System;

class test
{
    static void Main()
    {
        for (int i = 1; i < 10; i++)
        {
            for (int j = 1; j < 10; j++)
            {
                Console.WriteLine("{0}x{1}={2}",i,j,i*j);
            }
        }
    }
}

Measured memory_bytes: 5544
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;
int w,h;
int p[15][80];
int flag[15][80];
int sx,nid;
double x_ave[200];
int dx_min[200],dx_max[200];
int edge[200][200];
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};

void dfs(int x,int y,int id){
	if(flag[x][y])return;
	flag[x][y]=1;
	x_ave[id]+=(double)x+0.5;
	if(y==0 || (y>0 && p[x][y-1]>=1 && p[x][y-1]!=p[x][y])){
		dx_min[id]=min(dx_min[id],x);
		dx_max[id]=max(dx_max[id],x);
	}
	for(int i=0;i<4;i++){
		int nx=x+dx[i],ny=y+dy[i];
		if(nx<0 || nx>=w || ny<0 || ny>=h)continue;
		if(p[x][y]==p[nx][ny])dfs(nx,ny,id);
	}
	for(int i=0;i<1;i++){
		int nx=x+dx[i],ny=y+dy[i];
		if(nx<0 || nx>=w || ny<0 || ny>=h)continue;
		if(p[x][y]!=p[nx][ny] && flag[nx][ny]==0 && p[nx][ny]>=1){
			nid++;
			edge[id][nid]=1;
			dfs(nx,ny,nid);
		}
	}
}

int main(void){
	while(1){
		scanf("%d %d",&w,&h);
		if(w+h==0)break;
		nid=0;
		memset(p,0,sizeof(p));
		memset(flag,0,sizeof(flag));
		for(int i=0;i<200;i++)dx_min[i]=114;
		memset(dx_max,0,sizeof(dx_max));
		memset(x_ave,0,sizeof(x_ave));
		memset(edge,0,sizeof(edge));
		for(int i=h-1;i>=0;i--){
			string str;
			cin >> str;
			for(int j=0;j<w;j++){
				if(str[j]=='.')p[j][i]=0;
				else{
					p[j][i]=str[j]-'0';
					if(i==0)sx=j;
				}
			}
		}
		dfs(sx,0,0);
		for(int k=0;k<=nid;k++){
			for(int i=0;i<=nid;i++){
				for(int j=0;j<=nid;j++){
					edge[i][j]=max(edge[i][j],edge[i][k]&edge[k][j]);
				}
				edge[i][i]=1;
			}
		}
		bool st=true;
		for(int i=0;i<=nid;i++){
			double all=0.0,cnt=0.0;
			for(int j=0;j<=nid;j++){
				if(edge[i][j])cnt+=1.0,all+=x_ave[j]/4.0;
			}
			all/=cnt;
			if(all<=(double)dx_min[i] || all>=(double)(dx_max[i]+1.0))st=false;
		}
		printf("%s\n",st?"STABLE":"UNSTABLE");
	}
	return 0;
}

Measured memory_bytes: 1388
def isPrime( x ):
	if 2 == x or 3 == x:
		return True
	if 0 == x%2:
		return False
	i = 3 
	while  i*i <= x:
		if 0 == x%i:
			return False
		i += 1
	return True


n = int( input( ) )

cnt = i = 0
while i < n:
	num = int( input( ) )
	if isPrime( num  ):
		cnt += 1
	i += 1

print( cnt )

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

int main() {
  string s; cin >> s;
  ll k; cin >> k;
  
  ll pos = s.size(); int num;
  REP(i, s.size()) {
    if (s[i] != '1') {
      pos = i;
      num = s[i] - '0';
      break;
    }
  }
  
  cout << (k - 1 >= pos ? num : 1) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int dp[3100][3100];
string s, t;
string ans;

void dfs( int x, int y ){
	if( x == 0 || y == 0 ) return;
	if( dp[x-1][y] != dp[x][y-1] ){
		if( dp[x-1][y] > dp[x][y-1] ) dfs(x-1, y);
		else dfs(x, y-1);
	} else {
		if( dp[x-1][y] == dp[x][y]-1 && dp[x][y-1] == dp[x][y]-1 ){
			ans += s[x-1];
			dfs(x-1, y-1);
		} else {
			dfs(x-1, y);
		}
	}
}

int main(){
	 cin >> s >> t;
	int p = s.l_ength(), q = t.l_ength();
	for( int i = 0; i < p; ++i ){
		for( int j = 0; j < q; ++j ){
			dp[i+1][j+1] = max( dp[i][j+1], dp[i+1][j] );
			if( s[i] == t[j] ){
				dp[i+1][j+1] = dp[i][j]+1;
			}
		}
	}
	dfs(p, q);
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}

Measured memory_bytes: 37120
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
 
int32_t main() 
{
    IO;
    int n;
    cin>>n;
    cout<<(float)(2 * 3.14 * n);
    // cout<<lower_bound(v.begin(),v.end(),10) - v.begin();
	return 0;
}


Measured memory_bytes: 3804
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n; cin >> n; ll ans = 0;
  
  for(ll i=1; i <= n; i++){
    ll x = n/i;
    
    ans += i*x*(x+1)/2;
  }
  
  cout << ans << endl;
  
  
}

Measured memory_bytes: 3640
#include <iostream>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    bool b[n];
    for (int i=0; i<n; i++) b[i]=0;
    for (int i=0; i<k; i++){
        int d;
        cin>>d;
        for (int j=0; j<d; j++){
            int temp;
            cin>>temp;
            b[temp-1]=1;
        }
    }
    int ans=0;
    for (int i=0; i<n; i++){
        if (b[i]==0) ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<cstdio>
int fib(int);
using namespace std;
int main()
{
	int n,ans,dp[1001];
	dp[0] = 1;
	dp[1] = 1;
	cin >> n;
	for (int i = 0; i <= n; i++){
		dp[i + 2] = dp[i] + dp[i + 1];
	}
	//ans = fib(n - 1);
	ans = dp[n];
	cout << ans << endl;
}
int fib(int n)
{
	if (n < 1)
		return 1;
	else
	{
		return fib(n - 1)+fib(n - 2);
	}
}

Measured memory_bytes: 1164
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;//namespace

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define SANKOU(n,a,b) cout << ((n) ? (a) : (b) ) << endl;

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);// warshall-floyd

#define CIN(x) int x;cin>>x;
#define CIN2(x,y) int x,y;cin>>x>>y;
#define CIN3(x,y,z) int x,y,z;cin>>x>>y>>z;
#define SCIN(x) string x;cin>>x;
#define SCIN2(x,y) string x,y;cin>>x>>y;
#define COUT(x) cout<<(x)<<endl;
#define SCOUT(x) cout<<(x)<<" ";
#define ENDL cout<<endl;

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_;
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i];
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl;

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())


#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){
    CIN(n); V a(n);VECCIN(a);
    int sum=1;
    int dif=-1;
    REP(i,n-1){
        if(dif!=-1){
            if(dif==0&&a[i]>a[i+1]){dif=-1;sum++;}
            if(dif==1&&a[i]<a[i+1]){dif=-1;sum++;}
        }
        else{
            if(a[i]>a[i+1])dif=1;
            if(a[i]<a[i+1])dif=0;
        }
        
    }
    COUT(sum);
    return 0;
}


Measured memory_bytes: 640
/*input
axyb
abyxb
*/
#include<bits/stdc++.h>
using namespace std;

#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test int t;cin>>t;while(t--)
#define X first
#define Y second
#define pb push_back
#define all(s) s.begin(),s.end()

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

const int MOD = 1e9+7;

void solve(){
  string s,t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();
  int dp[n+1][m+1];

  for(int i=0;i<=n;i++)
    dp[i][0] = 0;
  for(int i=0;i<=m;i++)
    dp[0][i] = 0;

  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]);
      }
    }
  }

  string ans="";
  
  int i=n,j=m;

  while(i>0 && j>0){
    // if(dp[i][j]==dp[i-1][j-1]+1){
    //   ans.pb(s[i-1]);
    //   i--,j--;
    // }
    if(dp[i][j]==dp[i-1][j]){
      i--;
    }
    else if(dp[i][j]==dp[i][j-1])
      j--;
    else{
      ans.pb(s[i-1]);
      i--,j--;
    }
  }
  reverse(all(ans));
  cout << ans;
  // cout << dp[n][m];
}

int main(){
    // FIN;   
    // test
    solve();
}

Measured memory_bytes: 35456
#include<iostream>
#include<cstdio>
#include<cstring>
template<typename T>inline void check_max(T a,T &b){if(a>b)b=a;}
typedef long long ll;
const int N=101000;
ll s[N],t[N];
ll ans;
int n,k;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&s[i]);
		t[i]=t[i-1];
		if(s[i]>0)t[i]+=s[i];
		s[i]+=s[i-1];
	}
	ans=0;
	for(int i=k;i<=n;i++)
		check_max(std::max(s[i]-s[i-k],0ll)+t[i-k]+t[n]-t[i],ans);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1792
import java.io.IOException
import java.io.PrintWriter
import java.util.*

fun main(args: Array<String>) {
    val fs = FastScanner()
    val out = PrintWriter(System.out)
    val s = fs.next()
    val set: MutableSet<Char> = HashSet()
    for (i in 0 until s.length) {
        set.add(s[i])
    }
    if (set.size == 1) {
        out.println("No")
    } else {
        out.println("Yes")
    }
    out.flush()
}

internal class FastScanner {
    private val `in` = System.`in`
    private val buffer = ByteArray(1024)
    private var ptr = 0
    private var buflen = 0
    private fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            try {
                buflen = `in`.read(buffer)
            } catch (e: IOException) {
                e.printStackTrace()
            }
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }

    private fun readByte(): Int {
        return if (hasNextByte()) buffer[ptr++].toInt() else -1
    }

    private fun isPrintableChar(c: Int): Boolean {
        return 33 <= c && c <= 126
    }

    operator fun hasNext(): Boolean {
        while (hasNextByte() && !isPrintableChar(buffer[ptr].toInt())) ptr++
        return hasNextByte()
    }

    operator fun next(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b)
            b = readByte()
        }
        return sb.toString()
    }

    fun nextLong(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n: Long = 0
        var minus = false
        var b = readByte()
        if (b == '-'.toInt()) {
            minus = true
            b = readByte()
        }
        if (b < '0'.toInt() || '9'.toInt() < b) {
            throw NumberFormatException()
        }
        while (true) {
            if ('0'.toInt() <= b && b <= '9'.toInt()) {
                n *= 10
                n += b - '0'.toInt().toLong()
            } else return if (b == -1 || !isPrintableChar(b)) {
                if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextInt(): Int {
        val nl = nextLong()
        if (nl < Int.MIN_VALUE || nl > Int.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }

    fun nextDouble(): Double {
        return next().toDouble()
    }
}



Measured memory_bytes: 29592
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

using System.Collections;

class Program
{
    static void Main()
    {
        //「黒白黒白・・・」もしくは「白黒白黒・・・」の2パターン
        string S = Console.ReadLine();
        int N = S.Length;

        var sirokuro = new char[] { '1', '0' };
        var kurosiro = new char[] { '0', '1' };
        var pattern1 = new string(Enumerable.Repeat(0, int.MaxValue).SelectMany(n => sirokuro).Take(N).ToArray());
        var pattern2 = new string(Enumerable.Repeat(0, int.MaxValue).SelectMany(n => kurosiro).Take(N).ToArray());
        var dif1 = S.Zip(pattern1, (c1, c2) => new { c1, c2 }).Count(itm => itm.c1 != itm.c2);
        var dif2 = S.Zip(pattern2, (c1, c2) => new { c1, c2 }).Count(itm => itm.c1 != itm.c2);

        Console.WriteLine(Math.Min(dif1, dif2));

    }
}

Measured memory_bytes: 19548
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int n;
    cin>>n;

    vector<int> a(n),b(n),c(n);
    vector<vector<int>> dp(n,vector<int>(3,0));
    for(int i=0; i<n; i++){
        cin>>a[i]>>b[i]>>c[i];
    }

    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];

    for(int i=0; i<n-1; i++){
        dp[i+1][0]=max(dp[i][1]+a[i+1],dp[i][2]+a[i+1]);
        dp[i+1][1]=max(dp[i][0]+b[i+1],dp[i][2]+b[i+1]);
        dp[i+1][2]=max(dp[i][0]+c[i+1],dp[i][1]+c[i+1]);
    }

    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    return 0;
}

Measured memory_bytes: 6912
S = list(input())
s1 = list("keyence")

x = [1]
y = [1]
for i in range(7):
  if S[i] == s1[i]:
    x.append(x[len(x)-1])
  if S[len(S)-1-i] == s1[6-i]:
    y.append(y[len(y)-1])
  

if sum(x) + sum(y) >= 9:
  print("YES")  
else:
  print("NO")

Measured memory_bytes: 3064
from itertools import accumulate
import bisect

n = int(input())
a = list(map(int, input().split()))

acc = list(accumulate(a))

#idx = bisect.bisect_left(acc,acc[-1]//2)
#print(idx)
result = []
for i in range(n):
    result.append(abs((acc[-1] - acc[i] ) - acc[i]))
print(min(result))

Measured memory_bytes: 36204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    int x[5];
    For(i,0,5) {
        cin >> x[i];
        if(x[i]==0) cout<<i+1<<endl;
    }
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

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

		String ans = "Good" ;
		String S = scan.next();
		char[] str = S.toCharArray();

		for (int i = 0;i < 3;i++) {
			if (str[i] == str[i+1]) {
				ans = "Bad";
				break;
			}
		}

		System.out.println(ans);
	}
}

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

int main(){
    int n;
    cin >>n;
    int a[n+1];
    a[0]=0;
    ll ans=0;
    map<int,int> mp;
    rrep(i,n){
        cin >>a[i];
        ans+=mp[i-a[i]];
        mp[i+a[i]]++;

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

Measured memory_bytes: 21396
// skyrim belongs to the nords
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back 
#define sz(a) ((int)(a).size())
#define rep(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define dec(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end() 
#define LOGN 18
#define EPS 1e-8
#define fcin ios_base::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;

bool loc[100005];
set<int> sit;
int main(){
	fcin;
	cin.tie(0);
	int N, val;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> val;
		if (!sit.count(val)) sit.insert(val);
		else sit.erase(val);
	}
	cout << sit.size();
	return 0;
}
 

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

using namespace std;
long long C[9], V[99];
long long N;
long long cnt;
char A[15];

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

	while(N--){
		cin >> A;
		V[A[0]]++;
	}
	C[0] = V['M'];
	C[1] = V['A'];
	C[2] = V['R'];
	C[3] = V['C'];
	C[4] = V['H'];
	for (int i = 0; i < 5; i++) 
		for (int j = i + 1; j < 5; j++) 
			for (int k = j + 1; k < 5; k++) {
				cnt += C[i] * C[j] * C[k];
			}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repd(i,a,b) for(ll i=a;i>=b;i--)
#define ford(i,n)  for(ll i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
// const ll mod=998244353;	
const ll mod = 1e9 + 7;
const ll inf = std::numeric_limits<ll>::max();
const ll infi = std::numeric_limits<int>::max();
const double pi = acos(-1.0);
ll gcd(ll a, ll b){if(b == 0) return a; return gcd(b%a, a);}
ll fastexp(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%mod; y=y>>1; x=(x*x)%mod;} return res; }
ll inv_mod(ll n){return fastexp(n,mod-2);}
bool isPrime(ll n){ll srt = sqrt(n);rep(i,3,srt)if(n%i == 0)return false;return true;}
char alphabet[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

void solve() {
  int n;cin>>n;
  vi h(n), minc(n,infi);
  fori(i,n)cin>>h[i];
  minc[0] = 0, minc[1] = abs(h[1] - h[0]);
  rep(i, 2,n-1){
    minc[i] = min(minc[i-1] + abs(h[i] - h[i-1]), minc[i-2] + abs(h[i] - h[i-2]));
  }
  cout<<minc[n-1];
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int t = 1;
  // cin>>t;
  while(t--){
    solve();
  }
  return 0;
}


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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()

using ll = std::int64_t;
using vint = std::vector<int>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int n;
    cin >> n;
    vint v(n), c(n);
    rep(i, n) {
        int vi;
        cin >> vi;
        v[i] = vi;
    }

    rep(i, n) {
        int ci;
        cin >> ci;
        v[i] -= ci;
    }

    int ans = 0;
    rep(i, n) {
        if (v[i] > 0) {
            ans += v[i];
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
// CONTEST

#include <bits/stdc++.h>
using namespace std;

// Utility
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, X, Y) for (int I = (X); I < (Y); I++)
using ll = int64_t;
using ull = uint64_t;
namespace std {
template<class ...Ts>        istream& operator>>(istream& i, tuple<Ts...>& x) { apply([&](auto&&... ys){ ((i >> ys), ...); }, x); return i; }
template<class T1, class T2> istream& operator>>(istream& i, pair<T1, T2>& x) { i >> x.first >> x.second; return i; }
template<class T>            istream& operator>>(istream& i, vector<T>& x)    { for (auto& y : x) { i >> y; } return i; }
}

// Debugging
#define DD(X) std::cout << #X ": " << (X) << std::endl << std::flush
namespace std {
template<class ...Ts>        ostream& operator<<(ostream& o, const tuple<Ts...>& x) { o << "("; apply([&](auto&& y, auto&&... ys){ o << y; ((o << ", " << ys), ...); }, x); o << ")"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const pair<T1, T2>& x) { o << tie(x.first, x.second); return o; }
template<class T>            ostream& operator<<(ostream& o, const vector<T>& x)    { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const set<T1, T2>& x)  { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& x)  { o << "{"; for (auto it = x.begin(); it != x.end(); it++) { if (it != x.begin()) { o << ", "; } o << *it; } o << "}"; return o; }
}

// Main
void mainCase() {
  ll x, k, d; // <= 10^15
  cin >> x >> k >> d;

  // WLOG, x >= 0
  x = abs(x);

  auto solve = [&]() -> ll{
    // x >= k.d
    if (x / d >= k) {
      return x - k * d;
    }

    ll q = x / d;
    ll r = x % d;
    ll kk = k - q;
    ll res = (kk % 2 == 0) ? r : (d - r);
    return res;
  };

  cout << solve() << endl;
}

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

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
  par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
  vector<int> gt;
  aa(int n){
  gt= vector<int>(n, 1);
  }
  void c(V<int> d,int b){
  if(d[b]==0){
    gt[d[b]-1]++;
    gt[gt.sz-1]++;
  }
  else{
    gt[d[b]-1]++;
    c(d,d[d[b]]-1);
  }
}
void cok(int a){
  cout<<gt[a-1]<<endl;
  fo(i,a-1)
  cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){


*/
signed main(){
  int n;
  cin>>n;
  int b=0;
  V<int> a(n);
  fo(i,n){
    cin>>a[i];
  }
  Sort(a);
  fo(i,n-1){
    if(a[i]==a[i+1])
      b=1;
  }
  if(b)
    cout<<"NO"<<endl;
  else
    cout<<"YES"<<endl;
}

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

int main()
{
	int A, B;
	int ans = 0;
	cin >> A >> B;
	for (int a = 1; a <= 9; a++)
	{
		for (int b = 0; b <= 9; b++)
		{
			for (int c = 0; c <= 9; c++)
			{
				int t = 10001 * a + 1010 * b + 100 * c;
				if (A <= t && t <= B)
				{
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 500000
#define INFTY 1000000000

void marge(int,int,int);
void margeSort(int,int);

int arr[MAX],n,count=0;

int main(){

  int i,left=0,right;
  
  //in
  scanf("%d",&n);
  
  right = n;
  
  for(i=0;i<n;i++){
    scanf("%d",&arr[i]);
  }
  
  //sort
  margeSort(left,right);
  
  //out
  for(i=0;i<n;i++){
    if(i<n-1) printf("%d ",arr[i]);
    else printf("%d\n",arr[i]);
  }
  printf("%d\n",count);

  return 0;
}

void marge(int left,int mid,int right){
  int i,j,k,n1,n2,l[MAX],r[MAX];
  
  n1 = mid - left;
  n2 = right - mid;
  
  for(i=0;i<n1;i++){
    l[i]=arr[left+i];
  }
  
  for(i=0;i<n2;i++){
    r[i]=arr[mid+i];
  }
  
  l[n1] = INFTY;
  r[n2] = INFTY;
  
  i = j = 0;
  
  for(k=left;k<right;k++){
    if(l[i]<=r[j]){
      arr[k]=l[i];
      i++;
    }else{
      arr[k]=r[j];
      j++;
    }
    count++;
  }
}

void margeSort(int left,int right){
  int mid;
  
  if(left+1 < right){
    mid=(left+right)/2;
    margeSort(left,mid);
    margeSort(mid,right);
    marge(left,mid,right);
  }
}

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

int main(void) {
	while(true) {
		int x, y, s;
		cin >> x >> y >> s;
		if ( x == 0 ) { break; }
		x += 100;
		y += 100;

		int max = 0;

		for(int a=1; a<s; a++) {
			for(int b=1; b<s; b++) {
				if ( (a*x/100 + b*x/100) == s ) {
					int newsum = a*y/100 + b*y/100;
					if ( newsum > max ) { max = newsum; }
				}
			}
		}

		cout << max << std::endl;
	}
}

Measured memory_bytes: 3060
s = input().split()
a=int(s[0])
s = input().split()
c=0
max=0
for i in range(a-1):
        if(int(s[i])>=int(s[i+1])):
                c+=1
                if max < c:
                        max = c
        else:
                c=0

print(max)

Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll N, h, thh=0, count=0;
    cin>>N;
    rep(i, N){
        cin>>h;
        if(thh<=h){
            count+=h-thh;
        }
        thh=h;
    }
    cout<<count<<endl;
    return 0;
}


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

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

    cout << (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d) ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

    string s;
    cin>>s;
    int n = (int)s.size();
    int c = 0;
    long long ans = 0;
    for ( int i= 0 ; i < n; i++ ){
        if( s[ i ] == 'B') c++;
        else ans += c;
    }
    cout<<ans<<endl;
//sss
}

Measured memory_bytes: 640
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

m, n = map(int, input().split())


def bpm(x, y, N):
    """
     Bisection power method : 二分累乗法
     O(log y)でx^(y) mod N を求める。
    """
    ans = 1
    x %= MOD
    digit = int((math.log(y, 2) // 1 + 1))  # yの２進数表示の桁数
    for i in range(digit):
        if (y >> i) & 1 == 1:
            ans *= x
            ans %= MOD
        x **= 2
        x %= MOD
    return ans


print(bpm(m, n, MOD))



Measured memory_bytes: 6912
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>

using namespace std;

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

  vector<int> l(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &l[i]);
  }
  sort(l.begin(), l.end());

  int count = 0;
  for (int i1 = n - 1; i1 >= 0; i1--) {
    for (int i2 = i1 - 1; i2 >= 0; i2--) {
      int a = l[i1];
      int b = l[i2];

      auto it = lower_bound(l.begin(), l.end(), a + b);
      int d = distance(it, l.end());
      count += n - 1 - i1 - d;
    }
  }

  cout << count << endl;
}


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


using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    vector<int>a(k);
    for(int i=0;i<k;i++)
        cin>>a[i];
    int total=n;
    for(int i=0;i<k-1;i++){
        total=min(total,n-(a[i+1]-a[i]));
    }
    total=min(total,n-(a[0]+n-a[k-1]));
    cout<<total;
    return 0;
}


Measured memory_bytes: 1024
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }


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

    // ifstream fin(".in");
    // ofstream fout(".in");
i64 a,b,c,k;
cin>>a>>b>>c>>k;
i64 sum=0;
if(k>=a)
{
  sum+=a;
  k-=a;
}
else
{
  sum+=k;
  k=0;
}
if(k>=b)
{
  k-=b;
}
else
k=0;
if(k)
{

  sum-=min(k,c);
}
cout<<sum;

    return 0;
  }


Measured memory_bytes: 3640