akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#include <bitset>
#include <complex>
#define ll long long
#define INF 1000000000000000001
#define MOD 1000000007
using namespace std;


int main(){
int K,X;
cin >> K >> X;
if(K*500>=X){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
}

Measured memory_bytes: 256
n,m=map(int,input().split())
A=[int(input()) for i in range(m)]
mod=10**9+7
flag=1
S=[0 for i in range(n+3)]
S[0]=1
SET=set(A)
for i in range(n):
    if i in SET:
        S[i]=0
        if i+1 in SET:
            flag=0
    S[i+1]+=S[i]
    S[i+2]+=S[i]
    
print(S[n]%mod if flag==1 else 0)
#配る方で解いてみた。

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

constexpr int64_t MOD = 1000000007;

int main() {
  int64_t N, M;
  cin >> N >> M;
  if (abs(N - M) >= 2) {
    cout << 0 << endl;
    return 0;
  }
  int64_t x = (N == M ? 2 : 1);
  for (int64_t i = 1; i <= N; ++i) {
    x = x * i % MOD;
  }
  for (int64_t i = 1; i <= M; ++i) {
    x = x * i % MOD;
  }
  cout << x << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  string s; cin>>s;
  rep(i,s.size()){
    int size=s.size()-i;
    if(size%2!=0||i==0) continue;
    string a=s.substr(0,size/2);
    string b=s.substr(size/2,size/2);
    // cout<<a<<" "<<b<<endl;
    if(a==b){
      cout<<size<<endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,a,b,ans=0;cin>>n>>a>>b;
  if((b-a)%2==0) ans=(b-a)/2;
  else ans=min(a-1,n-b)+1+(b-a-1)/2;
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
	return x*f;
}
int m;
long long sum1,sum2,dlt;
priority_queue<int>q1;
priority_queue<int,vector<int>,greater<int> >q2;
int main(){
	int ord,x,d;
	m=read();
	while(m--){
		ord=read();
		if(ord==2){
			d=q1.top();
			long long ans=1ll*d*q1.size()-sum1 + sum2-1ll*d*q2.size()+dlt;
			printf("%d %lld\n",q1.top(),ans);
		}
		else{
			x=read();d=read();
			dlt+=d;
			if(q2.empty())q1.push(x),sum1+=x;
			else{
				if(x<=q2.top())q1.push(x),sum1+=x;
				else q2.push(x),sum2+=x;
			}
			while(q1.size()>q2.size()+1){
				x=q1.top();sum1-=x;q1.pop();
				q2.push(x);sum2+=x;
			}
			while(q1.size()<q2.size()){
				x=q2.top();sum2-=x;q2.pop();
				q1.push(x);sum1+=x;
			}
		}
	}
}

Measured memory_bytes: 4108
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const double PI = acos(-1);
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	lli n, m;
	cin >> n >> m;
	vector<vector<lli>> G(n+1);
	vector<int> dist(n+1, -1);
	map<lli, lli> trace;
	queue<lli> q;

	rep(i,m){
		lli a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dist[1] = 0;
	q.push(1);

	while(!q.empty()){
		lli v = q.front();
		q.pop();

		for(const auto& x : G[v]){
			if(dist[x] != -1) continue;
			dist[x] = dist[v] + 1;
			trace[x] = v;
			q.push(x);
		}
	}
	puts("Yes");
	for(const auto& t : trace){
		cout << t.second << endl;
	}
	return 0;
}


Measured memory_bytes: 18700
#include <iostream>

int main()
{
    int N;
    std::cin >> N;
    long long A[N+1], B[N];
    for(int i=0; i<N+1; i++) scanf(" %lld", &A[i]);
    for(int i=0; i<N; i++) scanf(" %lld", &B[i]);

    long long count = 0;
    for(int i=0; i<N; i++){
        long long m = (A[i] < B[i]) ? A[i] : B[i];
        count += m;
        B[i] -= m;
        m = (A[i+1] < B[i]) ? A[i+1] : B[i];
        count += m;
        A[i+1] -= m;
    }
    std::cout << count << std::endl;
}

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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define MP make_pair
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;

const double PI = acos(-1);
const double EPS = 1e-9;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

///////////////////////////////////////////////////////

const int N = 1e5;

ll h,w,a,b;
ll fact[2*N + 5];
ll addMod(ll a, ll b){
	return (a +b ) % MOD;
}

ll mulMod(ll a, ll b){
	return (a*b) % MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b % 2 == 1) tmp = mulMod(tmp,a);
	return tmp;
}

ll combin(int n, int k){
	return mulMod(fact[n], fast(mulMod(fact[n-k], fact[k]), MOD-2));
}

ll solve(){
	ll ret = 0;
	REP(i,1,h-a){
		int y = i;
		int x = b;
		ll val = combin(y+x-2,y-1);
		x++;
		val = mulMod(val, combin(h+w-y-x, h-y));
		ret = addMod(ret, val);
	}
	return ret;
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	fact[0] = 1;
	REP(i,1,2*N) fact[i] = mulMod(fact[i-1], i);
	cin >> h >> w >> a >> b;
	cout << solve() << endl;
	return 0;
} 

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 998244353;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	string s;
	cin >> n >> s;
	if(n<3200){
		cout<<"red"<<endl;
	}
	else{
		cout<<s<<endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c=1;

    scanf("%d%d",&a,&b);
if((a!=1)&&(b!=1))
{

    if(a>b)
        printf("Alice");
    else if(a<b)
        printf("Bob");
    else if (a==b)
        printf("Draw");
}
else
{
     if(a<b)
        printf("Alice");
    else if(a>b)
        printf("Bob");
    else if (a==b)
        printf("Draw");
}

}


Measured memory_bytes: 128
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n=parseInt(readline())
    s=chomp(readline())
    for i in s
        if i+n>'Z'
            print('A'+(i+n-1-'Z'))
        else
            print(i+n)
        end
    end
end
main()

Measured memory_bytes: 110356
s = input()
# sをリスト化
s = list(s)
# 1文字目から一つ置きに抜き出してリスト化
odd_list = s[0::2]
# 2文字目から一つ置きに抜き出してリスト化
even_list = s[1::2]

if "R" not in even_list and "L" not in odd_list:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9008
#include <iostream>
using namespace std;
typedef long long ll;
ll n,m,MOD=1000000007,dp[2001][2001],a[2001],b[2001];
int main(void){
    cin>>n>>m;
    for(int i=0;i<n;i++)cin>>a[i+1];
    for(int i=0;i<m;i++)cin>>b[i+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            if(i==0||j==0){
                dp[i][j]=1;
                continue;
            }
            dp[i][j]+=dp[i-1][j];
            dp[i][j]%=MOD;
            dp[i][j]+=dp[i][j-1]-dp[i-1][j-1];
            dp[i][j]%=MOD;
            if(a[i]==b[j]){
                //cout<<a[i]<<b[i]<<"W"<<endl;
                dp[i][j]+=dp[i-1][j-1];
                dp[i][j]%=MOD;
            }
        }
    }
    dp[n][m]+=MOD;
    dp[n][m]%=MOD;
    cout<<dp[n][m]<<endl;
}


Measured memory_bytes: 31616
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    int N; scanf("%d", &N);
    ll ans = 0;
    FOR(i,1,N+1){
        if(i % 3 != 0 && i % 5 != 0){
            ans += (ll)i;
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 3820
import sys
sys.setrecursionlimit(4100000)
import math
import fractions
import bisect

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行ありl
x = []
y = []
for i in range(5):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

'''


N, M = map(int, input().split())

ans = 0
for i in range(1, int(math.sqrt(M))+1):

    if M < i*N:
        break

    if M % i == 0:
        if M >= (M//i)*N:
            ans = M//i
            break

        ans = i



print(int(ans))

Measured memory_bytes: 5472
// Gear4        
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define FOR0(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define FOR(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i)
#define FORD(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define SZ(a) ((int)((a).size()))
#define printCase() "Case #" << caseNum << ": "
#define pb push_back
#define mp make_pair
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
#define ff first
#define ss second
template<typename T> using V = vector<T>;
template<typename T, typename U> using P = pair<T,U>;
using ld = long double;
using ll = long long;
#define endl '\n'
const int inf = 2e9, mod = 1e9 + 7;
const ll INF = 9e18;
const ld EPS = 1e-9, PI = acosl(-1.0);
const int N = 1e5 + 5;
int n, m, l, r, d;
vector<vector<pair<int,int>>> g(N);
bitset<N> vis;
int ans[N];
set<int> st;
int poss = 1;
void dfs(int u) {
    vis[u] = 1;
    st.insert(ans[u]);
    for(auto nxt : g[u]) {
        int nd = nxt.ss + ans[u];
        if(vis[nxt.ff]) poss &= nd == ans[nxt.ff];
        else {
            ans[nxt.ff] = nd;
            dfs(nxt.ff);
        }
    }
}
int main() {
    SYNC
    cin >> n >> m;
    FOR0(i, m) {
        cin >> l >> r >> d;
        g[l].pb(mp(r, d));
        g[r].pb(mp(l, -d));
    }
    const int MX = 1e9;
    FOR(i, 1, n + 1) {
        if(!vis[i]) {
            st.clear();
            ans[i] = 0;
            dfs(i);
            if(!st.empty() && (*(st.rbegin()) - *(st.begin())) > MX) poss = 0;
        }
    }
    cout << (poss ? "Yes": "No");
}

Measured memory_bytes: 15744
#include <iostream>
#include <algorithm>
using namespace std;
long long k,i,j,jj,sum;
int main()
{
    cin>>k;
    for (i=1;i<=k;++i)
    {
        for (j=1;j<=k;++j)
        {
            for (jj=1;jj<=k;++jj)
                 sum+=__gcd(i,__gcd(j,jj));
        }
    }
    cout<<sum;
}


Measured memory_bytes: 3648
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val a = br.readLine().replace(" ", "").toDouble()
    println(if (Math.sqrt(a)%1.0==0.0) "Yes" else "No")
}

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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	bool flag = true;
	int N, zero = 0, conm = 3;
	vector<int> A, con, dp;
	
	cin>>N;
	
	A.resize(N);
	con.resize(N);
	dp.resize(N+1);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		
		if(!A[i]) zero++;
	}
	
	if(zero > 3){
		cout<<0<<endl;
		return 0;
	}
	
	dp[0] = 1;
	
	for(int i = 0; i < N; i++){
		con[A[i]]++;
		
		if(con[A[i]] < 0){
			cout<<0<<endl;
			return 0;
		}
		
		if(A[i]){
			dp[i+1] = dp[i] * con[A[i]-1]--;
		} else {
			dp[i+1] = dp[i] * conm--;
		}
		
		dp[i+1] %= MOD;
	}
	
	cout<<dp[N]<<endl;
	
	return 0;
}

Measured memory_bytes: 2560
N,M=list(map(int,input().split()))
Key=[]
cnt=0
a=0
    
if N==1:
    a=input().split()
    print(len(a)-1)

else:    
    
    for i in range(N):
        tmp=input().split()
        for j in range(int(tmp[0])):
            Key.append(int(tmp[j+1]))
    
    for i in range(1,M+1):
        if Key.count(i)==N:
            cnt+=1
    
    print(cnt)

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

public class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int a = sc.nextInt();
        if (n < a) {
            System.out.println(0);
            return;
        }
            System.out.println(10);
    }
}

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: 22612
#include <iostream>
#include <chrono>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <unordered_set>
#include <vector>
#include <queue>
#include <math.h>

#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)

constexpr auto NMAX = (int)1e5 + 20;

using namespace std;

typedef unsigned long long ull;

ull n, k;

ull abs_diff(ull a, ull b)
{
	return MAX(a, b) - MIN(a, b);
}

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

	ull lower = (n / k) * k;
	ull upper = (n / k + 1) * k;
	cout << MIN(abs_diff(lower, n), abs_diff(upper, n)) << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr first
#define sc second

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
const int NMAX = 8000 + 8;

bool isYes(bool (*dp)[NMAX], vector<int> &v, int s) {
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for (int i = 1; i < v.size(); ++i) {
        for (int j = 0; j <= s; ++j) {
            dp[i][j] = dp[i - 1][j];
            if (j - v[i] >= 0) {
                dp[i][j] = max(dp[i][j], dp[i][j - v[i]]);
            }
        }
    }
    for (int i = 0; i < v.size(); ++i) {
        if (dp[i][s]) {
            return 1;
        }
    }
    return 0;
}

bool dpx[NMAX][NMAX];
bool dpy[NMAX][NMAX];

main()
{
    #ifdef HOME
        freopen("input.txt", "r", stdin);
    #else
//        freopen("rod.in", "r", stdin);
//        freopen("rod.out", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    string s;
    int x, y;
    cin >> s >> x >> y;
    int n = s.size();
    int Sx = 0, Sy = 0, segx = 0, segy = 0, prex = 0;
    bool isX = 1, isF = 1;
    vector<int> xv, yv;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'T') {
            isF = 0;
        }
        if (!isF) {
            if (s[i] == 'T') {
                if (segx > 0) {
                    xv.push_back(segx);
                } else if (segy > 0) {
                    yv.push_back(segy);
                }
                isX = !isX;
                segx = 0;
                segy = 0;
            } else {
                if (isX) {
                    ++segx;
                    Sx++;
                } else {
                    ++segy;
                    Sy++;
                }
            }
        } else {
            ++prex;
            assert(s[i] == 'F');
        }
    }
    x -= prex;
    x = abs(x);
    y = abs(y);
    xv.insert(xv.begin(), 0);
    yv.insert(yv.begin(), 0);
    if ((Sx - x) % 2 || (Sy - y) % 2) {
        cout << "No";
        return 0;
    }
    int decx = (Sx - x) / 2, decy = (Sy - y) / 2;
    if (isYes(dpx, xv, decx) && isYes(dpy, yv, decy)) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}


Measured memory_bytes: 34048
#B問題
w = input()
a = w.count("a") % 2
b = w.count("b") % 2
c = w.count("c") % 2
d = w.count("d") % 2
e = w.count("e") % 2
f = w.count("f") % 2
g = w.count("g") % 2
h = w.count("h") % 2
i = w.count("i") % 2
j = w.count("j") % 2
k = w.count("k") % 2
l= w.count("l") % 2
m = w.count("m") % 2
n = w.count("n") % 2
o = w.count("o") % 2
p = w.count("p") % 2
q = w.count("q") % 2
r = w.count("r") % 2
s = w.count("s") % 2
t = w.count("t") % 2
u = w.count("u") % 2
v = w.count("v") % 2
W = w.count("w") % 2
x = w.count("x") % 2
y= w.count("y") % 2
z = w.count("z") % 2

if(a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r + s+ t + u + v + W + x + y + z)== 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) begin(c), end(c)
#define ok() puts(ok?"Yes":"No");
template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int N,M;
vi to[200006];  
struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  // bool is useful for MST 
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main() {
  cin >> N >> M;
  UnionFind uf(N);
  rep(i,M) {
  int a,b; cin >> a >> b; a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
    uf.unite(a,b);
  }
  int ans = 0;
  rep(i,N) {
    chmax(ans, uf.size(i));
  }
  cout << ans << endl;
   return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/25  Problem: ARC 093 A / Link: http://arc093.contest.atcoder.jp/tasks/arc093_a  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	cin >> N;
	VL a(N+1);
	a[0] = 0;
	FOR(i, 0, N) {
		cin >> a[i+1];
	}
	LL sum = 0;
	FOR(i, 0, N+1) {
		sum += abs(a[(i + 1) % (N+1)] - a[i]);
	}
	FOR(i, 1, N+1) {

		LL ret = 0;
		LL x = a[i - 1];
		LL y = a[i];
		LL z = a[(i + 1)%(N+1)];
		LL cost = 2 * abs(x - y);// debug(cost);
		if (y < x && x <= z) {
			ret = cost;
		}
		if (z <= x && x < y) {
			ret = cost;
		}
		LL cost23 = 2*abs(y - z);
		if (y < z && z <= x) {
			ret = cost23;

		}

		if (x <= z && z < y) {
			ret = cost23;
		}
//		debug(ret);
		//cout << x << "," << y << "," << z << "," << ret << endl;
		cout << sum - ret << endl;
	}

	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define put(i) cout << fixed << i << endl
using namespace std;
using ll = long long;

int main() {
    int n, m, X, Y;
    cin >> n >> m >> X >> Y;
    vector<int> x(n), y(m), z;
    rep(i, n) cin >> x[i];
    rep(i, m) cin >> y[i];

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    for (int i = X + 1; i <= Y; i++) {
        z.push_back(i);
    }

    for (int i = 0; i < z.size(); i++) {
        if (x[n - 1] < z[i] && y[0] >= z[i]){
            put("No War");
            return 0;
        }
    }
    put("War");
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void){
        int n, m, q;
        int a[502][502] = {};



        cin >> n >> m >> q;

        int l, r;

        for (int i = 0; i < m; i++){
                cin >> l >> r;
                a[1][r]++;
                a[l+1][r]--;
                a[l][n+1]++;
                a[l+1][n+1]--;
        }

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

        for (int i = 0; i < q; i++){
                cin >> l >> r;

                cout << a[l][r] << endl;
        }





}

Measured memory_bytes: 1920
#include<iostream>
using namespace std;
#define ll long long int
#include<cmath>
int main()
{
	ll n;
	cin>>n;
	ll arr[n];
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	ll dp[n];
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(ll i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
	}
		
	cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;
int f[200005];
int n, a[200005], pos[200005];


int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d", &a[i]);
        pos[a[i]] = i;
    }
    int len = 1;
    int ans = 0;
    for (int i = 1; i < n; ++i)
    {
        if (pos[i + 1] > pos[i])
        {
            len++;
        }
        else
        {
            ans = max(ans, len);
            len = 1;
        }
    }
    ans = max(ans, len);
    cout << n-ans << endl;

    return 0;
}

Measured memory_bytes: 1792
/*
 * main.cpp
 *
 *  Created on: 2020/04/09
 *      Author: SkAaO
 */

#include <iostream>

using namespace std;

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

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

	for(int i = 0;; i++){
		bool is_even = true;

		for(int j = 0; j < N; j++){
			if(A[j] % 2 == 1){
				is_even = false;
			}
			A[j] /= 2;
		}
		if(!is_even){
			cout << i << endl;
			break;
		}else{
			continue;
		}
	}

	return 0;
}





Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<(a-c)*(b-d)<<endl;
}
int32_t main(){
  IOS;
  solve();
  //debug();
 #ifdef LOCAL_DEFINE
 cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
 #endif	
}


Measured memory_bytes: 256
from itertools import combinations_with_replacement


N,M,Q = map(int, input().split())
a = [0] * Q
b = [0] * Q
c = [0] * Q
d = [0] * Q
for i in range(Q):
    a[i], b[i], c[i], d[i] = map(int, input().split())

max_total = 0

A_ls = list(combinations_with_replacement(range(1, M+1), N))

for A in A_ls:
    total = 0
    for i in range(Q):
        if A[b[i]-1] - A[a[i]-1] == c[i]:
            total += d[i]
    max_total = max(max_total, total)

print(max_total)

Measured memory_bytes: 85024
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    S=list(input())

    ans = 0
    for i in range(1000):
        pin = str(i)
        if len(pin) == 1:
            pin = "00"+pin
        elif len(pin) == 2:
            pin = "0"+pin
        
        waiti = 0
        for j in range(N):
            if S[j] == pin[waiti]:
                waiti += 1
                if waiti == 3:
                    break
                    
        if waiti == 3:
            ans += 1

    print(ans)
            
            





if __name__ == "__main__":
    main()

Measured memory_bytes: 69172
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
int a[114514],b[114514];
signed main(){
	ic(n)
	b[0]=0,b[n+1]=0;
	rep(0,i,n){
		cin>>a[i];
		b[i+1]=a[i];
	}	
	int sum=0;
	rep(0,i,n+1)sum+=abs(b[i]-b[i+1]);
	rep(1,i,n+1){
		if((b[i-1]<=b[i]&&b[i]<=b[i+1])||(b[i-1]>=b[i]&&b[i]>=b[i+1]))c(sum)
		else c(sum-min(abs(b[i-1]-b[i]),abs(b[i+1]-b[i]))*2)
	}
}		

Measured memory_bytes: 2816
#include <stdio.h>
int main()
{
  int a,b,tmp,e;

  scanf("%d%d",&a,&b);
  if(a<b){
    tmp=a;
    a=b;
    b=tmp;
  }
  e=a%b;
  while(e!= 0){
    a=b;
    b=e;
    e=a%b;
  }
  printf("%d\n",b);
  return 0;
}



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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int H,W,Q;
int A[2222][2222];

int V[2222][2222];
int E1[2222][2222];
int E2[2222][2222];

signed main(){
    cin>>H>>W>>Q;
    rep(i,H){
        string s;cin>>s;
        rep(j,W)A[i][j]=s[j]=='1';
    }

    rep(i,H)rep(j,W)V[i+1][j+1]=V[i][j+1]+V[i+1][j]-V[i][j]+A[i][j];
    rep(i,H)rep(j,W)E1[i+1][j+1]=E1[i][j+1]+E1[i+1][j]-E1[i][j]+(A[i][j]&&A[i][j+1]);
    rep(i,H)rep(j,W)E2[i+1][j+1]=E2[i][j+1]+E2[i+1][j]-E2[i][j]+(A[i][j]&&A[i+1][j]);

    while(Q--){
        int x1,y1,x2,y2;
        cin>>y1>>x1>>y2>>x2;
        x1--;y1--;

        int v=V[y2][x2]-V[y2][x1]-V[y1][x2]+V[y1][x1];
        int e1=E1[y2][x2-1]-E1[y2][x1]-E1[y1][x2-1]+E1[y1][x1];
        int e2=E2[y2-1][x2]-E2[y2-1][x1]-E2[y1][x2]+E2[y1][x1];
        cout<<v-e1-e2<<endl;
    }
    return 0;
}


Measured memory_bytes: 147200
#include<stdio.h>
#define H 500000

int x,A[H+1];


maxHeapify(int A[],int i){
  
  int l,r,g,largest;
  
  l = 2*i;
  r = 2*i+1;
  if(l <= x && A[l] > A[i])
    largest = l;
  else 
    largest = i;
  if( r <= x && A[r] > A[largest])
    largest = r;
  if(largest != i){
      g=A[i];
    A[i]=A[largest];
    A[largest] = g;
    maxHeapify(A, largest);
  }
}

buildMaxHeap(int A[]){
  int i;
  for(i=x/2;i>=1;i--)
    maxHeapify(A,i);
}
      


int main(){

  int i;

  scanf("%d",&x);

  for(i=1;i<=x;i++){
    scanf("%d",&A[i]);
  }

  for(i=x/2;i>=1;i--){
    maxHeapify(A,i);
  }
  
  for(i=1;i<=x;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}

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

int main() {

    int64_t N,M,step2down=1,step1down=1,brokepoint=0;
    cin>>N>>M;
    vector<int64_t> A(100000);
    vector<int64_t> mem(100001,0);
    for(int i=0; i<M; i++){cin>>A[i];if(i>0){if(A[i]-A[i-1]==1){cout<<0<<endl;return 0;}}}

  if(A[0]==1){mem[1]=0;brokepoint++;}
  else mem[1]=1;
  mem[0]=1;
    for(int i=1;i<N;i++){
      if(A[brokepoint]==i+1){mem[i+1]=0;if(brokepoint<M-1)brokepoint++;}
      else mem[i+1]=mem[i]+mem[i-1];
      mem[i+1]%=1000000007;
}
    cout << mem[N] << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  string s, t;
  cin >> s;
  cin >> t;
  t.erase(t.end()-1);
  if (s == t){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
  

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

template <unsigned mod>
struct RollingHash {
  vector<unsigned> hashed;
  vector<unsigned> power;
  inline unsigned mul(unsigned a, unsigned b) const {
    unsigned long long x = (unsigned long long) a * b;
    unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
    asm("divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod));
    return m;
  }
  RollingHash(const string &s, unsigned base = 10007) {
    int n = (int) s.size();
    hashed.assign(n + 1, 0);
    power.assign(n + 1, 0);
    power[0] = 1;
    for (int i = 0; i < n; i++) {
      power[i + 1] = mul(power[i], base);
      hashed[i + 1] = mul(hashed[i], base) + s[i];
      if (hashed[i + 1] >= mod) hashed[i + 1] -= mod;
    }
  }
  unsigned get(int l, int r) const {
    unsigned ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
    if (ret >= mod) ret -= mod;
    return ret;
  }
};

using RH = RollingHash<1000000007>;

struct UnionFind {
  vector<int> par;
  vector<int> siz;
  UnionFind(int n) {
    par = vector<int>(n);
    siz = vector<int>(n, 1);
    iota(par.begin(), par.end(), 0);
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    par[x] = y;
    siz[y] += siz[x];
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return siz[root(x)];
  }
};

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  string ss = s;
  while (ss.size() < t.size()) {
    ss += s;
  }
  ss += ss;
  RH sh(ss), th(t);
  auto uf = UnionFind(n);
  for (int i = 0; i < n; i++) {
    if (sh.get(i, i + t.size()) == th.get(0, t.size())) {
      int x = i % n;
      int y = (i + t.size()) % n;
      if (uf.same(x, y)) {
        cout << -1 << endl;
        return 0;
      }
      uf.unite(x, y);
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, uf.size(i) - 1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 31412
S = input()


def is_OK(S):
    i = 1
    for s in S:
        if i % 2 != 0:
            if s not in ['R', 'U', 'D']:
                return False
        elif i % 2 == 0:
            if s not in ['L', 'U', 'D']:
                return False
        i += 1
    return True


if is_OK(S):
    print('Yes')
else:
    print('No')


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

int main()
{
	string a, b;
	bool f = 0;

	getline(cin, a);
	getline(cin, b);

	sort(a.begin(), a.end());
	sort(b.rbegin(), b.rend());

	if (a < b)
		f = true;

	if(f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#define Rint register int
#define mem(a,b) memset(a,(b),sizeof(a))
#define Temp template<typename T>
using namespace std;
typedef long long LL;
Temp inline void read(T &x){
    x=0;T w=1,ch=getchar();
    while(!isdigit(ch)&&ch!='-')ch=getchar();
    if(ch=='-')w=-1,ch=getchar();
    while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^'0'),ch=getchar();
    x=x*w;
}

const int maxk=2000+10;
int n,k;
int ans;
int w[maxk][maxk],b[maxk][maxk];

inline int getc(){
	char ch=getchar();
	while(ch!='W'&&ch!='B')ch=getchar();
	if(ch=='W')return 0;
	return 1;
}

int main(){
	read(n);read(k);
	int kk=(k<<1),x,y,c;
	for(Rint i=1;i<=n;i++){
		read(x);read(y);c=getc();
		x%=kk,y%=kk;
		if(x==0)x=kk;
		if(y==0)y=kk;
		if(c==0)w[x][y]++;
		else b[x][y]++;
	}
	for(Rint i=1;i<=kk;i++){
		for(Rint j=1;j<=kk;j++){
			w[i][j]+=w[i-1][j]+w[i][j-1]-w[i-1][j-1];
			b[i][j]+=b[i-1][j]+b[i][j-1]-b[i-1][j-1];
		}
	}
	for(Rint i=1;i<=k;i++){
		for(Rint j=1;j<=k;j++){
			for(Rint p=0;p<=1;p++){
				int res=0;
				if(p==0){
					int pi=k-i,pj=k-j;
					res+=w[pi][pj];
					res+=b[pi][pj+k]-b[pi][pj];
					res+=w[pi+k][pj+k]-w[pi][pj+k]-w[pi+k][pj]+w[pi][pj];
					res+=b[pi+k][pj]-b[pi][pj];
					
					res+=w[pi][kk]-w[pi][pj+k];
					res+=w[kk][kk]-w[pi+k][kk]-w[kk][pj+k]+w[pi+k][pj+k];
					res+=w[kk][pj]-w[pi+k][pj];
					res+=b[pi+k][kk]-b[pi][kk]-b[pi+k][pj+k]+b[pi][pj+k];
					res+=b[kk][pj+k]-b[pi+k][pj+k]-b[kk][pj]+b[pi+k][pj];
				}
				else{
					int pi=k-i,pj=k-j;
					res+=b[pi][pj];
					res+=w[pi][pj+k]-w[pi][pj];
					res+=b[pi+k][pj+k]-b[pi][pj+k]-b[pi+k][pj]+b[pi][pj];
					res+=w[pi+k][pj]-w[pi][pj];
					
					res+=b[pi][kk]-b[pi][pj+k];
					res+=b[kk][kk]-b[pi+k][kk]-b[kk][pj+k]+b[pi+k][pj+k];
					res+=b[kk][pj]-b[pi+k][pj];
					res+=w[pi+k][kk]-w[pi][kk]-w[pi+k][pj+k]+w[pi][pj+k];
					res+=w[kk][pj+k]-w[pi+k][pj+k]-w[kk][pj]+w[pi+k][pj];
				}
				ans=max(ans,res);
			}
		}
	}
	printf("%d\n",ans);
    return 0;
}

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

int main() {
  int N, K, S; cin >> N >> K >> S;

  int b;
  if (S == 1e9) {
    b = 1e9 - 1;
  }
  else {
    b = 1e9;
  }
  rep(i, K) {
    cout << S << " ";
  }
  rep(i, N - K) {
    cout << b << " ";
  }
  cout << endl;
}


Measured memory_bytes: 1280
S = list(input())

for i in range(len(S)):
    if i % 2 == 1:
        if S[i] not in ["L", "U", "D"]:
            print("No")
            exit()
    else:
        if S[i] not in ["R", "U", "D"]:
            print("No")
            exit()
print("Yes")


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(void){
    ll n,k;
    cin >>n >> k;
    ll cntk=0,cntk2=0;
    for(int i=1;i<=n;i++){
        if(i%k==0) cntk++;
    }
    if(k%2==0){
        for(int i=1;i<=n;i++){
            if(i%k==k/2) cntk2++;
        }
    }

    // cout << cntk <<' ' << cntk2 << endl;

    ll ans = pow(cntk,3);
    if(cntk2!=0) ans += pow(cntk2,3);
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <chrono>
using namespace std;
#pragma GCC optimize("-O3")
#define endl "\n"
#define mp make_pair
#define st first
#define nd second
#define pii pair<int, int>
#define pb push_back
#define _upgrade ios_base::sync_with_stdio(0), cout.setf(ios::fixed), cout.precision(10) //cin.tie(0); cout.tie(0);
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FWD(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define fwd(i, a, b) for (int i = (a); i < (b); ++i)
#define all(c) (c).begin(), (c).end()
#define what(x) cerr << #x << " is " << x << endl;
#define int long long

int odp(int a, int b, int plus = 0)
{
    return (abs(a - b) / 2) + plus;
}

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

    if (a > b)
        swap(a, b);

    if ((a + b) % 2 == 0)
    {
        cout << odp(a, b) << endl;
        exit(0);
    }
    cout << min(odp(a + n - b + 1, n, n - b + 1), odp(1, b - a, a)) << endl;
}

Measured memory_bytes: 256
fun main(args :Array<String>) {
    val (n, k) = readIntegerList()
    val s = readLine()!!
    val tmp = arrayListOf<Int>()
    var pre = s[0]
    var count = 1
    for (c in s.substring(1)) {
        if (pre == c) {
            count++
        } else {
            tmp.add(count)
            count = 1
        }

        pre = c;
    }
    tmp.add(count)

    if (s[0] == '0') {
        tmp.add(0, 0)
    }
    if (s.last() == '0') {
        tmp.add(0)
    }
    // println(tmp)
    var max = tmp
        .subList(0, Math.min(2 * k + 1, tmp.size))
        .sum()
    var a = max
    // println(a)
    for (i in 2 until tmp.size - (2 * k) step 2) {
        a = a - tmp[i - 1] - tmp[i - 2] + tmp[i + 2 * k - 1] + tmp[i + 2 * k]
        // println("${i - 2} ${i + 2 * k} ${a}")
        max = Math.max(max, a)
    }
    println(max)
}

fun readInteger() = readLine()!!.toInt()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)


Measured memory_bytes: 41348
#include<stdio.h>

int n,A[100000];

int binarySearch(int key){
    int left=0;
    int right=n;
    int mid;

    while (left < right){
        mid = (left + right)/2;
        if(key == A[mid]){
            return 1;
        }
        if(key > A[mid]){
            left = mid + 1;
        }
        else{
            right = mid;
        }
    }
    return 0;
}

int main(){
    int i, q, k, sum=0;
    //入力したい数字の行数
    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }

    scanf("%d",&q);

    for(i=0;i<q;i++){
        scanf("%d",&k);
        if(binarySearch(k)){
            sum++;
        }
    }
    printf("%d\n",sum);

    return 0;
}


Measured memory_bytes: 2100
s = input()
d = len(s)
n = int(s)
k = int(input())

top = int(s[0])



def k_2(s):
    d = len(s)
    top = int(s[0])
    first_non_zero = -1
    first_pos = -1
    for i in range(1, d):
        if s[i] != '0':
            first_non_zero = int(s[i])
            first_pos = d - i
            break
    x = ((d-2) * (d-1) // 2) * 81
    y =  (top-1) * 9 * (d-1)
    z = first_non_zero + (first_pos-1) * 9 if first_pos >= 0 else 0
    return (x+y+z)    


if k == 1:
    print((d-1) * 9 + top)

elif k == 2:
    print(k_2(s))

else:
    x = ((9 ** 3) * (((d-3)*(d-2)*(2*d-5) // 6) + ((d-3)*(d-2) // 2)) //2)
    y = (top-1) * 81 * ((d-1)*(d-2) // 2)
    
    first_non_zero = -1
    ind = -1
    for i in range(1, d):
        if s[i] != '0':
            ind = i
            break
    z = k_2(s[ind:])
    # print(x)
    # print(y)
    # print(z)
    print(x + y + z)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
 
int dp[5000001] = {0};
int main() {
        int k,m,n;
        dp[1] = 1;
        for(int i = 1 ; i <= 1000000 ; i++){
                dp[i*2] |= dp[i];
                dp[i*3] |= dp[i];
                dp[i*5] |= dp[i];
        }
        for(int i = 1 ; i <= 1000000 ; i++){
                dp[i] += dp[i-1];
        }
        while(cin >> m && m){
                cin >> n;
                cout << dp[n] - dp[m-1] << endl;
        }
        return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> P(N);
	rep(i, N) {
		cin >> P[i];
	}
	vector<int> Q(N);
	rep(i, N) {
		cin >> Q[i];
	}
	int ans = 0;
	if (P > Q) {
		do {
			if (P == Q) {
				break;
			}
			ans++;
		} while (next_permutation(Q.begin(), Q.end()));
	}
	else {
		do {
			if (P == Q) {
				break;
			}
			ans++;
		} while (next_permutation(P.begin(), P.end()));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import math
N = int(input())

A=1
T=1
for i in range(N):
  t, a = [int(n) for n in input().split()]
  ct = T//t
  if T % t != 0:
    ct += 1
  ca = A//a
  if A % a != 0:
    ca += 1
  n = max(ct, ca)
  T = n*t
  A = n*a

print(A+T)

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) { cin >> v[i]; }

  int ans = 0, count = 0;
  for (int i = 0; i < n - 1; i++) {
    if (v[i] >= v[i + 1])
      count++;
    else {
      ans = max(ans, count);
      count = 0;
    }
  }

  ans = max(ans, count);
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
int main()
{
  int n,x,t,time;
  scanf("%d %d %d", &n,&x,&t);
  
  time =t * (n / x) ;
  if (n % x > 0) {
    time = time +t;
  }
  printf("%d",time);
    
  return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> t(n), a(n);
  rep(i, n) cin >> t[i];
  rep(i, n) cin >> a[i];

  vector<int> ht(n, -1), ha(n, -1);
  rep(i, n) if (i == 0 || t[i - 1] != t[i]) ht[i] = t[i];
  for (int i = n - 1; i >= 0; i--)
    if (i == n - 1 || a[i + 1] != a[i]) ha[i] = a[i];

  ll ans = 1;
  rep(i, n) {
    if (ht[i] == -1 && ha[i] == -1) {
      ans = (ans * min(t[i], a[i])) % MOD;
    } else if (ht[i] == -1) {
      if (t[i] < ha[i]) {
        ans = 0;
        break;
      }
    } else if (ha[i] == -1) {
      if (ht[i] > a[i]) {
        ans = 0;
        break;
      }
    } else if (ht[i] != ha[i]) {
      ans = 0;
      break;
    }
  }

  cout << ans << endl;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  string o;
  cin >> o;
  string e;
  cin >> e;
  string ans;
  int n = min(o.size(), e.size());
  rep(i, 0, n) {
    ans.push_back(o[i]);
    ans.push_back(e[i]);
  }
  if (o.size() > e.size())
    ans.push_back(o.back());
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256