akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
    ifstream t("/proc/self/status");
    cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum = 0, fg = 1;
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef pair<int, int> pii;

LL A, B, C, D;

inline void input()
{
	A = read<LL>(), B = read<LL>(), C = read<LL>(), D = read<LL>();
}

inline void solve()
{
	if(B > D) { puts("No"); return; }
	LL A0 = A - max(A - C, 0ll) / B * B;
	if(A0 == C) A0 += D;
	if(A0 < B) { puts("No"); return; }
	A0 %= B;
//	printf("A0: %lld\n", A0);
	LL delta = __gcd(D, B), mx = (A0 + (B - A0) / delta * delta) % B;
	if(mx == 0) mx = (B - delta) % B;
//	printf("max: %lld\n", mx);
	if(mx > C) { puts("No"); return; }
	puts("Yes");
}

int main()
{
//#ifndef ONLINE_JUDGE
//	freopen("B.in", "r", stdin);
//	freopen("B.out", "w", stdout);
//#endif

	int T = read<int>();
	while(T--)
	{
		input();
		solve();
	}

	return 0;
}



Measured memory_bytes: 256
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    println!("{}",if a*b%2<1{"Even"}else{"Odd"})
}

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

// #define int long long

signed main(void)
{
  int num; // num
  // num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  num = numeric_limits<int>::max(); // min
  int n;
  int k;
  array<int, 100000> a;

  cin>> n >> k;
  for(auto it = a.begin(); it < a.begin() + n; ++it)
    cin >> *it;

  sort(a.begin(),a.begin() + n,greater<int>());

  for(auto it = a.begin(); it + k - 1< a.begin() + n; ++it)
    num = min(num, *it - *(it + k - 1));

  cout << num << endl;
  return 0;
}


Measured memory_bytes: 640
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    x, k, d = map(int, input().split())

    x = abs(x)
    d = abs(d)
    ans = 0

    count = x // d
    if k <= count:
        ans = x - k * d
    else:
        k -= count
        x = x - count * d
        x = abs(x)
        if k % 2 == 0:
            ans = x
        else:
            ans = abs(x - d)
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 72788
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int ans = 0;
		for (int i = 0; i < 5; i++)
			ans += Math.max(40, scanner.nextInt());
		System.out.println(ans / 5);
	}
}

Measured memory_bytes: 17164
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pll pair<ll,ll>
#define sll set<ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define vpl vector<pll>
#define gll greater<ll>
#define spl set<pll>
#define lb lower_bound
#define ub upper_bound
#define prq priority_queue
#define mp make_pair
#define pb push_back
#define rapido ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long int ll;
typedef long double ld;
ll mx=INT_MAX;
ll mn=INT_MIN;
ll mod=1e9+7;
const ll maxs=1e6+6;
ll max2d=1e3+3;
ll INF = 9e18;

int main(){
    rapido;
    ll N; cin>>N;
    string s; cin>>s;
    ll nr=0, ng=0, nb=0, i, j;
    for(i=0; i<N; i++){
        if(s[i]=='R') nr++;
        else if(s[i]=='G') ng++;
        else if(s[i]=='B') nb++;
    }
    ll no=0;
    for(i=0; i<N-2; i++){
        for(j=i+1; j<N-1; j++){
            ll k = 2*j-i;
            if(k>=N) continue;
            if(s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]) no++;
        }
    }
    ll ans = nr*ng*nb - no;
    cout<<ans;
    return 0;
}

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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define FORalld(it, a) for (__typeof((a).rbegin()) it = (a).rbegin(); it != (a).rend(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
template<class T> inline T isqrt(T k) {T r = sqrt(k) + 1; while (r * r > k) r--; return r;}
template<class T> inline T icbrt(T k) {T r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}

const int maxn = 100000 + 10;
int n;
vi adj[maxn];
int dp[maxn];

int func(int u) {
	int& res = dp[u];
	if (~res) return res;
	vi li;
	FOR(i, 0, sz(adj[u])) {
		int v = adj[u][i];
		li.pb(func(v));
	}
	sort(all(li), greater<int>());
	res = 0;
	FOR(i, 0, sz(li)) {
		chkmax(res, li[i] + i);
	}
	return res + 1;
}

void solve() {
	cin >> n;
	FOR(i, 1, n) {
		int u; cin >> u; u--;
		adj[u].pb(i);
	}
	ms(dp, -1);
	cout << func(0) - 1 << "\n";
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 17024
#include<bits/stdc++.h>
#define LL long long
#define maxn 2019
using namespace std;
int main()
{
	int a[4];
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+4);
	if(a[2]*2==a[1]+a[3])
	cout<<"YES";
	else
	cout<<"NO";
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        char[] c = str.toCharArray();
        
        int a = 1 -1;
        int b = c.length -1;
        while (a <= b) {
            if (c[a] != c[b]) {
                System.out.println("No");
                return;
            }
            a++;
            b--;
        }
        
        a = 1 -1;
        b = ((c.length - 1)/2) -1;
        while (a <= b) {
            if (c[a] != c[b]) {
                System.out.println("No");
                return;
            }
            a++;
            b--;
        }
        
        a = ((c.length+3)/2) -1;
        b = c.length -1;
        while (a <= b) {
            if (c[a] != c[b]) {
                System.out.println("No");
                return;
            }
            a++;
            b--;
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 22868
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL long long
#define MOD 100000
#define inf 1999999999
#define ALL(x) (x).begin(), (x).end()
#define LBi(x, n) lower_bound(ALL(x), n) - (x).begin()
#define ZIP(x) (x).erase(unique(ALL(x)), (x).end())
#define Pi pair<int, int>
#define Vi vector<int>

string s;
int a, b, c, d, x, m[5];

int main() {
	cin >> a >> b >> c;
	cout << ((a + b >= c) ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)

int main()
{
  int p, q, r;
  cin >> p >> q >> r;

  cout << min(min(p+q, q+r), r+p) << endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;
import java.util.regex.Pattern;

public class Main {
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct 

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long mod = (long) (1e9+7);
	static int N = (int) 1e5;
//	Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		 FastReader sc = new FastReader();

		 int n = sc.nextInt();
		 int[] a = new int[n];
		 long[] pre = new long[n+1];
		 Map<Long,Integer> map = new HashMap<>();
		 map.put(0L, 1);
		 long ans = 0;
		 for(int i=1;i<=n;++i) {
			 a[i-1] = sc.nextInt();
			 pre[i] = pre[i-1]+a[i-1];
			 add(map,pre[i]);
		 }
		 
		 for(long key : map.keySet()) {
			 long x = map.get(key);
			 ans+=(x*(x-1))/2;
		 }
		 out.println(ans);
		 
		 out.close();
	}
	

	private static void add(Map<Long, Integer> map, long i) {
		// TODO Auto-generated method stub
		if(map.containsKey(i)) map.put(i, map.get(i)+1);
		else map.put(i, 1);
		
	}
	private static void delete(Map<Integer, Integer> map, int i) {
		if(map.containsKey(i)) {
			if(map.get(i) == 1) map.remove(i);
			else map.put(i, map.get(i)-1);
		}
		
	}
}

Measured memory_bytes: 66812
#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

typedef struct TEAM{
	int tid;
	map<int,int> ptf;
	int score;
	int pena;

	bool operator < (const TEAM& oth)const{
		if(score==oth.score) {
			if(pena==oth.pena) return tid<oth.tid;
			return pena<oth.pena;
		}
		return score>oth.score;
	}

}TEAM_t;

int main(int argc, char const *argv[])
 {
 	int T,P,R;
 	int t,p,time_;
 	string s;

 	while(1){
 		cin>>T>>P>>R;
 		if(T+P+R==0) break;

 		vector<TEAM_t> team(T);

 		for(int i1=0;i1<T;i1++){
 			team[i1].tid=i1;
 			team[i1].score=0;
 			team[i1].pena=0;

 			for(int i2=0;i2<P;i2++){
				team[i1].ptf[i2]=0;
			}
 		}

 		for(int i1=0;i1<R;i1++){
 			cin>>t>>p>>time_>>s;
 			if(s=="CORRECT"){
 				team[t-1].score++;
 				team[t-1].pena+=time_+1200*team[t-1].ptf[p-1];
 			}
 			else {
 				team[t-1].ptf[p-1]++;
 			}
 		}

 		sort(team.begin(), team.end());

 		for(int i1=0;i1<T;i1++){
 			cout<<team[i1].tid+1<<" "<<team[i1].score<<" "<<team[i1].pena<<endl;
 		}
 		


 	}
 	return 0;
 } 

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

int reverse(int x) {
    int ret = 0;
    while (x > 0) {
        ret = ret * 10 + x % 10;
        x /= 10;
    }
    return ret;
}

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for (int i = a; i <= b; i++) {
        if (i == reverse(i))
            ans++;
    }
    cout << ans << endl;
    return 0;
}

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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x);1
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair	
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

using namespace std;
typedef long long ll;
typedef long double ld;	
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
	 
const ll MAX = 10000000;
const ll inf = 5e18-1;

int main() {
	fastio;
	string s;
	cin>>s;
	ll k=0,m=0;
	char in,tw='a';
	f(i,0,4){
		if(i==0) in=s[i];
		else if(s[i]==in) k=1;
		else if(s[i]!=in && s[i]!=tw) tw=s[i];
		else if(s[i]==tw) m=1;
	}
	if(k+m==2) yes;
	else no;
	return 0;
	}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    vector<int> a;
    for(int i = 0; i < n; i++){
        int in;
        cin >> in;
        a.push_back(in);
    }
    //cout << "lol" << endl;
    sort(a.begin(), a.end());
    if(a[0] < (a[n - 1] - 1)){
        cout << "No" << endl;
        return 0;
    }
    //cout << "A" << endl;
    if(n == 1){
        if(a[0] == 0){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        return 0;
    }
    if(a[n - 1] != a[n - 2]){
        cout << "No" << endl;
        return 0;
    }
    if(a[0] == a[n - 1]){
        if(a[0] == (n - 1)){
            cout << "Yes" << endl;
        } else if(a[0] <= (n / 2)){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        return 0;
    }
    int mini = 0;
    for(int i = 0; i < n; i++){
        if(a[i] == a[0]){
            mini++;
        }
    }
    if((a[0] >= mini) && (a[n - 1] <= mini + (n - mini) / 2)){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
const int MAX=5005;
int m,n;
char s[MAX];
pii u[6];
bool cmp(pii a,pii b){
    int k1=a.first,k2=b.first;
    if(k1==-1) return 0;
    if(k2==-1) return 1;
    while(1){
        if(s[k1]>s[k2]) return 0;
        else if(s[k1]<s[k2]) return 1;
        k1++,k2++;
        if(k2==b.second) return 0;
        else if(k1==a.second) return 1;
    }
}
int checker(pii a){
    for(int i=0;i<6;i++){
        if(u[i].first==-1||u[i].second-u[i].first!=a.second-a.first) continue;
        int c=1;
        int k1=u[i].first,k2=a.first;
        for(;k2!=a.second;k2++,k1++){
            if(s[k1]!=s[k2]) c=0;
        }
        if(c) return 0;
    }
    return 1;
}
void myp(){
    for(int i=u[m].first;i<u[m].second;i++) printf("%c",s[i]);
    printf("\n");
}
int main(){
    scanf(" %s %d",s,&m),m--;
    n=strlen(s);
    for(int i=0;i<6;i++) u[i]=make_pair(-1,-1);
    for(int i=0;i<n;i++) for(int j=i+1;j<=i+6&&j<=n;j++){
        pii t=make_pair(i,j);
        if(checker(t)) {
            u[5]=t;
            sort(u,u+6,cmp);
        }
    }
    myp();
}


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

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int H,W,N;
	cin >> H >> W >> N;
	int x,y;
	cin >> x >> y;
	x--;y--;
	string S;
	cin >> S;
	string T;
	cin >> T;
	bool alive = 1;
	string a = "LURD";
	string b = "RDLU";
	int dx[4] = {0,-1,0,1};
	int dy[4] = {-1,0,1,0};
	rep(j,4){
		int curx = x;
		int cury = y;
		rep(i,N){
			//a君はできるだけj方向に進み外に出す
			//b君はできるだけjとは逆方向に進むがマス目からは出ないようにする
			if(S[i]==a[j]){
				curx += dx[j];
				cury += dy[j];
			}
			if(curx<0||cury<0||curx>=H||cury>=W)alive = 0;
			if(T[i]==b[j]){
				int nx = curx+dx[(j+2)%4];
				int ny = cury+dy[(j+2)%4];
				if(nx>=0&&nx<H)curx = nx;
				if(ny>=0&&ny<W)cury = ny;
			}
		}
	}
	if(alive)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 920
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;
ll n;

//Number theory
ll gcd(ll a, ll b){ return a % b == 0 ? b : gcd(b, a%b); }
ll lcm(ll a, ll b){ return a * b/ gcd(a, b); }
ll extgcd(ll a, ll b, ll& x, ll& y){
	ll d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}

ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

ll mod_div(ll x, ll y) {
	return (x * mod_pow(y, MOD - 2)) % MOD;
}

//numの桁数(base進数)を返します
int getKeta(ll num, ll base=10){
	int keta=0;
	while(num > 0){
		num /= base;
		keta++;
	}
	return keta;
}

vector<pair<ll, int> > factorize(ll n){
	vector<pair<ll, int> > res; //sum(first[i]^second[i]) 
	for(ll i=2; i*i<=n; i++){
		if(n%i) continue;
		res.emplace_back(i, 0);
		while(n%i == 0){
			n /= i;
			res.back().second++;
		}
	}
	if(n != 1)res.emplace_back(n, 1);
	return res;
}

void gcd3(ll a, ll b){
	ll hoge = gcd(a, b);
	rep2(c,1, n+1){
		ans += gcd(hoge, c);
	}
}

//Sieve of Eratosthenes
#define MAX_N 1'000'000
int prime[MAX_N];
bool isPrime[MAX_N + 1];
int sieve(ll n){
	int p = 0;
	fill(isPrime, isPrime+n+1, true);
	isPrime[0] = isPrime[1] = false;
	for(ll i=2; i<=n; i++){
		if(isPrime[i]){
			prime[p++] = i;
			for(ll j=2*i; j<=n; j+=i){
				isPrime[j] = false;
			}
		}
	}
}


int main(void){
	cin >> n;
	rep2(i,1,n+1){
		rep2(j,1,n+1){
			 gcd3(i, j);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N, A, B = sc.nextLong()

    // 負けが右, 勝ちが左へ
    // 一番左で勝っても動かず、一番右で負けても動かない
    // 同時に動く場合, 一度に2ずつ近づける
    // * L = 2N + 1 台間にある場合には N ラウンドでOK
    // * L = 2N 台間にある場合には そのまま近づいていってもダメなので
    //   (A max B) min ((N - A) max (N - B)) で良い？
    def solve(N: Long, A: Long, B: Long): Long = {
      val L = B - A
      if ((L - 1L) % 2L == 1L) L / 2L
      else (((A - 1) min (N - B)) + 1 + (B - A - 1) / 2)
    }

    println(solve(N, A, B))
  }

}


Measured memory_bytes: 25536
import java.util.Scanner;
public class Main{
	public static int Int(char a) {
		if(a=='o') {
			return 100;
		}
		else {
		return 0;
		}
	}
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String a=scan.next();
		int ans=700;
		ans+=Int(a.charAt(0));
		ans+=Int(a.charAt(1));
		ans+=Int(a.charAt(2));
	System.out.println(ans);
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v){
  const char* delimiter = "";
  for (const auto& x:v) {
    cout << exchange(delimiter, " ") << x;
  }
  return os;
}
int32_t main(){
  string s,t; cin>>s>>t;
  vector<vector<size_t>> dp(s.size()+1,vector<size_t>(t.size()+1));
  // i=0
  for(size_t j=0; j<dp[0].size(); ++j) dp[0][j]=j;
  for(size_t i=1; i<dp.size(); ++i){
    // j=0
    dp[i][0]=i;
    for(size_t j=1; j<dp[i].size(); ++j){
      dp[i][j]=min(dp[i-1][j]+1,dp[i][j-1]+1);
      if(s[i-1]==t[j-1]) dp[i][j]=min(dp[i][j],dp[i-1][j-1]);
      else dp[i][j]=min(dp[i][j],dp[i-1][j-1]+1);
    }
  }
  cout<<dp.back().back()<<endl;
}


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

int main() {
  int N = 0;

  int count=0;

  double D = 0,x = 0,y = 0;

  scanf("%d %lf",&N,&D);

  for(int i=0;i<N;i++){
    scanf("%lf %lf",&x,&y);
    if(sqrt(x*x+y*y) <= D) count++;
  }

  printf("%d\n",count);

  return 0;
}

Measured memory_bytes: 2220
#include<cstdio>
#include<algorithm>
#include<set>
using namespace std;
multiset<int>Set;
int n, m;
int main(){
    int i, a;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        Set.insert(a);
    }
    scanf("%d",&m);
    for(i=0;i<m;i++){
        scanf("%d",&a);
        auto it = Set.find(a);
        if(it == Set.end()){
            printf("NO\n");
            return 0;
        }
        Set.erase(it);
    }
    printf("YES\n");
}

Measured memory_bytes: 9600
n = int(input())
a = list(map(int, input().split()))
mod = 1000000007
res = 0
for i in range(62):
  cnt = 0
  for x in a:
    if (x & (1<<i)) > 0:
      cnt += 1
  res = (res + (cnt * (n-cnt) * (1 << i))) % mod
print(res)

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    a.erase(unique(all(a)), a.end());
    if (int(a.size()) == n) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}



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

int main()
{
	int i, n, x, y;
	cin >> n;
	int a[n], b[n];
	for(i=0; i<n; i+=1)
	{
		cin >> a[i];
		b[i]=a[i];
	}
	sort(b, b+n);
	for(i=0; i<n; i+=1)
	{
		x=a[i];
		y=lower_bound(b, b+n, x)-b;
		if(y==n-1)
			cout << b[n-2] << endl;
		else
			cout << b[n-1] << endl;
	}
}

Measured memory_bytes: 3200
s = []
for i in range(2):
    s.append(input().split())
h = int(s[0][0])
n = int(s[0][1])
x = 0
for i in range(n):
    x = x + int(s[1][i])
if(h<=x):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9944
#include<cstdio>
#include<map>
using namespace std;
int n,a[200005];
long long k;
map<int,int> mp;
int main()
{
	scanf("%d%lld",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	int now=1;
	for(int i=1;i<=n;i++)
	{
		if(mp[now])
		{
			int x=mp[now];
			int ans=x+((k-x)%(i-x)),tmp=1;
			if(k<=n) ans=k; 
			for(int j=1;j<=ans;j++) tmp=a[tmp];
			printf("%d\n",tmp);
			return 0;
		}
		mp[now]=i;
		now=a[now];
	}
} 

Measured memory_bytes: 13384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) (v).begin(),(v).end()
#define out(a) cout << (a) << endl
using namespace std;
using ll = long long;
int main(){
    int r;
    cin >> r;
    cout << fixed << setprecision(20);
    out(r*2*M_PI);
}

Measured memory_bytes: 3784
import sys

n=int(input())
a = list(map(int, input().split())) #a1 a2 a3 // b1 b2 b3
if a.count(0)>=1:
    print(0)
    sys.exit()
ans=1
for at in a:
  ans*=at
  if ans>10**18:
    print(-1)
    sys.exit()
print(ans)

Measured memory_bytes: 21644
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    double x,h;
    while(cin >> x >> h, h){
        cout << fixed  << setprecision(6);
        cout << sqrt(x * x / 4 + h * h) * x * 2 + x * x << endl;
    }
}

Measured memory_bytes: 1276
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
#ifdef _75108D01685041AA959399A981476AD7
  std::freopen("input.txt", "r", stdin);
#endif
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> v(s.size()+1);
  for (int j = 2; j <= s.size(); j++) {
    if (s[j-2] == 'A' && s[j-1] == 'C') v[j] = v[j-1]+1;
    else v[j] = v[j-1];
  }
  cout << endl;
  for (int i = 0; i < q; i++) {
    int l, r;
    cin >> l >> r;
    cout << v[r]-v[l] << "\n";
  }

  return 0;
}

Measured memory_bytes: 1488
#include <iostream>

using namespace std;
int main(){
int a,b,c,m,i,g,h;
    cin>>a>>b>>c;
    i=0;
       for(m=1;m<=c;m++){
            if(c%m==0){
                g=m;
                 if(a<=g && b>=g){
                     h=i+1;
                     i=h;
                 }
                     }
                     }
            cout<<i<<endl;   
            return 0;      
}

Measured memory_bytes: 1160
#include <iostream>
#include <cmath>
using namespace std;
long long n,a,b,c,d,e,t,mmax;
long long i,ok;
struct transport
{
     long long urmoras,locuri;
} v[7];
int main()
{
    cin >> n;
    for(i = 1; i <= 5; ++i)
    {
        cin >> v[i].urmoras;
        v[i].locuri=n/v[i].urmoras;
        if(n%v[i].urmoras!=0)
            v[i].locuri++;
        mmax=max(mmax,v[i].locuri);
    }
    mmax+=4;
    cout<<mmax;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <map>

using namespace std;

bool kaibun(string s){
    size_t len = s.length();
    for(int i = 0; i < len/2; i++){
        if(s[i] != s[len-i-1]) return false;
    }
    return true;
}

int main(){
    int N,M,ans=0;
    cin >> N >> M;
    map<int,int> cond;
    for(int i = 0; i < M; i++){
        int a,b;
        cin >> a >> b;
        auto ret = cond.insert(std::make_pair(a,b));
        if(ret.second == false && cond[a] != b){
            cout << "-1" << endl;
            return 0;
        }
    }
    if(N==1){
        if(cond.count(2)) {cout << "-1"<< endl; return 0;}
        if(cond.count(3)) {cout << "-1"<< endl; return 0;}
        ans = cond[1];
    }else if(N==2){
        if(cond.count(3)) {cout << "-1"<< endl; return 0;}
        ans = cond[1]*10 + cond[2];
        if(ans < 10) ans+=10;
    }else if(N==3){
        if(cond.count(1) && cond[1] == 0) {cout << "-1" << endl; return 0;}                                                     ans = cond[1]*100 + cond[2]*10 + cond[3];
        if(ans < 100) ans+=100;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
///******* In the name of Allah *******///

#include <bits/stdc++.h>
using namespace std;

long int gcd(long int a, long int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}

void Ok()
{
    long long int a,b,c,d[1013],e,f,g,h,t,i,j = 0,k,l1,l2,m,n,x,y,sum,ans_1,ans_2,ans_3,cnt,Max,Min,flag,div,rcv,temp;
    long double aa,bb,cc,dd,ee,ff,gg;
    char aaa[100013],bbb[1013],ccc[1013],alpbt;

    cin>>a>>b;
    if(a>=13)
    {
        cout<<b<<endl;
    }
    else if(a>=6 && a<=12)
    {
        ans_1 = b/2;
        cout<<ans_1<<endl;
    }
    else
    {
        cout<<"0"<<endl;
    }

    return;
}

int main()
{
    Ok();

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <set>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;

char buf[100000+10];

int main(void) {
  scanf("%s", buf);
  int res = 0;
  for(int i = 0; buf[i]; ++i) {
    char my = i & 1 ? 'p' : 'g';
    res += my == buf[i] ? 0 : my == 'p' ? 1 : -1;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> d(n);
    for(int i=0; i<n; i++){
        cin >> d[i];
    }
    sort(d.begin(),d.end());
    int ans;
    int sz;
    sz = d.size();
    int hf;
    hf = sz/2;
    ans = d[hf]-d[hf-1];
    cout << ans << endl;
}




Measured memory_bytes: 640
# 1. 最大公約数を求める(ユークリッドの互除法)
# 2. 最大公約数を2と3以上の奇数で順次割っていくする（下から計算したら、素数判定は不要）
# 3. 2.の結果に含まれる数の種類の数＋１が答え

def main():
  a, b = map(int, input().split())
  while b != 0: a, b = b, a % b #最大公約数を求める
  print(num_facto(a) + 1)  
  
def num_facto(n):
  ans = 0
  max_n = int(n ** 0.5) + 1
  if n == 1: return ans
  two_and_odds = [2] + [x for x in range(3, max_n, 2) if x ** 2 <= n]
  for cursor in two_and_odds:
    if n % cursor == 0: ans += 1
    while n % cursor == 0: n = n // cursor
  if n != 1: ans += 1
  return ans
    
if __name__ == "__main__":
  main()


Measured memory_bytes: 79600
from itertools import accumulate

N,K = map(int, input().split())
p=list(map(int,input().split()))

q=[0]+p
q=list(accumulate(q)) 

ans=[]
for i in range(N-K+1):
    ans.append(((q[i+K]-q[i])+K)*0.5)

print(max(ans))

Measured memory_bytes: 25540
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

void comb_sub(int n, int r, int m, vector<int> &vec, vector<vector<int> > &res) {

	if (r == 0) {
		res.push_back(vector<int>(vec));
	}
	else if (r == n) {
		for (int i = r; i > 0; i--)
			vec[m++] = i;
		res.push_back(vector<int>(vec));
	}
	else {
		comb_sub(n - 1, r, m, vec, res);
		vec[m] = n;
		comb_sub(n - 1, r - 1, m + 1, vec, res);
	}
}

vector<vector<int> > comb(int n, int r) {

	auto res = vector<vector<int> >();
	auto vec = vector<int>(r);

	comb_sub(n, r, 0, vec, res);

	return res;
}


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

	int arr[27] = { 0 };
	char buf[11];
	for (int i = 0; i < N; i++) {
		cin >> buf;
		arr[buf[0] - 'A']++;
	}
	arr['B' - 'A'] = arr['M' - 'A'];
	arr['D' - 'A'] = arr['R' - 'A'];
	arr['E' - 'A'] = arr['H' - 'A'];

	auto comVV = comb(5, 3);

	LL cnt = 0;
	for (auto vec : comVV) {
		LL subcnt = 1;
		for (auto val : vec) {
			subcnt *= arr[val -1];
		}
		cnt += subcnt;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
using namespace std;

signed main(){
    map<string,int> map;
    int q;
    cin>>q;
    while(q--){
        int y;
        string k;
        cin>>y>>k;
        if(y==0){
            int x;
            cin>>x;
            map[k]=x;
        }
        else if(y==1){
            auto it=map.find(k);
            cout<<(it!=map.end()?it->second:0)<<endl;
        }
        else{
            map.erase(k);
        }
    }
    return 0;
}


Measured memory_bytes: 27672
#include<cstdio>

using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    int c[n-1];
    int s[n-1];
    int f[n-1];
    for(int i = 0; i < n-1; i++){
        scanf("%d %d %d", &c[i], &s[i], &f[i]);
    }
    for(int i = 0; i < n - 1; i++){
        int t = 0;
        for(int j = i; j < n - 1; j++){
            if (t <= s[j]) t = s[j] + c[j];
            else if (t % f[j] == 0) t += c[j]; 
            else t = t - (t % f[j]) + f[j] + c[j];
        }
        printf("%d\n", t);
        
    }
    puts("0");
}

Measured memory_bytes: 256
import math
def isprime(x):
    if x ==2:
        return True
    if x<2 or x%2 ==0:
        return False
    else:
        sx = int(math.sqrt(x))
        for i in range(3,sx+1,2):
            if x%i ==0:
                return False
            
        return True
a = 0
n = int(input())
for i in range(n):
    a+= isprime(int(input()))
print(a)



Measured memory_bytes: 5672
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define sort(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())

using namespace std;

int main() {
	int n, k, q;
	cin >> n >> k >> q;
	int s = q - k+1;
	vector<int> ac(n);
	ff(i, 0, n) {
		ac.at(i) = 0;
	}
	ff(i, 0, q) {
		int a;
		cin >> a;
		a--;
		ac.at(a)++;
	}
	ff(i, 0, n) {
		if (ac.at(i) >= s) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll N, X;
    cin >> N >> X;
    ll ans = 0;
    vector<ll>vec(N);
    for(ll i = 0; i < N; i++){
        cin >> vec[i];
        if(vec[i] > X){
            ans += vec[i] - X;
            vec[i] = X;
        }
    }
    for(ll i = 1; i < N; i++){
        ll sum = vec[i - 1] + vec[i];
        ll ov = sum - X;
        if(ov > 0){
            ans += ov;
            vec[i] -= ov;
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 1024
def resolve():
    '''
    code here
    '''
    import collections
    N = int(input())
    S = input()

    cnt_dict = collections.Counter([item for item in S])
    ng_cnt = 0
    for i in range(N):
        for j in range(i, N):
            k = 2*j - i
            if k < N:
                if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
                    ng_cnt += 1
    
    print(cnt_dict['R']*cnt_dict['G']*cnt_dict['B'] - ng_cnt)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9460
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int A[200000];
int ball[200000];
int M;
int B[200000];
int main(){
  int i, j, k;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  for(k=N;k;k--){
    j = A[k-1];
    for(i=k;i<=N;i+=k){
      j ^= ball[i-1];
    }
    ball[k-1] = j;
  }
  for(i=0;i<N;i++){
    if(ball[i]){
      B[M++] = i+1;
    }
  }
  wt_L(M);
  wt_L('\n');
  {
    int KL2GvlyY;
    if(M==0){
      putchar_unlocked('\n');
    }
    else{
      for(KL2GvlyY=0;KL2GvlyY<M-1;KL2GvlyY++){
        wt_L(B[KL2GvlyY]);
        wt_L(' ');
      }
      wt_L(B[KL2GvlyY]);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay varsion 20190715-1

// --- original code ---
// int N, A[2d5];
// 
// int ball[2d5];
// int M, B[2d5];
// {
//   int i, j, k;
//   rd(N,A(N));
// 
//   for(k=N;k;k--){
//     j = A[k-1];
//     for(i=k;i<=N;i+=k) j ^= ball[i-1];
//     ball[k-1] = j;
//   }
// 
//   rep(i,N) if(ball[i]) B[M++] = i+1;
//   wt(M);
//   wt(B(M));
// }


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

void solve()
{
    int N;
    cin >> N;

    vector<LL> a(N);
    LL sum_a = 0;
    REP0 (i, N)
    {
        cin >> a[i];
        sum_a += a[i];
    }

    vector<LL> b(N);
    LL sum_b = 0;
    REP0 (i, N)
    {
        cin >> b[i];
        sum_b += b[i];
    }

    LL op_max = sum_b - sum_a;
    LL ops = 0;
    REP0 (i, N)
    {
        if (a[i] < b[i])
        {
            ops += (b[i] - a[i] + 1) / 2;
        }
    }

    cout << (op_max >= ops ? "Yes" : "No") << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 384
#C
n,k,q=map(int,input().split())
a=[int(input()) for _ in range(q)]
b=[k-q for _ in range(n)]
for i in range(q):
    b[a[i]-1]+=1
for i in range(n):
    if b[i]<=0:
        print("No")
    else:
        print("Yes")



Measured memory_bytes: 58328
#include <iostream>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
using namespace std;
typedef vector<int> vi;
typedef vector<pair<int,int> > vp;

int main()
{
  while(1)
    {
      string s;
      getline(cin,s);
      if(s==".") break;
      stack<char> pot;
      int sql=0,sqr=0,cil=0,cir=0;
      bool miss=false;
      bool psql=false,pcil=false;
      for(int i=0;i<s.size();i++)
	{
	  if(s[i]=='(')
	    {
	      cil++;
	      pot.push('(');
	    }
	  else if(s[i]==')') 
	    {		  
	      cir++;
	      if(pot.empty() || pot.top()!='(')
		{
		  cout << "no" << endl;
		  miss=true;
		  break;
		}
	      pot.pop();
	    }
	  else if(s[i]=='[') 
	    {
	      sql++;
	      pot.push('[');
	    }
	  else if(s[i]==']') 
	    {
	      sqr++;
	      if(pot.empty() || pot.top()!='[')
		{
		  cout << "no" << endl;
		  miss=true;
		  break;
		}
	      pot.pop();
	    }
	  if(sqr>sql || cir>cil)
	    {
	      cout << "no" << endl;
	      miss=true;
	      break;
	    }
	}
      if(!miss)
	{
	  if(sql==sqr && cil==cir)
	    {
	      cout << "yes" << endl;
	    }
	  else
	    {
	      cout << "no" << endl;
	    }
	}
    }
  return 0;
}
      



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

int main(){
  string s;
  while(cin>>s){
    for(int i=0; i<s.size(); i++){
      if(s[i]!='@') putchar(s[i]);
      else {
	i++;
	int n=s[i]-'0';
	i++;
	for(int j=0; j<n; j++){
	  putchar(s[i]);
	}
      }
    }
    putchar('\n');
  }
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
    //#ifndef ONLINE_JUDGE
      //  freopen("input.txt", "r", stdin);
       // freopen("output.txt", "w", stdout);
    //#endif
   	string s;
   	cin>>s;
   	lli n=s.size();
   	string s1="",s2="";
   	for(lli i=0;i<n;i++){
   		if(i%2==0)s1+='1',s2+='0';
   		else s1+='0',s2+='1';
   	}
   	lli ans1=0,ans2=0;
   	for(lli i=0;i<n;i++){
   		if(s1[i]!=s[i])ans1++;
   		if(s2[i]!=s[i])ans2++;
   	}
   	cout<<min(ans1,ans2);

    return 0;
 }

Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char *argv[]) {
    std::string input;
    std::getline(std::cin, input);

    std::vector<std::string> fives;
    std::vector<std::string> sevens;

    auto first_pos(input.find(" "));
    std::string first_number(input.substr(0, first_pos));

    if (first_number == "5") {
        fives.push_back(first_number);
    } else if (first_number == "7") {
        sevens.push_back(first_number);
    } else {
        std::cout << "NO" << std::endl;
    }   

    auto second_pos(input.find(" ", first_pos + 1));
    std::string second_number(input.substr(first_pos + 1, second_pos - first_pos - 1));
    
    if (second_number == "5") {
        fives.push_back(second_number);
    } else if (second_number == "7") {
        sevens.push_back(second_number);
    } else {
        std::cout << "NO" << std::endl;
    }   

    std::string third_number(input.substr(second_pos + 1));

    if (third_number == "5") {
        fives.push_back(third_number);
    } else if (third_number == "7") {
        sevens.push_back(third_number);
    } else {
        std::cout << "NO" << std::endl;
    }   

    if (fives.size() == 2 && sevens.size() == 1) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }   

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  LINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  string a,b,c;
  cin >> a >> b >> c;
  cout << 'A' << b[0] << 'C' << endl; 
  return 0;
}

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

int arr[4000][4000];

int main() {
	string a, b;
	cin >> a >> b;
	
	for(int i = 1; i <= a.length(); i++) {
		for(int j = 1; j <= b.length(); j++) {
			if(i == 0 || j == 0) {
				arr[i][j] = 0;
			} else {
				arr[i][j] = max(arr[i-1][j], arr[i][j-1]);
				if(a[i-1] == b[j-1]) {
					arr[i][j] = max(arr[i][j], arr[i-1][j-1]+1);
				}
			}
		}
	}
	
	stack<int> s;
	int pos1 = a.length();
	int pos2 = b.length();
	while(pos1 > 0 && pos2 > 0) {
		while(pos2 > 0 && arr[pos1][pos2] == arr[pos1][pos2-1]) {
			pos2--;
		}
		while(pos1 > 0 && arr[pos1][pos2] == arr[pos1-1][pos2]) {
			pos1--;
		}
		if(pos1 > 0 && pos2 > 0) {
			s.push(a[pos1-1]);
		}
		pos1--;
		pos2--;
	}
	if(s.size()) {
		while(s.size()) {
			printf("%c", s.top());
			s.pop();
		}
		printf("\n");
	}
}

Measured memory_bytes: 47360
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    long long n,h,t=0,f=0,maxa=0;
    cin>>n>>h;
    long long a[n], b[n];
    bool ok=true;
    for (int i=0; i<n; i++)
    {
        cin>>a[i]>>b[i];
        if (maxa<a[i]) maxa=a[i];
    }
    sort(b,b+n);
    for (int i=n-1; i>=0; i--)
    {
        if (b[i]<maxa) { f=i+1; break; }
    }
    for (int i=n-1; i>=f; i--)
    {
        h-=b[i]; t++;
        if (h<=0) {ok=false; break;}
    }
    if (ok)
    {
        if (h%maxa==0) t+=h/maxa;
        else t+=h/maxa+1;
    }
    cout<<t<<endl;
    return 0;
}

Measured memory_bytes: 1792