akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i=0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
const ll INF = 1LL << 60;
//cout << fixed << setprecision(10);

int main(){
    ll n, m;
    cin>>n>>m;
    vector<ll> M(n+1), h(n+1);
    rep(i,n) cin>>h[i+1];
    int a,b;
    rep(i,m){
        cin>>a>>b;
        chmax(M[a], h[b]);
        chmax(M[b], h[a]);
    }
    ll ans = 0;
    FOR(i, 1, n+1){
        if(M[i] < h[i]) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4772
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL N = 1000000007;

struct mat{
	LL a[205][205];
}M;

LL n,k;

mat operator * (const mat &x,const mat &y){
	mat c;
	memset(c.a,0,sizeof(c.a));
	for(LL k = 1;k <= n;k ++){
		for(LL i = 1;i <= n;i ++){
			for(LL j = 1;j <= n;j ++){
				c.a[i][j] = (c.a[i][j] + x.a[i][k] * y.a[k][j]) % N;
			}
		}
	}
	return c;
}

mat matE(LL x){
	mat ret;
	for(LL i = 1;i <= x;i ++){
		for(LL j = 1;j <= x;j ++){
			if(i == j) ret.a[i][j] = 1;
			else ret.a[i][j] = 0;
		}
	}
	return ret;
}

void output(mat x){
	for(LL i = 1;i <= n;i ++){
		for(LL j = 1;j <= n;j ++){
			if(M.a[i][j] != 0x3f3f3f3f3f3f3f3f) cout << M.a[i][j] << (j == n ? '\n' : ' ');
			else cout << 0 << (j == n ? '\n' : ' ');
		}
	}
}

mat pwr(mat x,LL y){
	mat ans = x,tmp = x;
	y --;
	while(y){
		if(y & 1) ans = ans * tmp;
		tmp = tmp * tmp;
		y >>= 1;
	}
	return ans;
}

int main(){
	scanf("%lld %lld",&n,&k);
	for(LL i = 1;i <= n;i ++){
		for(LL j = 1;j <= n;j ++){
			scanf("%lld",&M.a[i][j]);
		}
	}
	M = pwr(M,k);
	LL cnt = 0;
	for(LL i = 1;i <= n;i ++){
		for(LL j = 1;j <= n;j ++){
			cnt += M.a[i][j];
			cnt %= N;
		}
	}
	printf("%lld\n",cnt);
	return 0;
}
//

Measured memory_bytes: 1920
#include <iostream>
#include <vector>

using namespace std;

template <class T>
ostream& operator<<(ostream& os, vector<T> const& v) {
  for (int i = 0; i < v.size() - 1; i++) os << v[i] << ' ';
  if (!v.empty()) os << v.back();

  return os;
}

int main(void) {
  uint64_t K;
  cin >> K;

  constexpr uint64_t N = 50;
  vector<uint64_t> ans(N);
  for (auto& x : ans) x = (N - 1) + K / N;

  for (uint64_t i = 0; i < (K % N); i++) {
    ans[i] += N;
    for (uint64_t j = 0; j < N; j++) {
      if (i != j) ans[j]--;
    }
  }
  cout << N << endl;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define N 1000

int max(int x,int y){
  if(x>y) return x;
  else return y;
}

char str1[N+1],str2[N+1];

int longestCs(){
int c[N+1][N+1];
int maxv=0,i,j,m,n;

m=strlen(str1);
n=strlen(str2);

for(i=0;i<=m;i++) c[i][0]=0;
for(j=0;j<=n;j++) c[0][j]=0;

for(i=1;i<=m;i++){
  for(j=1;j<=n;j++){
    if(str1[i-1]==str2[j-1]){
      c[i][j]=c[i-1][j-1]+1;
    } else {
      c[i][j]=max(c[i-1][j],c[i][j-1]);
    }
    maxv=max(maxv,c[i][j]);
    }
  }

return maxv;
}

int main(){
int n,i;

scanf("%d",&n);
for(i=0;i<n;i++){
  scanf("%s",str1);
  scanf("%s",str2);
  printf("%d\n",longestCs());
  }
return 0;
}

Measured memory_bytes: 4508
K=int(input())
arr=[[1,2,3,4,5,6,7,8,9]]
for _ in range(9):
    tmp=[]
    for v in arr[-1]:
        if v%10!=0:
            tmp.append(v*10+(v%10-1))
        tmp.append(v*10+(v%10))
        if v%10!=9:
            tmp.append(v*10+(v%10+1))
    arr.append(tmp)
ans=[]
for i in range(len(arr)):
    for v in arr[i]:
        ans.append(v)
ans=sorted(ans)
print(ans[K-1])

Measured memory_bytes: 15144
#include <bits/stdc++.h>
	using namespace std;
	#define IOS ios::sync_with_stdio(false), cin.tie(0)
	#define REP(i, n) for (int i = 0; i < n; i++)
	#define FOR(i, a, b) for (int i = a; i < b; i++)
	#define ALL(x) (x).begin(), (x).end()
	#define dump(x) cout << (x) << endl
	#define LMAX 9223372036854775807LL
	#define LMIN -9223372036854775807LL

	using ll = long long;
	template<typename T>
	using vec = vector<T>;
	using P = pair<ll, ll>;

	template <typename A, size_t N, typename T>
	void Fill(A (&array)[N], const T &val){
		fill((T *)array, (T *)(array + N), val);
	}
	
	const ll INF = 1e18;
	const ll mod = 1e9 + 7;

	//int dx[4] = {1,0,-1,0};
	//int dy[4] = {0,1,0,-1};
	//ll pas[51][52];
	
	signed main(){
		IOS;
		ll n;
		cin >> n;
		vec<ll> a(n),b(n);
		ll sum1,sum2;
		sum1 = sum2 = 0;
		REP(i,n){
			cin >> a[i];
			sum1 += a[i];
		}
		REP(i,n){
			cin >> b[i];
			sum2 += b[i];
		}
		ll sum = sum2 - sum1;
		ll tmp = 0;
		REP(i,n){
			if(a[i] < b[i])tmp += (b[i] - a[i] - 1) / 2 + 1;
		}
		dump(tmp <= sum ? "Yes" : "No");
	}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N;
  
  int64_t i2 = 2;
  int64_t i1 = 1;
  
  int64_t Lucas;
  
  cin >> N;
  
  if(N != 1){
    for(int i = 1; i < N-1; i++){
      	int64_t w = i2;
      	i2 = i1;
    	i1 = i1 + w;
    }
    Lucas = i2 + i1;
  }else{
  	Lucas = 1;
  }
 
  cout << Lucas << endl;
}

Measured memory_bytes: 256
'use strict'

function Main(input){
	let temp = input.trim().split("\n");
	let NMC = temp[0].split(" ").map( (v)=>(parseInt(v)) );
	let B = temp[1].split(" ").map( (v)=>(parseInt(v)) );
	let A = new Array(NMC[0]);
	for(let i=0;i<NMC[0];i++){
		A[i] = temp[i+2].split(" ").map( (v)=>(parseInt(v)) );
	}

	let count=0;

	for(let i=0;i<NMC[0];i++){
		let sum = NMC[2];
		for(let j=0;j<NMC[1];j++){
			sum += A[i][j] * B[j];
		}

		if(sum>0) count++;
	}
	console.log(count);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int A = 0;
int B = 0;
int C = 0;
int X = 0;
int Y = 0;

long long solve() {
  long long price[4] = {0};
  price[0] = A*X + B*Y;
  price[1] = C*(X*2) + ((Y-X > 0) ? B*(Y-X) : 0);
  price[2] = C*(Y*2) + ((X-Y > 0) ? A*(X-Y) : 0);
  price[3] = C*(max(X, Y)*2);
  return min(min(price[0], price[1]), min(price[2], price[3]));
}

int main() {
  cin >> A >> B >> C >> X >> Y;
  printf("%lld\n", solve());
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(int argc, char* argv[])
{
	int K;
	string s;
	cin>>s;
	cin>>K;
	map<string,int> myMap;
	map<string,int>::iterator mit;
	int i,j;
	int sLen=s.length();
	int sLen1=min(K,sLen);
	for (i=0;i<sLen;i++){
		for (j=1;j<=sLen1;j++){
			string subS=s.substr(i,j);
			mit=myMap.find(subS);
			if (mit==myMap.end()){
				myMap[subS]=1;
			}
		}

	}
	int k=0;
	for (mit=myMap.begin();mit!=myMap.end();mit++){
		k++;
		if (k==K){
			cout<<(*mit).first<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1920
n = int(input())
nList = list(map(int,input().split()))
cdSetList= []
def cdSet(x,y):
    return {i for i in range(1, min(x,y)+1) if x%i==0 and y%i==0}

for i in range(len(nList)-1):
    cdSetList.append(cdSet(nList[i],nList[i+1]))
from functools import *
cdForAll = sorted(reduce(set.intersection, cdSetList))
for i in cdForAll:
    print(i)


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

#define ll long long int
#define mp make_pair
#define pb push_back
#define MOD 1000000007ULL
#define F first
#define S second

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    // freopen("in.in", "r", stdin);
    // freopen("out.out", "w", stdout);
    
    ll n;
    cin >> n;
    ll temp = 0, last_dig, temp1 = 0;
    while(n>0)
    {
        temp1 += 9;
        last_dig = n%10LL;
        temp = temp + last_dig;
        n = n/10LL;
    }
    ll ans = max(temp1 - 9 + last_dig - 1, temp);
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
vector<int>g[210000];
int t[210000];
struct wolf{
	long long a;
	int b;
	int c;
	wolf(){}
	wolf(long long A,int B,int C){a=A;b=B;c=C;}
};
inline bool operator<(const wolf&a,const wolf&b){
	return (long long)a.b*b.c>(long long)a.c*b.b;
}
priority_queue<wolf> dp[210000];
void calc(int a){
	for(int i=0;i<g[a].size();i++){
		calc(g[a][i]);
	}
	int now=a;
	for(int i=0;i<g[a].size();i++){
		if(dp[now].size()<dp[g[a][i]].size()){
			while(dp[now].size()){
				dp[g[a][i]].push(dp[now].top());
				dp[now].pop();
			}
			now=g[a][i];
		}else{
			while(dp[g[a][i]].size()){
				dp[now].push(dp[g[a][i]].top());
				dp[g[a][i]].pop();
			}
		}
	}
	swap(dp[a],dp[now]);
	if(t[a]==0){
		dp[a].push(wolf(0LL,0,1));
	}else{
		if(dp[a].empty()){
			dp[a].push(wolf(0LL,1,0));
		}else{
			wolf tp=dp[a].top();
			dp[a].pop();
			// printf("%d: %d %lld %d %d\n",a,dp[a].size(),tp.a,tp.b,tp.c);
			tp.a+=tp.c;
			tp.b++;
			while(dp[a].size()&&(long long)tp.b*dp[a].top().c>=(long long)tp.c*dp[a].top().b){
				wolf tq=dp[a].top();
				// printf("%d: %lld %d %d\n",a,tq.a,tq.b,tq.c);
				tp.a+=tq.a;
				tp.a+=(long long)tp.b*tq.c;
				tp.b+=tq.b;
				tp.c+=tq.c;
				dp[a].pop();
			}
			// printf("%d: %d %lld %d %d\n",a,dp[a].size(),tp.a,tp.b,tp.c);
			dp[a].push(tp);
		}
	}

}
int main(){
	int a;scanf("%d",&a);
	for(int i=1;i<a;i++){
		int s;scanf("%d",&s);s--;
		g[s].push_back(i);
	}
	for(int i=0;i<a;i++)scanf("%d",t+i);
	calc(0);
	long long ret=0;
	int one=0;
	while(dp[0].size()){
		wolf tp=dp[0].top();
		dp[0].pop();
		ret+=tp.a;
		ret+=(long long)tp.c*one;
		one+=tp.b;
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 45944
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    
    int ans = n;
    int ed = 0;
    int ns = 0;
    if(s[0] == 'L'){
        ans --;
        ed ++;
    }
    if(s[n-1] == 'R'){
        ans --;
        ed ++;
    }
    for(int i = 0; i < n-1; i++){
        if(s[i] == 'R' && s[i+1] == 'L'){
            ans -= 2;
            ns ++;
        }
    }
    int tmp = 0;
    for(int i = 1; i <= k; i++){
        if(ns + ed ==1){
            ans = n-1;
        }else{
            if(tmp < ns){
            ans += 2;
        }else if(tmp < ns + ed - 1){
            ans ++;
        }
        tmp ++;
        }
        
    }
    cout << ans <<endl;
    return 0;
}



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

int main(){
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<int> vec;
    vec.push_back(0);
    for(int i=1;i<n;i++){
        if((s[i]=='1' && s[i-1]=='0') || (s[i]=='0' && s[i-1]=='1')) vec.push_back(i);
    }
    int ans=0;
    rep(i,vec.size()){
        if(s[vec[i]]=='0'){
            if(i+2*k<vec.size()) ans=max(ans,vec[i+2*k]-vec[i]);
            else ans=max(ans,n-vec[i]);
        }
        else{
            if(i+2*k+1<vec.size()) ans=max(ans,vec[i+2*k+1]-vec[i]);
            else ans=max(ans,n-vec[i]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1020
#include<stdio.h>
#include<math.h>

int main(){
    int n;
    int A[110000];
    int max=-10000, min=10000;
    int max1=-10000, min1=10000;
    int i, j, k;
    int ans;
    int sumf=0;
    int sumb=0;

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

    for(i=0; i<n; i++){
        if(i==0){
            ans = sumb+abs(A[0]-A[2]);
        }else if(i==n-1){
            ans = sumf+abs(A[n-1]-A[n+1]);
        }else{
            ans = sumb+sumf+abs(A[i]-A[i+2]);
        }
        printf("%d\n", ans);
        sumf+=abs(A[i]-A[i+1]);
        sumb=sumb-abs(A[i+2]-A[i+3]);
    }

    return 0;
}

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

int main(){
    string s;
    cin >> s;

    if(s[0] != 'A'){
        cout << "WA" << endl;
        return 0;
    }

    bool flag = false;
    int cidx = 0;
    for(int i=2;i<s.size()-1;i++){
        if(s[i] == 'C'){
            if(flag){
                flag = false;
                break;
            }
            cidx = i;
            flag = true;
        }
    }
    if(!flag){
        cout << "WA" << endl;
        return 0;
    }

    flag = true;
    for(int i=1;i<s.size();i++){
        if(i==cidx)
            continue;

        if(s[i]<'a' || s[i]>'z'){
            flag = false;
            break;
        }
    }
    if(flag){
        cout << "AC" << endl;
    }
    else{
        cout << "WA" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  int n;
  string S;
  cin >> n >> S;
  string U;
  
  for(int i = 0;i < n / 2; i++){
    U += S[i];
  }
  
  if(U+U == S){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
# 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]
    for pref_idx, pref in enumerate(P[1:], 1):
        if pref:
            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")

if __name__ == "__main__":
    main()

Measured memory_bytes: 46096
#include<bits/stdc++.h>
using namespace std;
char s[110];
bool flag=0;

int main() {
	scanf("%s",s);
	for(int i=0;i<strlen(s);i++) {
		if(s[i]=='C')	flag=1;
		else if(s[i]=='F') {
			if(flag) {
				printf("Yes\n");return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#![allow(dead_code)]
#![allow(unused_imports)]
use ascii::{AsciiChar, AsciiStr, AsciiString};
use indexmap::IndexMap;
use itertools::*;
use libm::*;
use num::*;
use ordered_float::OrderedFloat;
use permutohedron::LexicalPermutation;
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::mem::swap;

fn main() {
    input!(n:usize, m:usize, k:usize, a:[usize; n], b:[usize; m]);
    let mut suma = vec![0];
    for x in a {
        suma.push(suma.last().unwrap()+x);
    }
    let mut sumb = vec![0];
    for x in b {
        sumb.push(sumb.last().unwrap()+x);
    }

    let (mut ans, mut j) = (0, m);
    for i in 0..suma.len() {
        let a = suma[i];
        if a > k {break;}
        let b = k - a;
        while sumb[j] > b {
            j -= 1;
        }
        ans = max(ans, i+j);
    }
    println!("{:?}", ans);

}



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

int M[11][5];

int main() {
	ios::sync_with_stdio(false);
	while(true) {
		int H; cin >> H;
		if(H == 0) break;
		memset(M, 0, sizeof(M));
		for(int i = H - 1; i >= 0; --i) {
			for(int j = 0; j < 5; ++j) {
				cin >> M[i][j];
			}
		}
		int ans = 0;
		while(true) {
			/*
			for(int i = H - 1; i >= 0; --i) {
				for(int j = 0; j < 5; ++j) printf("%d", M[i][j]);
				printf("\n");
			}
			*/
			bool update = false;
			for(int i = 0; i < H; ++i) {
				for(int j = 0; j < 5; ++j) {
					if(M[i][j] == 0) continue;
					int s = 0;
					for(int k = j; k < 5; ++k) {
						if(M[i][k] == M[i][j]) ++s;
						else break;
					}
					if(s >= 3) {
						ans += s * M[i][j];
						for(int x = 0; x < s; ++x) {
							M[i][j + x] = 0;
						}
						update = true;
					}
				}
			}
			for(int j = 0; j < 5; ++j) {
				while(true) {
					bool update2 = false;
					for(int i = 0; i < H; ++i) {
						if(M[i][j] == 0 && M[i + 1][j] != 0) {
							M[i][j] = M[i + 1][j];
							M[i + 1][j] = 0;
							update2 = true;
						}
					}
					if(!update2) break;
				}
			}
			if(!update) break;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1196
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	int X, Y;
	cin >> X >> Y;

	cout << X + Y / 2 << endl;



ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	if (A == 0 || B == 0) return max(A, B);
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

Measured memory_bytes: 504
/*
"Won't stop untill I'm Phenomenal"
- Phenomenal, EMINEM
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;



int main(){
    Shazam;
    string s; cin>>s;
    vector<int> cnt(2019);
    cnt[0]++;
    int n = s.size();
    int mod = 2019;
    ll p10 = 1;
    ll curr = 0;
    ll ans = 0;
    for(int i = n-1; i>=0; i--){
        curr = (curr + p10*(s[i]-'0')%mod)%mod;
        ans += cnt[curr];
        cnt[curr]++;
        p10 = p10*10%mod;
    }
    cout<<ans<<endl;
    return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    cout << (180) * (n - 2) << endl;
    return 0;
}

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

using namespace std;

#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define ok puts("ok");
#define whatis(x) cerr << #x << " = " << x << endl;
#define pause system("pause");
#define random rand() ^ (rand() << 5)

const int N = (int)1e5 + 7;
const int inf = (int)1e9 + 7;

int n, u, v;
vector < int > gr[N];
int h[N], p[N], is[N], v1;
int cnt = 1;
vector < int > ans, vec[2];

void dfs(int v, int pr = 0) {
	p[v] = pr;
	for (int to : gr[v]) {
		if (to == pr) continue;
		h[to] = h[v] + 1;
		dfs(to, v);
		is[v] = is[to];
	}
}

void no() {
	puts("-1");
	exit(0);
}

void dfs1(int v, int pr = 0) {
	if (is[v]) {
		h[v] = 0;
		int c = 1;
		for (int to : gr[v]) {
			if (to == pr || is[to]) continue;
			ans.pb(cnt + c);
			c++;
		}
		ans.pb(cnt);
		cnt += c;
	} else if (h[v] > 1) {
		no();
	}
	for (int to : gr[v]) {
		if (to == pr) continue;
		h[to] = h[v] + 1;		
		dfs1(to, v);
		
	}
}

main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		scanf("%d %d", &u, &v);
		gr[u].pb(v);
		gr[v].pb(u);
	}
	dfs(1);
	int mx = 0;
	int v = -1;
	int v2;
	for (int i = 1; i <= n; i++) {
		if (h[i] > mx) {
			mx = h[i];
			v = i;
		}
	}
	h[v] = 0;
	dfs(v);
	v2 = v;
	v = -1;
	mx = 0;
	for (int i = 1; i <= n; i++) {
		if (h[i] > mx) {
			mx = h[i];
			v = i;
		}
	}
	int v1 = v;
	while (v != 0) {
		is[v] = 1;
		v = p[v];
	}
	dfs1(v1);
	vec[0] = ans;
	cnt = 1;
	ans.clear();
	dfs1(v2);
	vec[1] = ans;
	int fl = 0;
	for (int i = 1; i <= n; i++) {
		if (vec[0][i - 1] == vec[1][i - 1]) continue;		
		if (vec[0][i - 1] > vec[1][i - 1]) {
			fl = 1;
		}
		break;
	}
	for (int to : vec[fl]) {
		printf("%d ", to);
	}
}

Measured memory_bytes: 18168
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long            ll;
typedef unsigned long long   ull;
typedef vector<int>          vi;
typedef vector<ll>           vl;
typedef pair<int, int>       pi;
typedef pair<ll, ll>         pl;
typedef vector<pi>           vpi;
typedef vector<pl>           vpl;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define read        freopen("in.c", "r", stdin)
#define write       freopen("out.c", "w", stdout)
#define all(a)      a.begin(), a.end()
#define bye         exit(0)
#define mp          make_pair
#define ff          first
#define ss          second
#define L(x)        ((x) << 1)
#define R(x)        ((x) << 1 | 1)
#define SZ(a)       (ll)(a).size()
#define pb          push_back
#define eb          emplace_back
#define eps         1e-9
#define inf         (1000000000)
#define infl        (1000000000000000000LL)
#define cs(p)       printf("Case %d:", (p)++)
#define ptc(c)      putchar(c)
#define gtc()       getchar()
#define nl          puts("")
#define sp          printf(" ")
#define out(a)      printf("%lld", (ll)(a))
#define SET(a, x)   memset((a), x, sizeof(a))
#define dbg(x)      cout << "--- " << #x << " = " << (x) << '\n'

ll bgm(ll a, ll b, ll m) {
    b = (b == -1) ? (m - 2) : b;
    a %= m;
    ll rem = 1;
    while(b != 0) {
        if(b&1)
            rem = (rem * a) % m;
        a = (a * a) % m;
        b >>= 1;
    }
    return rem;
}

inline ll in() {
    ll a;
    assert(scanf("%lld", &a) != EOF);
    return a;
}

const int MAX = 1000000 + 5;
const int LEN = 50;
const ll MOD = 1000000007;

int ara[5][4][11];
int b,f,r,v;



int main() {
    //read,write;
    int m,f,r;
    while(1){
        cin >> m >> f >> r;
        if(m==-1 && f==-1 && r==-1) break;
        if(m==-1 || f == -1) cout << "F" << endl;
        else if(m+f >= 80) cout << "A" << endl;
        else if(m+f>=65 && m+f<80) cout << "B" << endl;
        else if(m+f>=50 && m+f<65) cout << "C" << endl;
        else if(m+f>=30 && m+f<50 && r<50) cout << "D" << endl;
        else if(m+f>=30 && m+f<50 && r>=50) cout << "C" << endl;
        else cout << "F" << endl;
    }


    return 0;
}



Measured memory_bytes: 3104
#include <stdio.h>
#include <inttypes.h>

int cmp(const void* x,const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a > b ? -1 : a < b;
}


int N, M, V, P;
int A[114514];

int main(void) {
	int i;
	int ume;
	int ok, ng;
	if (scanf("%d%d%d%d", &N, &M, &V, &P) != 4) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	qsort(A, N, sizeof(*A), cmp);
	ume = V - (P - 1);
	if (ume < 1) ume = 1;
	ok = P - 1;
	ng = N;
	while (ok + 1 < ng) {
		int mid = ok + (ng - ok) / 2;
		if (mid < P) ok = mid;
		else if (N <= mid) ng = mid;
		else if (A[P - 1] > A[mid] + M) ng = mid;
		else {
			int64_t left = (int64_t)M * ume;
			int target = A[mid] + M;
			for (i = P - 1; i < N; i++) {
				int delta = target - A[i];
				if (delta > M) delta = M;
				if (delta > left) delta = left;
				left -= delta;
			}
			if (left > 0) ng = mid; else ok = mid;
		}
	}
	printf("%d\n", ok + 1);
	return 0;
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n-1);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n-1) cin >> c[i];

    int ans = 0;
    rep(i,n){
        a[i]--;
    }
    rep(i,n){
        ans += b[a[i]];
        if(i != 0){
            if(a[i] == a[i-1] + 1) ans += c[a[i-1]];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n;
    cin>>n;
    vector<ll> v(n);
    ll ans = 0;
    rep(i, n){
        ll a, b;
        cin>>a>>b;
        ans -= b;
        v[i] = a+b;
    }
    sort(v.begin(), v.end(), greater<ll>());
    for(int i = 0;i<=n-1;i+=2){
        ans += v[i];
    }
    cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

double dot(P a,P b){return real(conj(a)*b);};
double cross(P a,P b){return imag(conj(a)*b);};

int main(){
  vi a(5);
  REP(i,5)cin>>a[i];
  sort(ALL(a));
  reverse(ALL(a));
  cout<<a[0];
  REPR(i,5)cout<<" "<<a[i];
  cout<<endl;
  return 0;
}

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

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = Integer.parseInt(in.nextLine());
        String[] params = in.nextLine().split(" ");

        double[] vs = new double[n];
        for( int i = 0 ; i < n ; i++ ){
            vs[i] = Double.parseDouble(params[i]);
        }

        Arrays.sort(vs);

        for( int i = 0 ; i < n - 1 ; i++ ){
            vs[i+1] = (vs[i] + vs[i+1])/2;
        }

        System.out.println( vs[n-1] );

    }

}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;

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

    int sa = 0, sb = 0;
    sort(begin(a), end(a));
    reverse(begin(a), end(a));
    for (int i = 0; i < n; i++) {
        if (i%2 == 0) sa += a.at(i);
        else sb += a.at(i);
    }

    cout << sa-sb << endl;
}


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

int N;

int main(void) {
  cin >> N;
  int temp = N % 10;
  string ans;
  if (temp == 3) {
    ans = "bon";
  } else if (temp == 0 || temp == 1 || temp == 6 || temp == 8) {
    ans = "pon";
  } else {
    ans = "hon";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
lli n;
double dp[301][301][301];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // lli n;
    cin >> n;
    // double dp[301][301][301];
    lli c1 = 0, c2 = 0, c3 = 0;
    for1(i, 0, n)
    {
        lli k;
        cin >> k;
        if (k == 1)
        {
            c1 += 1;
        }
        else if (k == 2)
        {
            c2 += 1;
        }
        else if (k == 3)
        {
            c3 += 1;
        }
    }
    dp[0][0][0] = 0.00;
    for1(k, 0, n + 1)
    {
        for1(j, 0, n + 1)
        {
            for1(i, 0, n + 1)
            {
                double s = i + j + k;
                if (s == 0 || s > n)
                {
                    continue;
                }
                else
                {
                    dp[i][j][k] = 1;
                    if (i)
                    {
                        dp[i][j][k] += (double)((double)i / (double)n * dp[i - 1][j][k]);
                    }
                    if (j)
                    {
                        dp[i][j][k] += (double)((double)j / (double)n * dp[i + 1][j - 1][k]);
                    }
                    if (k)
                    {
                        dp[i][j][k] += (double)((double)k / (double)n * dp[i][j + 1][k - 1]);
                    }
                }
                dp[i][j][k] *= (double)(n / (double)s);
                // cout << i << " " << j << " " << k << " " << dp[i][j][k] << endl;
            }
        }
    }
    cout << fixed << setprecision(15) << dp[c1][c2][c3] << endl;
}

Measured memory_bytes: 213248
inp = input
out = print
N, K = map(int, inp().split())
S = inp().rstrip('\n')

S += '1' if S[N-1] == '0' else '0'

#count
lenz = []
valz = []
cnt = 1
for i in range(1, N+1):
    if S[i] == S[i-1]:
        cnt += 1
    else:
        #add to lenz
        lenz.append(cnt)
        valz.append(1 if S[i-1] == '1' else 0)
        cnt = 1

M = len(lenz)
sumz = 0#[0]*(M+1)
maxsum = 0
right = 0
cnt = 0
left = 0
while left < M:
    while right < M:
        if valz[right] == 0:
            cnt += 1
        if cnt > K: break
        sumz += lenz[right]
        right += 1
    if maxsum < sumz: maxsum = sumz

    if right >= M:
        #finish, no more longer series
        break

    tmp = left
    cnt -= 1
    while left < M and valz[left] != 0:
        sumz -= lenz[left]
        left += 1
    if left < M:
        sumz -= lenz[left]
        cnt -= 1
        left += 1

out(maxsum)


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

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size();
	if ((s.front() == s.back()) ^ (s.size() % 2 == 0)) cout << "Second" << endl;
	else cout << "First" << endl;
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

string T[3] = {"Sunny", "Cloudy", "Rainy"};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    REP(i, 3) {
        if (S == T[i]) {
            cout << T[(i + 1) % 3] << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#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 unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
ll read(){ll a;scanf("%lld",&a);return a;}

const int inf = TEN(9) + 10;
const int mod = TEN(9) + 7;

inline ll mod_pow(ll a, ll x, ll m)
{
	if (x == 0) return 1;

	ll res;

	if (x % 2 == 0) {
		res = mod_pow(a, x / 2, m);
		res *= res;
		res %= m;
	} else {
		res = mod_pow(a, x / 2, m);
		res *= res;
		res %= m;
		res *= a;
		res %= m;
	}

	return res;
}

ll inv[1000010];
ll fac[1000010], fac_inv[1000010];

void comb_init()
{
	int N = 1000005;
	inv[1] = 1;

	for (int i = 2; i <= N; ++i) {
		inv[i] = mod - (mod / i) * inv[mod % i] % mod;
	}

	fac[0] = fac_inv[0] = 1;

	for (int i = 1; i <= N; ++i) {
		fac[i] = (fac[i - 1] * i) % mod;
		fac_inv[i] = (fac_inv[i - 1] * inv[i]) % mod;
	}
}


map<int, int> lcm; // lcm の素因数分解
map<int, int> AA[10010];

map<int, int> p_factor(int n) {
	map<int, int> ret;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n]++;

	for (pii p : ret) {
		chmax(lcm[p.fst], p.scd);
	}

	return ret;
}


int N;

signed main()
{
	cin >> N;
	vi A(N);

	rep(i, N) {
		cin >> A[i];
		AA[i] = p_factor(A[i]);
	}

	int LCM = 1;

	for (pii p : lcm) {
		LCM *= mod_pow(p.fst, p.scd, mod);
		LCM %= mod;
	}

	int ans = 0;

	comb_init();

	rep(i, N) {
		ans += LCM * inv[A[i]] % mod;
		ans %= mod;
	}

	cout << ans << endl;
}




Measured memory_bytes: 27392
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from bisect import bisect_left
from itertools import accumulate

n,q = li()
a = list(li())
x = [ni() for _ in range(q)]


cum_nor = list(accumulate(a))
cum_odd = list(accumulate(a[::2]))
cum_evn = list(accumulate(a[1::2]))
cum_kog = [cum_odd[i//2] if i%2==0 else cum_evn[i//2] for i in range(n)]

# 高橋君が左からtak個取れるならTrue そうでないならFalse
def check(a:list, tak:int, pivot:int):
    if tak > (len(a)+1)//2:
        return False
    
    if pivot-a[-2*tak+1] > a[-tak]-pivot:
        return False
    else:
        return True
        
    
def binsearch(a:list,xi:int):
    low = 1
    high = len(a)
    while high-low > 1:
        mid = (high+low) // 2
        if check(a,mid,xi):
            low = mid
        else:
            high = mid
            
    return low


for xi in x:
    tak = binsearch(a,xi)
    ans = cum_nor[-1] - cum_nor[-tak-1]
    if 2*tak < n:
        ans += cum_kog[-2*tak-1] 
    
    print(ans)

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int ModPow(int a,int r,int m)
{
	int x=1;
	for(;r;r>>=1){
		if(r&1) x=(ll)x*a%m;
		a=(ll)a*a%m;
	}
	return x;
}

int ModInverse(int a,int m)
{
	int x=1;
	for(int b=m,u=0;b;){
		ll t=a/b;
		swap(a-=b*t,b);
		swap(x-=u*t,u);
	}
	return (x+m)%m;
}

int ModMul(int a,int b,int m)
{
	return (ll)a*b%m;
}

int ModDiv(int a,int b,int m)
{
	return ModMul(a,ModInverse(b,m),m);
}

int main()
{
	for(int n,k;cin>>n>>k&&n|k;){
		vi divs;
		for(int i=1;i*i<=n;i++){
			if(n%i==0){
				divs.push_back(i);
				if(i*i!=n)
					divs.push_back(n/i);
			}
		}
		sort(all(divs));

		int m=divs.size();
		vi dp(m);
		rep(i,m){
			dp[i]=ModPow(k,(divs[i]+1)/2,MOD);
			rep(j,i) if(divs[i]%divs[j]==0)
				dp[i]=(dp[i]-dp[j]+MOD)%MOD;
		}

		int res=0;
		rep(i,m)
			if(divs[i]%2==0)
				(res+=ModDiv(ModMul(divs[i],dp[i],MOD),2,MOD))%=MOD;
			else
				(res+=ModMul(divs[i],dp[i],MOD))%=MOD;
		cout<<res<<endl;
	}
}


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

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

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

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




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

	REP(i, 100) {
		REP(j, 100) {
			if (i * 4 + j * 7 == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String args[]) throws IOException {
        Scanner input=new Scanner(System.in);
        int n=input.nextInt();
        long k=input.nextLong();
        int arr[]=new int[n];
        for(int i=0;i<n;i++) {
            arr[i]=input.nextInt()-1;
        }
        solve(n,arr,k);
    }
    public static void solve(int n,int arr[],long k) {
        int vis[]=new int[n];
        for(int i=0;i<n;i++) {
            vis[i]=-1;
        }
        long loop=-1;
        int i=0;
        for(int time=0;k>0;time++,k--) {
            if(vis[i]!=-1) {
                loop=time-vis[i];
                break;
            }
            vis[i]=time;
            i=arr[i];
        }
        if(k==0) {
            System.out.println(i+1);
            return;
        }
        k%=loop;
        while(k!=0) {
            i=arr[i];
            k--;
        }
        System.out.println(i+1);
    }
}


Measured memory_bytes: 60032
/*
    @uthor: Varun Mishra
    "varun21999" ->  Codechef, Codeforce, Hackerrank, Hackerearth;
*/
//#include<boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
//#define int     long long int
#define ull     unsigned int
#define ld      long double
#define pb      push_back
#define pa      pair<int,int>
#define ppa     pair<pair<int,int>,int>
#define pap     pair<int,pair<int,int>>
#define v1d     vector<int>
#define v2d     vector<vector<int> >
#define vpa     vector<pair<int,int>>
#define M       1000000007
#define MN      LLONG_MIN
#define MX      LLONG_MAX
#define ff      first
#define ss      second
#define endl    "\n"
#define v1s     vector<string>
#define all(v)  v.begin(),v.end()
#define S(v)    sort(v.begin(),v.end())
#define RS(v)          sort(v.rbegin(),v.rend())
#define R(v)           reverse(v.begin(),v.end())
#define mxpq(T)        priority_queue <T>
#define mnpq(T)        priority_queue<T,vector<T>,greater<T>>
#define T              int tc;cin>>tc;while(tc--)
#define p2d(v)         for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)         for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)         for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define forIloop(i,n)  for(auto i=0;i<n;i++);
#define forDloop(i,n)  for(auto i=n-1;i>=0;i--);
#define qqq 400005
const int MOD = 1e9 + 7;
// int popcount(int num){
//     num = num - ((num >> 1) & 0x55555555);
//     num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
//     return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
// }
// int powerOfTwo(int n){
//     return 1 << n;
// }

// int arr[1000001];
// bool temet = false;




void codeChef(){
    int x,y; cin>>x>>y;
    int m1 = x*2, m2 = x*4;
    if(y%2==0 && y>=m1 && y<= m2){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return;
}




int32_t main(){

    cout<<fixed<<setprecision(16);
    cin.sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
    /*#ifndef _DEBUG
     freopen("input.txt",  "r",  stdin);
     freopen("output.txt", "w", stdout);
    #endif*/
    //auto start = high_resolution_clock::now();

    // Lucario();
    //codeforceContest();
    //hackerEarth();
    codeChef();

   /* auto stop = high_resolution_clock::now();
    auto duration = duration_cast<seconds>(stop - start);
    cout << "Time: "<<duration.count()<<endl;*/
    return 0;
}

Measured memory_bytes: 3636
n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n-i+1):
        if i*10000 + j*5000 + (n-i-j)*1000 == y:
            print(i, j, n-i-j)
            break
    else:
        continue
    break
else:
    print(-1, -1, -1)

Measured memory_bytes: 40684
#include <bits/stdc++.h>
#define fio() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define int long long
#define MOD 998244353
using namespace std;
int32_t main()
{
	fio();
	int n;
	cin>>n;
	string s;
	cin>>s;
	int a[7]={0};
	memset(a,0,sizeof(a));
	a[0]=n;
	int ans=1;

	for(int i=0;i<3*n;i++)
	{
		if(s[i]=='R')
		{
			if(a[5]>0)
			{
				ans*=a[5];
				ans%=MOD;
				a[5]--;
			}
			else if(a[2]>0)
			{
				ans*=a[2];
				ans%=MOD;
				a[2]--;
				a[4]++;
			}
			else if(a[3]>0)
			{
				ans*=a[3];
				ans%=MOD;
				a[3]--;
				a[6]++;
			}
			else
			{
				ans*=a[0];
				ans%=MOD;
				a[0]--;
				a[1]++;
				//cout<<ans<<endl;
			}
		}
		else if(s[i]=='B')
		{
			if(a[6]>0)
			{
				ans*=a[6];
				ans%=MOD;
				a[6]--;
			}
			else if(a[1]>0)
			{
				ans*=a[1];
				ans%=MOD;
				a[1]--;
				a[4]++;
			}
			else if(a[3]>0)
			{
				ans*=a[3];
				ans%=MOD;
				a[3]--;
				a[5]++;
			}
			else
			{
				ans*=a[0];
				ans%=MOD;
				a[0]--;
				a[2]++;
			}
		}
		else
		{
			if(a[4]>0)
			{
				ans*=a[4];
				ans%=MOD;
				a[4]--;
			}
			else if(a[1]>0)
			{
				ans*=a[1];
				ans%=MOD;
				a[1]--;
				a[6]++;
			}
			else if(a[2]>0)
			{
				ans*=a[2];
				ans%=MOD;
				a[2]--;
				a[5]++;
			}
			else
			{
				ans*=a[0];
				ans%=MOD;
				a[0]--;
				a[3]++;
			}
		}
		//cout<<ans<<endl;
	}

	cout<<ans;
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
#define mx 10000010
typedef long long ll;
ll dv[mx];
void divisors()
{
    ll i,j,c;
    for(i=1;i<=mx;i++)
    {
        for(j=i;j<=mx;j+=i)dv[j]++;
    }
}
int main()
{
    ll n,sum=0;
    divisors();
    cin>>n;
    for(ll i=1;i<=n;i++)sum+=i*dv[i];
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 81724
N = int(input())
uvw = [list(map(int,input().split())) for i in range(N-1)]
u = []
v = []
distance = []
for i in range(N-1):
    u.append(uvw[i][0])
    v.append(uvw[i][1])
    distance.append(uvw[i][2])
graph = [dict() for i in range(N)]
for i in range(N-1):
    graph[u[i]-1][v[i]-1] = distance[i]
    graph[v[i]-1][u[i]-1] = distance[i]

trav = [-1]*N
trav[0]=0
pos = [0]
while len(pos)>0:
    r = pos.pop()
    for i in graph[r]:
        if trav[i] != -1:
            continue
        else:
            trav[i] = trav[r]+graph[r][i]
            pos.append(i)

color = [0]*N
for i in range(N):
    color[i] = trav[i]%2
    print(color[i])

Measured memory_bytes: 76560
n=int(input())
hp=list(map(int,input().split()))
ak=list(map(int,input().split()))
ans=0
for i in range(n):
        if ak[i]<=hp[i]:
                ans+=ak[i]
                continue
        else:
                ak[i]-=hp[i]
                ans+=hp[i]
        ans+=min(ak[i],hp[i+1])
        hp[i+1]=max(0,hp[i+1]-ak[i])
print(ans)

Measured memory_bytes: 18476