akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <algorithm>
using namespace std;

int n, h;
#define maxn 100000
class sword {
public:
    //挥砍攻击力
    int a;
    //投掷攻击力
    int b;
    bool operator<(sword& as) {
        return b < as.b;
    }
}s[maxn+5];

int main() {
    int maxa = 0;
    int dmg=0;
    int att=0;

    cin>>n>>h;
    for (int i = 0; i < n; ++i) {
        cin>>s[i].a>>s[i].b;
    }

    //按投掷攻击力的大小排序（重载<运算符）
    sort(s, s + n);

    //找到挥砍攻击力最大的那把
    for (int i = 0; i < n; ++i) {
        maxa = s[maxa].a < s[i].a ? i : maxa;
    }
    //把投掷攻击力大于最大挥砍攻击力的剑从大到小依次扔出去
    for (int i = n - 1; dmg < h&&s[i].b> s[maxa].a;--i) {
        if (i == maxa)continue;//不能把最大挥砍攻击的剑扔了
        dmg += s[i].b; ++att;
    }

    //投掷攻击力更大的剑都扔出去了，剩下的伤害用最大挥砍攻击的剑完成
    if (dmg < h) {
        if (s[maxa].a > s[maxa].b) {//挥砍攻击力比投掷攻击力高，最后一下仍是挥砍攻击
            att +=  (h - dmg) / s[maxa].a;
            //向上取整
            if ((h - dmg) % s[maxa].a != 0) 
                ++att;

        }
        else {//挥砍攻击力比投掷攻击力低，最后一下可以投掷攻击
            //提前把投掷攻击的伤害算上
            att += 1; dmg += s[maxa].b;
            if (dmg < h) {
                att += (h - dmg) / s[maxa].a;
                //向上取整
                if ((h - dmg) % s[maxa].a != 0) 
                    ++att;
            }
        }
    }
    cout << att;
}


Measured memory_bytes: 1024
#include<iostream>
    #include<algorithm>
    #include<cstdio>
    #include<cmath>
    #include<cstring>
    #include<vector>
    #include<list>
    #include<map>
    #define endl "\n"
    #define eb emplace_back
    #define FOR(i, a, b) for(long long i = a; i < b; ++i)
    #define FORR(n) for(long long i = n - 1; i >= 0; --i)
    #define FORE(n) for(const auto &i : n)
    #define MS(n, i) memset(n, i, sizeof(n))
    typedef long long ll;
    inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
    inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
    using namespace std;
    
    /*
    bool desc(pair<ll, ll> a, pair<ll, ll> b)
    {
        return b.second > a.second;
    }
    
    ll total(string a)
    {
        int len = a.size();
        ll s = 0;
        FOR(i, 0, len)
        {
            s += a[i];
        }
        return s;
    }
    void SeivePrime(int n)
    {
        bool prime[n + 1];
        memset(prime, true, sizeof(prime));
        for(int p = 2; p * p <= n; p++)
        {
            if(prime[p])
            {
                for(int i = p * p; i <= n; i += p)
                    prime[i] = false;
            }
        }
    }
    */

    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while (t--)
        {
            int x;
            cin >> x;
            if(x >= 30)
                cout << "Yes" << endl;
            else
                cout << "No" << endl;
        }
    }


/*
input:
6
7
abacaba
7
???????
11
aba?abacaba
11
abacaba?aba
15
asdf???f???qwer
11
abacabacaba

output:
Yes
abacaba
Yes
abacaba
Yes
abadabacaba
Yes
abacabadaba
No
No
*/

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

#define ll long long
#define pii pair<int, int>
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

void solve() {
    int minX = -1000000;
    int maxX = 1000000;
    int K, X;
    cin >> K >> X;

    for (int i=0; i<2*K-1; i++) {
        cout << X - K + 1 + i;
        if (i!=2*K-2) cout << " ";
        else cout << endl;
    }

}

signed main() {
    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()
 
int main(){
  ll N,M,ans=0;
  cin >> N >> M;
  vector<P> A(N);
  rep(i,N){
    cin >> A.at(i).first >> A.at(i).second;
  }
  sort(all(A));
  priority_queue<ll> B;
  ll t=0;
  rep(i,M){
    while(t<N&&A.at(t).first<=i+1){
      B.push(A.at(t).second);
      t++;
    }
    if(!B.empty()){
      ans+=B.top();
      B.pop();
    }
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 5856
import java.util.*;
import java.io.*;
  class Main {
     static long gcd(long a,long b){if(b==0){return a;}return gcd(b,a%b);}

static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
 
  public static void main(String args[]) throws  IOException {
      assign();
    long[] a=long_arr();
    long n=a[0],k=a[1];
   
    if(n>k){
    	n=n%k;
    	out.write(Math.min(n,k-n)+"");
    }
    else{out.write(Math.min(n,k-n)+"");}
    
    out.flush();
    
  }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int t;
int main(){
	cin>>t;
	int c=t%10;
	if(c==3)cout<<"bon";
	else if(c==0 || c==1 || c==6 || c==8)cout<<"pon";
	else cout<<"hon";
	return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<set>
#define LL long long
LL N;
LL A[200010], map[200010];
std::set<LL> memo;
LL ans;
int main() {
	std::cin >> N;
	for (int i = 1; i <= N; i++) {
		std::cin >> A[i];
		map[A[i]] = i;
	}
	memo.insert(0);
	memo.insert(N + 1);
	for (int i = 1; i <= N; i++) {
		memo.insert(map[i]);
		auto it = memo.find(map[i]);
		LL l = *(--it);
		it++;
		LL r = *(++it);
		ans += (map[i] - l)*(r - map[i])*i;
	}
	std::cout << ans << std::endl;
	return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> sx(N), sy(N), tx(N), ty(N);
  vector<int> xs(N * 2), ys(N * 2);
  for (int i = 0; i < N; ++i) {
    cin >> sx[i] >> sy[i] >> tx[i] >> ty[i];
    xs[i * 2] = sx[i];
    ys[i * 2] = sy[i];
    xs[i * 2 + 1] = tx[i];
    ys[i * 2 + 1] = ty[i];
  }
  sort(begin(xs), end(xs));
  sort(begin(ys), end(ys));
  xs.erase(unique(begin(xs), end(xs)), end(xs));
  ys.erase(unique(begin(ys), end(ys)), end(ys));
  int szX = xs.size();
  int szY = ys.size();

  map<int, int> mpX, mpY;
  for (int i = 0; i < szX; ++i) mpX[xs[i]] = i;
  for (int i = 0; i < szY; ++i) mpY[ys[i]] = i;

  vector<vector<int>> imos(szX + 1, vector<int>(szY + 1, 0));
  for (int i = 0; i < N; ++i) {
    ++imos[mpX[sx[i]]][mpY[sy[i]]];
    --imos[mpX[sx[i]]][mpY[ty[i]]];
    --imos[mpX[tx[i]]][mpY[sy[i]]];
    ++imos[mpX[tx[i]]][mpY[ty[i]]];
  }

  for (int i = 0; i < szX + 1; ++i) {
    for (int j = 0; j < szY; ++j) imos[i][j + 1] += imos[i][j];
  }
  for (int i = 0; i < szX; ++i) {
    for (int j = 0; j < szY + 1; ++j) imos[i + 1][j] += imos[i][j];
  }

  ll ans = 0;
  for (int i = 0; i < szX; ++i) {
    for (int j = 0; j < szY; ++j) {
      if (imos[i][j] > 0) ans += 1LL * (xs[i + 1] - xs[i]) * (ys[j + 1] - ys[j]);
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 65952
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000001
using namespace std;
int arr[MAXX];
void trozen()
{
    int x,y;
    cin>>x>>y;
    int minn=x*2;
    int maxx=x*4;
    if(y%2==0&&y>=minn&&y<=maxx)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}
int32_t main()
{
    op1;op2;op3;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    trozen();
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
const string tr="abcdefghijklmnopqrstuvwxyz";
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}
bool ip/*is_prime*/(long long N) {if (N == 1) return false;for (long long i = 2; i * i <= N; ++i) {if (N % i == 0) return false;}return true;}
int digit(ll N) {int ans = 0;while (N) {++ans;N /= 10;}return ans;}
vector<pair<ll,ll>> pf/*prime_factorize*/(ll n){vector<pair<ll,ll>> res;for(ll a=2;a*a<=n;a++){if(n%a!=0) continue;ll ex=0;while(n%a==0){ex++;n/=a;}res.pb({a,ex});}if(n!=1) res.pb({n,1});return res;}

int main() {
  COMinit();
  ll n,m;
  cin>>n>>m;
  ll ans=1;
  auto p=pf(m);
  for(auto x:p){
    ans*=COM(x.second+n-1,n-1);
    ans%=MOD;
  }
  if(ans<0) ans+=MOD;
  cout<<ans<<endl;
}

Measured memory_bytes: 27060
#include <stdio.h>
int main() {
	int n,m,i,c1,c2;
	scanf("%d%d",&n,&m);
	int c[50];
	for(i=1;i<=n;i++) {
		c[i]=0;
	}
	for(i=0;i<m;i++){
		scanf("%d%d",&c1,&c2);
		c[c1]+= 1;
		c[c2]+= 1;
	}
	for(i=1;i<=n;i++){
		printf("%d\n",c[i]);
	}
	return 0;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto &x : a) cin >> x;
  if (is_sorted(a.begin(),a .end())) {
        cout << "YES\n";
        return 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      swap(a[i], a[j]);
      if (is_sorted(a.begin(),a .end())) {
        cout << "YES\n";
        return 0;
      } else {
        swap(a[i], a[j]);
      }
    }
  }
  cout<< "NO\n";
  return 0;
}


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

const int mod = 1e9 + 7;

string S;
int N;
int po[300010], psum[300010];

int cc[300010][2][2][2];
int dp(int idx, int p, int a, int b) {
    if(idx == N) return p && b;
    int &ret = cc[idx][p][a][b];
    if(ret != -1) return ret;

    ret = 0;
    if(S[idx] != '1') {
        ret += dp(idx + 1, 0, a, b);
        ret %= mod;
    }
    if(S[idx] != '0') {
        if(p) {
            if(idx % 2) {
                if(b) ret += po[ psum[idx + 1] ];
                else ret += dp(idx + 1, 1, 1, b);
            }
            else {
                ret += dp(idx + 1, 1, a, 1);
            }
        }
        else ret += dp(idx + 1, 1, a, b);
        ret %= mod;
    }
    return ret;
}

int main() {
    po[0] = 1;
    for(int i = 1; i < 300010; i++) {
        po[i] = po[i - 1] * 2 % mod;
    }

    cin >> S;

    N = S.size();
    for(int i = N - 1; i >= 0; i--) {
        psum[i] = S[i] == '?';
        psum[i] += psum[i + 1];
    }

    memset(cc, -1, sizeof(cc));
    printf("%d", dp(0, 1, 0, 0));
}


Measured memory_bytes: 35844
#include <iostream>

using namespace std;

const int max_n = (2e3) + 5;
const long long mod = (1e9) + 7;

int n,k;
int a[max_n];
int geng[max_n] = {0},eg[max_n] = {0};
long long inv = 0;

int main()
{
	cin >> n >> k;
	for(int i=0;i<n;++i)
		cin >> a[i];
	for(int i=0;i<n;++i)
	{
		for(int j=0;j<n;++j)
		{
			if(a[j]>a[i])
				++geng[i];
		}
	}
	for(int i=0;i<n;++i)
	{
		for(int j=0;j<i;++j)
		{
			if(a[j]>a[i])
				++eg[i];
		}
	}
	for(int i=0;i<n;++i)
		inv = (inv + ((1ll) * k * eg[i]) + (((((1ll) * (k-1) * k) / 2) % mod) * geng[i])) % mod;
	cout << inv << endl;
	return 0;
}

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

N = int(raw_input())
A = map(int, raw_input().split())
for i in range(N):
    v = A[i]
    j = i-1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print ' '.join(map(str, A))

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll A, B, K;
    cin >> A >> B >> K;

    ll taka = min(K, A);
    cout << A - taka << " " << max(B-(K-taka), 0ll) << endl;
    return 0;
}

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

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

int main(){
    int64_t A,B,C,D;
    cin >> A >> B >> C >> D;
    int count = 0;
    int64_t numC = B/C -(A - 1)/C;
    int64_t numD = B/D -(A - 1)/D;
    int64_t l = C*D/gcd(C, D);
    int64_t numCD = B/l - (A -1)/l;
    cout << (B - A + 1) - (numC + numD - numCD) << endl;
}

Measured memory_bytes: 256
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

N=I()
A=LI()

ans=0
f=1

for i in range(100):
    if f==0:
        break
    for j in range(N):
        if A[j]%2==0:
            A[j]=A[j]//2
        else:
            f=0
            break
    if f==1:
        ans+=1
    
print(ans)




Measured memory_bytes: 39408
H, W = map(int, input().split())
C = []
for i in range(H):
    C.append(list(input()))

# for k in range(len(C)):
#     C.insert(-1-2*k, C[-1-2*k])

for j in range(len(C)):
    print(''.join(C[j]))
    print(''.join(C[j]))

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan =new Scanner(System.in);
		int A =scan.nextInt();
		int B =scan.nextInt();
		int C =scan.nextInt();
		int K=scan.nextInt();
		int result=0;
		if(K<=A+B+C) {
			if(A>K)
				result=K;
			else 
			result=A*1;
			if(K-A>0) {
				result+=0*(K-A);
				if(K-A-B>0) {
					result+=-1*(K-A-B);
				}
			}
		}
		System.out.println(result);
		
	}
}


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

 int n;
 cin>>n;
 string k;
 cin>>k;

 int s=k.size();

 string m;
 if(s<=n){

    cout<<k<<endl;
 }

 else {

    k=k.substr(0,n);
    k+="...";
    cout<<k<<endl;

 }
}









Measured memory_bytes: 3632
function Main (input){
  input = input.split("\n");
  tmp = input[0].split(" ");
  var S = (tmp[0]);
  var answer = 0;
  if(S === 'SUN'){
    answer = 7;
  }else if(S === 'MON'){
    answer = 6;
  }else if(S === 'TUE'){
    answer = 5;
  }else if(S === 'WED'){
    answer = 4;
  }else if(S === 'THU'){
    answer = 3;
  }else if(S === 'FRI'){
    answer = 2;
  }else if(S === 'SAT'){
    answer = 1;
  }
  console.log(answer);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
	int a[100010];
	int m = 0;
	long long minx = 10000000000;
	int ans;
	int n, i;
	scanf("%d", &n);
	for (i = 0;i<n;i++){
		scanf("%d", &a[i]);
		m = max(m, a[i]);
	}
	sort(a, a + n);
	for (i = 0;i<n - 1;i++){
		if (abs(a[n - 1] / 2 - a[i]) <= minx){
			minx = abs(a[n - 1] / 2 - a[i]);
			ans = a[i];
		}
	}
	printf("%d %d", m, ans);
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void){
	
	char a;
	int i,j,A[4][13]={0},n;\
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf(" %c %d",&a,&j);
		switch(a){
			case 'S':
				A[0][j-1]=1;
				break;
			case 'H':
				A[1][j-1]=1;
				break;
			case 'C':
				A[2][j-1]=1;
				break;
			case 'D':
				A[3][j-1]=1;
				break;
		}
	}
	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			if(A[i][j]==0){
				switch(i){
					case 0:
						printf("S %d\n",j+1);
						break;
					case 1:
						printf("H %d\n",j+1);
						break;
					case 2:
						printf("C %d\n",j+1);
						break;
					case 3:
						printf("D %d\n",j+1);
						break;
				}
			}
		}
	}
	return 0;
}

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

int main(void){
  int a[5];
  for(int i = 0; i < 5; i++)
    cin >> a[i];
  
  int ans = 0;
  int x = 10;
  int cnt = 0;
  for(int i = 0; i < 5; i++){
    if(a[i] % 10 == 0){
      ans += a[i];
      cnt++;
    }else{
      ans += (((a[i] / 10) * 10) + 10);
      if(x > (a[i] % 10)){
        x = a[i] % 10;
      }
    }
  }
  if(cnt == 5){
    cout << ans << endl;
  }else{
    cout << (ans - 10 + x) << 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++)
#define REPR(i, n) for(int i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef unordered_map<ll, ll> ump;

const ll mod = 1e9+7;

ll max(ll a, ll b){
	if (a > b) return a;
	else return b;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<ll> a1(n);
	vector<ll> a2(n);
	REP(i, n){cin >> a1[i];}
	REP(i, n){cin >> a2[i];}
	ll ans = 0;
	REP(i, n){
		ll sum = 0;
		REP(j, i+1){
			sum += a1[j];
		}
		FOR(j, i, n){
			sum += a2[j];
		}
		ans = max(sum, ans);
	}
	cout << ans << endl;
}


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

int main() {
  int A=0, B=0, C=0;
  cin >> A >> B;
  
  for(int i=A; i<=B; i++){
    if(i / 10000 == i % 10){
      if(i / 1000 % 10 == i / 10 % 10){
        C += 1;
      }
    }
  }
  cout << C << endl; 
}

Measured memory_bytes: 3604
#include <iostream>

int main () {
	int A, B, C, X;
	int count = 0;
	std::cin >> A >> B >> C >> X;
	for (int a = 0; a <= A; a++) {
		for (int b = 0; b <= B; b++) {
			for (int c = 0; c <= C; c++) {
				if (a * 500 + b * 100 + c * 50 == X) count++;
			}
		}
	}
	std::cout << count << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i=0;i<N;i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    
    int alice=0;
    for(int i=0;i<N;i+=2){
        alice+=vec.at(i);
        }
    int bob=0;
    for(int i=1;i<N;i+=2){
        bob+=vec.at(i);
    }
    
        cout << alice - bob << endl;
    




}

Measured memory_bytes: 3632
using System;

namespace kadai2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split(' ');
            int a = int.Parse(array[0]);
            int b = int.Parse(array[1]);
            int t = int.Parse(array[2]);
            int sum = 0;
            int i;

            if (a < 1 || a > 20 || b < 1 || b > 20 || t < 1 || t > 20)
                Console.WriteLine("エラー");

            else
            {
                for(i=a; i<t+0.5; i = i + a)
                {
                    sum = sum+b;
                }
                Console.WriteLine(sum);
            }
        }
    }
}

Measured memory_bytes: 13140
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    S = input().strip()
    T = input().strip()

    ans = 0
    for i in range(3):
        if S[i] == T[i]:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 8988
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PI;
const LL N=100005;
LL n,S;
LL x[N],p[N];
vector<PI> vec[N];
void link (LL x,LL y,LL c)	{vec[x].push_back({y,c});}
LL ans[N];
void dfs (LL x)
{
	LL siz=vec[x].size();
	for (LL u=0;u<siz;u++)
	{
		LL y=vec[x][u].first,z=vec[x][u].second;
		ans[y]=ans[x]+z;
		dfs(y);
	}
}
int main()
{
	scanf("%lld%lld",&n,&S);
	for (LL u=1;u<=n;u++)	scanf("%lld%lld",&x[u],&p[u]);
	LL l=1,r=n;
	while (l<r)
	{	
		//printf("YES:%lld %lld\n",l,r);
		if (x[l]>=S)	{link(l,l+1,x[l+1]-x[l]);l++;}
		else if (x[r]<=S)	{link(r,r-1,x[r]-x[r-1]);r--;}
		else if (p[l]>=p[r]) {link(l,r,x[r]-x[l]);p[l]+=p[r];r--;}
		else {link(r,l,x[r]-x[l]);p[r]+=p[l];l++;}
	}
	ans[l]=abs(x[l]-S);
	dfs(l);
	printf("%lld\n",max(ans[1],ans[n]));
	return 0;
}

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

int main() {
  int X,Y,Z,K,i,j,n=0;
  cin >> X >> Y >> Z >> K;
  vector<ll> A(X),B(Y),C(Z),E(X*Y),F(min(X*Y,K)*Z);
  for(i=0; i<X; i++)
    cin >> A.at(i);
  for(i=0; i<Y; i++)
    cin >> B.at(i);
  for(i=0; i<Z; i++)
    cin >> C.at(i);
  
  for(i=0; i<X; i++)
    for(j=0; j<Y; j++)
      E.at(n++) = A.at(i)+B.at(j);
  sort(E.begin(), E.end(), greater<ll>());
  
  n=0;
  for(i=0; i<min(X*Y,K); i++)
    for(j=0; j<Z; j++)
      F.at(n++) = E.at(i)+C.at(j);
  sort(F.begin(), F.end(), greater<ll>());
  
  for(i=0; i<K; i++)
    cout << F.at(i) << endl;
}

Measured memory_bytes: 31616
import difflib

s = input()
t = input()

ans= len(t)

if t in s:
    print(0)
    exit()

for i in range(len(s) - len(t) + 1):
    diff = 0
    for j in range(len(t)):
        if s[j+i] != t[j]:
            diff = diff + 1

    ans = min(ans, diff)

print(ans)


Measured memory_bytes: 9928
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef pair<int,int> P;
int H,W,N;
int to(int w,int h){		//to(w,0)=w
	if(w==1){
		h=(h+2*W)%(2*W);
		if(h<W) return 1+h;
		else return 2*W-h;
	}
	if(w%2){
		return to(1,h+w-1);
	}
	return W+1-to(W+1-w,h);
}
int main(){
	cin>>H>>W>>N;
	vector<P> vc;
	rep(i,N){
		int a,b;
		cin>>a>>b;
		vc.pb(P(-a,b));
	}
	sort(all(vc));
	int o[200001];
	rep1(i,W) o[i]=i;
	for(P p:vc){
		int h=-p.fs,w=p.sc;
		if(h%2){
			swap(o[to(w,H-h+1)],o[to(w+1,H-h+1)]);
		}
		else{
			swap(o[to(w,H-h)],o[to(w+1,H-h)]);
		}
	}
	rep1(i,W) cout<<o[to(i,H)]<<endl;
}

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

int main() {
	string S ,tmp;
	long N;
	cin >> S >> N;
	vector<string> unit;
	for (int i = 0; i < S.size(); i++){
		if(i == 0){
			tmp = S.at(0);
		}else{
			if(S.at(i) != tmp.at(0)){
				unit.push_back(tmp);
				tmp = S.at(i);
			}else{
				tmp += S.at(i);
			}
		}
	}
	unit.push_back(tmp);

	long cnt = 0;
	if(unit.size() == 1){
		cnt = long(S.size() * N / 2);
	}else{
		for (int i = 1; i < unit.size() - 1; i++){
			cnt += long(unit.at(i).size() / 2);
		}
		cnt = cnt * N;

		
		if(unit.at(0).at(0) == unit.at(unit.size()-1).at(0)){
			cnt += long((unit.at(0).size() + unit.at(unit.size()-1).size()) / 2) * (N - 1);
			cnt += long(unit.at(0).size() / 2);
			cnt += long(unit.at(unit.size()-1).size() / 2);
		}else{
			cnt += long(unit.at(0).size() / 2) * N;
			cnt += long(unit.at(unit.size()-1).size() / 2) * N;
		}
	}

	cout << cnt << endl;

}


Measured memory_bytes: 256
<?php
list($N, $W) = array_map("intval", explode(" ", trim(fgets(STDIN))));
for($i = 0; $i < $N; $i++){
    $map[] = array_map("intval", explode(" ", trim(fgets(STDIN))));
}
array_unshift($map,[]);

for($j = 0; $j <= $W; $j++){
    $dp[0][$j] = 0;
}
for($i = 1; $i <= $N; $i++){
    list($w, $p) = $map[$i];
    $dpn = &$dp[$i];
    $dpp = &$dp[$i-1];
    for($j = 0; $j <= $W; $j++){
        $dpn[$j] = $dpp[$j];
    }
    for($j = $map[$i][0]; $j <= $W; $j++){
        $dpn[$j] = max($dpn[$j], $dpp[$j - $w] + $p);
    }
}
echo $dp[$N][$W];


Measured memory_bytes: 333836
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    x,y = map(int, input().split())
    a = 0
    b = 0
    if x==1:
        a += 300000
    if x==2:
        a += 200000
    if x==3:
        a += 100000
    if y==1:
        b += 300000
    if y==2:
        b += 200000
    if y==3:
        b += 100000
    if a+b == 600000:
        print(1000000)
    else:
        print(a+b)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int a, b, x;
	cin >> a >> b >> x;
	if (a + b >= x&&a<=x)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

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

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

    int N;
    cin >> N;

    vector<int> H(N);
    for(int i=0; i<N; i++)
        cin >> H.at(i);

    for(int i=N-2; i>=0; i--){
        if(H[i] <= H[i+1])
            continue;
        else
            H[i]--;
    }
    
    bool res = true;
    for(int i=0; i<N-1; i++){
        int cur =H.at(i), nxt = H.at(i+1);
        if(cur <= nxt)
            continue;
        else{
            res = false;
            break;
        } 
    }

    if(res == true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}

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

const int N = 18;
const int MN = (1 << N);

vector <int> e[MN];
vector <int> reve[MN];

int c[MN];

int req[MN];
int a[MN];

int cur;

set <int> avail;


void no() {
    cout << "NO\n";
    exit(0);
}

int dfs(int x) {
    if (a[x] != -1) {
        return a[x];
    }

    int vl = MN;

    for (int y : e[x]) {
        vl = min(vl, dfs(y));
    }

    auto it = avail.lower_bound(vl);

    if (it == avail.begin()) {
        no();
    }

    --it;
    vl = a[x] = *it;
    avail.erase(it);

    return vl;
}


int buf[MN];
int b[MN];
int inita[MN];

void dfsgo(int v, int val) {
    for (int u : e[v]) {
        if (dfs(u) <= val) {
            no();
        }
    }

    a[v] = val;
}

int n, k;

void cool() {
    for (int i = k; i > 0; --i) {
        copy(a, a + n, buf);
        int c = 1 << i;
        for (int l = 0; l < n; l += c) {
            int r = l + c;
            int md = (l + r) / 2;
            for (int cc = 0; cc < (md - l); ++cc) {
                a[l + cc] = buf[l + cc * 2];
                a[md + cc] = buf[l + cc * 2 + 1];
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        assert(a[i] == inita[i]);
    }
}

int main() {
#ifdef PAUNSVOKNO
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif

    cin >> k;
    n = (1 << k);
    cur = n - 1;
    fill(req, req + n, -1);

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < k; ++j) {
            if ((i & (1 << j)) == 0) {
                e[i].push_back(i + (1 << j));
            }
        }
    }

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

    for (int i = 0; i < n; ++i) {
        if (req[i] == -1) {
            avail.insert(i);
        }
    }

    for (int i = n - 1; i >= 0; --i) {
        if (req[i] != -1) {
            dfsgo(req[i], i);
        }
    }

    if (a[0] > 0) {
        no();

    }

    dfsgo(0, 0);
    copy(a, a + n, inita);

    for (int i = 2; i <= k; ++i) {
        copy(a, a + n, buf);
        for (int j = 0; j < (1 << (k - i)); ++j) {
            int l = (j << i);
            int r = ((j + 1) << i);
            int m = (l + r) / 2;

            for (int i2 = 0; i2 < (1 << (i - 1)); ++i2) {
                a[l + i2 * 2] = buf[l + i2];
                a[l + i2 * 2 + 1] = buf[m + i2];
            }
        }
    }



    cout << "YES\n";
    for (int i = 0; i < n; ++i) {
        cout << a[i] + 1 << " ";
    }

    cool();
}

Measured memory_bytes: 48512
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Obj[] arr = new Obj[n];
		for (int i = 0; i < n; i++) {
			Obj o = new Obj();
			o.i = i + 1;
			o.x = sc.nextInt();
			arr[i] = o;
		}
		sc.close();

		Arrays.sort(arr, (o1, o2) -> o1.x - o2.x);
		Queue<Integer> que = new ArrayDeque<>();
		for (Obj o : arr) {
			for (int i = 1; i < o.i; i++) {
				que.add(o.i);
			}
		}

		List<Integer> list = new ArrayList<>(n * n);
		int idx = 1;
		for (Obj o : arr) {
			while (idx < o.x) {
				if (que.isEmpty()) {
					System.out.println("No");
					return;
				}
				list.add(que.poll());
				idx++;
			}
			if (que.contains(o.i)) {
				System.out.println("No");
				return;
			}
			list.add(o.i);
			idx++;
			for (int i = o.i + 1; i <= n; i++) {
				que.add(o.i);
			}
		}

		System.out.println("Yes");
		StringBuilder sb = new StringBuilder();
		for (int i : list) {
			sb.append(i).append(' ');
		}
		while (!que.isEmpty()) {
			sb.append(que.poll()).append(' ');
		}
		sb.deleteCharAt(sb.length() - 1);
		System.out.println(sb.toString());
	}

	static class Obj {
		int i, x;
	}
}


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

#include <iostream>
#include <fstream>

#include <iostream>
#include <fstream>

#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

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

ll LCM(ll a, ll b) {
    return a/GCD(a,b)*b;
}

class DDerangement {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll n;in>>n;
        vector<ll> p(n);
        rep(i,n) {
            in>>p[i];
            --p[i];
        }
        ll cnt=0;
        rep(i,n-1){
            if(p[i]==i) {
                swap(p[i],p[i+1]);
                ++cnt;
            }
        }
        if(p[n-1]==n-1){
            swap(p[n-1],p[n-2]);
            ++cnt;
        }
        out<<cnt<<endl;
	}
};


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


Measured memory_bytes: 1024
#include <iostream>
int main() {
	int h, m, s;
	int S;
	std::cin >> S;
	s = S % 60;
	m = S / 60 % 60;
	h = S / 60 / 60;
	std::cout << h << ":" << m << ":" << s << std::endl;
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>

using namespace std;

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

  int N = S.length();
  for(int i = 0; i < N; i+= w){
    cout << S[i];
  }
  cout << endl;

  return 0;

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long;

int main()
{
	int x, y;
	cin >> x;
	cin >> y;
	if (x == 4 || x == 6 || x == 9 || x == 11)
		if (y == 4 || y == 6 || y == 9 || y == 11) {
			cout << "Yes" << endl;
			return 0;
		}
	if (x == 2 && y == 2) {
		cout << "Yes" << endl;
		return 0;
	}
	if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12)
		if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) {
			cout << "Yes" << endl;
			return 0;
		}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()

int ar[100005];
int32_t main(){
	int n;cin>>n;
	for(int i=1;i<=n;i++){
		cin>>ar[i];
	}
	stack<int> st;
	st.push(0);
	int ans = 0;
	for(int i=1;i<=n;i++){
		if(ar[i]==i){
			int t = st.top();st.pop();
			st.push(t+1);
		}
		else {
			st.push(0);
		}
	}
	while(!st.empty()){
		//cout<<st.top()<<"\n";
		int t = st.top();
		st.pop();
		ans += (t+1)/2;
	}
	cout<<ans;
}


Measured memory_bytes: 1792
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <utility>

#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
  ll n,k; cin >> n >> k;
  if(k%2 == 0){
    cout << (ll)pow(((n-n%k)/k),3)+(ll)pow((((n+k/2)-(n+k/2)%k)/k),3);
  } else {
    cout << (ll)pow(((n-n%k)/k),3);
  }
 
 return 0;
}

Measured memory_bytes: 384
/*
problem's name:
statue:
writer:Chris
*/
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#include <cctype>
#include <sstream>
#include <math.h>
#include <stdio.h>
#include <time.h>
#define mp make_pair
#define P pair<ll,ll>
#define MP(a,b) make_pair(a,b)
typedef long long ll;
using namespace std;
const ll INF=1e9;
/*------------main part------------*/
bool vis[1000005];
ll n,m,dis[1000005],head,tail,t,h[1000005];
ll cost;
priority_queue<P> q;
set<ll> in[1000005];
struct E
{
	ll v,c,next;
}g[1000005];
void ins(ll u,ll v,ll c)
{
	g[++t].v=v;
	g[t].c=c;
	g[t].next=h[u];
	h[u]=t;
}
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
int main()
{	while(cin>>n>>m)
	{
		memset(dis,0x3f,sizeof(dis));
		memset(vis,0,sizeof(vis));
		memset(g,0,sizeof(g));
		memset(h,0,sizeof(h));
		for(ll i=0;i<=n;i++)
		{
			in[i].clear();
		}
		for(ll i=1;i<=m;++i)
		{
			ll u,v,c;
			u=read(),v=read(),c=read();
			ins(u,v,c);
			ins(v,u,c);
		}
		q.push(mp(0,1));
		dis[1]=0;
		while(!q.empty())
		{
			ll u=q.top().second;
			cost=-q.top().first;
			q.pop();
			vis[u]=1;
			if(cost>dis[u]) continue;
			for(ll j=h[u];j;j=g[j].next)
			{
				if(vis[g[j].v])
				{
					continue;
				}
				ll v=g[j].v,c=g[j].c,d=dis[u]+(!in[u].count(c));
				if(d>dis[v])
				{
					continue;
				}
				if(d<dis[v])
				{
					q.push(MP(-d,v));
					dis[v]=d;
					in[v].clear();
				}
				in[v].insert(c);
			}
		}
		printf("%d\n",(int)dis[n]==1061109567?-1:dis[n]);
	}
}


Measured memory_bytes: 97268
//सत्यान्न प्रमदितव्यम्  ||
//Still, Taking my time to perfect the beats
//And I still got love for the streets, it's the A-D-D-U

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define nt _int128
#define fir first
#define sec second
#define fast_as_levi ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define debug(x) cout<<x<<"\n";
#define debugged cout<<"debugged\n";
#define inf 0x3f3f3f3f
#define LINF  0x3f3f3f3f3f3f3f3fll
#define rall(v) v.rbegin(),v.rend()
#define all(v) v.begin(),v.end() 

const ll mod = 999983;
#define mx 1000005
const ll mxi = 3005;

int main()
{
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a)
    {
        cout<<k;
    }
    else if(k<=a+b)
    {
        cout<<a;
    }
    else
    {
        cout<<a - min(k-(a+b),c);
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"
using namespace std;

int n,m;
string s;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
#ifdef LOCAL_DEFINE
    FILE *stream1;
    //FILE *stream2;
    stream1=freopen("in","r",stdin);
    //stream2=freopen("out","w",stdout);
    if(stream1==NULL)return 0;
    //if(stream2==NULL)return 0;
#endif
    cin>>n;
    set<int> se;
    for(int i=0;i<n;i++){
        int a;cin>>a;
        se.insert(a);
    }
    cout<<se.size()<<endl;
#ifdef LOCAL_DEFINE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    fclose(stream1);
    //fclose(stream2);
#endif
    return 0;
}


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

#define ll long long
#define y1 caibictq
#define P pair<int, int>
#define fi first
#define se second

using namespace std;

const int MAXN = 200010;
const int MAXM = 100010;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

ll n, m, k, d;
int tot, cnt, ans;

int read() {
	int f = 1, s = 0;
	char ch = getchar();
	while ('0' > ch || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
	while ('0' <= ch && ch <= '9') {s = (s << 1) + (s << 3) + ((int)ch ^ 48); ch = getchar();}
	return s * f;
}

int a[MAXN], b[MAXN];

string s;

int main() {
	int T;
	scanf("%lld%lld%lld", &n, &k, &d);
	n = abs(n);
	if (k <= n / d + 1) printf("%lld\n", abs(n - k * d));
	else {
		ll tmp = (k - n / d & 1) ? d : 0;
//		cout << tmp << " " << n % d << endl;
		ll minn = min(abs(n % d - tmp), n % d + tmp);
		printf("%lld\n", minn);
	}
//	if (n / d)
	return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b;
    cin >> n >> a >> b;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];

    vector<int> cnt(3, 0);
    for (int i = 0; i < n; i++) {
        if (p[i] <= a) cnt[0]++;
        else if (p[i] > b) cnt[2]++;
        else cnt[1]++;
    }
    cout << *min_element(cnt.begin(), cnt.end()) << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


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


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    return math.ceil(N/2)/N


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()


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


import sys
import math

# 1整数
# n = int(input())

# 空白区切り2整数
H, W = list(map(int, input().split()))
h, w = list(map(int, input().split()))

# 空白区切りリスト
print((H - h) *( W - w))


Measured memory_bytes: 2940
N = int(input())
h = list(map(int, input().split()))

dp = [float('inf') for _ in range(N)]

dp[0] = 0

for i in range(1, N):
    dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

print(dp[N-1])

Measured memory_bytes: 13928
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]



def main():
    s=input()
    if s=="AAA" or s=="BBB":
        print("No")
    else:
        print("Yes")


if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

ll modpow(ll a, ll b, ll p = 1e9+7){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

struct ModComb{
    vector<ll> po, inv;
    ll N;

    ModComb(ll n) : N(n), po(n), inv(n) {
        po[0] = 1;
        for(int i = 1; i < N; i++)  po[i] = (po[i-1] * i) % mod;
        inv[N-1] = modpow(po[N-1], mod-2, mod);
        for(int i = N-2; i >= 0; i--)   inv[i] = (inv[i+1] * (i+1)) % mod;
    }
    
    ll nCk(ll n, ll k){
        if(n < k)   return 0;
        return (((po[n]*inv[n-k])%mod)*inv[k])%mod;
    }

    ll nPk(ll n, ll k){
        if(n < k)   return 0;
        return (po[n]*inv[n-k])%mod;
    }

    ll nHk(ll n, ll k){
        if(n == 0 && k == 0)    return 1;
        return nCk(n+k-1, k);
    }
};

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

    ModComb mc(1001);
    if(n > k)   cout << 0 << endl;
    else        cout << mc.nCk(k, n) << endl;

    return 0;
}


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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int dp[81][81][80 * 200 * 2];
int main() {
    ll n, m, i, j, k;
    ll h, w;
    cin >> h >> w;
    ll A[h][w], B[h][w];
    for(i = 0; i < h; i++) {
        for(j = 0; j < w; j++) {
            cin >> A[i][j];
        }
    }
    for(i = 0; i < h; i++) {
        for(j = 0; j < w; j++) {
            cin >> B[i][j];
        }
    }
    ll cen = 80 * 200;
    dp[0][0][cen + abs(A[0][0] - B[0][0])] = 1;
    dp[0][0][cen - abs(A[0][0] - B[0][0])] = 1;
    for(i = 0; i < h; i++) {
        for(j = 0; j < w; j++) {
            for(k = 0; k < 80 * 200 * 2; k++) {
                if(dp[i][j][k] == 1) {
                    if(i != h - 1) {
                        if(k + abs(A[i + 1][j] - B[i + 1][j])<80*200*2) dp[i + 1][j][k + abs(A[i + 1][j] - B[i + 1][j])] = 1;
                        if(k - abs(A[i + 1][j] - B[i + 1][j]) >=0) dp[i + 1][j][k - abs(A[i + 1][j] - B[i + 1][j])] = 1;
                    }
                    if(j != w - 1) {
                        if(k + abs(A[i][j+1] - B[i][j+1]) < 80 * 200 * 2) dp[i][j+1][k + abs(A[i][j+1] - B[i][j+1])] = 1;
                        if(k - abs(A[i][j+1] - B[i][j+1]) >= 0) dp[i][j+1][k - abs(A[i][j+1] - B[i][j+1])] = 1;
                    }
                }
            }
        }
    }
    ll ret = INF;
    for(k=0;k<80*200*2;k++){
        if(dp[h-1][w-1][k]==1)ret = min(ret,abs(k-cen));
    }
    cout << ret << endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    long long H,W;
    cin >> H >> W;
    vector<long long> A(N);
    vector<long long> B(N);
    int count=0;
    for(int i=0;i<N;i++){
        cin >> A.at(i) >> B.at(i);
        if(A.at(i)>=H&&B.at(i)>=W) count++;
    }
    cout << count << endl;

}

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

bool exist[1000001];

int main(){
  for(int i=0;i<=1000000;++i){
    exist[i]=false;
  }
  
  int s;
  std::cin>>s;
  exist[s]=true;
  for(int i=2;;++i){
    if(s%2==0){
      s=s/2;
    }else{
      s=3*s+1;
    }
    if(exist[s]){
      std::cout<<i<<std::endl;
      return 0;
    }
    exist[s]=true;
  }
  
  return 0;
}


Measured memory_bytes: 1280
N = int(input())
word = []
for i in range(N):
    W = input()
    word.append(W)
if len(set(word)) != N:
    print("No")
else:
    for i in range(1,N):
        if list(word[i])[0] != list(word[i-1])[-1]:
            print("No")
            break
    else:
        print("Yes")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    int X,T;
    cin >> T >> X;

    double ans;

    ans = T / (double)X;

    cout << ans << endl;
    
}

Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 2000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

int gcd(int a, int b) {
  if(a < b) return gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

signed main(){
  int a,b,c;
  string s;
  int ans = 0;
  string ss;
  cin >> s;
  s[0] = s[0]+1;
  cout << s << endl;
  //cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int n;
  cin >> n >>s;
  for(int i=0;i<s.length();i++){
	if(s[i]+n == 'A'||s[i]+n == 'B'||s[i]+n == 'C'||s[i]+n == 'D'||
      s[i]+n == 'E'||s[i]+n == 'F'||s[i]+n == 'G'||s[i]+n == 'H'||
      s[i]+n == 'I'||s[i]+n == 'J'||s[i]+n == 'K'||s[i]+n == 'L'||
      s[i]+n == 'M'||s[i]+n == 'N'||s[i]+n == 'O'||s[i]+n == 'P'||
      s[i]+n == 'Q'||s[i]+n == 'R'||s[i]+n == 'S'||s[i]+n == 'T'||
      s[i]+n == 'U'||s[i]+n == 'V'||s[i]+n == 'W'||s[i]+n == 'X'||
      s[i]+n == 'Y'||s[i]+n == 'Z'){
      s[i]=s[i]+n;
	}else{
		s[i]=s[i]-26+n;
	}
  }
  cout << s;
  return 0;
}

Measured memory_bytes: 256