akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
 
using namespace std;

void bfs( int s , vector<int> &vis , vector< vector<int> > v , vector<int> &dist )
{
    queue<int> q;
    q.push(s);
    vis[s] = 1;

    while(!q.empty())
    {
        int p = q.front();
        q.pop();

        for ( int i = 0 ; i < v[p].size() ; i++ )
        {
            if ( vis[v[p][i]] == 0 )
            {
                vis[v[p][i]] = 1;
                q.push(v[p][i]);
                dist[v[p][i]] = dist[p]+1;
            }
        }
    }
}

signed main()
{
    fast;
    int n,x,y;
    cin>>n>>x>>y;

    map<int,int> ans;

    vector < vector<int> > v(n+1);

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

    v[x].pb(y);
    v[y].pb(x);

    for ( int i = 1 ; i <= n ; i++ )
    {
        vector<int> vis(n+1,0);
        vector<int> dist(n+1,0);

        bfs(i,vis,v,dist);

        for ( int i = 1 ; i < dist.size() ; i++ )
        {
            ans[dist[i]]++;
        }
    }

    for ( int i = 1 ; i <= n-1 ; i++ )
    {
        cout<<ans[i]/2<<endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n;
vector<vector<int> > G;
const ll MOD = 1e9+7;
vector<vector<ll> > memo;

ll dfs(int now, int ago, int color){
	if(memo[now][color] != -1) return memo[now][color];
	ll ans = 1;
	if(color == 0){
		for(auto next : G[now]){
			if(next == ago) continue;
			(ans *= dfs(next, now, 1)) %= MOD;
		}
	}
	else{
		for(auto next : G[now]){
			if(next == ago) continue;
			(ans *= dfs(next, now, 0) + dfs(next, now, 1)) %= MOD;
		}
	}
	return memo[now][color] = ans;
}

signed main(){
	scanf("%d", &n);
	G.resize(n);
	memo.resize(n, vector<ll> (2, -1));
	for(int i = 1; i < n; i++){
		int x, y;
		scanf("%d %d", &x, &y);
		--x; --y;
		G[x].push_back(y); G[y].push_back(x);
	}
	ll ans = (dfs(0, -1, 0) + dfs(0, -1, 1)) % MOD;
	cout << ans << endl;
}

Measured memory_bytes: 22540
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

int v[105];
int w[105];
int dp[105][10005];

int main(){
    cin.tie(0);

    int N, W; cin >> N >> W;

    for (int i = 0; i < N; i++){
        cin >> v[i] >> w[i];
    }

    for (int i = 0; i < 10005; i++){
        if (w[0] <= i) dp[0][i] = v[0]; 
    }
    for (int i = 1; i < N; i++){
        for (int j = 0; j < 10005; j++){
            dp[i][j] = dp[i-1][j];
            if (w[i] <= j) dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]] + v[i]);
        }
    }
    cout << dp[N-1][W] << endl;

} 



Measured memory_bytes: 6992
#include <stdio.h>

int main(void) {
  int c, a, b, x, ans = 0, i, j, k;
  scanf("%d%d%d%d", &a, &b, &c, &x);
  x /= 50;
  for(i = 0; i <= a; ++i) {
    for(j = 0; j <= b; ++j) {
      for(k = 0; k <= c; ++k) {
        if(k + 2 * j + i * 10 == x) ++ans;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

int a, b;

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> a >> b;
    int ans = a - b*2;

    cout << max(0LL, ans) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int partition(int A[], int p, int r)
{
  int i, j;
  int x = A[r];
  i = j = p;
  for(j=p; j<r; j++)
  {
    if(A[j] <= x)
    {
      swap(A[i], A[j]);
      i++;
    }
  }
  swap(A[r], A[i]);
  return i;
}
int main()
{
  int n;
  scanf("%d", &n);
  int A[100005];
  for(int i=0; i<n; i++)
  {
    scanf("%d", &A[i]);
  }
  int j = partition(A, 0, n-1);
  for(int i=0; i<n; i++)
  {
    if(i) printf(" ");
    if(i == j) printf("[%d]", A[i]);
    else printf("%d", A[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 3560
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int W, H, N;
  cin >> W >> H >> N;
  int x[N], y[N], a[N];
  int minx = 0, miny = 0, maxx = W, maxy = H;
  for(int i = 0; i < N; ++i){
    cin >> x[i] >> y[i] >> a[i];
    if(a[i] == 1){
      if(minx < x[i]) minx = x[i]; 
    }
    if(a[i] == 2){
      if(x[i] < maxx) maxx = x[i];
    }
    if(a[i] == 3){
      if(miny < y[i]) miny = y[i];
    }
    if(a[i] == 4){
      if(y[i] < maxy) maxy = y[i];
    }
  }
  cout << max(0, maxx - minx)*max(0, maxy - miny) << endl;
}

Measured memory_bytes: 256
s = list(input())
K = int(input())
a = ord('z') + 1
for i in range(len(s)-1):
    if s[i] == 'a':
        continue
    #print(K,a - ord(s[i]))
    if K >= (a - ord(s[i])):
        K -= a - ord(s[i])
        s[i] = 'a'
    #print(K,a - ord(s[i]))
i = len(s)-1
s[len(s)-1] = chr((ord(s[i])-ord('a') + K) % 26 + ord('a'))
print(''.join(s))


Measured memory_bytes: 71192
#include <cstdio>
#include <cstring>
int main()
{
 int a,b,c;
 char v[3];
 while(true){
  scanf("%d %s %d\n",&a,v,&b);
  if (strcmp(v,"?")==0) break;
  if (strcmp(v,"+")==0) c=a+b;
  if (strcmp(v,"-")==0) c=a-b;
  if (strcmp(v,"*")==0) c=a*b;
  if (strcmp(v,"/")==0) c=a/b;
  printf("%d\n",c);
 }
 return 0;
}

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

int main() {
    int a, b;

    while ( 1 ) {
        cin >> a >> b;
        if ( a == 0 && b == 0 ) break;

        for (int i = 0; i < a; i++ ) {
            for ( int n = 0; n < b; n++) {
                if ( 0 < i && i < a - 1 && 0 < n && n < b - 1 ) {
                    cout << ".";
                } else {
                    cout << "#";
                }
            }
            cout << "\n";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n, m;
llong h[100005];
llong a, b;
vector<vector<llong>> g;

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

    for (int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    
    g.resize(n + 1);
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    llong ans = 0;
    for (int i = 1; i <= n; i++) {
        llong mh = 0;
        for (int j = 0; j < g[i].size(); j++) {
            mh = max(mh, h[g[i][j]]);
        }

        if (h[i] > mh) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9832
#include<stdio.h>

int main(){
	
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	int median = (a+b)/2;
	
	int dis1 = median - a;
	int dis2 = b - median;
	
	if(dis1==dis2){
		printf("%d\n",median);
	}
	
	else{
		printf("IMPOSSIBLE\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	tmp = input[1].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var n = parseInt(input[0], 10);
	var b = tmp[0];
    var c = tmp[1];
  //  console.log(b,c);
	
	        
              var result = '';
               
              // 文字列をすべて取得するまで繰り返す
              for(var i=0; i<n; i++) {
               
                  // 1文字ずつ「result」に格納していく
                  result += b.charAt( i );
                  result += c.charAt( i );}
     console.log(result);
	
	
	
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (x >= r && x <= W - r && y >= r && y <= H - r) {
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
}



Measured memory_bytes: 3108
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}

	tmp := true
	for _, a := range as {
		if !judge(a) {
			tmp = false
			break
		}
	}

	if tmp {
		fmt.Print("APPROVED")
	} else {
		fmt.Print("DENIED")
	}
}

func judge(n int) bool {
	if n % 2 == 1 || (n % 3 == 0 || n % 5 == 0) {
		return true
	} else {
		return false
	}
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }



typedef pair<ll, pair<ll, ll>> prr;
int main() {
    ll n,k; cin >> n >> k;
    vector<ll> a(n);
    vector<ll> f(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];

    sort(a.begin(), a.end());
    sort(f.begin(), f.end(), greater<ll>());


    ll l = -1, r = 1e12;

    while(l+1 < r) {
        ll c = (l+r)/2;
        bool ok = [&] {
            ll s = 0;
            rep(i, n) {
                s += max(0ll, a[i]-c/f[i]);
            }
            return s <= k;
        }();
        if (ok) r = c; else l = c;
    }
    cout << r << endl;

    return 0;
}



Measured memory_bytes: 3456
using System;

class Program_a
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');

        int Health = int.Parse(input[0]);
        int Attack = int.Parse(input[1]);

        int Count = Health / Attack;
        int Amari = Health % Attack;

        if (Amari > 0)
        {
            Count += 1;
        }

        Console.WriteLine(Count);
    }
}

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

public class Main {
	static final int mod = (int) 1e9 + 7;
	static final int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int[] DX8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, DY8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	static final String nextLine = "\n";

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		String s = fs.next();
		int n = s.length();
		long ans = 0;
		for(int i=0;i<1<<n-1;i++) {
			long sum = 0;
			int bd = 0;
			for(int j=0;j<n;j++) {
				if((i>>j&1)==1) {
					String now = s.substring(bd,j+1);
					long t = Long.parseLong(now);
					sum += t;
					bd = j+1;
				}
			}
			String now = s.substring(bd);
			long t = Long.parseLong(now);
			sum += t;
			ans += sum;
		}
		System.out.println(ans);
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 21460
import sys
sys.setrecursionlimit(10**9)
n, m = map(int, input().split())

root = [-1]*n

def find(n):
    if root[n] < 0:
        return n
    else:
        root[n] = find(root[n])
        return root[n]

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    else:
        root[x] += root[y]
        root[y] = x

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    unite(a, b)

ans = -1
for i in root:
    if i < 0:
        ans += 1

print(ans)

Measured memory_bytes: 79472
#define NDEBUG
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAX_N = 5e5 + 5;

int N;
char s[MAX_N];
int pre[MAX_N], nxt[MAX_N];
int dp[MAX_N];

void solve()
{
  assert(0);
  pre[0] = s[0] == '0' ? 0 : -1;
  for (int i = 1; i < N; ++i) {
    if (s[i] == '0') {
      pre[i] = i;
    } else {
      pre[i] = pre[i - 1];
    }
  }
  nxt[N - 1] = s[N - 1] == '0' ? N - 1 : N;
  for (int i = N - 2; i >= 0; --i) {
    if (s[i] == '0') {
      nxt[i] = i;
    } else {
      nxt[i] = nxt[i + 1];
    }
  }
  for (int i = 0; i < N; ++i) {
    dp[i + 1] = max(dp[i + 1], dp[i]);
    if (i - 2 >= 0 && s[i - 2] == '1' && s[i - 1] == '0' && s[i] == '1') {
      int j = pre[i - 2];
      dp[i + 1] = max(dp[i + 1], dp[j + 1] + i - 2 - j);
      if (j != i - 3) {
        dp[i + 1] = max(dp[i + 1], dp[j + 2] + i - 3 - j);
      }
    }
    if (i + 2 < N && s[i] == '1' && s[i + 1] == '0' && s[i + 2] == '1') {
      int j = nxt[i + 2];
      dp[j] = max(dp[j], dp[i] + j - i - 2);
      if (j != i + 3) {
        dp[j - 1] = max(dp[j - 1], dp[i] + j - i - 3);
      }
    }
  }
  printf("%d\n", dp[N]);
}

int main()
{
#ifdef linjian
freopen("C:\\Users\\linjian\\Documents\\in.txt", "r", stdin);
#endif
  scanf("%d%s", &N, s);
  solve();
  return 0;
}


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

using namespace std;

int main(void){
    int N, M, n, m;
    vector<int> L, R;
    cin>>N>>M;

    L.resize(M);
    R.resize(M);

    for(int i=0; i<M; i++){
        cin>>n>>m;
        L[i] = n;
        R[i] = m;
    } 

    sort(L.begin(), L.end());
    sort(R.begin(), R.end());

    int Lmax = L[M-1];
    int Rmin = R[0];
    int cnt = 0;

    for(int i=1; i<=N; i++){
        if(Lmax<=i && i<=Rmin)cnt++;
    }

    cout<<cnt<<endl;
}

Measured memory_bytes: 1024
// https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/10/ITP1_10_C

#include <iostream>
#include <cmath>
#include <iomanip>

int main()
{
    int n, sum = 0;
    double m, dev;
    while (std::cin >> n && n != 0)
    {
        int s[n];
        for (int i = 0; i < n; i++)
        {
            std::cin >> s[i];
            sum += s[i];
        }
        m = (double)sum / (double)n;

        double tmp;
        for (auto &x : s)
        {
            tmp += pow((double)x - (double)m, 2);
        }
        dev = sqrt((double)tmp / (double)n);

        std::cout << std::fixed << std::setprecision(5) << dev << std::endl;
        tmp = 0;
        sum = 0;
    }
}


Measured memory_bytes: 3236
import java.util.*;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
//        String str = sc.nextLine();
        int count = sc.nextInt();
        ArrayList<Integer> data = new ArrayList<>();
        for (int i = 1; i <= count*2; i++) {
            data.add(sc.nextInt());
        }
        List<Integer> sorted = data.stream().collect(Collectors.toList());
        sorted.sort(Comparator.reverseOrder());
        int j=1;
        int sum=0;
        for(Integer s:sorted){
            if(j%2==0)
                sum=sum+s;
            j++;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 27220
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in1(x) int x; cin>>x;
#define in2(x, y) int x, y; cin>>x>>y;
#define in3(x, y, z) int x, y, z; cin>>x>>y>>z;
#define in4(x, y, z, w) int x, y, z, w; cin>>x>>y>>z>>w;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
using namespace std;

//bool primes[1000001];vi prime;
//void seive(){memset(primes, true, sizeof(primes));primes[0] = primes[1] = false;for(int i = 2; i*i<=1000000;i += 1){
//if(primes[i]){for(int j = i*i; j <= 1000000;j += i) primes[j] = false;}}rep(i, 2, 1000001){if(primes[i]) prime.pb(i);}}
//int gcd(int a, int b){return b==0 ? a : gcd(b, a%b);}
//int power(int x, int y){ int res = 1;x = x % mod; if (x == 0) return 0;
//while (y > 0){ if(y & 1) res = (res*x) % mod; y = y>>1; x = (x*x) % mod;} return res;}

int32_t main(void){
	IOS;
	in1(n);
	int sum = 0;
	int arr[n];
	mi m;
	rep(i, 0, n)
	{
		cin>>arr[i];
		sum += arr[i];
		m[arr[i]] += 1;
	}
	in1(q);
	while(q--)
	{
		in2(b, c);
		int cnt = m[b];
		if(cnt == 0) cout<<sum<<endl;
		else
		{
			sum -= (cnt*b);
			sum += (cnt*c);
			m[b] = 0;
			m[c] += cnt;
			cout<<sum<<endl;
		}
	}
}

Measured memory_bytes: 7720
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>
#include <functional>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define loop(i, n) for(ll i = 0; i < n; i++)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long long int lli;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T LCM(T a, T b){
  return a*b/GCM(a,b);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
T modpow(T x, T p, ll mod){
    T res = 1;
    while(p > 0){
        if(p&1) res = (res*x)%mod;
        x = (x*x)%mod;
        p /= 2;
    }
    return res%mod;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();
const ll LL_INF = std::numeric_limits<ll>::max();

void solution();
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

void solution(){
  ll n, k;
  cin >> n>> k;
  n = n%k;
  cout << min(n, k-n)<< endl;
}     



Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H, W, D = map(int, readline().split())
    A = [list(map(int, readline().split())) for _ in range(H)]
    Q, *LR = map(int, read().split())

    vec = [0] * (H * W + 1)
    for i in range(H):
        for j in range(W):
            vec[A[i][j]] = (i + 1, j + 1)

    csum = [0] * (H * W + 1)
    for i in range(D + 1, H * W + 1):
        csum[i] = csum[i - D] + abs(vec[i][0] - vec[i - D][0]) + abs(vec[i][1] - vec[i - D][1])

    ans = [0] * Q
    for i, (l, r) in enumerate(zip(*[iter(LR)] * 2)):
        ans[i] = csum[r] - csum[l]

    print('\n'.join(map(str, ans)))
    return


if __name__ == '__main__':
    main()


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

int ans;
int n;
int dp[111111][13];//i番目は決まって,%13==jのとき
signed main(){
	string s;
	cin>>s;
	n=s.size();
	if(s[0]=='?'){
		rep(i,10)dp[1][i]=1;
	}
	else dp[1][s[0]-'0']=1;
	
	rep(i,n){
		rep(j,13){
			if(s[i]=='?'){
				rep(k,10){
					(dp[i+1][(j*10+k)%13]+=dp[i][j])%=MOD;
				}
			}
			else (dp[i+1][(j*10+(s[i]-'0'))%13]+=dp[i][j])%=MOD;
		}
	}
	cout<<dp[n][5]<<endl;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
int x,y;
int main()
{
	scanf("%d %d",&x,&y);
	if(x<0 && y>0)
	{
		printf("Zero");
		return 0;
	}
	if(x==0 || y==0)
	{
		printf("Zero");
		return 0;
	}
	if(x>0 && y>0)
	{
		printf("Positive");
		return 0;
	}
	if(x<0 && y<0)
	{
		if((y-x)%2==1)
		{
			printf("Positive");
			return 0;
		}
		if((y-x)%2==0)
		{
			printf("Negative");
			return 0;
		}
	}
}


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

using namespace std;

typedef long long int ll;

const int N = (int) 3e3 + 10;

int n;
double p[N];
double memo[N][N];

double dp(int at, int h, int t) {
    if(at == n) return h > t;
    double &ans = memo[at][h];
    if(ans != -1) return ans;
    ans = 0;
    ans += p[at] * dp(at + 1, h + 1, t);
    ans += (1 - p[at]) * dp(at + 1, h, t + 1);
    return ans;
}

void solve() {
    cin >> n;
    for(int i = 0; i < n; ++i) cin >> p[i];
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < N; ++j) {
            memo[i][j] = -1;
        }
    }
    cout << dp(0, 0, 0) << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    solve();
    return 0;
}

Measured memory_bytes: 71296
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

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

    vector<int> h(n);
    rep(i, n)
    {
        cin >> h[i];
    }

    vector<int> a(n);
    copy(h.begin(), h.end(), a.begin());
    a.push_back(0);
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());

    const int64_t M = 1'000'000'000L * n;
    vector<vector<vector<int64_t>>> dp(n + 1, vector<vector<int64_t>>(k + 1, vector<int64_t>(a.size())));
    irep(i, n) irep(j, k)
    {
        if (i == 0) {
            rep(l, a.size())
            {
                dp[i][j][l] = j == 0 && l == 0 ? 0 : M;
            }
        } else {
            rep(l, a.size())
            {
                dp[i][j][l] = M;
                if (a[l] == h[i - 1]) {
                    rep(l2, a.size())
                    {
                        dp[i][j][l] = min(dp[i][j][l], dp[i - 1][j][l2] + max(0L, (int64_t)a[l] - a[l2]));
                    }
                }
            }
            if (j > 0) {
                int64_t x = M;
                rep(l, a.size())
                {
                    x = min(x, dp[i - 1][j - 1][l] - a[l]);
                    dp[i][j][l] = min(dp[i][j][l], x + a[l]);
                }

                int64_t y = M;
                rrep(l, a.size())
                {
                    y = min(y, dp[i - 1][j - 1][l]);
                    dp[i][j][l] = min(dp[i][j][l], y);
                }
            }
        }
    }

    int64_t result = M;
    irep(j, k) rep(l, a.size())
    {
        result = min(result, dp[n][j][l]);
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 216832
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i+=2){
    cout<<s[i];
  }
      cout<<endl;
}

Measured memory_bytes: 512
function main(input) {
  const inputList = input.split('');
  const A = inputList[0];
  const B = inputList[1];
  const C = inputList[2];
  const D = inputList[3];
  var result = 'No';
  if (A === B && C === D && A !== C ||
     A === C && B === D && A !== B ||
     A === D && B === C && A !== B) {
    result = 'Yes';
  }
  console.log(result);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(){
    int n, odd = 0, even = 0;
    scanf("%d", &n);
    while (n--){
        int temp;
        scanf("%d", &temp);
        if (temp%2) odd++;
        else even++;
    }

    if (odd%2 == 0)// && ((odd/2+even)%2 == 0 || odd/2+even == 1))
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <set>
#include <cmath>
using namespace std;
double p(double x, int A){
    if (x < 0)
        x = x * -1;
    double t = A - x;
    if (t < 0)
        t = t * -1;
    return t;
}
int main() {
    int N, T, A, temp;
    cin >> N;
    cin >> T >> A;
    double m = 1000000;
    int ind = 0;
    double temp1 = 0;
    for(int i = 0; i < N; i ++){
        cin >> temp;
        temp1 = T - temp*0.006;
        temp1 = A - temp1;
        temp1 = abs(temp1);
        if (temp1 < m) {
            m = temp1;
            ind = i + 1;
        }
    }
    cout << ind;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

constexpr ll INF = 1e16;
constexpr ll INM = 114514;
constexpr ll MOD = 1e9 + 7;
constexpr ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

ll dp[5002][5002];

int main() {
	IOS();
	ll n, m;
	string s;
	cin >> n >> s;
	m = s.size();
	Fill(dp, 0);
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			if (j) dp[i][j] += 2 * dp[i - 1][j - 1];
			if (j == 0) dp[i][j] += dp[i - 1][j];
			dp[i][j] += dp[i - 1][j + 1];
			dp[i][j] %= MOD;
		}
	}
	ll ans  = dp[n][m];
	ll inv2 = powm(2, MOD - 2, MOD);
	for (int i = 0; i < m; i++) {
		ans *= inv2;
		ans %= MOD;
	}
	dump(ans);
	return 0;
}

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

using namespace std;

int a[100005];

int main(){
    int n,q,tmp;
    cin >> n;
    int count = 0;
    for(int i = 0;i<n;i++){
        scanf("%d",&a[i]);
    }
    cin >> q;
    for(int j = 0;j<q;j++){
        scanf("%d",&tmp);
        if(binary_search(a,a+n,tmp)){
            count++;
        }
    }

cout << count << endl;
    return 0;
}


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

int main()
{
  int a, b;
  cin >> a >> b;
  if (a + b == 15)
    cout << '+' << endl;
  else if (a * b == 15)
    cout << '*' << endl;
  else
    cout << 'x' << endl;
}

Measured memory_bytes: 3676
#include <stdio.h>
#include <math.h>

double yogen(int, int, double);
double height(int, double);

int main() {
    int a, b, kaku;
    double rad, c, s, l = 0, h;

    scanf("%d%d%d", &a, &b, &kaku);

    rad = M_PI / 180 * kaku;

    c = yogen(a, b, rad);
    h = height(b, rad);

    l = (double)a + b + c;
    s = a * h / 2;

    printf("%f\n", s);
    printf("%f\n", l);
    printf("%f\n", h);

    return 0;
}


double yogen(int a, int b, double rad) {
    double c;

    c = a * a + b * b - ( 2 * a * b * cos(rad) );

    return sqrt(c);
}

double height(int b, double rad) {
    double h;

    h = b * sin(rad);

    return h;
}



Measured memory_bytes: 2120
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		char[] s = new char[4];
		s = in.next().toCharArray();

		for ( int i = 0; i + 1 < 4; i++ ) {
			if ( s[i] == s[i + 1] ) {
				System.out.println("Bad");
				return;
			}
		}
		
		System.out.println("Good");
		in.close();
	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

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

  
  return 0;
}


Measured memory_bytes: 3776
import random
import copy
import time
def evaluateSatisfaction(d, c, s, ans):
    score = 0
    last = [-1 for i in range(26)]
        
    for i in range(d):
        
        score += s[i][ans[i]]
        last[ans[i]] = i
        for j in range(26):
            if j != ans[i] or True:
                score -= c[j]*(i - last[j])
    return score
    
def valuationFunction(d,c,s,contestType,day,last):
    las = copy.copy(last)
    las[contestType] = day
    gain = s[day][contestType]
    lost = 0
    for i in range(1,10):
        for j in range(26):
            lost += c[j]*(d + i - las[j])
    return gain - lost

def Input():
    d = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for i in range(d)]
    #s[3][25] =   contest(25+1) of day(3+1)
    return d, c, s

def evolution(d, c, s, ans):
    score_before = evaluateSatisfaction(d, c, s, ans)
    ans_after = copy.copy(ans)
    x = random.randint(0,(d-1)-10)
    idx1 = x
    idx2 = x+random.randint(1,5)
    
    tmp = ans_after[idx1]
    ans_after[idx1] = ans_after[idx2]
    ans_after[idx2] = tmp

    score_after = evaluateSatisfaction(d,c,s,ans_after)

    if score_after > score_before:
        return ans_after
    else:
        return ans

if __name__ == "__main__":
    
    d, c, s = Input()
    
    #print("val =", evaluateSatisfaction(d, c, s, [1, 17, 13, 14, 13]))

    #calc start
    t1 = time.time()
    ans = [0 for i in range(d)]
    last = [-1 for i in range(26)]
    for i in range(d):
        evalValueList = [0 for j in range(26)]
        for j in range(26):
            evalValueList[j] = valuationFunction(d, c, s, j,i,last)

        max_idx = 0
        max = evalValueList[0]

        for j in range(26):
            if (max < evalValueList[j]):
                max_idx = j
                max = evalValueList[j]
        
        ans[i] = max_idx
        last[ans[i]] = i


    
    #ans = [1, 2, 3, 4, 5]
    t2 = time.time()
    while(float(t2-t1) < 1.8):
        ans = evolution(d, c, s, ans)
        #print("ans = ",evaluateSatisfaction(d,c,s,ans))
        t2 = time.time()
    for x in ans:
        print(x + 1)
    #print(evaluateSatisfaction(d,c,s,ans))

Measured memory_bytes: 10020
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
#include <cmath>
using namespace std;

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

    int tmp;
    tmp = max(a + b, a - b);
    cout << max(tmp, a * b) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1003;
int n, m, dis[N], par[N];
vector<int> adj[N], ans;
int main(int argc, char const *argv[])
{
	cin >> n >> m;
	for (int i = 0; i < m; ++i)
	{
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
	}
	for (int s = 1; s <= n; ++s)
	{
		queue<int> q;
		memset(dis, -1, sizeof(dis));
		memset(par, -1, sizeof(par));
		q.push(s);
		dis[s] = 0;
		while (!q.empty())
		{
			int u = q.front();
			q.pop();
			for (int v: adj[u])
			{
				if (dis[v] == -1)
				{
					par[v] = u;
					dis[v] = 1 + dis[u];
					q.push(v);
				}
				else if (v == s)
				{
					int cur = u;
					vector<int> temp;
					while (cur != -1)
					{
						temp.push_back(cur);
						cur = par[cur];
					}
					if (temp.size() < ans.size() || ans.empty())
					{
						ans.clear();
						for (int node: temp)
							ans.push_back(node);
					}
				}
			}
		}
	}
	if (ans.empty())
		cout << -1 << '\n';
	else
	{
		cout << ans.size() << '\n';
		for (int nodes: ans)
			cout << nodes << '\n';
	}
	return 0;
}

Measured memory_bytes: 3640
import sys
import resource

sys.setrecursionlimit(200000)

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

dp = []
for i in range(n):
    dp.append(-1)
 
def flog(m):
    if dp[m] != -1:
        return dp[m]
    if m == 0:
        dp[m] = 0
        return 0
    if m == 1:
        dp[m] = abs(h[0]-h[1])
        return dp[m]
    else:
        dp[m] = min(flog(m-1) + abs(h[m-1] - h[m]),flog(m-2) + abs(h[m-2] - h[m]))
        return dp[m]
  
print(flog(n-1))

Measured memory_bytes: 95540
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const ll INF = ll(1e18) + 3;
int main(){
    int n; ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    ll l =  - INF; ll r = INF;
    while(l+1<r) {
        ll x = (l+r)/2;
        bool ok = [&]{
            ll y = 0;
            rep(i,n) {
                if(a[i]>=0) {
                    int l = -1; int r = n; //index
                    while(l+1<r) {
                        int c = (r+l)/2;
                        if(a[i]*a[c]<x) l = c;
                        else r = c;
                    }
                    y+=r;
                }
                else {
                    int l = -1; int r = n; //index
                    while(l+1<r){
                        int c = (l+r)/2;
                        if(a[i]*a[c]<x) r = c;
                        else l = c;
                    }
                    y+=n-r;
                }
                if(a[i]*a[i]<x) y--;
            }
            y/=2;
            return y < k;
        }();
        if(ok) l = x;
        else r = x;
    }
    cout << l << endl;
    return 0;
}


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

int main(){
    int a,b;cin>>a>>b;
    int count=0;
    for(int i=a;i<=b;i++){
        string s=to_string(i);
        bool isP=true;
        for(int j=0;j<s.size();j++){
            if(s[j]!=s[s.size()-1-j]){
                isP=false;
                break;
            }
        }
        if(isP) count++;
    }
    cout<<count<<endl;
}

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

#define fti(i, x, y) for(int i = (x), _y = (y); i <= _y; ++ i)
#define ftd(i, x, y) for(int i = (x), _y = (y); i >= _y; -- i)
#define ll long long

using namespace std;

int a, b;

void inp()
{
    scanf("%d %d", &a, &b);
}

void proc()
{
    printf("%d\n", max(0, a - 2 * b));
}

int main()
{
    inp();
    proc();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> vv;

int dig(int a){
  if(a<10) return a;
  return a%10 + dig(a/10);
}

int main(){
  int n;
  cin >> n;
  if(n%dig(n) == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		Double n1, n2;
		
		n = sc.nextInt();
		while (n != -1) {
			n1 = n * 1.0 / 2;
			n2 = n1 - (n1 * n1 * n1 - n) / (3 * n1 * n1);
			while (0.000001 * n <= Math.abs(n2 * n2 * n2 - n)) {
				n1 = n2;
				n2 = n1 - (n1 * n1 * n1 - n) / (3 * n1 * n1);
			}
			System.out.printf("%.6f\n", n2);
			n = sc.nextInt();
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define int long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
const int MOD=1e9+7;
const int INF=1e15;

signed main(){
    int A,B,C;cin>>A>>B>>C;
    cout<<max(A,max(B,C))-min(A,min(B,C))<<endl;
}

Measured memory_bytes: 256
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

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

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

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

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

n,a,b = lr()
s = sr()
ret = a+b
reto = b
for c in s:
    if c == 'a' and ret > 0:
        print('Yes')
        ret-=1
    elif c == 'b' and ret > 0 and reto > 0:
        print('Yes')
        ret-=1
        reto-=1
    else:
        print('No')

Measured memory_bytes: 80880
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int X;
    cin >> X;
    if (X == 3 || X == 5 || X == 7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;

signed main(){
  int a,b,x;
  cin>>a>>b>>x;
  if(a>x||a+b<x){
    cout<<"NO"<<endl;
  }else{
    cout<<"YES"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
def z_alg(S):
    N = len(S)
    A = [0]*N
    i = 1; j = 0
    A[0] = l = len(S)
    while i < l:
        while i+j < l and S[j] == S[i+j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l-i > k < j - A[k]:
            A[i+k] = A[k]
            k += 1
        i += k; j -= k
    return A

n = int(input())
s = input()
ans = 0
for i in range(n):
    data = z_alg(s[i:])
    for j,x in enumerate(data[1:]):
        ans = max(ans,min(x,j+1))

print(ans)


Measured memory_bytes: 52316
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <utility>
#include <map>
#include <algorithm>
typedef long long ll;
using namespace std;
#define MX 1000000000

long long GCD(long long a, long long b)
{
    if (b > a)
        swap(a, b);
    if (a % b == 0)
        return b;
    return GCD(b, a % b);
}
long long LCM(long long a, long long b)
{
    return a * b / GCD(a, b);
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b;
    cin >> a >> b;
    cout << a * b << "\n";
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+9;
int n,k,d[N],e[N],p,ans;
int mmax(int x,int y){
	if(x<y) return y;
	else return x;
}
signed main(){
	ios::sync_with_stdio(0);
	std::cin>>k>>n;
	for(register int i=1;i<=n;++i) std::cin>>d[i];
	for(register int i=2;i<=n;++i) e[i]=d[i]-d[i-1],p=mmax(p,e[i]),ans+=e[i];
	e[1]=d[1]+k-d[n]; p=mmax(p,e[1]),ans+=e[1];
	std::cout<<ans-p; 
	return 0;
}

Measured memory_bytes: 5888
import itertools as itt

N = input()

def check(snum):
    three = snum.count("3")
    five = snum.count("5")
    seven = snum.count("7")
    if (three == 0 or five == 0 or seven == 0) or (int(snum) > int(N)): return False
    else: return True

C = ["3", "5", "7"] #choice
digit = len(N)
cnt = 0
for d in range(3, digit+1): #3桁の入力から考える
    L = list(itt.product(C, repeat=d))
    for l in L:
        gen = "".join(l)
        if check(gen):
            #print(gen)
            cnt += 1

print(cnt)

Measured memory_bytes: 6756
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

typedef long long ll;

int main(){
    int n;
    int sum = 0;
    vector<int> a;
    cin >> n;
    a.resize(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i=i+2){
        if(a[i]%2 == 1)sum++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3600
while True:
    H, W = [int(i) for i in input().split()]
    if H == W == 0:
        break

    for h in range(H):
        for w in range(W):
            if (h + w) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')

        print()
    print()

Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int x,y,z;
	cin >> x >> y >> z;

	cout << z <<endl;
	cout <<  x <<endl;
	cout << y << endl;

  return 0;
}


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

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int N, M, K;
    cin >> N >> M >> K;
    bool ans = false;
    REP (x, 0, N + 1) REP (y, 0, M + 1) {
        int sum = x * M + y * N - 2 * x * y;
        if (sum == K) ans = true;
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<cmath>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;



int main(){
  ll X,Y,ans=0;
  cin>>X>>Y;
  while(X<=Y){
    X*=2;
    ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256