akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include<string.h>

int main(void)
{
    int check;
    int a,b,c,d;
    int count = 0;
    
    while(scanf("%d",&check) == 1){
        for(a = 0; a < 10; a++){
            for(b = 0; b < 10; b++){
                for(c = 0; c < 10; c++){
                    for(d = 0; d < 10; d++){
                        if(a + b + c + d == check){
                            count++;
                        }
                    }    
                }
            }
        }
        printf("%d\n",count);
        count = 0;
    }
    
    
	return 0;
}



Measured memory_bytes: 1988
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


int main() {
    ll a, b, x;
    
    cin >> a >> b >> x;
    
    cout << b / x - ((a % x == 0)? a / x - 1 : a / x) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
     int a,b,c;
     cin>>a>>b>>c;
     cout<<min(a*b,c)<<endl;

    return 0;
}


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

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		long k = sc.nextLong();

		int a[] = new int[n];
		int time[] = new int[n];

		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt() - 1;
		}

		Arrays.fill(time, -1);
		time[0] = 0;
		int currentTime = 0;
		int loopBegin = -1;
		int loopLength = -1;
		int next = a[0];
		while(true){
			currentTime++;
			if(time[next] == -1){
				time[next] = currentTime;
				next = a[next];
			}
			else {
				loopBegin = next;
				loopLength = currentTime - time[next];
				break;
			}
		}

//		for(int i = 0; i < n; i++){
//			System.out.println(time[i]);
//		}
//		System.out.println("loop begin "+ loopBegin + " loop length "+loopLength);

		int loopBeginTime = time[loopBegin];

		if(k <= loopBeginTime){
			for(int i = 0; i < n; i++){
				if(time[i] == k){
					System.out.println(i + 1);
					return;
				}
			}
		}
		else {
			k -= loopBeginTime;
			k %= loopLength;
//			System.out.println("k = "+k);

			if(k == 0){
				System.out.println(loopBegin + 1);
			}
			else {
				next = a[loopBegin];
				for(int i = 0; i < k - 1; i++){
					next = a[next];
				}

				System.out.println(next + 1);
			}
		}

	}

}


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

using namespace std;

int main(){
    int N, tmp;
    int max_v=0;
    int ans=0;

    cin >> N;
    for(int i = 0 ; i < N ; i++){
        cin >> tmp;
        if(max_v < tmp){
            max_v = tmp;
        }
        ans += tmp;
    }
    ans -= max_v / 2;
    
    cout << ans << 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 a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(c>=a&&c<=b) System.out.println("Yes");
		else System.out.println("No");
	}

}

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

int main() {
  int N;
  cin >> N;
  vector<int> card(N);
  for(int i=0; i<N; i++)
    cin >> card.at(i);
  sort(card.begin(), card.end());
  int A=0, B=0;
  bool f=true;
  for(int i=card.size()-1; i>=0;i--){
   	if(f)
      A+=card.at(i);
    else
      B+=card.at(i);
    f = not f;
  }
  cout << A-B << endl;
  
  return 0;
    
}

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

int main(){
	int N,M;
	cin >> N >> M;
	int A = 0;
	rep(i,M){ int t; cin >> t; A+=t; }
	if(N-A<0)cout << -1 << endl;
	else cout << N-A << endl;
}


Measured memory_bytes: 3636
#include<stdlib.h>
#include<stdio.h>
int main()
{
	long long int m, n, p;
	scanf("%lld%lld", &m, &n);
	if (m%n==0)printf("-1");
	else
	{
		for (p = m;p%n == 0;p += m);
		printf("%lld", p);
	}
	return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		long X = sc.nextLong();
		long Y = sc.nextLong();
		int count = 0;
		while (X <= Y) {
			count++;
			X *= 2;
		}
		System.out.println(count);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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


Measured memory_bytes: 21332
fn main() {
    let v = read_vec::<u32>();
    let n = v[0];
    let m = v[1];
    yn(n == m);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

using namespace std;

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

using ll = long long;

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
    cout << '[';
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len-1) s << ", ";
	}
    cout << ']';
	return s;
}


ll x, y, z, K;
vector<ll> a(1000);
vector<ll> b(1000);
vector<ll> c(1000);


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

	cin >> x >> y >> z >> K;
	rep(i, x) cin >> a[i];
	rep(i, y) cin >> b[i];
	rep(i, z) cin >> c[i];

	a.shrink_to_fit();
	b.shrink_to_fit();
	c.shrink_to_fit();

	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	sort(c.rbegin(), c.rend());

	vector<ll> ab(x*y);
	int cnt = 0;
	rep(i, x){
	    rep(j, y){
	        ab[cnt] = a[i]+b[j];
			++cnt;
		}
	}

	sort(ab.rbegin(), ab.rend());
	ab.resize(K);

	vector<ll> s(K*z);
	cnt = 0;
	rep(i, K){
	    rep(j, z){
			s[cnt] = ab[i]+c[j];
			++cnt;
	    }
	}
	sort(s.rbegin(), s.rend());

	rep(i, K){
	    ppp(s[i]);
	}

    return 0;
}


Measured memory_bytes: 31616
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 62;

int main() {
  //
  ll n;
  cin >> n;
  vl a(n);
  ll toremove = 0;
  unordered_set<ll> st;
  rep(i, n) {
    ll a;
    cin >> a;
    if (st.find(a) == st.end()) {
      st.insert(a);
    } else {
      ++toremove;
    }
  }
  if (toremove & 1) {
    cout << n - toremove - 1 << endl;
  } else {
    cout << n - toremove << endl;
  }
  return 0;
}


Measured memory_bytes: 5024
#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;

int main()
{
	int a, b, c, d;
	int start = 0, stop = 0;
	cin >> a >> b >> c >> d;
	if (a < c) {
		start = c;
	}
	else {
		start = a;
	}
	if(b<d){
		stop = b;
	}
	else {
		stop = d;
	}
	if (start < stop) {
		cout << (stop - start);
	}
	else {
		cout << 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long long n;
  cin >> n;
  long long b = 1;
  while(2 * b <= n) b *= 2;
   cout<<2*b-1<<endl;
  }


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

int main() {
  // ここにプログラムを追記
  int a;
  cin >> a;
  
  if (a == 111){
  cout << 3 << endl;
  }
  else{
    cout << a % 3 << endl;
  }
    
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
using namespace std;
int main()
{
	int W,H,n,x,y,a,s=0,r[111][111]={0};cin>>W>>H>>n;
	for(int i=0;i<n;i++)
	{
		cin>>x>>y>>a;
		if(a==1)
		{
			for(x--;x>=0;x--)for(int h=0;h<H;h++)r[x][h]=1;
		}
		else if(a==2)
		{
			for(;x<W;x++)for(int h=0;h<H;h++)r[x][h]=1;
		}
		else if(a==3)
		{
			for(y--;y>=0;y--)for(int w=0;w<W;w++)r[w][y]=1;
		}
		else
		{
			for(;y<H;y++)for(int w=0;w<W;w++)r[w][y]=1;
		}
	}
	for(int i=0;i<W;i++)for(int j=0;j<H;j++)s+=r[i][j];
	cout<<W*H-s<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Collections;
using static System.Math;
using static System.Console;

class E { static void Main() => new J(); }
class J
{
	const int Mod = 1000000007;
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G();
		WriteLine(Min(Z(I[0], I[1]), Z(I[1], I[0])));
	}
	long Z(long X, long Y)
	{
		var ans = X * Y;
		for (var x = 1; x < X; x++)
		{
			var f = F(X - x, Y);
			var k = x * Y;
			ans = Min(ans, Max(f.Item2, k) - Min(f.Item1, k));
		}
		return ans;
	}
	Tuple<long, long> F(long X, long Y)
	{
		var mx = X / 2;
		var my = Y / 2;
		var a = new Tuple<long, long>(mx * Y, (X - mx) * Y);
		var b = new Tuple<long, long>(X * my, (Y - my) * X);
		var da = a.Item2 - a.Item1;
		var db = b.Item2 - b.Item1;
		if (da <= db) return a;
		else return b;
	}
	long GCD(long a, long b)
	{
		var n = (ulong)Abs(a); var m = (ulong)Abs(b);
		if (n == 0) return (long)m; if (m == 0) return (long)n;
		int zm = 0, zn = 0;
		while ((n & 1) == 0) { n >>= 1; zn++; }
		while ((m & 1) == 0) { m >>= 1; zm++; }
		while (m != n)
		{
			if (m > n) { m -= n; while ((m & 1) == 0) m >>= 1; }
			else { n -= m; while ((n & 1) == 0) n >>= 1; }
		}
		return (long)n << Min(zm, zn);
	}
}

Measured memory_bytes: 17480
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    int n,a;
    cin>>n>>a;
    if(n%500<=a){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
/**
 *  author: MahfuzAhmed
 *  created: 27.05.2019
**/

#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
#define mp make_pair
#define forn(i, s, n) for(int i = s; i < int(n); i++)

typedef long long ll;
//~ const double pi = 2*acos(0.0);
//~ const long long mod = 1e9+7;
//~ const int MAX_N = 1e6+5;

int main(int argc, char* argv[]){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
       
    #ifdef _DEBUG
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    
    int a, p; cin >> a >> p;
    
    int x = ((a*3)+p) / 2;
    
    cout << x << "\n";
    
    
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = int(input())

while True:
	if N < 0:
		break
	elif N%4 == 0:
		print('Yes')
		sys.exit()
	N -= 7

print('No')

Measured memory_bytes: 4336
A,B,C,D = map(int,input().split())

taka = 0
aoki = 0

while True:
    if A <= 0:break
    A -= D
    taka += 1

while True:
    if C <= 0:break
    C -= B
    aoki += 1

if taka >= aoki:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9176
#include<iostream>
using namespace std;
int main(void){
  int a[5],f1,f2,f3;
  for(;;){
    cin >> a[0];
    if(!a[0]) break;
    cin >> a[1] >> a[2] >> a[3] >> a[4];
    f1=0; f2=0; f3=0;
    for(int i=0;i<5;i++){
      if(a[i]==1) f1=1;
      else if(a[i]==2) f2=1;
      else if(a[i]==3) f3=1;
    }
    if(f1 && f2 && f3 || f1 && !f2 && !f3 || !f1 && f2 && !f3 || !f1 && !f2 && f3){
      for(int i=0;i<5;i++) cout << "3" << endl;
    }
    else if(f1 && f2){
      for(int i=0;i<5;i++){
	if(a[i]==1) cout << "1" << endl;
	else cout << "2" << endl;
      }
    }
    else if(f2 && f3){
      for(int i=0;i<5;i++){
	if(a[i]==2) cout << "1" << endl;
	else cout << "2" << endl;
      }
    }
    else if(f1 && f3){
      for(int i=0;i<5;i++){
	if(a[i]==3) cout << "1" << endl;
	else cout << "2" << endl;
      }
    }
  }
}


Measured memory_bytes: 1156
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
typedef long long ll;
#include<cstdio>
#include<iomanip>

int main(int argc, char *argv[])
{
	int n;

	cin >> n;
	vector<double> x(n);
	vector<double> y(n);
	for (int i=0; i<n; i++)
	{
		cin >> x[i]>>y[i];
	}
	double d=0;
	for (int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			d+=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
		}
	}


	cout <<std::setprecision(10)<< (d*2/n) << endl;
	return 0;
}



Measured memory_bytes: 256
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b,c,d=parseMap(split(readline()))
    if abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d)
        println("Yes")
    else
        println("No")
    end
end
main()

Measured memory_bytes: 110204
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author emli
 */


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

typedef long long ll;
class AKyuInAtCoder {
public:
    void solve(std::istream& cin, std::ostream& cout) {
		ios::sync_with_stdio(false);
        cin.tie(nullptr);

        int x;

        cin >> x;
        if (x >= 1800){
            cout << 1 << endl;
        }else if (x >= 1600){
            cout << 2 << endl;
        }else if(x >= 1400){
            cout << 3 << endl;
        }else if (x >= 1200){
            cout << 4 << endl;
        }else if (x >= 1000){
            cout << 5 << endl;
        }else if (x >= 800){
            cout << 6 << endl;
        }else if (x >= 600){
            cout << 7 << endl;
        }else if (x >= 400){
            cout << 8 << endl;
        }
	}
};


int main() {
	AKyuInAtCoder solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3648
x,y = map(int,input().split())
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]
ls = [A,B,C]
ans = 'No'
for i in range(3):
    if x in ls[i] and y in ls[i]:
        ans = 'Yes'
print(ans)

Measured memory_bytes: 9184
# ABC 175 C
# https://atcoder.jp/contests/abc175/tasks/abc175_c

x, k, d = gets.chomp.split(/ /).map(&:to_i)
xp = x.abs

if xp >= d * k
  puts xp - d * k
  exit
end

if k % 2 == 0
  # 0, 2d, 4d, ..., kd 動く
  # i: xp - 2 * i * d > 0 となる最小の i
  # xp > 2 * i * d
  # i < xp / (2 * d)
  i = xp / (2 * d)
  puts [xp - 2 * i * d, xp - 2 * (i + 1)*d].map(&:abs).min
else
  # d, 3d, 5d, ..., kd 動く
  # i: xp - (2 * i + 1) * d > 0 となる最小の i
  # xp > (2 * i + 1) * d
  # xp - d > 2 * i * d
  # i < (xp - d) / (2 * d)
  i = (xp - d) / (2 * d)
  puts [xp - (2 * i + 1)*d, xp - (2 * i + 3)*d].map(&:abs).min
end


Measured memory_bytes: 14420
#include <bits/stdc++.h>
#define maxn (int)(2e5)
#define i64 long long
#define pii pair<i64,i64>
#define all(x) x.begin(),x.end()
#define LB(x,v) lower_bound(all(x), v) - x.begin()
#define fread() freopen("in.txt", "r", stdin);
using namespace std;
int a[maxn+2] , sa[maxn+2], freq[maxn+2];
void init(){
    for(int i=0;i<=maxn;i++) freq[i] = 0;
}

void solve(int n){
    sort(sa, sa+n);
    for(int i=0;i<n;i++){
        int val = a[i];
        if(val < sa[n-1]) printf("%d\n", sa[n-1]);
        else {
            printf("%d\n", freq[val] > 1 ? val : sa[n-2]);
        }
    }
}
int main() {
    /*BEFORE SUBMIT, CHECK
    sample i/o format
    statements for debugging are removed/comment out
    global values / stl containers are initialized/cleared for each test (if needed)
    all array size are sufficient
    loop variable or output value doesn't cross min/max limit of input
    // */
    
    int n;
    string s;
    while(scanf("%d",&n)==1){
        int maxVal = 0;
        for(int i=0;i<n;i++) {
            scanf("%d",&a[i]);
            sa[i] = a[i];
        }
        solve(n);
    }    
    return 0;
}

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

int cnt;
int m, n;
char map[101][101];
bool vis[101][101];

struct Node {
	int x, y;
	Node () {}
	Node (int X,int Y) {
		x = X; y = Y;
	}
};

int X[] = {1, 0, -1, 0};
int Y[] = {0, -1, 0, 1};

void dfs(Node now) {
	Node nex;
	for (int i=0; i<4; i++) {
		nex = Node(now.x + X[i], now.y + Y[i]);
		if (nex.x < m && nex.x >= 0 && nex.y < n && nex.y >= 0) {
			if (vis[nex.x][nex.y] == false && map[nex.x][nex.y] == map[now.x][now.y]) {
				vis[nex.x][nex.y] = true;
				dfs(nex);
			}
		}
	}
}
 	
int main () {
	while (cin >> m >> n) {
		if (m == 0 && n == 0) break;
		cnt = 0;
		memset(vis,false,sizeof(vis));
		for (int i=0; i<m; i++) {
			cin >> map[i];
		}
		for (int i=0; i<m; i++) {
			for (int j=0; j<n; j++) {
				if (vis[i][j] == false) {
					vis[i][j] = true;
					dfs(Node (i,j));
					cnt++;
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 1812
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int main(){
  int flag=1,i,j,N,swap,minj;

  //scanf N
  scanf("%d",&N);

  //making array
  char A_in_sig[N], A_out_b_sig[N], A_out_s_sig[N];
  int A_in_val[N], A_out_b_val[N], A_out_s_val[N];
  
  //fill A_in[]
  for(i=0;i<N;i++){ //?¢??????°???N2???????????????????????\??????????????°???N2-1(????????????????????????????????§???????????????)
    scanf(" %c%d",&A_in_sig[i],&A_in_val[i]); //getc???????????°"????????????????????????"????????¨
  }
  
  //copying A_in_val[] to each output Arrays
  for(i=0;i<N;i++){
//    printf("%d: %c\n",i,A_in_val[i]);
    A_out_b_val[i] = A_in_val[i];
    A_out_b_sig[i] = A_in_sig[i];
    A_out_s_val[i] = A_in_val[i];
    A_out_s_sig[i] = A_in_sig[i];
  }

  

  //BUBBLE SORT
  i=0;
  while(flag){
    flag = 0;
    for(j=N-1;j>i;j--){ //???????????????????????°??????????????????????????????
      if(A_out_b_val[j]<A_out_b_val[j-1]){
        //int
        swap = A_out_b_val[j];
        A_out_b_val[j] = A_out_b_val[j-1];
        A_out_b_val[j-1] = swap;
        //char
        swap = A_out_b_sig[j];
        A_out_b_sig[j] = A_out_b_sig[j-1];
        A_out_b_sig[j-1] = swap;
        flag = 1; //to be continue
      }
    }
    i++;
  }

  //print Array
  for(i=0;i<N;i++){
    printf("%c%d", A_out_b_sig[i],A_out_b_val[i]);
    if(i<N-1){ //?????????????????????????????????
      printf(" ");
    }
  }
  printf("\n");
  //print Stablily 
  printf("Stable\n"); //always 'Stable'
  
  
  //SELECTION SORT
  for(i=0;i<N-1;i++){
    minj = i; //first
    for(j=i;j<N;j++){
      if(A_out_s_val[j]<A_out_s_val[minj]){ //update minj
        minj = j;
      }
    }
    //changing
    if(minj != i) {
      //int
      swap = A_out_s_val[i];
      A_out_s_val[i] = A_out_s_val[minj];
      A_out_s_val[minj] = swap;
      //char
      swap = A_out_s_sig[i];
      A_out_s_sig[i] = A_out_s_sig[minj];
      A_out_s_sig[minj] = swap;
    }
  }

  //print Array
  for(i=0;i<N;i++){
    printf("%c%d", A_out_s_sig[i],A_out_s_val[i]);
    if(i<N-1){ //?????????????????????????????????
      printf(" ");
    }
  }
  printf("\n");
  
  //print Stablity
  if(strcmp(A_out_b_sig, A_out_s_sig) == 0){
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }

  return 0;
}

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

int main() {
  int n; cin>>n;
  int numRed=0;
  vector<char> stones(n);
  for(int i=0; i<n; i++) {
    cin>>stones[i];
    if(stones[i]=='R') numRed++;
  }
  //for(auto v:stones) cout << v << endl;
  // 赤の個数を求めておく
  int count=0;
  for(int i=0; i<numRed; i++) {
    if(stones[i]=='W') count++;
  }
  cout << count << endl;
}


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

using namespace std ;

const long long mod = 1e9 + 7ll ;
 
long long modpower(long long a , long long b)
{
    if(b == 0)
        return 1ll ;
    long long x = modpower(a , b / 2ll) ;
    x = (x * x) % mod ;
    if(b & 1)
        return (x * a) % mod ;
    return (x % mod) ;
}
 
struct combination
{
    vector<long long>fact , inv ;
    combination(int sz) : fact(sz + 1) , inv(sz + 1)
    {
        fact[0] = 1ll ;
        inv[0] = 1ll ;
        for(long long i = 1 ; i <= sz ; ++i)
            fact[i] = (fact[i-1] * i) % mod ;
        inv[sz] = modpower(fact[sz] , mod - 2ll) ;
		for(long long i = sz-1; i >= 1; --i)
		    inv[i] = (inv[i+1] * (i+1)) % mod;
    }
    long long choose(int n , int k) const
    {
        if(k < 0 || n < k)
            return 0 ;
        return ((((fact[n] * inv[k]) % mod) * inv[n - k]) % mod) ;
    }
};

const int MAX = 2e6 + 10 ;

combination comb(MAX) ;
int n , m ;
string s ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	cin>>s ;
	m = s.size() ;
	n += m ;
	long long ans = 0ll ;
	for(int i = m ; i <= n ; ++i)
	{
		long long x = modpower(26 , n-i) ;
		long long a = comb.choose(i-1 , m-1) ;
		long long y = (a * modpower(25 , i - m)) % mod ;
		x = (x * y) % mod ;
		ans = (ans + x) % mod ;
	}
	return cout<<ans<<"\n" , 0 ;
}		

Measured memory_bytes: 35524
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  if(A + B >= C)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys

sys.setrecursionlimit(10**7)

# Override `input` function because `stdin.readline()` is 10x faster than built-in `input()`
input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def main():
    S, = read_h(typ=str)
    ints = [int(i) for i in S]

    for i in range(2**3):
        ops = ['+'] * 3
        for j in range(3):
            if ((i >> j) & 1):
                ops[j] = '-'

        #  print(ints)
        #  print(ops)

        s = ints[0]
        for op, i in zip(ops, ints[1:]):
            if op == '+':
                s += i
            else:
                s -= i

        if s == 7:
            ans = ''.join([str(i) + op for i, op in zip(ints, ops + [''])] + ['=7'])
            print(ans)
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
*> AtCoder My Practice
       *> author: Leonardone @ NEETSDKASU
       *>
       IDENTIFICATION DIVISION.
       PROGRAM-ID. Answer.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       REPOSITORY.
              FUNCTION ALL INTRINSIC.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
              01 Input-Values.
                     05 n      BINARY-SHORT.
                     05 arare  PIC X(200).
              01 Calc-Values.
                     05 ans    PIC X(5).
       PROCEDURE DIVISION.
       AnswerMain SECTION.
       000-Start.
       
              ACCEPT n.
              ACCEPT arare.
              
              MOVE "Three" TO ans.
              MULTIPLY 2 BY n.
              SUBTRACT 1 FROM n.
       001-LoopHead.
              IF arare(n:1) = "Y" THEN
                     MOVE "Four" TO ans
                     GO TO 002-Output
              END-IF.
              SUBTRACT 1 FROM n.
              IF n < 0 THEN
                     GO TO 002-Output
              END-IF.
              GO TO 001-LoopHead.
       002-Output.
              DISPLAY TRIM(ans).
       END PROGRAM Answer.


Measured memory_bytes: 512
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long L = sc.nextLong();
    long R = sc.nextLong();
    long mL = L%2019;
    long mR = R%2019;
    long out = 3000;
    if(R-L >= 2018 || mL > mR){
      System.out.println(0);
    } else {
      for (long i=mL; i<=mR-1; i++) {
        for (long j=i+1; j<=mR; j++) {
          if(out > (i*j)%2019){
            out = (i*j)%2019;
          }
        }
      }
      System.out.println(out);
    }
  }
}



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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)
ll a[100100];
ll su[100100];

int main(void)
{
    ll n, k, q;
    cin >> n >> k >> q;
    REP(i, q) { cin >> a[i]; su[i] = 0;}
    REP(i, q) su[a[i]-1] ++;
    REP(i, n) {
        if(k-q+su[i] <= 0 ) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }



}


Measured memory_bytes: 2176
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    b = LI()
    ans = []
    for j in range(n):
        for i in range(len(b))[::-1]:
            if b[i] == i+1:
                x = b.pop(i)
                ans.append(x)
                break
    if b:
        print(-1)
    else:
        print(*ans[::-1],sep = "\n")
    return

#B
def B():
    n,a,b,c,d = LI()
    s = S()
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    k = b
    while b < d:
        if s[b+1] == ".":
            b += 1
        else:
            if s[b+2] == "#":
                print("No")
                return
            b += 2
    b = k
    if c < d:
        while a < c:
            if s[a+1] == ".":
                a += 1
            else:
                if s[a+2] == "#":
                    print("No")
                    return
                a += 2
        print("Yes")
    else:
        for i in range(b-1,d):
            if s[i:i+3].count(".") == 3:
                print("Yes")
                return
        print("No")
    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    B()


Measured memory_bytes: 62448
( N, L ) = gets.split(' ').map(&:to_i)
sum = 0
if L < 0
  if (N - 1) / 2 < L.abs
    (N-1).times do |i| 
      sum += L + i
    end
    puts sum
  else
    N.times do |i| 
      sum += L + i
    end
    puts sum
  end
else
  (L+1...N+L).each do |i|
    sum += i
  end
  puts sum
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio (false) ;cin.tie(NULL);
#define tc  int t;cin>>t;for(int i=0;i<t;i++)
#define ll long long int
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define um(a,b) unordered_map<a,b>
#define vv(a) vector<a>
#define pp(a,b) pair<a,b>

int main() {

     ll n,k;
     cin>>n;
     ll a,b,c;
     unordered_map<ll,ll> mymap;
     ll sum=0;
     forn(i,n){
       cin>>a;
       mymap[a]++;
       sum=sum+a;
     }
     ll q;
     cin>>q;
     while(q--){
        ll b,c;
        cin>>b>>c;
        if(mymap.find(b)!=mymap.end()){
            ll f=mymap[b];
            mymap.erase(b);
            sum=sum-b*f;
            sum=sum+c*f;
            mymap[c]+=f;
        }
        cout<<sum<<endl;
     }
}


Measured memory_bytes: 6612
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;
	VI A(N);
	REP(i, N)cin >> A[i];
	int ans = 0;
	VI bi[20];
	
	REP(i, N) {
		REP(j, 20) {
			if (A[i] & (1 << j))bi[j].push_back(i);
		}
	}
	REP(j, 20) {
		bi[j].push_back(N);
		bi[j].push_back(N);
	}

	REP(L, N) {
		int R = INF;

		REP(j, 20) {
			auto it = UB(bi[j], L);

			if (!(A[L] & (1 << j))) it++;

			chmin(R, *it);
		}

		ans += R - L;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 21136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define reps(i,start,end,step) for(int i=start;i< end;i+=step)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define Pr(x) cout << x << endl
#define Prs(x) cout << x << " "

int a[10];

int main()
{
    int N;
    cin >> N;
    
    int temp=0;
    rep(i, N){
        cin >> temp;
        temp /= 400;
        if(temp < 8) a[temp]++;
        else a[8]++;

    }

    int ans =0;

    rep(i, 8){
        if(a[i] >0){
            ans++;
        }
    }
    if(ans > 0) cout << ans << " " << ans + a[8] << endl;
    else cout << 1 << " " << a[8] << endl;
    
    return 0;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_LARGE = 1000000100;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

void Main()
{
	string s,t;
	cin >> s >> t;
	int sn = SIZE(s);
	int tn = SIZE(t);
	VVI a(26);


	REP(i,sn){
		a[s[i]-'a'].push_back(i+1);
	}

	LL r = 0;
	int now = 0;
	REP(i,tn){
		int moji = t[i]-'a';
		if(SIZE(a[moji]) == 0){
			cout << "-1" << endl;
			return;
		}
		auto it = upper_bound(a[moji].begin(), a[moji].end(), now);
		if(it == a[moji].end()){
			r += sn;
			now = a[moji][0];
		}
		else{
		    now = *it;
		}
	}

	cout << r+now << endl;

	return;
}

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

Measured memory_bytes: 1228
function Main(input) {
	input = input.trim();
	var CAPITAL = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  	var small = "abcdefghijklmnopqrstuvwxyz";
	var ans;
  	if (CAPITAL.indexOf(input) === -1){
      ans = 'a';
    } else {
      ans = 'A';
    }
  	console.log(ans);
}   
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){

  int n;
  long long a;
  long long min=1000000;
  long long max=-1000000;
  long long sum=0;

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a<min)min=a;
    if(a>max)max=a;
    sum+=a;
  }
  cout<<min<<" "<<max<<" "<<sum<<endl;
}


Measured memory_bytes: 3116
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>

using namespace std;

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

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

void print(vi &A) {
	FOR(i, 0, (int)A.size())
		printf("%d ", A[i]);
	cout << endl;
}

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

	vi A(n);
	FOR(i, 0, n) {
		scanf("%d", &A[i]);
	}
	// print(A);

	sort(A.begin(), A.end());

	ll ans = 0;

	FOR(i, 0, n - k) {
		ans += (ll)A[i];
	}

	cout << ans << endl;

	return 0;
}

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


def solve():
    N = int(input())
    A,B  = map(int,input().split())
    P = list(map(int,input().split()))
    P1 = list(p for p in P if p<=A)
    P2 = list(p for p in P if A<p<=B)
    P3 = list(p for p in P if B<p)
    res = min(len(P1),len(P2),len(P3))
    return str(res)

if __name__ == '__main__':
    print(solve())

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

string s; int n;
int K;
int dp[300][300][301];	//dp[l][r][x] = 区間[l, r]内における最長回文の長さ（変更数≦x)
int iter[2][300][26];	//iter[left or right][pos][moji] = (leftの場合)s[pos],…,s[n-1]の間において文字mojiが出現する最初の場所
						//, (rightの場合)s[0],…,s[pos]の間において文字mojiが出現する最後の場所

int dfs(int l, int r, int x) {
	int len = r - l + 1;
	if (len == 1) return 1;
	if (len <= 0) return 0;
	if (dp[l][r][x] != -1) return dp[l][r][x];
	
	int ret = 0;
	if (x > 0 && len >= 2) ret = 2 + dfs(l + 1, r - 1, x - (s[l] != s[r]));
	
	for (int i = 0; i < 26; i++) {
		int nl = iter[0][l][i];
		int nr = iter[1][r][i];
		if (nl == -1 || nr == -1 || nl > nr) continue;
		int res = 2 - (nl == nr) + dfs(nl + 1, nr - 1, x);
		ret = max(ret, res);
	}
	return dp[l][r][x] = ret;
}

int main() {
	int i, j, k;
	
	cin >> s >> K;
	n = s.length();
	rep(i, n) rep(j, n) rep(k, n + 1) dp[i][j][k] = -1;
	rep(i, 2) rep(j, n) rep(k, 26) iter[i][j][k] = -1;
	
	rep(i, n) {
		for (j = i; j < n; j++) {
			if (iter[0][i][s[j] - 'a'] == -1) {
				iter[0][i][s[j] - 'a'] = j;
			}
		}
		for (j = i; j >= 0; j--) {
			if (iter[1][i][s[j] - 'a'] == -1) {
				iter[1][i][s[j] - 'a'] = j;
			}
		}
	}
	int res = dfs(0, n - 1, K);
	cout << res << endl;
	return 0;
}

//K=0の場合で実験すると、最長部分列のうち一つは回文になっていると予想できる。これが正しければ、最長回文の長さが解の上界になる。
//まあ、AGCなので正しいだろう（は？）
//また、Tの回文部分列なら何でも、TとT'の共通部分列になっている。よって、最長回文の長さが解の下界になる。
//
//よって、「文字列Sの文字をK文字まで変更できるとき、作れる回文部分列の長さは最大でいくらになるか？」という問題になる。
//これは、
//１．文字を変更する→（回文になるように）左から文字を選ぶ
//２．左から文字を選ぶ→（回文になるように）文字を変更する→変更数≦Kかをチェックする。
//３．両端から文字を選ぶ→（回文になるように）文字を変更する
//のいずれでも解くことができるが、３の方針で考えると見通しがよい。このとき、以下の問題を解くのが本質になる。
//
//「両端からペアを作っていく。1文字だけのペアも作れるが、ペアは入れ子構造になっている必要がある。
//ペアを作るとき、違う文字ならコストが1発生する。コストK以下でいくつペアを作れるか？」
//
//この問題は、dp[左端l][右端r][変更数x] = そこからいくつのペアを作れるか？というDPで解くことができる。
//遷移は、「両端(l, r)を使う」「コストを消費せず、文字aでペアを作る」の2つだが、どちらもO(1)で行うことができる。
//計算量はO(N^3) * 26 / 2くらいになる。これ間に合うのか？

Measured memory_bytes: 106112
use proconio::input;

#[allow(unused_variables)]
fn main() {
    input! {
      a: usize, b: usize
    };

    let mut ans = 0;

    let mut c = 1;

    while b > c {
        ans += 1;
        c += a - 1;
    }

    println!("{}", ans);
}


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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(a.rbegin(), a.rend());
    rep(i, n) {
        h -= a[i];
        if (h <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main()
{


    int n;
    cin>>n;


    vector<int> w(n);
    for(int i=0;i<n;i++){
        cin>>w.at(i);
    }

    int64_t s1,s2,minwk=10000000;
    for(int i=0;i<n;i++){
        s1=0;
        s2=0;
        for(int j=0;j<i;j++){
            s1+=w.at(j);
        }
        for(int k=i;k<n;k++){
            s2+=w.at(k);
        }

        minwk=min(minwk,abs(s1-s2));
    }

    cout<<minwk<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;
const int mod = 1e9+7;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
const int MAX_N = 5e5+5;
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(int n, int k) {
    return fact[n]*ifact[n-k];
  }
} c(MAX_N);



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

  mint sum = 0;
  rep(i,n+1) {
    mint now = c(n,i);
    now *= c.p(m-i,n-i);
    if (i&1) now = -now;
    sum += now;
  }
  sum *= c.p(m,n);
  cout << sum << endl;
}


Measured memory_bytes: 10992
#include<bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
const int maxn = 1<<9, mod = 924844033;
int n, m, a[maxn][maxn], c[maxn][maxn][2];
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m;
	char t;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++) {
			cin >> t;
			a[i][j] = t=='#';
		}
	int d = 0, x = 1, y = 1, cl = 0, bcnt = 0, ccnt = 0;
	if(a[1][m]) x = 1, y = m;
	if(a[n][m]) x = n, y = m;
	if(a[n][1]) x = n, y = 1;
	if(x == n) swap(dx[0], dx[2]);
	if(y == m) swap(dy[1], dy[3]);
	while(true) {
		//cout << x << " " << y << '\n';
		if(c[x][y][0] + c[x][y][1]) break;
		c[x][y][cl] = 1;
		if((x == 1 || x == n) && (y == 1 || y == m)) {
			bcnt += a[x][y];
			ccnt++;
			if(a[x][y] && bcnt == 2) cl++;
			else if(ccnt == 3) cl++;
		}
		while(x + dx[d] < 1 || x + dx[d] > n || y + dy[d] < 1 || y + dy[d] > m) d = (d+1)%4;
		x += dx[d], y += dy[d];
	}
	
	for(int i = 2; i < n; i++)
		for(int j = 2; j < m; j++)
			c[i][j][c[i-1][j][0]==1?1:0] = 1;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			if(a[i][j]) c[i][j][0] = c[i][j][1] = 1;
	
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			assert((c[i][j][0]=='#'&&c[i][j][1]=='#')==(a[i][j]=='#'));
	
	for(int i = 1; i <= n; i++, cout << '\n')
		for(int j = 1; j <= m; j++)
			cout << (c[i][j][0]?'#':'.');
	for(int i = 1; i <= n; i++, cout << '\n')
		for(int j = 1; j <= m; j++)
			cout << (c[i][j][1]?'#':'.');
}


Measured memory_bytes: 3712
#include<stdio.h>
static const int N=100;

int main(){
  int A[N][N],n,u,k,v,i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++)A[i][j]=0;
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      A[u][v]=1;
  }
  }
  
for(i=0;i<n;i++){
  for(j=0;j<n;j++){
    if(j!=0)printf(" ");
    printf("%d",A[i][j]);
  }
  printf("\n");
  }

 return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N,M,X,countA,countB;
    cin>>N>>M>>X;
    int A[M];
    countA=countB=0;
    for(int i=0;i<M;i++){
        cin>>A[i];
    }
    for(int i=X;i>0;i--){
        for(int j=0;j<=M;j++){
            if(i==A[j]){
                countA++;
            }
        }
    }
    for(int i=X;i<N;i++){
        for(int j=0;j<=M;j++){
            if(i==A[j]){
                countB++;
            }
        }
    }
    cout<<min(countA,countB)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
long ff(long p,long q){
    long mod=1000000007;
    if(q%2==0){
        return ff(p,q/2)*ff(p,q/2)%mod;
    }
    else if(q==1){
        return p;
    }
    else{
        return ff(p,q-1)*p%mod;
    }
}
long f(long long n,long long m){
    long p=1,q=1;
    long mod=1000000007;
    //cout<<n<<" "<<m<<"W"<<endl;
    for(long i=1;i<=n;i++)p=p*i%mod;
    for(long i=1;i<=m;i++)q=q*i%mod;
    for(long i=1;i<=n-m;i++)q=q*i%mod;
    //cout<<ff(q,mod-2)<<endl;
    return (ff(q,mod-2)*p)%mod;
}
int main(void){
    // Your code here!
    long n,m;
    cin>>n>>m;
    map<long,long>p;
    for(long i=2;i<=m;i++){
        while(m%i==0){
            m/=i;
            p[i]++;
        }
    }
    long mod=1000000007;
    long ans=1;
    for(auto x:p){
        long a=x.second;
        ans=ans*f(a+n-1,a)%mod;
        ans%=mod;
    }
    cout<<ans%mod<<endl;
}


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

using namespace std;

int P[1005];
int expo[1005];
int MOD = 1000000007;

void Criba() {
	for (int i = 0; i < 1005; ++i) {
		P[i] = i;
	}
	for (int i = 2; i < 1005; i += 2)
	{
		P[i] = 2;
	}
	for (int i = 3; i < 1005; i += 2) {
		if (P[i] == i) {
			for (int j = 2; i * j < 1005; ++j) {
				P[i * j] = i;
			}
		}
	}
}

void Factorizar(int a) {
	while (a > 1) {
		int x = 0;
		int d = P[a];
		while (a % d == 0) {
			a = a / d;
			x++;
		}
		expo[d] += x;
	}
}

int main() {
	int n;
	Criba();
	scanf("%d", &n);
	for (int i = 0; i < 1005; ++i)
	{
		expo[i] = 0;
	}
	for (int i = 1; i <= n; i++) {
		Factorizar(i);
	}
	long long sol = 1;
	for (int i = 2; i <= n; ++i) {
		if (expo[i] != 0) {
			sol = (sol * ((1ll * expo[i] + 1) % MOD) ) % MOD; 
		} 
	}
	printf("%lld\n", sol);
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

x = int(input())
k = 100
while k <x:
  k = k * 101 // 100
  count += 1
print(count)

Measured memory_bytes: 9540