akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

constexpr ll _get_K_max(){
    ll ret = 1;
    for (unsigned int j = 0; j < 18; ++j) {
        ret *= 10;
    }
    return ret;
}

constexpr ll _get_square_K_max(){
    ll ret = 1;
    for (unsigned int j = 0; j < 9; ++j) {
        ret *= 10;
    }
    return ret;
}

static constexpr ll K_max = _get_K_max();

static constexpr ll square_K_max = _get_square_K_max();

pair<bool, ll> get_square(ll target){
    ll m = 1;
    ll M = square_K_max+1;
    while (true) {
        ll now = (m + M) / 2;
        ll sq = now * now;
        ll sq_plus = (now + 1) * (now + 1);
        if (sq < target){
            if (sq_plus > target) {
                return make_pair(false, now);
            } else {
                m = now;
            }
        } else if (sq > target) {
            M = now;
        } else {
            return make_pair(true, now);
        }
    }
}

ll calc(ll A, ll B){
    bool b;
    ll sq;
    ll K = A*B;
    tie(b, sq) = get_square(K);
    if (b){
//        (sq, sq)が抜けるので，必ずどの点も2点以上が保証される
        if (A == sq && B == sq){
            return 2 * sq - 2;
        } else {
            return 2 * sq - 3;
        }
    }else{
//        A * B = K
//        A < B とすると
//        (A-i)(B+i) < K [ただしi > 0]
//        ここで，AはBではないことから，
//        sq-i == A-i かつ sq+i == B+iになることはない
//        よって，どんな場合にもありえる最大-1通りが返せることが示される
        if (sq * (sq+1) < K) {
            return 2 * sq - 1;
        } else {
            return 2* sq - 2;
        }
    }
}

int main() {
    ll Q;
    cin >> Q;
    for (auto &&i: boost::irange(0LL, Q)){
        ll a, b;
        cin >> a >> b;
        cout << calc(a, b) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    from builtins import int, map, list, print
    from collections import defaultdict
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    X, Y = input_number_list()
    d = defaultdict(lambda: 0)
    d.update({3: 100000, 2: 200000, 1: 300000})
    ans = d[X] + d[Y]
    if X == Y == 1:
        ans += 400000
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;

int N, A, B, C;
vector<int> l;
ll INF = (1<<30);

ll dfs(int cur, int a, int b, int c){
    if (cur == N) {
        if (min(a,min(b,c))>0) {
            return abs(a-A)+abs(b-B)+abs(c-C) - 30;
        }
        else {
            return INF;
        }
    }
    ll ret0 = dfs(cur+1, a, b, c);
    ll ret1 = dfs(cur+1, a+l[cur], b, c) + 10;
    ll ret2 = dfs(cur+1, a, b+l[cur], c) + 10;
    ll ret3 = dfs(cur+1, a, b, c+l[cur]) + 10;

    return min(ret0, min(ret1, min(ret2, ret3)));
}

int main(int argc, char const *argv[])
{
    cin >> N >> A >> B >> C;
    for (int i = 0; i < N; ++i) {
        int li;
        cin >> li;
        l.emplace_back(li);
    }

    cout << dfs(0, 0, 0, 0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int a[50];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>s;
    int i,j,c=1,d;
    for(i=0; i<s.length(); i++)
    {
        if(s[i]>='a'&&s[i]<='z')
        {
            a[s[i]-'a']++;
        }

    }
    for(i=0; i<26; i++)
    {
        if(a[i]%2!=0)
        {
            c=0;
            break;
        }
    }
    if(c==0)
    {
        cout<<"No\n";
    }
    else
        cout<<"Yes\n";




    return 0;
}



Measured memory_bytes: 3624
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
#define non __builtin_popcount
#define ml map<ll, ll> 
#define ms map<string , ll> 
using namespace std;
 
bool isp[mx];
 
void sv(){
 
	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}
 
ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	
    ll n,a[mx], i, j;
    cin>>n;
    double an= 0.0;
    for(i=0; i< n; i++){
        cin>>a[i];
       // an+= (1.0/a[i]);
    }
    
    sort(a, a+n);

    double tmp= a[0];
    for(i=1; i< n; i++){

        tmp= (tmp+ a[i])/2.0;
    }

    cout<<tmp;

    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 256
#include <stdio.h>

const int MAX = 101;
int H,W,N;
int as[MAX*MAX];
int board[MAX][MAX];

void coloring(){
    int c = 0;
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            board[h][w] = c;
            as[c]--;
            if (as[c] == 0) {
                c++;
                if (c == N) {
                    return;
                }
            }
        }
        h++;
        for (int w = W-1; w >= 0; w--) {
            board[h][w] = c;
            as[c]--;
            if (as[c] == 0) {
                c++;
                if (c == N) {
                    return;
                }
            }
        }
    }
}
int main(){
    scanf("%d %d %d", &H, &W, &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &as[i]);
    }
    coloring();
    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            printf("%d ", board[h][w] + 1);
        }
        printf("\n");
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int D,T,S;
    cin>>D>>T>>S;
    float v;
    v=(float)D/S;
    if(v<=T)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)

bool cmp(pair<string,int> a,pair<string,int> b){
  if(a.first.size()<b.first.size())return true;
  if(a.first.size()==b.first.size() && a.first<b.first)return true;
  return false;

}


int main(void){
  map<string,int> m;
  int n;
  string s;int c;
  cin>>n;
  rep(i,n){
    cin>>s>>c;
    m[s]+=c;
  }
  vector<pair<string,int> > w;
  for(map<string,int>::iterator it=m.begin();it!=m.end();it++){
    w.push_back(make_pair(it->first,it->second));
  }
  sort(w.begin(),w.end(),cmp);
  for(vector<pair<string,int> >::iterator it=w.begin();it!=w.end();it++){
    cout<<it->first<<" "<<it->second<<endl;
  }
}

Measured memory_bytes: 1236
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println((b-a)%2==0?"Alice":"Borys");
	}

}


Measured memory_bytes: 21972
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
bool is_prime(int n){
  for(int i = 2; i * i <= n ; i++){
    if(n % i == 0) return false;
  }
  return true;
}

int main(){
  int m, a, b;
  while(cin>>m>>a>>b && b){
    int product = 0;
    int ansp, ansq;
    for(int p = 2; p * p <= m; p++)if(is_prime(p)){
      for(int q = p; ; q++){
        if(!((ll)a * q <= (ll)p * b)) break;
        if(!(q <= m / p)) break;
        if(!is_prime(q)) continue;
        if(product < p * q){
          product = p * q;
          ansp = p;
          ansq = q;
        }
      }
    }
    printf("%d %d\n", ansp, ansq);
  }
  return 0;
}

Measured memory_bytes: 1144
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      String s = sc.next();
      String t = sc.next();
      int cnt = 0;
      int x = -1;
      for(int i = 0;i < s.length();i++){
      	for(int j = 0;j < t.length()&&i+j<s.length();j++){
        	if(s.substring(j+i,j+i+1).equals("?")||s.substring(j+i,j+i+1).equals(t.substring(j,j+1)))cnt++;
        }
        if(cnt==t.length())x = i;
        cnt = 0;
      }
      if(x==-1){
      	System.out.println("UNRESTORABLE");
        return;
      }
      String first = "";
      String last = "";
      if(x>=1)first = s.substring(0,x);
      if(x+t.length()<=s.length()-1)last = s.substring(x+t.length(),s.length());
      StringBuilder sb = new StringBuilder();
      for(int i = 0;i < first.length();i++){
      	if(first.substring(i,i+1).equals("?"))sb.append("a");
        else sb.append(first.substring(i,i+1));
      }
      sb.append(t);
      for(int i = 0;i < last.length();i++){
      	if(last.substring(i,i+1).equals("?"))sb.append("a");
        else sb.append(last.substring(i,i+1));
      }
      System.out.println(sb.toString());
    }
}

Measured memory_bytes: 21844
void main()
{
    long[] abc = readln.split.to!(long[]);

    abc.sort!"a < b";
    long cnt = abc[2] - abc[1];
    long diff = abc[2] - abc[0] - cnt;
    cnt += (diff + 1) / 2 + diff % 2;

    cnt.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    ll n,m,ans=1;
    scanf("%lld%lld",&n,&m);
    // ll [n];
    if(n==1){
        printf("%lld\n",m);
        return 0;
    }
    rrep(i,m/n,2){
        if(m%i==0 ){
            ans=i;
            break;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
char A[2100];
char B[2100];
int dp[2100][2100];
int rev[2100][2100];
char ret[2100];
int main(){
	while(~scanf("%s",A)){
		int n=strlen(A);
		for(int i=0;i<n;i++)B[n-1-i]=A[i];
		for(int i=0;i<=n;i++)for(int j=0;j<=n;j++){
			dp[i][j]=-999999999;
			rev[i][j]=-1;
		}
		dp[0][0]=0;
		for(int i=0;i<=n;i++)for(int j=0;j<=n;j++){
			if(i<n&&j<n&&A[i]==B[j]&&dp[i+1][j+1]<dp[i][j]+1){
				dp[i+1][j+1]=dp[i][j]+1;
				rev[i+1][j+1]=2;
			}
			if(i<n&&dp[i+1][j]<dp[i][j]){
				dp[i+1][j]=dp[i][j];
				rev[i+1][j]=0;
			}
			if(j<n&&dp[i][j+1]<dp[i][j]){
				dp[i][j+1]=dp[i][j];
				rev[i][j+1]=1;
			}
		}
		ret[dp[n][n]]=0;
		int na=n;
		int nb=n;
		while(na||nb){
			if(rev[na][nb]==2){
				na--;nb--;
				ret[dp[na][nb]]=A[na];
			}else if(rev[na][nb]==1){
				nb--;
			}else{
				na--;
			}
		}
		printf("%s\n",ret);
	}
}

Measured memory_bytes: 34604
# -*- coding: utf-8 -*-
import sys

def main():
	Sa = list(input())
	Sb = list(input())
	Sc = list(input())

	next = "a"
	qa = Queue()
	qb = Queue()
	qc = Queue()
	for i in Sa:
		qa.enqueue(i)
	for i in Sb:
		qb.enqueue(i)
	for i in Sc:
		qc.enqueue(i)

	while True:
		if next == "a":
			next = qa.dequeue()
			if next == None:
				print("A");
				sys.exit();
		if next == "b":
			next = qb.dequeue()
			if next == None:
				print("B");
				sys.exit();
		if next == "c":
			next = qc.dequeue()
			if next == None:
				print("C");
				sys.exit();

class Queue:
    def __init__(self, queue = None):
        if type(queue) is type([]):
            self.queue = queue
        else:
            self.queue = []

    def enqueue(self, e):
        self.queue.append(e)
        return self.queue

    def dequeue(self):
        try:
            qEl = self.queue[0]
            del self.queue[0]
            return qEl
        except IndexError:
            return None


if __name__ == "__main__":
	main()


Measured memory_bytes: 3064
/** author: __nishad__ **/
//#pragma GCC optimize(2)
//#pragma GCC optimize(3, "Ofast", "inline")
#include<bits/stdc++.h>
using namespace std;


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a,b) for(ll i=(a);i<=(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;

    int n, a, b, count=0;
    cin>>n;

    loop(i, 1, n){
        cin>>a>>b;
        count = count + b - a +1;
    }

    cout<<count;



}





























Measured memory_bytes: 3580
import collections
 
n = int(input())
d = list(map(int,input().split()))
MOD = 998244353
#頂点1が0でないとだめ
if d[0]!=0:
  print(0)
  exit()
  
#同じ長さの位置に何個頂点があるか
cnt = dict(collections.Counter(d))
#頂点1だけが0じゃないとだめ
if cnt[0]==1:
  m = max(cnt)
  #一番大きい数字までにちゃんとすべての数字が揃ってないとだめ
  for i in range(m):
    if i not in cnt:
      print(0)
      exit()
  ans = 1
  for i in range(m):
    val_1 = cnt[i]
    val_2 = cnt[i+1]
    ans *= (val_1**val_2)%MOD
 
  print(ans%MOD)
else:
  print(0)

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

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

const int mod=1e9+7;

int n,m;
char ara[1010][1010];
int dp[1010][1010];

void chk(int s,int e)
{
	for(int i=s;i<n+1;i++)
	{
		for(int j=e;j<m+1;j++) if(ara[i][j]=='.') { dp[i][j]=dp[i-1][j]+dp[i][j-1]; dp[i][j]%=mod; }
	}
}

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

	cin>>n>>m;
	for(int i=1;i<n+1;i++) for(int j=1;j<m+1;j++) cin>>ara[i][j];
	
	if(ara[1][1]=='.') dp[1][1]=1;
	
	chk(1,2);
	chk(2,1);

	cout<<dp[n][m];
			
	cerr << "\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	
	return 0;
}


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

int main(){
  int N, A;
  int chk;
  
  cin >> N >> A;
  chk = N % 500;
  if(chk == 0){
    cout << "Yes" << endl;
  }else if((A - chk) > 0){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
}
  

Measured memory_bytes: 3608
import java.util.*;
 
public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        int d[] = new int[n];
        for(int i = 0; i < n; i++){
        	d[i] = sc.nextInt();
        }
        Arrays.sort(d);
        int count = 1;
        for(int i = 1; i < n; i++){
        	if(d[i] != d[i - 1]){
            	count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 36024
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;
string sJudge;
void judge(){
    int a, b;
    cin >> a >> b;
	if(a % 2 ==0 || b % 2 == 0){
    	sJudge = "Even";
    } else {
    	sJudge = "Odd";
    }  
}

int main(){
    judge();
	cout << sJudge << endl;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N = 4e5 + 50;

/*
int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
int gcd(int a,int b){ return !b?a:gcd(b,a%b); }
*/

int n, a[N], vis[N];
long long k;
vector<int> g[N], c, w;

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("d.in", "r", stdin); 
#endif
	scanf("%d %lld", &n, &k); 
	lop(i, 0, n) {
		scanf("%d", a + i); 
		a[n + i] = a[i];
		g[a[i]].pb(i); 
		g[a[i]].pb(n + i); 
	}
	lop(i, 0, N) sort(all(g[i]));
	c.pb(0); w.pb(0);
	while (true) {
		int last = c.back(), f = 0; 
		int p = *upper_bound(all(g[a[last]]), last);
		++p;
		while (p >= n) p -= n, f += 1;
		c.pb(p), w.pb(f);
		if (p == 0) break;
	}
	--k;
	int len = 0;
	for (int x : w) len += x;
	k %= len;
	
	int p = 0;
	for (int i = 1;i < c.size();++i) {
		if (k < w[i]) break; else k -= w[i];
		p = c[i];
	}
	
	vector<int> ans;
	lop(i, p, n) {
		if (vis[a[i]]) {
			int t;
			do {
				t = ans.back(); 
				vis[t] = 0; 
				ans.pop_back();
			} while (t != a[i]); 
			continue;
		}
		vis[a[i]] = 1;
		ans.pb(a[i]); 
	}
	
	for (int x : ans) printf("%d ", x) ; puts(""); 
	return 0;
}

Measured memory_bytes: 22764
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	a, _ := strconv.Atoi(sc.Text())
	sc.Scan()
	b, _ := strconv.Atoi(sc.Text())
	fmt.Println(a + b/2)
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  int a_ct = count(s.begin(), s.end(), 'a');
  int b_ct = count(s.begin(), s.end(), 'b');
  int c_ct = count(s.begin(), s.end(), 'c');

  float mean = float(a_ct + b_ct + c_ct) / 3;
  // cout << mean << endl;
  if (abs(a_ct - mean) < 1 && abs(b_ct - mean) < 1 && abs(c_ct - mean) < 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 512
import java.io.BufferedInputStream;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;

public class Main {

    public static void main(String[] args) {
        Scanner sc=new Scanner(new BufferedInputStream(System.in));
        int a=sc.nextInt();
        int b=a%10;
        int c=a/100;
        int d=a/10%10;
        if(b==7||c==7||d==7)
            System.out.println("Yes");
        else
            System.out.println("No");


    }
}


Measured memory_bytes: 35700
#include<bits/stdc++.h>
#define endl "\n" 
#define pi acos(-1)
#define ll long long 
using namespace std;
void att(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
}
void sirra(){
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
}
void solve();
int main(){
	att();sirra();
	int q=1;//cin>>q;
	while(q--){
		solve();
	}
}
void solve(){
	char a;cin>>a;
	if(a>64 && a<91)
		cout<<"A";
	else 
		cout<<"a";
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;

int N;
vector<int> graph[1005]; // 0-indexed

vector<int> bfs(int sv) {
    vector<int> dist(N, INF);
    dist[sv] = 0;
    vector<int> pre(N, -1);
    queue<int> que;
    que.push(sv);
    while(!que.empty()) {
        int cur = que.front(); que.pop();
        for (int next : graph[cur]) {
            if (dist[next] != INF) continue;
            pre[next] = cur;
            que.push(next);
            dist[next] = dist[cur] + 1;
        }
    }
    // 最小のサイクルを探す
    P best(INF, -1);
    rep(i, N) {
        if (i == sv) continue;
        for (int a : graph[i]) {
            if (a == sv) {
                best = min(best, make_pair(dist[i], i));
            }
        }
    }
    if (best.first == INF) return vector<int> (N+1);
    vector<int> ret;
    int cur = best.second;
    while (cur != -1) {
        ret.push_back(cur);
        cur = pre[cur];
    }
    return ret;
}

int main() {
    int M;
    cin >> N >> M;
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        graph[a].push_back(b);
    }
    vector<int> ans(N+1);
    rep(i, N) {
        vector<int> cur = bfs(i);
        if (sz(cur) < sz(ans)) ans = cur;
    }
    if (sz(ans) == N+1) {
        cout << -1 << '\n';
        return 0;
    }
    cout << sz(ans) << '\n';
    for (int a : ans) {
        cout << a+1 << '\n';
    }
    return 0;
    // ll, 0, -, 1i, for s&g, debug
}

Measured memory_bytes: 3712
#include<iostream>
#include<string>
using namespace std;
int main(){
    string s1,s2;
    int count=0,n;
    cin>>s1>>s2;
    n=s1.length();
    for(int i=0;i<n;i++){
        if(s1[i]!=s2[i])count++;
    }
    cout<<count;
}

Measured memory_bytes: 3916
#include <stdio.h>

typedef struct List {
	struct List *next;
	int v;
} list;

int main()
{
	int i, N, M, u, w;
	list *adj[100001] = {}, e[400001];
	scanf("%d %d", &N, &M);
	for (i = 0; i < M; i++) {
		scanf("%d %d", &u, &w);
		e[i*2].v = w;
		e[i*2+1].v = u;
		e[i*2].next = adj[u];
		e[i*2+1].next = adj[w];
		adj[u] = &(e[i*2]);
		adj[w] = &(e[i*2+1]);
	}
	
	int iso = 0, bip = 0, nonbip = 0, flag[100001] = {}, q[100001], head, tail, tmp;
	list *p;
	for (i = 1; i <= N; i++) {
		if (flag[i] != 0) continue;
		
		flag[i] = 1;
		if (adj[i] == NULL) {
			iso++;
			continue;
		}
		
		q[0] = i;
		for (head = 0, tail = 1, tmp = 0; head < tail; head++) {
			u = q[head];
			for (p = adj[u]; p != NULL; p = p->next) {
				w = p->v;
				if (flag[w] == 0) {
					flag[w] = -flag[u];
					q[tail++] = w;
				} else if (flag[w] == flag[u]) tmp = 1;
			}
		}
		if (tmp != 0) nonbip++;
		else bip++;
	}
	
	printf("%lld\n", (long long)iso * (N * 2 - iso) + (long long)(bip + nonbip) * (bip + nonbip) + (long long)bip * bip);
	fflush(stdout);
	return 0;
}

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

int main(){
    int n; cin >> n;
    vector<int>A(n);
    for(int i=0;i<n;i++){
        cin >> A.at(i);
    }
    sort(A.begin(), A.end());
    cout << abs(A.at(0) - A.at(n - 1)) << endl;
}

Measured memory_bytes: 256
n = int(input())
ans = n

if 8 < n:
    num = 8
    ans = 8
    add = 1
    flag = 0
    
    while 1:
        add *= 10
        
        for i in range(9):
            num += add
            ans += 1
            
            if n <= num:
                flag = 1
                break
                
        if flag == 1:
            break
            
print(ans)

Measured memory_bytes: 9056
def d_factorization(MOD=10**9 + 7):
    N, M = [int(i) for i in input().split()]

    def prime_factorization_dict(n):
        if n == 1:
            return {2: 0}  # 1は素数の0乗の積とみなす
        i, table = 2, {}
        while i**2 <= n:
            table[i] = 0
            while n % i == 0:
                table[i] += 1
                n //= i
            if table[i] == 0:
                table.pop(i)
            i += 1
        if n > 1:
            table[n] = 1
        return table

    class Combination(object):
        """参考: https://harigami.net/contents?id=5f169f85-5707-4137-87a5-f0068749d9bb"""
        __slots__ = ['mod', 'factorial', 'inverse']

        def __init__(self, max_val_arg: int = 10**6, mod: int = 10**9 + 7):
            fac, inv = [1], []
            fac_append, inv_append = fac.append, inv.append

            for i in range(1, max_val_arg + 1):
                fac_append(fac[-1] * i % mod)

            inv_append(pow(fac[-1], mod - 2, mod))

            for i in range(max_val_arg, 0, -1):
                inv_append((inv[-1] * i) % mod)

            self.mod, self.factorial, self.inverse = mod, fac, inv[::-1]

        def combination(self, n, r):
            if n < 0 or r < 0 or n < r:
                return 0
            return self.factorial[n] * self.inverse[r] * self.inverse[n - r] % self.mod

        def combination_with_repetition(self, n, r):
            if n == 0 and r > 0:
                return 0
            if n >= 0 and r == 0:
                return 1
            return self.combination(n + r - 1, r)

    prime_m = prime_factorization_dict(M)
    h = Combination(max(prime_m.values()) + N - 1).combination_with_repetition
    ans = 1
    for b in prime_m.values():
        ans = (ans * h(N, b)) % MOD
    return ans

print(d_factorization())

Measured memory_bytes: 11824
package main

import (
	"fmt"
)

func main() {
	var l, r, d int
	fmt.Scan(&l, &r, &d)

	var cnt int
	for i := l; i <= r; i++ {
		if i%d == 0 {
			cnt++
		}
	}

	fmt.Println(cnt)
}

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

int main() {
	string s, a, b;
	cin >> s;
	int n = s.size(), cnt1 = 0, cnt2 = 0;
	for ( int i = 0; i < n; i++ ) {
		if ( i % 2 ) {
			a += '1';
			b += '0';
		} 
		else {
			a += '0';
			b += '1';
		}
	}
	for ( int i = 0; i < n; i++ ) {
		if ( s[i] != a[i] ) {
			cnt1++;
		}
		if ( s[i] != b[i] ) {
			cnt2++;
		}
	}
	cout << min( cnt1, cnt2 );
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		int ans = 999;
		for (int i = 0; i < S.length() - 2; i++) {
			String ss = S.substring(i, i + 3);
			int num = Integer.parseInt(ss);
			if (ans > Math.abs(num - 753))
				ans = Math.abs(num - 753);
		}
		System.out.println(ans);
	}
}


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

const int MOD = 1e9+7;

int main(){

  string S; cin >> S;
  int sl = S.size();
  vector<vector<long long>> dp(sl+1, vector<long long>(13));

  dp.at(0).at(0) = 1;
  for(int i=0; i<sl; i++){
    
    int c;
    if(S.at(i) == '?')
      c = -1;
    else
      c = S.at(i) - '0';
      
    if(c != -1){
      for(int j=0; j<13; j++)
        dp.at(i+1).at( (j*10+c)%13 ) += dp.at(i).at(j);
    }else{
      for(int j=0; j<13; j++)
        for(int k=0; k<10; k++)
          dp.at(i+1).at( (j*10+k)%13 ) += dp.at(i).at(j);     
    }
    
    for(int j=0; j<13; j++)
      dp.at(i+1).at(j) %= MOD;
  
  }
  cout << dp.at(sl).at(5) << endl;

}

Measured memory_bytes: 13696
#include<iostream>
using namespace std;
 
class Dice{
		int _num[6];
		
	public:
        void set(int num[6]){
            for(int i = 0; i < 6; i++) 
				_num[i] = num[i];
        }
		int Get(int n){
			return _num[n];
		}
		void N(){
			swap(_num[0],_num[4]);
			swap(_num[0],_num[5]);
			swap(_num[0],_num[1]);
		}
		void S(){
			swap(_num[0],_num[1]);
			swap(_num[0],_num[5]);
			swap(_num[0],_num[4]);			
		}
		void W(){
			swap(_num[0],_num[3]);
			swap(_num[0],_num[5]);
			swap(_num[0],_num[2]);			
		}
		void E(){
			swap(_num[0],_num[2]);
			swap(_num[0],_num[5]);
			swap(_num[0],_num[3]);			
		}
		void SetTop(int n){
			if(_num[2] == n) 
				W();
			else if(_num[3] == n)
				E();
			else{
				for(int i = 0; i < 4; i++){
					if(_num[0] == n) break;
					S();
				}
			}
		}
		void SetFront(int n){
			for(int i = 0; i < 4; i++){
				if(_num[1] == n) break;
				S();
				W();
				N();
			}
		}

		bool SameAs(Dice other){
			other.SetTop(this->Get(0));
			other.SetFront(this->Get(1));
			
			bool same = true;
			for(int i = 0; i < 6; i++){
				if(other.Get(i) != this->Get(i)){
					same = false;
					break;
				}
			}
			return same;
		}
};
 
int main(){
	int n;
	cin >> n;
	
	Dice dice[n];
	for(int i = 0; i < n; i++){
		int num[6];
		for(int j = 0; j < 6; j++){
				cin >> num[j];
		}
		dice[i].set(num);
	}
	for(int i = 0; i < n; i++){
		for(int j = i + 1; j < n; j++){
			if(dice[i].SameAs(dice[j])){
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;
}

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

#A,B,Cの空港
#P,Q,R時間かかる
#最短何時間？

#入力
line = input().split()
ab = int(line[0])
bc = int(line[1])
ca = int(line[2])

#最小時間を求める
time = [ab, bc, ca]
min_time = sum(time) - max(time)

print(min_time)

Measured memory_bytes: 3060
def ABC088D():
    
    H, W = map(int, input().split())
    s = [list(input()) for i in range(H)]
    visited = [[False for i in range(W)] for i in range(H)]
    black_cnt = 0
    for i in range(H):
        for j in range(W):
            if s[i][j] == "#":
                visited[i][j] = True
                black_cnt += 1
    will_visit = [[0, 0, 0]]
    def sarch(i, j, dist):
        visited[i][j] = True
        if 0 <= i - 1:
            if not visited[i - 1][j]:
                will_visit.append([i - 1, j, dist + 1])
        if 0 <= j - 1:
            if not visited[i][j - 1]:
                will_visit.append([i, j - 1, dist + 1])
        if j + 1 < W:
            if not visited[i][j + 1]:
                will_visit.append([i, j + 1, dist + 1])
        if i + 1 < H:
            if not visited[i + 1][j]:
                will_visit.append([i + 1, j, dist + 1])

    key = 0
    next = 0
    while len(will_visit) > next:
        #print(will_visit)
        next_i = will_visit[next][0]
        next_j = will_visit[next][1]
        next_dist = will_visit[next][2]
        if not visited[next_i][next_j]:
            if next_i == H - 1 and next_j == W - 1:
                key = next_dist
                break
            sarch(next_i, next_j, next_dist)
        if key != 0:
            break
        next += 1
    if key == 0:
        print(-1)
    else:
        key += 1
        print(H * W - key - black_cnt)
        
ABC088D()

Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
	ll N;
	cin >> N;
	ll ans=0,tmp=5;
	if(N%2==0){
		while(N>=tmp){
			ans+=N/tmp/2;
			tmp*=5;
		}
	}
	cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int,int>mp;
int a[101010],b[101010];
bool flag;
int n,s,num,ans;
int dog[202020],fa[202020];
bool br[202020];
int find(int x)
{
	if (fa[x]==x) return x;
	fa[x]=find(fa[x]);
	return fa[x];
}
void merge(int x,int y)
{
	x=find(x); y=find(y);
	if (x!=y) fa[x]=y;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&a[i]),s^=a[i];
	for (int i=1;i<=n;++i)
	{
		scanf("%d",&b[i]);
		if (s==b[i]) flag=1;
	}
	for (int i=1;i<=n;++i)
	{
		if (!mp[a[i]]) ++num,mp[a[i]]=num;
		a[i]=mp[a[i]];
		if (!mp[b[i]]) ++num,mp[b[i]]=num;
		b[i]=mp[b[i]];
	}
	if (!mp[s]) ++num,mp[s]=num;
	s=mp[s];
 
	for (int i=1;i<=n;++i) ++dog[a[i]];
	++dog[s];
	for (int i=1;i<=n;++i)
	{
		--dog[b[i]];
		if (dog[b[i]]<0) 
		{
			printf("-1\n");
			return 0;
		}
	}
//	printf("?\n");
	
	for (int i=1;i<=num;++i) fa[i]=i;
	for (int i=1;i<=n;++i) if (a[i]!=b[i])
	{
		++ans;
		br[a[i]]=br[b[i]]=1;
		merge(a[i],b[i]);
	}
	for (int i=1;i<=num;++i) if (br[i])
		if (find(i)==i) ++ans;
	printf("%d\n",max(ans-flag,0));
	return 0;
}

Measured memory_bytes: 8192
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def main():
    K = int(input())
    ans = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            for k in range(1, K+1):
              ans += gcd(i, j, k)

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 69320
#include <stdio.h>
int main(){
  int m,n,i,j,a[100][100],b[100],c[100];
  scanf("%d %d",&n,&m);
  for(i=0; i<n; i++){
    for(j=0; j<m; j++){
      scanf("%d ",&a[i][j]);
    }   
  }
  for(j=0; j<m; j++){
    scanf("%d",&b[j]);
  }
  for(i=0; i<n; i++){
    c[i]=0;
  }
  for(i=0; i<n; i++){
    for(j=0; j<m; j++){
      c[i]+=(a[i][j]*b[j]);
    }
  }//-----                          
 for(i=0; i<n; i++){
    printf("%d\n",c[i]);
  }
  return 0;
}


Measured memory_bytes: 2076
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int N, W; cin >> N; cin >> W;
    int v[N], w[N];
    REP(i,N){
        cin >> w[i];
        cin >> v[i];
    }
    int vmax = N * 1000 + 10; //上限は余裕を持って
    ll wmax = N * 1e10 + 10; //取っておいたほうが無難
    ll DP[N+1][vmax+1] = {};
    REP(i, N+1){
        REP(j, vmax+1){
            DP[i][j] = wmax;
        }
    }
	DP[0][0] = 0;
    REPS(i, N){
        REP(j, vmax+1){
            if (j - v[i-1] >= 0) chmin(DP[i][j], DP[i-1][j-v[i-1]] + w[i-1]);//一行で書かないほうが良い。
            chmin(DP[i][j], DP[i-1][j]);
        }
    }
  	
    int res = 0;
    REP(j, vmax + 1){
        if (DP[N][j] <= W) {
            chmax(res, j);//増加しているのでres = jで良い。

        }
    }
    
    cout << res;
}

Measured memory_bytes: 79104
dice, target = input().split()
dice, target = int(dice), int(target)

dev = 1.0
OK = 0
rem = dice
while 1:
  if rem <= 0:
    break
  elif rem >= target:
    OK += (rem-target+1)*dev
    rem = target-1
  target = int((target+1)/2)
  dev /= 2.0
      
print('{:.10f}'.format(OK/dice))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<vector<int>> a(n,vector<int>(m));
	rep(i,n){
		rep(j,m){
			cin>>a[i][j];
			a[i][j]--;
		}
	}
	int ret=m,ans=INF;
	vector<bool> ng(m,false);
	while(ret--){
		map<int,int> now;
		rep(i,n){
			rep(j,m){
				if(ng[a[i][j]]) continue;
				now[a[i][j]]++;
				break;
			}
		}
		int nans=0,ma=0;
		for(auto itr:now){
			if(chmax(nans,itr.se)){
				ma=itr.fi;
			}
		}
		ng[ma]=true;
		chmin(ans,nans);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))
num = dict()
ans = 0

for i in range(n):
    num[i+a[i]] = 0

for i in range(n):
    if i-a[i] in num:
        ans += num[i-a[i]]
    num[i+a[i]] += 1
print(ans)
    


Measured memory_bytes: 40332
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

vvll dp(5005, vll(5005));

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  string S;
  cin >> S;
  
  for(int i = N-1; i >= 0; i--){
    for(int j = N-1; j >= 0; j--){
      if(S.at(i) != S.at(j)) dp.at(i).at(j) = 0;
      else dp.at(i).at(j) = dp.at(i+1).at(j+1) + 1;
    }
  }
  ll ans = 0LL;
  for(ll i = 0; i < N-1; i++){
    for(ll j = i+1; j < N; j++){
      ll res = min(dp.at(i).at(j), j-i);
      chmax(ans, res);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 198144
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int a,b,c;cin>>a>>b>>c;
    if(b-a==c-b)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
signed main(void) {
    int H, W;
    cin >> H >> W;
    char G[H][W];
    rep(i, H) rep(j, W) cin >> G[i][j];
    vector<vector<int>> dist(H, vector<int>(W, INF));
    if(G[0][0] == '#')
        dist[0][0] = 1;
    else
        dist[0][0] = 0;
    rep(i, H) rep(j, W) {
        if(i < H - 1) {
            int res;
            if(G[i][j] == '.' && G[i + 1][j] == '#')
                res = 1;
            else
                res = 0;
            dist[i + 1][j] = min(dist[i + 1][j], dist[i][j] + res);
        }
        if(j < W - 1) {
            int res;
            if(G[i][j] == '.' && G[i][j + 1] == '#')
                res = 1;
            else
                res = 0;
            dist[i][j + 1] = min(dist[i][j + 1], dist[i][j] + res);
        }
    }
    cout << dist[H - 1][W - 1] << endl;
}


Measured memory_bytes: 384
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define fe(vec,lambda) std::for_each(vec.begin(), vec.end(), lambda );
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}
inline bool operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){vector<pair<T,T>> out(input.size()-1);rep(i,input.size()-1){out[i].first =input[i  ];out[i].second=input[i+1];}return(out);}
vector<char> String_to_vector_char(const string& input){vector<char> out(input.size());rep(i,input.size()){out[i]=input[i];}return out;}
void YesNo(bool flag){ cout<<(flag? "Yes":"No");}

ll a,b,c,d,n,x;
vector<ll>v[3];
map<ll,ll>m;
string s,s2,s3,s4;
void input(){
    cin>>s>>s2;
    s3=s,s4=s2;
    reverse(s.begin(),s.end());
    reverse(s2.begin(),s2.end());
}
void src(){
    cout<<(s3==s2 and s==s4? "YES":"NO" );
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<bits/stdc++.h>
#define forv(v) for(vector <int> :: iterator iter=v.begin();iter!=v.end();++iter)
#define form(v) for(map<int,int> :: iterator iter=v.begin();iter!=v.end();++iter)
#define rep1(i,a,b) for(int i=(a);(i)<=(b);(i)++)
#define rep(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ford(i,a,b) for(int i=(a);i>=b;i--)
#define rall(v) (v).rbegin(),(v).rend()
#define all(v) (v).begin(),(v).end()
#define rev(a,n) reverse(a,a+n)
#define pql priority_queue<ll>
#define ort1(a) sort(a+1,a+n+1)
#define ort(a) sort(a,a+n)
#define LL long long
#define N 500005
using namespace std;
int n,res;
string s;
int main(){
	cin>>n>>s;
	queue<int> pos;
	rep(i,0,n) {
		if(s[i]=='W') pos.push(i);
	}
	ford(i,n-1,0){
		if(s[i]=='W') continue;
		if(pos.empty()) break;
		int p=pos.front();
		pos.pop();
		if(p>i) break;
		else {
			swap(s[p],s[i]);
			res++;
		}
	}
	cout<<res<<"\n";
	return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= int(n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
    x = 0; char c = getchar(); int f = 0;
    for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
    for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if (f) x = -x;
}

const int N = 6666;
int B[N], B_cnt, A[N], A_cnt;
char str[N]; int m, n;
string dp[N];

string doit(int l) {
	if (l > n) return "";
	int cnt = 0;
	for (int i = l; i <= n; i++) cnt += B[i] < A[i];
	string ans = "";
	if (!cnt) {
		int la = 0;
		for (int i = l; i <= n; i++) {
			if (A[i] > la) {
				ans += "ab";
				la = B[i];
			}
		}
		return ans;
	}
	int la = -1, pa = -1;
	vector <int> vis(2 * n + 1, 0);
	for (int i = l; i <= n; i++) {
		if (B[i] > la && la != -1) break;
		if (B[i] < A[i] && (la == -1 || B[i] < la)) {
			vis[B[i]] = true;
			vis[A[i]] = true;
			la = A[i];
			pa = i;
		}
	}
	rep (i, 2 * n) if (vis[i]) ans += str[i];
	return ans + dp[pa + 1];
}

int main(void) {
	read(n); m = 2 * n;
	scanf("%s", str + 1);
	rep (i, m) {
		if (str[i] == 'a') A[++A_cnt] = i;
		else B[++B_cnt] = i;
	}
	for (int i = n; i >= 1; i--) {
		dp[i] = max(doit(i), dp[i + 1]);
	}
	cout << dp[1] << "\n";
}


Measured memory_bytes: 14592
def main():
    N, x = map(int, input().split())
    A = list(map(int, input().split()))
    ans = 0
    if A[0] > x:
        ans += A[0]-x
        A[0] = x
    for i in range(1, N):
        if A[i] + A[i-1] > x:
            ans += A[i] + A[i-1] - x
            A[i] = x - A[i-1]
    print(ans)


if __name__ == "__main__":
    main()


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

  #define vi vector<int>
  #define all(v) v.begin(),v.end()
  #define ll long long int
  #define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
  #define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

  const ll MOD=1e9+7;

  void solve(){
     int n;
     cin >> n;
     vector<int> v(n);
     for(int i=0;i<n;i++)cin >> v[i];
     int i=0;
     for(i=n-1;i>=0;i-=2){
        cout << v[i] <<' ';
        // assert((i<n && i>=0));
     }
     for(int j=i+1;j<n;j+=2){
       if(j<n && j>=0)
       cout << v[j] << ' ';

     }
  }


  int main(){
    IOS
       solve();
       cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 2944
#include<stdio.h>
int main(){
  char x[2][4];
  scanf("%s%s",x[0],x[1]);
  if(x[0][0]==x[1][2] && x[0][1]==x[1][1] && x[0][2]==x[1][0])
    puts("YES");
  else
    puts("NO");
  return 0;
}

Measured memory_bytes: 128