akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
 
        String line1 = scanner.next();
        String line3 = scanner.next();

        int a = Integer.parseInt(line1);
        int b = Integer.parseInt(line3);

        if(a > b){
            System.out.println("a > b");
        }else if(a < b){
            System.out.println("a < b");
        }else{
            System.out.println("a == b");
        }
        
    }
}


Measured memory_bytes: 26080
#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 irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v) for (auto &&V : v)
#define all(x) (x).begin(), (x).end()
using lint = long long;
const int INF = 1 << 29;
const double EPS = 1e-9;
using namespace std;

int main(void) {
  int r, d, x2000;
  cin >> r >> d >> x2000;
  int now = x2000;
  rep(i, 10) {
    now = r * now - d;
    cout << now << endl;
  }
  return 0;
}

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

#define f first
#define s second
#define pb push_back
#define all(c) c.begin(),c.end()

#define gi(x) scanf("%d", &x)
#define pi(x) printf("%d", x)
#define gl(x) scanf("%lld", &x)
#define pl(x) printf("%lld", x)
#define sp printf(" ")
#define nl printf("\n")

typedef long long int lld;
typedef long double ldb;

lld n;
lld inp[100010];
lld a, b;
vector <lld> t;
bool check(lld x){
    t.resize(n);
    for(int i = 0; i < t.size(); ++i) {
        t[i] = inp[i] - b*x;
    }
    sort(all(t));
    for(int i = t.size() - 1; i >= 0; --i){
        if(t[i] <= 0) break;
        if(t[i] > 0){
            if(t[i] > x*(a - b)) return 0;
            else x -= ceil((ldb)t[i]/(a - b));
        }
    }
    return 1;
}

main(){
    cin >> n >> a >> b;
    for(int i = 0; i < n; ++i) cin >> inp[i];
    lld md, lo = 0, hi = 1e9;
    for(int i = 0; i < 34; ++i){
        md = (lo + hi) >> 1;
        if(check(md)) hi = md;
        else lo = md;
    }
    if(check(lo)) cout << lo << endl;
    else if(check(hi)) cout << hi << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#define MOD 1000000007LL
using namespace std;

int main(){
	long long int a, b, c;
	cin >> a >> b >> c;
	if(((a % 2) * (b % 2) * (c % 2)) == 0) cout << 0 << endl;
	else cout << min(min(a*b, b*c), c*a) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cctype>
#include <queue>
#define ll long long 
#define ri register int 
using namespace std;
template <class T>inline void read(T &x){
    x=0;int ne=0;char c;
    while(!isdigit(c=getchar()))ne=c=='-';
    x=c-48;
    while(isdigit(c=getchar()))x=(x<<3)+(x<<1)+c-48;
    x=ne?-x:x;return ;
}
const int maxn=200005;
const int inf=0x7fffffff;
struct S_Heap{
	int n,heap[maxn];
	inline void up(int fa){
		while(fa>1){
			if(heap[fa]<heap[fa>>1]){
				swap(heap[fa],heap[fa>>1]);
				fa=fa>>1;
			}
			else break;
		}
	}
	inline void push(int v){
		heap[++n]=v;
		up(n);
	}
	inline void down(int fa){
		int s=fa<<1;
		while(s<=n){
			if(s<n&&heap[s]>heap[s+1])s++;
			if(heap[s]<heap[fa]){
				swap(heap[s],heap[fa]);
				fa=s;s=fa<<1;
			}
			else break;
		}
	}
	inline void pop(){
		heap[1]=heap[n--];
		down(1);
	}
	inline int size(){
		return n;
	}
	inline int top(){
		return heap[1];
	}
}q_1;
struct B_Heap{
	int n,heap[maxn];
	inline void up(int fa){
		while(fa>1){
			if(heap[fa]>heap[fa>>1]){
				swap(heap[fa],heap[fa>>1]);
				fa=fa>>1;
			}
			else break;
		}
	}
	inline void push(int v){
		heap[++n]=v;
		up(n);
	}
	inline void down(int fa){
		int s=fa<<1;
		while(s<=n){
			if(s<n&&heap[s]<heap[s+1])s++;
			if(heap[s]>heap[fa]){
				swap(heap[s],heap[fa]);
				fa=s;s=fa<<1;
			}
			else break;
		}
	}
	inline void pop(){
		heap[1]=heap[n--];
		down(1);
	}
	inline int size(){
		return n;
	}
	inline int top(){
		return heap[1];
	}
}q_2;
int Q;
int cnt=0;
ll ans=0;
int opt;
int mi=inf,mx=-inf;
int main(){
	int x,y,lst=0;
	read(Q);
	while(Q--){
		read(opt);
		if(opt==1){
			read(x),read(y);
			/*if(!q_1.n||x>q_1.top())q_1.push(x);
			else q_2.push(x);
			if(q_1.size()>q_2.size()+1){q_2.push(q_1.top());q_1.pop();}
			if(q_2.size()>q_1.size()+1){q_1.push(q_2.top());q_2.pop();}*/
			if(cnt%2==0){
				if(q_2.top()>=x){
					q_2.push(x),lst=q_2.top();
					ans+=abs(q_2.top()-x);
				}
				else{
					q_1.push(x),lst=q_1.top();
					ans+=abs(x-q_1.top());
				}
			}
			else{
				ans+=abs(lst-x);
				if(q_2.top()>=x){
					q_2.push(x);
				}
				else q_1.push(x);
				if(q_1.size()>q_2.size()+1){q_2.push(q_1.top());q_1.pop();}
				if(q_2.size()>q_1.size()+1){q_1.push(q_2.top());q_2.pop();}
				lst=0;
			}
			cnt++,ans+=y;
			/*cnt++;
			q.push(x);
			b+=y;
			if(x>mx)mx=x;
			if(x<mi)mi=x;*/
		}
		else{
			if(cnt==1)printf("%d %lld\n",lst,ans);
			else if(cnt==0)puts("0 0");
			else{
				/*if(cnt%2==1){
					lst=q.top();
					q.pop();
					printf("%d %lld\n",q.top(),b+1ll*(cnt/2)*(mx-mi));
					q.push(lst);
				}
				else{
					printf("%d %lld\n",q.top(),b+1ll*(cnt/2)*(mx-mi));
				}*/
				if(cnt%2==0){
					printf("%d %lld\n",q_2.top(),ans);
				}
				else {
					printf("%d %lld\n",lst,ans);
				}
			}
		}	
	}
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <string.h>
#include <string>
#include <vector>
#include <sstream>
using namespace std;
vector <int> vt[100005];
int n,m,q,x,y,v,d,c;
int cl[100005],dd[100005][11];
int main(){
    std::ios::sync_with_stdio(false);     
    std::cin.tie(0); 
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> x >> y;
        vt[x].push_back(y);
        vt[y].push_back(x);
    }
    cin >> q ;
    for(int i = 1; i <= q; i++){
        cin >> v >> d >> cl[i];
        dd[v][d] = i;
    }
    for(int i = 9; i >= 0; i--){
        for(int j = 1; j <= n; j++){
            dd[j][i] = max(dd[j][i],dd[j][i + 1]);
            for(int k = 0; k < vt[j].size(); k++){
                dd[j][i] = max(dd[j][i],dd[vt[j][k]][i + 1]);
            }
        }
    }
    for(int i = 1; i <= n; i++)
        cout << cl[dd[i][0]] << endl;
    return 0;
}

Measured memory_bytes: 11256
/*
	本以为要记录 pre 然后 kd-tree 区间查询的
	发现联通块是树, 直接记录前缀和就行了
*/
#include <iostream>
#include <cstdio>
#define N 2005

using namespace std;

int n, m, Q;
bool rect[N][N];
int sum[N][N], del[2][N][N];

inline void read(int &x) {
	x = 0; char ch = getchar();
	while(!isdigit(ch)) ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
}
inline int calc(int (*s)[N], int u, int l, int d, int r) {
	return s[d][r] - s[d][l - 1] - s[u - 1][r] + s[u - 1][l - 1];
}

int main() {
	read(n), read(m), read(Q);
	for(int i = 1; i <= n; ++i) {
		char ch;
		for(int j = 1; j <= m; ++j) {
			ch = getchar();
			while(!isdigit(ch)) ch = getchar();
			sum[i][j] = rect[i][j] = (ch == '1');
			if(rect[i][j]) {
				if(rect[i - 1][j]) ++del[0][i - 1][j];
				if(rect[i][j - 1]) ++del[1][i][j - 1];
			}
		}
	}
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= m; ++j) {
			sum[i][j] += sum[i][j - 1];
			del[0][i][j] += del[0][i][j - 1];
			del[1][i][j] += del[1][i][j - 1];
		}
		for(int j = 1; j <= m; ++j) {
			sum[i][j] += sum[i - 1][j];
			del[0][i][j] += del[0][i - 1][j];
			del[1][i][j] += del[1][i - 1][j];
		}
	}
	int l, r, u, d, ans;
	while(Q--) {
		read(u), read(l), read(d), read(r);
		if(l > r) swap(l, r);
		if(u > d) swap(u, d);
		ans = calc(sum, u, l, d, r);
		ans -= calc(del[0], u, l, d - 1, r);
		ans -= calc(del[1], u, l, d, r - 1);
		printf("%d\n", ans);
	}
	return 0;
}

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

const int mod=1000000007;
int f[610][610],g[610][610],n,k,l,r,sum[610],h[610],ans;
bool bo[610][610];

int main()
{
	h[0]=1;
	for (int i=2; i<=600; i+=2) h[i]=1ll*(i-1)*h[i-2]%mod;
	memset(bo,1,sizeof(bo));
	scanf("%d%d",&n,&k),sum[0]=0,n<<=1;
	for (int i=1; i<=k; i++) 
	{
		scanf("%d%d",&l,&r);
		if (l>r) swap(l,r);
		sum[l]++,sum[r]++;
		for (int j=1; j<=l; j++)
			for (int k=l; k<r; k++) bo[j][k]=0;
		for (int j=l+1; j<=r; j++)
			for (int k=r; k<=n; k++) bo[j][k]=0;
	}
	for (int i=1; i<=n; i++) sum[i]+=sum[i-1];
	for (int i=1; i<=n; i++)
		for (int j=i+1; j<=n; j+=2)
			if (bo[i][j]) f[i][j]=h[j-i+1-sum[j]+sum[i-1]];
	for (int i=1; i<=n; i++)
		for (int j=i+1; j<=n; j+=2)
		{
			g[i][j]=f[i][j];
			for (int k=i+1; k<j; k+=2) g[i][j]=(g[i][j]+1ll*(mod-g[i][k])*f[k+1][j])%mod;
			ans=(ans+1ll*h[n-(j-i+1-sum[j]+sum[i-1])-2*k]*g[i][j])%mod;
		}
	return printf("%d\n",ans),0;
}

Measured memory_bytes: 3456
class Node():
    def __init__(self, parent =None ,left =None ,right = None):
        self.parent = parent
        self.left = left
        self.right = right
        self.depth = -1

def get_depth(u,tree_list):
    d = 0
    while tree_list[u].parent != -1:
        u = tree_list[u].parent
        d += 1
    return d

if __name__ == "__main__":
    n = int(input())

    r = 0
    tree_list = [Node(-1,-1,-1) for m in range(n)]
    node_list = []
    for i in range(n):
        l = input().split()
        v = int(l[0])
        c_list = [int(l[m]) for m in range(2,len(l))]
        node_list.insert(v,c_list)
        for ci in range(int(l[1])):
            if ci == 0:
                tree_list[v].left = c_list[ci]
            else:
                tree_list[c].right = c_list[ci]
            c = c_list[ci]
            tree_list[c].parent = v

    for i,t in enumerate(tree_list):
        d = get_depth(i,tree_list)
        tree_type = ''
        if tree_list[i].parent == -1:
            tree_type = 'root'
        elif tree_list[i].left == -1:
            tree_type = 'leaf'
        else:
            tree_type = 'internal node'

        n = ', '.join([str(x) for x in node_list[i]])

        print('node {}: parent = {}, depth = {}, {}, [{}]'.format(i,t.parent,d,tree_type,n))



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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);




void solve(int testCase){

    int n;
    scanf("%d" , &n);

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

    vector < int > dp(n , 2e9);
    dp[0] = 0;
    for(int i = 0 ; i < n ; i ++){
            for(int j : {i + 1 , i + 2}){
                    if(j < n){
                            dp[j] = min(dp[j] , dp[i] + abs(a[i] - a[j]));
                    }
            }
    }

    printf("%d\n" , dp[n-1]);

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n,a[111111];
map<int,int>mp;
int main(){
	cin>>n;
	rep(i,n){
		cin>>a[i];
		if(i<=1){
			for(int j=1;j<=sqrt(a[i]);j++){
				if(a[i]%j==0){
					if(j*j==a[i])mp[j]++;
					else mp[j]++,mp[a[i]/j]++;
				}
			}
		}
	}
	int ans=1;
	for(auto p:mp){
		int ok=2;
		rep(i,n)if(a[i]%p.first)ok--;
		if(ok>0)ans=max(ans,p.first);
		
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
import itertools

S = input()

seq = (0, 1)
ptr = itertools.product(seq, repeat=len(S)-1)
res = 0 

for p in ptr:
    tmp = 0
    tmps = S[0]
    
    for i in range(len(S)-1):
        if p[i] == 0:
            tmps += S[i+1]
        else:
            tmp += int(tmps)
            tmps = S[i+1]
            
    if tmps != '':
        tmp += int(tmps)     
        
    res += tmp
     
print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++)cin>>h[i];
    int dp[n];
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 4344
#include<iostream>
#include<string>
#include<vector>
#include<map>

/*
二分探索木mapに対してiteratorで取り出しを行なうと, キーでソートされた状態で出てくる
*/

int main(){
    int N;
    std::cin >> N;
    std::string S;
    std::map<std::string, int> mp;
    for(int i = 0; i < N; i++){
        std::cin >> S;
        mp[S]++;
    }
    int mx = 0; // 頻度の最大値
    for(auto const &p: mp) mx = std::max(mx, p.second);
    for(auto const &p: mp){
        if(p.second != mx) continue;
        std::cout << p.first << std::endl;
    }

    return 0;
}

Measured memory_bytes: 25216
#include<bits/stdc++.h>
using namespace std;
double a[3002],dp[3002][3002],ans=0;
int n;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(i==0&&j==0) dp[i][j]=1;
            else if(j==0) dp[i][j]=dp[i-1][j]*(1-a[i]);
            else if(i==j) dp[i][j]=dp[i-1][j-1]*a[i];
            else if(i<j) dp[i][j]=0;
            else{
                dp[i][j]=a[i]*(dp[i-1][j-1])+(1-a[i])*dp[i-1][j];
            }
        }
    }
    for(int i=n/2+1;i<=n;i++){
        ans+=dp[n][i];
    }
    cout<<setprecision(10)<<fixed<<ans<<endl;
    return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check(int n) {
    for(int i=2;i*i<=n;++i) {
        if(n%i==0)
        return false;
    }
    return true;
}


// bool cmp(pair<int,int>p,pair<int,int>q) {
//     // return p.first>q.first;//descending by first
//     // return p.first<q.first;//ascending by first
//     // return p.second>q.second;//descending by second
//     return p.second<q.second;//ascending by second
// }

bool cmp(int p,int q) {
    return p>q;//descending
    // return p<q;//ascending
}


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    int a,b,p,q;
    cin>>a>>b>>p>>q;

    
    (p>a)?cout<<"1"<<endl:cout<<"0"<<endl;
    
    return 0;
}

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

using namespace std;

#define REP(i, n) for (int i=0; i<(n); ++i)
#define RREP(i, n) for (int i=(int)(n)-1; i>=0; --i)
#define FOR(i, a, n) for (int i=(a); i<(n); ++i)
#define RFOR(i, a, n) for (int i=(int)(n)-1; i>=(a); --i)

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;

template<class T>
ostream &operator<<(ostream &os, const vector <T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair <T, U> &p) {
    return os << "(" << p.first << " " << p.second << ")";
}

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

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
const ld eps = 1e-9;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    // ifstream in("in.txt");
    // cin.rdbuf(in.rdbuf());

    int N; cin >> N;
    vector<int> V(N+1), W(N+1);
    FOR(i, 1, N+1) {
        cin >> V[i] >> W[i];
    }

    int M = sqrt(N);

    const int MAX_L = 1e5;
    vector<vector<ll>> dp(M, vector<ll>(MAX_L+1));

    FOR(i, 1, M) {
        dp[i] = dp[i / 2];
        for (int w = 0; w <= MAX_L - W[i]; ++w) {
            chmax(dp[i][w + W[i]], dp[i / 2][w] + V[i]);
        }
    }

    int Q; cin >> Q;
    REP(i, Q) {
        ll v, L; cin >> v >> L;

        vector<int> ids;
        int u = v;
        while (u >= M) {
            ids.push_back(u);
            u >>= 1;
        }

        ll ans = 0;
        for (int s = 0; s < 1<<SZ(ids); ++s) {
            ll totalv = 0, totalw = 0;
            REP(j, SZ(ids)) {
                if (s >> j & 1) {
                    totalv += V[ids[j]];
                    totalw += W[ids[j]];
                }
            }

            if (totalw > L) continue;
            chmax(ans, dp[u][L - totalw] + totalv);
        }

        cout << ans << '\n';
    }

    return 0;
}


Measured memory_bytes: 406596
//
//  main.cpp
//  task 1 B
//
//  Created by Aly Hesham on 05/08/2018.
//  Copyright © 2018 Aly Hesham. All rights reserved.
//

#include <iostream>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {
    
    string s , t;
    cin >> s >> t ;
    bool ans = false;
    for (int i = 0; i < s.size(); ++i){
        if (s == t){
            ans = true;
            break;
        }
        s = s.back() + s.substr(0, s.size()-1);
    }
    if (ans)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <deque>
#define ll long long

using namespace std;

int n, k;
vector<int> w;

int wsum;
int wmax;

bool canConvey(int P) {
	int cnt = 1;
	int curweight = 0;
	for(int i=0;i<w.size();i++) {
		if (curweight + w[i] > P) {
			curweight = w[i];
			cnt++;
		}
		else {
			curweight += w[i];
		}
	}
	if (cnt > k) return false;
	else return true;
}

int main() {
	cin >> n >> k;
	w.assign(n, 0);
	int wsum = 0;
	int wmax = 0;
	for (int i = 0; i < n; i++) {
		cin >> w[i];
		wsum += w[i];
		wmax = max(wmax, w[i]);
	}

	int left = wmax;
	int right = wsum;
	while (left < right) {
		int md = (left + right) / 2;
		if (canConvey(md)) {
			right = md;
		}
		else left = md + 1;
	}
	cout << left << endl;

	return 0;

}





Measured memory_bytes: 3132
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


class Combination:
    def __init__(self, n, mod):
        assert 0 < n
        self.mod = mod
        self.fact = [1] * (n + 1)
        self.inv = [1] * (n + 1)
        for i in range(1, len(self.fact)):
            self.fact[i] = (i * self.fact[i - 1]) % self.mod
            self.inv[i] = pow(self.fact[i], self.mod - 2, self.mod)

    def nCr(self, n, k):
        assert 0 <= n < len(self.fact) and 0 <= k
        assert n >= k
        a = self.fact[n]
        b = (self.inv[k] * self.inv[n - k]) % self.mod
        return a * b % self.mod


def main():
    N = int(input())
    A = list(map(int, input().split()))
    MOD = 10 ** 9 + 7

    comb = Combination(10**5 + 10, MOD)

    pos = [-1] * 100010
    for i, a in enumerate(A):
        if pos[a] != -1:
            pos1, pos2 = min(pos[a], i), max(pos[a], i)
            break
        pos[a] = i

    dist = pos2 - pos1
    for i in range(1, N + 2):
        ans = comb.nCr(N + 1, i)
        rest = N + 1 - dist - 1

        if rest >= i - 1:
            ans -= comb.nCr(rest, i - 1)

        print(ans % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21200
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
  ll n;
  cin>>n;
  ll ans=0;
  for(ll i=1;i<=n;i++){
    ll num=n/i;
    ll adder=(1+num)*num*i;
    adder/=2;
    ans+=adder;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
    int n, m; cin>>n>>m;
    vector<int> vb[100010];
    for(int i=0; i<n; i++){
        int a, b; cin>>a>>b;
        vb[a].push_back(b);
    }
    priority_queue<int> que;
    int ans=0;
    for(int i=1; i<=m; i++){
        for(auto b:vb[i]) que.push(b);
        if(!que.empty()){
            ans+=que.top();
            que.pop();
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
std::string S;

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

    std::cin >> N;

    int res = 0;
    int a = 0, b = 0, c = 0;

    for(int i=0;i<N;++i){
        std::cin >> S;

        for(int j=0;j+1<S.size();++j){
            if(S[j] == 'A' && S[j+1] == 'B'){
                res += 1;
            }
        }

        if(*S.begin() == 'B' && *S.rbegin() == 'A'){
            c += 1;
        }else if(*S.begin() == 'B'){
            b += 1;
        }else if(*S.rbegin() == 'A'){
            a += 1;
        }
    }

    if(a > 0){
        res += std::min(a, b) + c;
    }else if(b > 0){
        res += c;
    }else{
        res += std::max(c - 1, 0);
    }

    std::cout << res << std::endl;
}


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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
//#define endl '\n'  
typedef long long ll; 
typedef unsigned long long ull; 
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1e9+7;
const ll inf=1e17+10;
const ll N=3000;
ll fact[N];
ll mod_expo(ll a,ll b, ll c)
{
	ll ans=1;
	while(b)
	{
		if(b & (ll)1) ans=(ans*a)%c;
		a=(a*a)%c;
		b=b>>1;
	}
	return ans;
}
ll invese(ll n)
{
	return mod_expo(n,mod-2,mod);
}

ll ncr(ll n, ll k)
{
	if(n<k) return 0;
	ll ans=1;
	ans*=fact[n];
	ans%=mod;
	ans*=invese(fact[k]);
	ans%=mod;
	ans*=invese(fact[n-k]);
	ans%=mod;
	return ans;
}

int main()
{
	boost;

	fact[0]=1;
	for(ll i=1;i<N;i++) fact[i]=(i*fact[i-1])%mod;
	ll n,k;
	cin>>n>>k;
	for(ll i=1;i<=k;i++)
	{
		cout<<(ncr(n-k+1,i)*ncr(k-1,i-1))%mod<<endl;
	}
  	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N;
    cin >> N;
    while (N!=0){
        ll sum = 0;
        for (int i = 1; i <= N; ++i) {
            sum += i;
            if(sum >= N){
                cout << i << endl;
                N -= i;
                break;
            }
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long int
#define mod 1000000007
#define MAX 26
using namespace std;
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	/*int t; 
	cin>>t;
	while(t--)*/
	{
		string s;
		cin>>s;
		for(LL i=0; i<s.length(); i++)
		{
			if(s[i]=='?')
			s[i]='D';
		}
		cout<<s<<"\n";
		
	}
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
int n,k,cnt;
string s;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k>>s;
	for (int i=1;i<s.size();++i) if (s[i]==s[i-1]) ++cnt;
	cout<<min(n-1,cnt+k*2);
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>
struct _point {
    double x;
    double y;
};

/*
struct _line {
    int x1;
    int y1;
    int x2;
    int y2;
};
*/
struct _point rotate_pi_3(struct _point o, struct _point a) {
    struct _point a_rotate;
    a_rotate.x = o.x + (a.x - o.x)/2.0 - pow(3.0,0.5)/2.0 * (a.y - o.y);
    a_rotate.y = o.y + pow(3.0,0.5) / 2.0 * (a.x - o.x) + (a.y - o.y) / 2.0;
    return a_rotate;
} 

int koch(struct _point a, struct _point b, int n) {
    if(n == 0) {
        printf("%lf %lf\n",a.x,a.y);
        return 1;
    }
    struct _point na = {a.x + (b.x - a.x)/3.0, a.y + (b.y - a.y)/3.0};
    struct _point nb = {a.x + (b.x - a.x) * (2.0/3.0), a.y + (b.y - a.y) * (2.0/3.0)};
    struct _point nc =rotate_pi_3(na,nb);
    n--;
    koch(a,na,n);
    koch(na,nc,n);
    koch(nc,nb,n);
    koch(nb,b,n);    
    return 0;
}

int main() 
{
    int n;
    scanf("%d",&n);
    struct _point a = {0.0,0.0};
    struct _point b = {100.0,0.0};
    koch(a,b,n);
    printf("%lf %lf\n",b.x,b.y);
    return 0; 
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

struct UnionFind
{
    vector<int> par, sz;
    int n_cc;

    UnionFind(int N){
        par = vector<int>(N);
        REP(i, N) par[i] = i;
        sz = vector<int>(N, 1);
        n_cc = N;
    }

    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;

        if(sz[x] < sz[y]) swap(x, y);

        par[y] = x;
        sz[x] += sz[y];
        n_cc--;
    }

    bool is_union(int x, int y){
        x = find(x);
        y = find(y);
        return x == y;
    }

    int union_size(int x){
        return sz[find(x)];
    }

};



signed main(){

    int N, M; cin >> N >> M;
    UnionFind UF(N);
    REP(i, M){
        int x, y, z; cin >> x >> y >> z;
        UF.unite(x - 1, y - 1);
    }
    Out(UF.n_cc);

    return 0;
}


Measured memory_bytes: 1920
# ABC113C - ID
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    P = [[] for _ in range(N + 1)]  # prefectures
    for num in range(M):
        pref, year = map(int, input().split())
        P[pref] += [(year, num)]
    ans = []
    P = [sorted(p) for p in P]  # sort by year
    for pref_idx, pref in enumerate(P):
        for city_idx, (_, num) in enumerate(pref, 1):
            x = "{:06}{:06}".format(pref_idx, city_idx)
            ans += [(num, x)]
    print(*[i[1] for i in sorted(ans)], sep="\n")  # sort by input order

if __name__ == "__main__":
    main()

Measured memory_bytes: 46120
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long int
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j;
            cin>>n;
            ll x,ans=0;
            map<ll,ll> mp;
            int pre=-1;
            for(i=1;i<=n;++i)
            {
                cin>>x;
                mp[x]=pre;
                pre=x;
            }
            for(i=1;i<=n;++i)
            {
                cin>>x;
                ans=ans+x;
            }
            for(i=2;i<=n;++i)
            {
                cin>>x;
                //cout<<i<<" "<<mp[i]<<endl;
                if(mp[i]==i-1)
                    ans=ans+x;
            }
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

const int M = 1e7+10;
bool isPrime[M];

void sieve(){
    for(int i=2;i<M;i++) isPrime[i] = true;
    for(int i=2;i*i<M;i++){
        if(!isPrime[i]) continue;
        for(int j=2*i;j<M;j+=i){
            isPrime[j] = false;
        }
    }
}

int main(){
    sieve();
    int n;
    while(cin >> n){
        int c = 0;
        for(int i=0;i<=n;i++){
            if(isPrime[i]) c++;
        }
        cout << c << endl;
    }
}

Measured memory_bytes: 10924
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=sorted([A[i]-B[i]for i in range(N)])
if sum(C)<0:print(-1);exit()
D=[i for i in C if i<0]
m=sum(D)
i=0
while m<0:m+=C[N-i-1];i+=1
print(len(D)+i)


Measured memory_bytes: 100336
# 入力
n = gets.to_i
a = gets.chomp.split.map(&:to_i)
# 配列から偶数をだす
even = a.select{|x|x%2==0}

# 3と５で割れるかの判定
flag = true
even.each do|i|
 if i%3==0 || i%5==0
    flag = true
 else
    flag = false
    break
 end
end

if flag
   puts "APPROVED"
else
   puts "DENIED"
end


Measured memory_bytes: 1788
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

int main (int argc, char const *argv[])
{
    int64_t N, M, X, Y, x[100], y[100];
    int64_t xmax, ymin, ans = 0;

    scanf("%"PRId64"%"PRId64"%"PRId64"%"PRId64, &N, &M, &X, &Y);
    for (int i = 0; i < N; i++) {
        scanf("%"PRId64, &x[i]);
    }
    for (int i = 0; i < M; i++) {
        scanf("%"PRId64, &y[i]);
    }

    xmax = X;
    for (int i = 0; i < N; i++) {
        if (xmax < x[i]) xmax = x[i];
    }
    ymin = Y;
    for (int i = 0; i < M; i++) {
        if (ymin > y[i]) ymin = y[i];
    }

    if (xmax < ymin) {
        puts("No War");
    } else {
        puts("War");
    }

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
set<int> a[100005][2];
int f[100005];
int main() {
  int n, m, x;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &x);
    f[x]++;
  }
  queue<int> q;
  for (int i = 1; i <= 100000; i++) {
    if (f[i] == 0) continue;
    a[i % m][f[i] % 2].insert(i);
    if (f[i] % 2 == 1) {
      q.push(i);
    }
  }
  int ans = 0;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    if (f[x] % 2 == 0) continue;
    a[x % m][1].erase(x);
    f[x]--;
    if (f[x]) {
      a[x % m][0].insert(x);
    }
    int other = (m - x % m) % m;
    if (!a[other][1].empty()) {
      int y = *(a[other][1].begin());
      a[other][1].erase(y);
      f[y]--;
      if (f[y]) {
        a[other][0].insert(y);
      }
      ans++;
      //printf("%d %d\n", x, y);
    } else if (!a[other][0].empty()) {
      int y = *(a[other][0].begin());
      a[other][0].erase(y);
      f[y]--;
      ans++;
      a[other][1].insert(y);
      q.push(y);
      //printf("%d %d\n", x, y);
    }
  }
  for (int i = 1; i <= 100000; i++) {
    ans += f[i] / 2;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
string fyes="Yay";
string fno=":(";
int n,k;
signed main(){
	cin>>n>>k;
	if(k==1)cout<<0<<endl;
	else cout<<n-k<<endl;
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  bool sp = true;
  int mi = s.size()/2;
  rep(i, mi) {
    if (s[i] != s[mi-1-i]) sp = false;
    if (s[i] != s[mi+1+i]) sp = false;
    if (s[i] != s[s.size()-1-i]) sp = false;
  }
  if (sp) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

#include <algorithm>

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;
const ll INFLL = 1000000000000000007LL;

void solve() {
  int A, B, X;
  cin >> A >> B >> X;
  string ans = "NO";
  if (X >= A && X <= A + B) ans = "YES";
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // cout << fixed << setprecision(12);

  solve();

  return 0;
}


Measured memory_bytes: 256
S = str(input())
l = list(range(0,len(S)))
m = list(range(len(S)-1, -1, -1))
#print(l)
#print(m)
cnt = 0
for i, k in zip(l, m):
  if S[i] != S[k]:
    cnt = cnt + 1

cnt = int(cnt/2)
print(cnt)


Measured memory_bytes: 3060
def Pow(i, n):
    if n == 0:
        return 1
    else:
        ans = Pow(i * i % mod, n//2)
        if n % 2 == 1:
            ans *= i
            ans %= mod
        return ans

N = int(input())
A = [int(i) for i in input().split()]
mod = 7 + 10 ** 9
num = [-1 for i in range(N)]
for i, a in enumerate(A):
    if num[a-1] == -1:
        num[a-1] = i
    else:
        Double = [num[a-1], i]

Nfact = [1]
for i in range(1, N+2):
    Nfact.append((Nfact[i-1] * (i)) % mod)
NfactRev = [Pow(Nfact[N+1], mod-2)]
for i in range(1, N+1):
    NfactRev.append(NfactRev[i-1] * (N+2-i) % mod)
NfactRev.append(1)
NfactRev.reverse()

doublearray = N + 1 - (Double[1] - Double[0])
for i in range(1, N+2):
    whole = Nfact[N+1] * NfactRev[N+1-i] * NfactRev[i] % mod
    if i <= doublearray:
        double = Nfact[doublearray-1] * NfactRev[doublearray-i] * NfactRev[i-1] % mod
    else:
        double = 0
    print((whole - double) % mod)

Measured memory_bytes: 20472
#include <stdio.h>

int main(void)
{
	int n;
	int a[4];
	
	scanf("%d", &n);
	
	a[0] = n /100;
	a[1] = n /10 %10;
	a[2] = n %100 %10;
	
	a[3] = a[0] + a[1] +a[2];
	
	printf("%d", a[3]);
	
	return 0;
}

Measured memory_bytes: 128
n = gets.to_i
h = gets.split.map(&:to_i)
dp = Array.new(n,0)
dp[1] = (h[0]-h[1]).abs
for i in 2..n-1
    dp[i] = [dp[i-1]+(h[i]-h[i-1]).abs,dp[i-2]+(h[i]-h[i-2]).abs].min
end
puts dp[n-1]

Measured memory_bytes: 11396
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    int h, ans = 0;
    rep(i, n){
        cin >> h;
        if(h >= k) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * Created by hwzheng on 2016/12/13.
 */
public class Main {
    public static void main(String[] a) {
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        int minutes = i / 60;
        int second = i % 60;
        int minute = minutes % 60;
        int hour = minutes / 60;
        System.out.println(hour + ":" + minute + ":" + second);
    }
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n;
	ll k;
	cin >> n >> k;
	vector<vector<int> >dp(65, vector<int>(n));
	rep (i, n) {
	  cin >> dp[0][i];
	  dp[0][i]--;
	}
	rep (k, 64) {
	  rep (i, n) {
		dp[k + 1][i] = dp[k][dp[k][i]];
	  }
	}
	int p = 0;
	rrep (i, 64) {
	  if ((k >> i) & 1) p = dp[i][p];
	}
	cout << p + 1 << endl;
    
    return 0;
}


Measured memory_bytes: 54948
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut ans: u128 = 1;
    for _ in 0..n {
        let i: u128 = read();

        if ans * i > 3402823669209384634633746074317 {
            ans = 3402823669209384634633746074317;
        } else {
            ans *= i;
        }
    }
    if ans > 10u128.pow(18) {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 2260
#include <stdio.h>

int Prime(int);

int main()
{
    int n,x,i,cnt=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&x);
        if(Prime(x) == 1) cnt++;
    }
    printf("%d\n",cnt);
    
    return 0;
}
int Prime(int x)
{
    int i;
    if(x<2) return 777;
    if(x==2) return 1;
    if(x%2==0) return 777;
    for(i=3;i*i<=x;i+=2){
        if(x%i==0) return 777;
    }
    return 1;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <string.h>


#define num1 20000

int main(void)
{
	char men[num1];
  int k=0;
  int i;
  int s1[num1];
  int s2[num1];
  int R[num1];
	scanf("%s", men);
	int count1=0;
  int count2=0;
	int x=0;
  int y=0;
  i=0;

	while(i<strlen(men)){
		  if(men[i]=='\\'){
			     s1[count1++]=i;
		                  }
		                    else if(count1>0 && men[i]=='/' ){
                      			x=s1[--count1];
                      			y=i-x;
                      			while(count2>0 && s2[count2-1]>x){
				                          y=y+R[--count2];
			                             }
			R[count2]=y;
			s2[count2]=i;
			count2++;
		}
    i++;
	}

	for(i=0; i<count2; i++){
		k=k+R[i];
	}

	printf("%d\n", k);
	printf("%d", count2);
	for(i=0; i<count2; i++){
		printf(" %d", R[i]);
	}
	printf("\n");

	return 0;
}



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

int main() {
  string s;
  cin>>s;
  bool result=false;
  
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='9')result=true;
  }
  if(result)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

using namespace std;

const int M = 262144;

int A[M], tr[M << 1];
int n, q;

void update(int p, int x) {
    tr[p | M] = x;
    for (p = (p | M) >> 1; p != 0; p >>= 1)
        tr[p] = max(tr[p << 1], tr[p << 1 | 1]);
}

int query(int l, int r) {
    int res = -1;
    for (l += M - 1, r += M + 1; (l ^ r) != 1; l >>= 1, r >>= 1) {
        if ((~l & 1) == 1)
            res = max(res, tr[l ^ 1]);
        if ((r & 1) == 1)
            res = max(res, tr[r ^ 1]);
    }
    return res;
}

int main() {
    scanf("%d%d", &n, &q);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &A[i]);
        tr[i | M] = A[i];
    }
    for (int i = M - 1; i != 0; --i)
        tr[i] = max(tr[i << 1], tr[i << 1 | 1]);
    while (q-- != 0) {
        int t, x, y;
        scanf("%d%d%d", &t, &x, &y);
        if (t == 1)
            update(x, y);
        if (t == 2)
            printf("%d\n", query(x, y));
        if (t == 3) {
            int l = x, r = n, res = n + 1;
            while (l <= r) {
                int mid = (l + r) >> 1;
                if (y <= query(x, mid)) {
                    res = mid;
                    r = mid - 1;
                } else
                    l = mid + 1;
            }
            printf("%d\n", res);
        }
    }
    return 0;
}

Measured memory_bytes: 6400
#include <iostream>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;

int main() {
    ll N;
    ll x;
    ll c = 0;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x;
        if (x % 2 == 1) {
            c++;
        }
    }

    if (c % 2 == 1) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <tuple>
#include <set>
#include <functional>

using namespace std;

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

    double ans = 0.0;
    for (int i = 0; i < n; i++) {
        double x;
        string s;
        cin >> x >> s;
        if (s == "JPY") {
            ans += x;
        } else {
            ans += (x * 380000);
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
B - K個のケーキ / K Cakes
https://atcoder.jp/contests/code-festival-2016-qualc/tasks/codefestival_2016_qualC_b

"""
import sys


def solve(K, T, cakes):
    if T == 1:
        return K-1
    m = (K + 1)//2
    return max(cakes[-1]-m, 0, cakes[-1]-(K-cakes[-1])-1)


def main(args):
    K, T = map(int, input().split())
    cakes = sorted([int(a) for a in input().split()])
    ans = solve(K, T, cakes)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
guruguru,line = (input() for i in range(2))
atama = []
target = line[0]
index = -1
saa = True
while True:
    index = guruguru.find(target, index + 1)
    atama.append(index)
    if index == -1:
        break
for i in range(len(atama)):
    stt = ""
    for i2 in range(len(guruguru)):
        if len(guruguru) <= atama[i]+i2:
            index += 1
            stt += guruguru[index]
        else:
            stt += guruguru[atama[i]+i2]
    if line in stt:
        print("Yes")
        saa = False
        break
    index = -1
if saa:
    print("No")

Measured memory_bytes: 7560