akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, b) for (long long i = (a); i < (b); i++)
#define rep2(r, aa, bb) for (long long r = (aa)-1; r >= (bb); r--)

using namespace std;


int main()
{
    int n, co=0;
    cin >> n;
    string s;
    cin >> s;
    rep(i,0,s.size()-2){
        if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C'){
            co++;
        }
    }
    cout << co << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
money, type = [], []
for i in range(N):
    m, t = input().split()
    money.append(float(m))
    type.append(t)

sum = 0
for i in range(N):
    if type[i] == 'JPY':
        sum += money[i]
    else :
        sum += money[i]*3.8*10**5
print(sum)

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 100000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem1246 : Concert Hall Scheduling**/
const int MAX_V = 1000;

class Flow {
public:
	struct edge { int to, cap, rev, cost;};
	vector<edge> G[MAX_V];
	bool used[MAX_V];
	int V;
	
	int dist[MAX_V];
	int prevv[MAX_V], preve[MAX_V];
	
	Flow() {V=MAX_V;}
	Flow(int v) {
		V = v;
	}
	
	void add_edge(int from, int to, int cap) {
		G[from].push_back((edge){to, cap, (int)G[to].size(), 0});
		G[to].push_back((edge){from, 0, (int)G[from].size()-1, 0});
	}
	
	void add_edge_with_cost(int from, int to, int cap, int cost) {
		G[from].push_back((edge){to, cap, (int)G[to].size(), cost});
		G[to].push_back((edge){from, 0, (int)G[from].size()-1, -cost});
	}
	
	// 最大流
	int dfs(int v, int t, int f) {
		if (v==t) return f;
		used[v] = true;
		for (int i=0; i<G[v].size(); i++) {
			edge &e = G[v][i];
			if (!used[e.to] && e.cap>0) {
				int d = dfs(e.to, t, min(f, e.cap));
				if (d>0) {
					e.cap-=d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
	
	int max_flow(int s, int t) {
		int flow = 0;
		for (;;) {
			memset(used, 0, sizeof(used));
			int f = dfs(s, t, INF);
			if (f==0) return flow;
			flow += f;
		}
	}
	
	// 最小費用流
	int min_cost_flow(int s, int t, int f) {
		int res=0;
		while (f>0) {
			fill(dist, dist+V, INF);
			dist[s]=0;
			bool update=true;
			while (update) {
				update = false;
				for (int v=0; v<V; v++) {
					if (dist[v]==INF) continue;
					for (int i=0; i<G[v].size(); i++) {
						edge &e = G[v][i];
						if (e.cap>0 && dist[e.to] > dist[v] + e.cost) {
							dist[e.to] = dist[v] + e.cost;
							prevv[e.to] = v;
							preve[e.to] = i;
							update = true;
						}
					}
				}
			}
			
			if (dist[t] == INF) {
				return -1;
			}
			
			int d=f;
			for (int v=t; v!=s; v=prevv[v]) {
				d = min(d, G[prevv[v]][preve[v]].cap);
			}
			f -= d;
			res += d*dist[t];
			for (int v=t; v!=s; v=prevv[v]) {
				edge &e = G[prevv[v]][preve[v]];
				e.cap -= d;
				G[v][e.rev].cap += d;
			}
		}
		return res;
	}
};

int main()
{
	int N;
	while (cin>>N, N) {
		Flow F(366);
		
		rep(i, 365) {
			F.add_edge_with_cost(i, i+1, 2, 0);
		}
		
		rep(i, N) {
			int a, b, c;
			cin>>a>>b>>c;
			F.add_edge_with_cost(a-1, b, 1, -c);
		}
		
		cout << -F.min_cost_flow(0, 365, 2) << endl;
	}
}

Measured memory_bytes: 1352
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
void solve()
{
	int n,a,b;
	cin>>n>>a>>b;
		cout<<n/(a+b)*a+min(n%(a+b),a);



}
signed main()
{
	fastio;
//	test
		solve();
}




Measured memory_bytes: 256
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n, a[100000], b[100000] = {}, cnt = 0;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &a[i]);
    b[a[i]]++;
  }

  if(n % 2 == 0){
    for(int i = 0; i < n / 2; i++){
      if(b[2 * i + 1] == 2) cnt++;
    }
  }
  else{
    for(int i = 0; i < n / 2; i++){
      if(b[2 + 2 * i] == 2) cnt++;
    }
  }
    

  if(cnt == n / 2 && b[0] <= 1){
    long ans = 1;
    for(int i = 0; i < cnt; i++){
      ans <<= 1;
      ans %= 1000000007;
    }
    printf("%ld\n", ans);
  }

  else printf("0\n");

  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int n;
int num[100010];
long long s,w,q,ans;
long long a[100010];
long long b[100010];
long long c[100010];
long long pw[100010];
int main() {
    while (~scanf("%d%lld%lld%lld",&n,&s,&w,&q)) {
        if (n==0&&s==0&&w==0&&q==0) break;
        ans=0;
        pw[0]=1;
        for (int i=1; i<=n; i++) pw[i]=(pw[i-1]*10)%q;
        long long g=s;
        for (int i=1; i<=n; i++) {
            c[i]=a[i]=(g/7)%10;
            if (g%2==0) g/=2;
            else g=(g/2)^w;
        }
        if (q==2) {
            int cnt=0;
            for (int i=n; i>=1; i--) {
                if (a[i]>0) ans+=cnt;
                if (a[i]%2==0) {
                    cnt++;
                    if (a[i]>0) ans++;
                }
            }
        } else if (q==5) {
            int cnt=0;
            for (int i=n; i>=1; i--) {
                if (a[i]>0) ans+=cnt;
                if (a[i]%5==0) {
                    cnt++;
                    if (a[i]>0) ans++;
                }
            }
        } else {
            for (int i=n; i>=1; i--) a[i]=(a[i]*pw[n-i])%q;
            a[n+1]=0;
            for (int i=n; i>=1; i--) a[i]=(a[i+1]+a[i])%q;
            for (int i=n+1; i>=1; i--) b[i]=a[i];
            sort(b+1,b+1+n+1);
            int len=unique(b+1,b+1+n+1)-b-1;
            for (int i=1; i<=n+1; i++) a[i]=lower_bound(b+1,b+1+len,a[i])-b;
            memset(num,0,sizeof(num));
            for (int i=n+1; i>=1; i--) {
                if (c[i]!=0&&i<=n) ans+=num[a[i]];
                num[a[i]]++;
            }
        }
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 4708
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define BUGAVOID(x) x
#define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define sz(c) (int)(c.size())
#define all(c) c.begin(),c.end()
#define ms(a,v) memset(a,v,sizeof(a))
#define unq(v) v.erase(unique(v.begin(),v.end()),v.end());
#define mp make_pair
#define write(x) cout<<(x)<<endl
using namespace std; typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; }return 0; }
const int INF = 1 << 28; const ll LINF = 1ll << 60;
const int MAX = 1e5 + 5; const int MOD = 1e9 + 7; const double EPS = 1e-6;
const int dy[4] = { 0,1,0,-1 }; const int dx[4] = { 1,0,-1,0 };
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int N, M, H, W;
//int n, m, a, b, c, d, ans;
string s;

int X[MAX];
int d[MAX];

int main() {
    cin >> N >> M;
    rep(i, M) cin >> X[i];

    if (M <= N) {
        write(0);
        return 0;
    }

    sort(X, X + M);

    for (int i = 0; i < M - 1; ++i) {
        d[i] = X[i + 1] - X[i];
    }
    sort(d, d + M - 1);
    
    for (int i = 0; i < N - 1; ++i) {
        d[M - 2 - i] = 0;
    }

    int ans = 0;
    rep(i, M - 1) ans += d[i];
    write(ans);
}

Measured memory_bytes: 1024
extern crate core;

use std::fmt;
use std::cmp::{Ordering, min, max};
use std::f32::MAX;
use std::ops::{Add, Sub, Mul, Div, Neg, Index, IndexMut, SubAssign, Range};
use std::collections::{BTreeMap, VecDeque, BinaryHeap, BTreeSet, HashMap};
use std::fmt::{Display, Formatter, Error};
use std::hash::{Hash, Hasher};

fn show<T: Display>(vec: &Vec<T>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        print!("[{}", vec[0]);
        for i in 1 .. vec.len() {
            print!(", {}", vec[i]);
        }
        println!("]");
    }
}
fn show2<T: Display>(vec: &Vec<Vec<T>>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        for l in vec {
            show(l);
        }
    }
}
macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}
macro_rules! read_value{
    () => {
        read_line!().trim().parse().ok().unwrap()
    }
}
macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
macro_rules! let_mut_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let mut $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
fn upper_bound(array: &Vec<i32>, mut from: usize, mut until: usize, target: i32) -> usize {
    while from < until {
        let mid = (from + until) / 2;
        if array[mid] <= target {
            from = mid + 1;
        }else {
            until = mid;
        }
    }
    until
}
fn main() {
    loop {
        let_all!(n: usize, s: i32);
        if n == 0 {
            return
        }
        let mut power: Vec<i32> = Vec::with_capacity(n);
        for _ in 0 .. n {
            power.push(read_value!());
        }
        power.sort();
        let mut count = 0;
        for i in 0 .. power.len() {
            if power[i] + power[i] <= s {
                count += power.len() - upper_bound(&power, i + 1, power.len(), s - power[i]);
            }else {
                count += power.len() - i - 1;
            }
        }
        println!("{}", count);
    }
}


Measured memory_bytes: 5052
import java.util.Scanner;

class Main{




	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		
		String string = sc.next();
		if(string.charAt(0) == 'a' || string.charAt(0) == 'e' || string.charAt(0) == 'i' || string.charAt(0) == 'o' || string.charAt(0) == 'u'){
			System.out.println("vowel");
		}else{
			System.out.println("consonant");
		}
		
		


	}
}

class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}




Measured memory_bytes: 22868
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
    	// Solution sol = new Solution();
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	StringTokenizer st= new StringTokenizer(br.readLine());
    	int N = Integer.parseInt(st.nextToken());
    	int M = Integer.parseInt(st.nextToken());
    	System.out.print((N*(N-1)+M*(M-1))/2);
    }
}

Measured memory_bytes: 20692
def solve():
    mod = 10**9+7
    N, K = map(int, input().split())
    lis = [0]*(K+1)
    ans = 0
    for i in range(K,0,-1):
        lis[i] = pow((K//i),N,mod)
        for j in range(2,K//i+1):
            lis[i] -= lis[i*j]
        ans += lis[i]*i
        ans %= mod
    return ans
print(solve())

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

#define int long long
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  int a,b,c;cin>>a>>b>>c;
  if(c<a+b)fin("No");
  if(4*a*b<((c-b-a)*(c-b-a)))fin("Yes");
  fin("No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll //9223372036854775807
#define pi acos(-1.0)
#define ms(a,b) memset(a,b,sizeof(a))
#define nl "\n"
#define FAST_IO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef long long ll;
const int mod = 998244353;
//ll qpow(ll x, ll y){ll s=1;while(y){if(y&1)s=s*x%mod;x=x*x%mod;y>>=1;}return s;}
ll qpow(ll a, ll b){ll s=1;while(b>0){if(b%2==1)s=s*a;a=a*a;b=b>>1;}return s;}
inline ll read(){ll x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();return x*f;}
ll inve(ll x){return x==1?1:(mod-mod/x)*inve(mod%x)%mod;}
 
const int N = 1e6;
 
int a,b,vis[6];
 
int main()
{
    for(int i=1;i<=3;i++)
    {
        cin>>a>>b;
        vis[a]++,vis[b]++;
    }
    int n1 = 0, n2 = 0;
    for(int i=1;i<=4;i++)
    {
        if(vis[i]==1) n1++;
        if(vis[i]==2) n2++;
    }
    if(n1==n2 && n1==2) puts("YES");
    else puts("NO");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

int main(){
	int n;
	cin >> n;
	int a = n%10;
	if(a==2||a==4||a==5||a==7||a==9) cout << "hon";
	else if(a==3) cout << "bon";
	else cout << "pon";
}

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

using namespace std;
using ll = long long;

vector<vector<int>> g;
vector<int> dep;

void dfs(int v, int pr) {
	for (auto u : g[v]) {
		if (u != pr) {
			dep[u] = dep[v] + 1;
			dfs(u, v);
		}
	}
}

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

	int n;
	cin >> n;

	g.resize(n);

	for (int i = 1; i < n; i++) {
		int v, u;
		cin >> v >> u;
		v--, u--;
		g[v].push_back(u);
		g[u].push_back(v);
	}

	dep.resize(n);

	dfs(0, 0);

	array<vector<int>, 2> vers;
	for (int i = 0; i < n; i++) {
		vers[dep[i] % 2].push_back(i);
	}
	if (vers[1].size() < vers[0].size()) {
		swap(vers[0], vers[1]);
	}

	array<vector<int>, 3> free;
	for (int i = 1; i <= n; i++) {
		free[i % 3].push_back(i);
	}

	vector<int> ans(n, -1);

	if (vers[0].size() <= free[0].size()) {
		for (auto el : vers[0]) {
			ans[el] = free[0].back();
			free[0].pop_back();
		}
	} else {
		while (free[1].size()) {
			ans[vers[0].back()] = free[1].back();
			free[1].pop_back();
			vers[0].pop_back();
		}

		while (free[2].size()) {
			ans[vers[1].back()] = free[2].back();
			free[2].pop_back();
			vers[1].pop_back();
		}
	}

	for (int i = 0; i < n; i++) {
		if (ans[i] == -1) {
			int j = 0;
			while (!free[j].size()) {
				j++;
			}
			ans[i] = free[j].back();
			free[j].pop_back();
		}
	}

	for (auto el : ans) {
		cout << el << ' ';
	}
}

Measured memory_bytes: 21368
#include <cstdio>
#include <map>

using namespace std;

map<int, int> ps;
int os[31];

int main() {
  for (int id, x; scanf("%d,%d", &id, &x) == 2 && !(!id && !x);) {
    ps[id] = x;
    os[x]++;
  }
  for (int x = 30, o = 1; x >= 0; x--)
    if (os[x])
      os[x] = o++;
  for (int id; scanf("%d", &id) == 1;)
    printf("%d\n", os[ps[id]]);
  return 0;
}

Measured memory_bytes: 0
// kyopro.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define rep2(N1,N2) for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)for(int k=0;k<N3;k++)

void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int main(){
	int N, M;
	cin >> N >> M;
	int a;
	a = N * (N - 1) / 2;
	a = a + M * (M - 1) / 2;
	cout << a;
}

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

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

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N, W;
	cin >> N >> W;
	vector<ll> w(N), v(N);
	REP(i, N) cin >> w[i] >> v[i];

	ll vmax = 101010;
	ll dp[105][vmax];
	ll INF = LLONG_MAX/3;
	REP(i, 105)REP(j, vmax) dp[i][j] = INF;
	dp[0][0] = 0;
	REP(i, N){
		REP(j, vmax){
			dp[i+1][j] = min(dp[i][j], dp[i+1][j]);
			if(j+v[i]<=vmax)dp[i+1][j+v[i]] = min(dp[i][j] + w[i], dp[i+1][j+v[i]]);
		}
	}
	ll res = 1;
	REP(i, 105)REP(j, vmax) if(dp[i][j]<=W) res = max(res, (ll)j);
	cout << res << endl; 
    return 0;
}

Measured memory_bytes: 83072
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}

int main(){
	ll k;
	cin>>k;
    ll sum = 0;
	for( ll a = 1 ; a<=k ; a++){
		 for( ll b = 1; b<=k ;b ++){
		 	 for(ll c = 1; c<=k; c++){
                  ll g1 = __gcd(b,c);
                  ll gcd = __gcd(a,g1);
                  sum += gcd;
		 	 }
		 }
	}

	cout<<sum<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>
#include <complex>
#define repi(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) repi(i, 0, n)
#define int long long
using namespace std;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a,b;
    int k,cnt=0;
    int ans=0;
    cin>>a>>b>>k;
    while(a.size() > b.size() ){
        b='0'+b;
    }
    int borrow[10]={0};    
    for(int i=a.size()-1;i>=1;i--){
        if(a[i]-b[i]-borrow[i+1] < 0){
            //cout<<i<<endl;
            borrow[i]=1;
        }
    }
    rep(i,a.size() ){
        if( borrow[i]==1){
            if(a[i-1]-b[i-1]-borrow[i]!= -1){
                a[i-1]+=1;
                cnt++;
            }
        }
        if(cnt==k) break;
    }
    //cout<<a<<endl;
    int bo=0;
    int num;
    int c=1;
    for(int i=a.size()-1;i>=0;i--){
        num=a[i]-b[i]-bo;
        if(num<0){bo=1;num+=10;}
        else bo=0;
        ans+=num*c;
        c*=10;
    }
     
   
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 3232
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <stdio.h>

using namespace std;

#define fo(i,n) for(int i=0; i<(int)n; i++)
#define rep(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define pii pair<int,int>

int n,w;
int t[110];

int main() {

    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

	while (scanf("%d%d",&n,&w)==2 && n!=0) {
		for (int i=0; i<110; i++) t[i] = 0;
		for (int i=0; i<n; i++) {
			int v;
			scanf("%d",&v);
			t[v/w]++;
		}
		int m = 0;
		int last = 100;
		while (t[last]==0) last--;
		for (int i=0; i<=last; i++) m = max(m,t[i]);
		double p = 0.0;
		for (int i=0; i<=last; i++) {
			if (last!=0) p += (double)t[i]/m*(double)(last-i)/last;
			else p += 1.0;
		}
		p += 0.01;
		printf("%.12lf\n",p);
	}

    return 0;

}

Measured memory_bytes: 1224
#include<stdio.h>
#define STRING_MAX 101
#define TEICE 2
#define FRG_OFF 0
#define FRG_ON 1
#define ARRAY_RESET 0
#define LOOP_RESET 0
#define COUNT_RESET 0
#define RETURN 0
unsigned short s_scan_sentence(unsigned char * str, unsigned short length_max);
unsigned short s_sarch_text(unsigned char * ring, unsigned short r_length, unsigned char * look, unsigned short l_length);

int main(){
	unsigned char ubW_D_ring_text[STRING_MAX]; 	
	unsigned char ubW_D_look_text[STRING_MAX]; 	
	unsigned short usW_D_ring_length;   	
	unsigned short usW_D_look_length;   	
	unsigned short usW_F_frg_main = FRG_OFF;  	
	unsigned short usW_C_i;             	
	
	for(usW_C_i = LOOP_RESET;usW_C_i < STRING_MAX;usW_C_i++){
		ubW_D_ring_text[usW_C_i] = ARRAY_RESET;
		ubW_D_look_text[usW_C_i] = ARRAY_RESET;
	}
	
	usW_D_ring_length = s_scan_sentence(ubW_D_ring_text, STRING_MAX);
	usW_D_look_length = s_scan_sentence(ubW_D_look_text, STRING_MAX);
	
	usW_F_frg_main = s_sarch_text(ubW_D_ring_text, usW_D_ring_length, ubW_D_look_text, usW_D_look_length);
	
	if(usW_F_frg_main == FRG_OFF){
		printf("No\n");
	}
	else if(usW_F_frg_main == FRG_ON){
		printf("Yes\n");
	}
	
	return RETURN;
}


/* 関数名：文字列入力 */
/* 概要：文字列を入力する。その長さを返す */
/* 引数：文字列を格納する配列の先頭アドレス、その配列の大きさ */
/* 戻り値：入力された文字列の長さ */
unsigned short s_scan_sentence(unsigned char * str, unsigned short length_max)
{
	unsigned short usW_C_count_text = COUNT_RESET;  	/* 文字列長カウンタ */
	unsigned short usW_C_i;                         	/* ループ変数 */

	/* 文字列の入力 */
	for(usW_C_i = LOOP_RESET;usW_C_i < length_max;usW_C_i++){
		scanf("%c", str + usW_C_i);
		/* 入力終了の処理 */
		if(*(str + usW_C_i) == '\n'){
			break;
		}
		/* 文字数をカウント */
		usW_C_count_text++;
	}

	/* 文字列長を返す */
	return usW_C_count_text;
}

unsigned short s_sarch_text(unsigned char * ring, unsigned short r_length, unsigned char * look, unsigned short l_length)
{
	unsigned char twi_ring[STRING_MAX * TEICE];
	unsigned short usW_F_frg_fanc = FRG_OFF;
	unsigned short usW_C_i, usW_C_j;
	
	for(usW_C_i = LOOP_RESET;usW_C_i < (STRING_MAX * TEICE);usW_C_i++){
		twi_ring[usW_C_i] = ARRAY_RESET;
	}
	
	for(usW_C_i = LOOP_RESET;usW_C_i < r_length;usW_C_i++){
		twi_ring[usW_C_i] = *(ring + usW_C_i);
	}
	for(usW_C_i = LOOP_RESET;usW_C_i < l_length;usW_C_i++){
		twi_ring[r_length + usW_C_i] = *(ring + usW_C_i);
	}
	
	for(usW_C_i = LOOP_RESET;usW_C_i <= r_length;usW_C_i++){
		for(usW_C_j = LOOP_RESET;usW_C_j <= l_length;usW_C_j++){
			if(*(look + usW_C_j) == '\n'){
				usW_F_frg_fanc = FRG_ON;
			}
			if(twi_ring[usW_C_i + usW_C_j] != *(look + usW_C_j)){
				break;
			}
		}
	}
	
	return usW_F_frg_fanc;
}



Measured memory_bytes: 2100
N = int(input())
word_list = []
ans = "Yes"
for i in range(N):
  word = input()
  word_list.append(word)
  if i != 0:
    if not(word[0] == word_list[i - 1][-1] and word_list.count(word) == 1):
      ans = "No"
      break
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<stdio.h>
#include<string.h>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include<complex>

using namespace std;

typedef long long            ll;
typedef unsigned             ui;
typedef unsigned long long   ull;
typedef pair<int,int>        i_i;
typedef pair<ll,int>         ll_i;
typedef pair<ll,ll>          ll_ll;
typedef pair<double,int>     d_i;
typedef pair<double,double>  d_d;
typedef vector<int>          vi;
typedef vector<vector<int> > vii;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long
#ifndef int
#define INF __INT32_MAX__
#else
#define INF __INT64_MAX__
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

signed main(void)
{
  char a[4],b[4];
  scanf("%s %s",a,b);
  char s[100];
  sprintf(s,"%s%s",a,b);
  int x;
  sscanf(s,"%d",&x);
  double sq=sqrt(x);
  if(sq == (int)sq){
    puts("Yes");
  }
  else{
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>
#include<sstream>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cout << '\n';}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << '[' << *it << " = " << a << "]  ";
    err(++it, args...);
}

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<lli, lli> tii;
typedef tuple<lli, lli, lli> tiii;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;


void solve(){
	int k; cin>>k;
	string s; cin>>s;
	if(s.size()<=k) cout<<s;
	else cout<<s.substr(0,k)<<"...";

}

int main(){
	fast_io
	int tc=1;
	//cin>>tc;
	while(tc--){solve();}
	return 0;
}

Measured memory_bytes: 3092
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	map<string, int> net;
	ll x, y;
	cin >> x >> y;
	ll answer = 0;
	while(x <= y)
	{
		++answer;
		x *= 2;
	}
	cout << answer << '\n';
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC100A
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputedStrs = Console.ReadLine().Split();
            var d = int.Parse(inputedStrs[0]);
            var n = int.Parse(inputedStrs[1]);
            Console.WriteLine($"{n * Math.Pow(100, d) + n / 100 * Math.Pow(100, d)}");
        }
    }
}

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

int main() {
	int kaisu = 0;
	int l[100];
	int n, tmp;
	int d = 0;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> l[i];
	}
	if (n == 1) {
		cout << l[0] << endl << 0 << endl;
	}else {
		for (;;) {
			for (int i = n - 1; i > 0; i--) {
				if (l[i] < l[i - 1]) {
					tmp = l[i];
					l[i] = l[i - 1];
					l[i - 1] = tmp;
					kaisu += 1;
				}
			}
			d += 1;
			if (d == n - 1) {
				break;
			}
		}
		sort(l, l + n);
		for (int i = 0; i < n; i++) {
			cout << l[i];
			if (i == n - 1) {
				cout << endl;
			}
			else cout << " ";
		}
		cout << kaisu << endl;
	}
	char c;
	cin >> c;
}

Measured memory_bytes: 3132
N = int(input())

a = [int(x) for x in input().split()]

a.sort()
ali = 0
bob = 0

for i in range(N):
    if i % 2 == 0:
        ali += a[N-1-i]
    else:
        bob += a[N-1-i]
print(ali-bob)

Measured memory_bytes: 3060
a,b,c,k=map(int,input().split( ))
g=0
if a>=k:
    print(k)
else:
    g+=a
    k-=a
    if b>=k:
        print(g)
    else:
        k-=b
        if c>=k:
            g-=k
            print(g)
        
    


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

int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> l(n), r(n);
  rep(i, q) {
    cin >> l[i] >> r[i];
    --l[i], --r[i];
  }

  vector<int> sum(n);
  sum[0] = 0;
  rep2(i, 1, n) {
    if (s[i-1] == 'A' && s[i] == 'C') {
      sum[i] = sum[i-1] + 1;
    } else {
      sum[i] = sum[i-1];
    }
  }
  rep(i, q) {
    cout << sum[r[i]] - sum[l[i]] << endl;
  }
  return 0;
}


Measured memory_bytes: 2304
import itertools, math

n, k = input().split()
nums = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"} - {x for x in input().split()}
length = len(n)
coms = itertools.product(nums, repeat=length+1)
n = int(n)
ans = float("inf")
for com in coms:
    tmp = "".join(com)
    if n <= int(tmp) < ans:
        ans = int(tmp)

coms = itertools.product(nums, repeat=length)
for com in coms:
    tmp = "".join(com)
    if n <= int(tmp) < ans:
        ans = int(tmp)

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef long int li;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<double, double>P;
typedef tuple<ll, int, int>T;
#define PI 3.14159265358979
#define MOD (ll)1000000007
typedef vector<ll> vec;
typedef vector<vec> mat;

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  ll dp[N][N];
  rep(i,N){
  	rep(j,N){
      dp[i][j]=0ll;
    }
  }
  rep(i,N){dp[0][i]=1ll;}
  
  rep(i,N-1){
    ll sum[N+1];
    rep(j,N){sum[j]=0ll;}
    sum[1]=dp[i][0];
    rep(j,N){sum[j+1]=sum[j]+dp[i][j];sum[j+1]%=MOD;}
    rep(j,N){
      if(S[i]=='<'){
        dp[i+1][j]=(sum[j+1])%MOD;
      }
      if(S[i]=='>'){
        dp[i+1][j]=(sum[N-i]-sum[j+1]+MOD)%MOD;
      }
    }
  }
  cout<<dp[N-1][0]<<endl;
}

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

int main(){
  while(1){
    int a,b;
    char op;
    cin >> a >> op >>  b;
    if(op == '?'){
       break;
    }else if(op == '+'){
        cout << a+b << endl;
    }else if(op == '-'){
        cout << a-b << endl;
    }else if(op == '*'){
        cout << a*b << endl;
    }else if(op == '/'){
        cout << a/b << endl;
    }
  }

  return 0;

}


Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, A, B;
	cin >> N >> A >> B;
	int min;
    if(N*A >= B){
        min = B;
    } else {
        min = N*A;
    }
    cout << min << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int,int>;

const int mx = 2e5+5;
int n, m, vis[mx];
vector<int> g[mx];

void dfs(int u){
    vis[u] = 1;
    for(int v : g[u])
        if(!vis[v])
            dfs(v);
}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);

    cin >> n >> m; int u, v;
    while(m--){
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    int ans = -1;
    for(int i=1; i<=n; i++)
        if(!vis[i]) dfs(i),  ans++;
    cout << ans << "\n";
    return 0;
}



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

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	
	string s;
	while (cin >> s) {
		if (s == "Y") {cout << "Four"; return 0;}
	}
	cout << "Three";
	
	return 0;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


using vvll = vector< vector<ll> >;
using vll = vector<ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

ll fast(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        y >>= 1;
    }
    return res;
}

ll inv(ll n){
    return fast(n,mod-2);
}

void pre(){


}

void solve(){

    ll n;
    cin >> n;
    ll a[n];
    map<ll,ll> MAP;
    ll sum=0;
    for(ll i=1;i<=n;i++){
        cin >> a[i];
        MAP[a[i]]++;
        sum += a[i];
    }
    ll q;
    cin >> q;
    while(q--){
        ll x,y;
        cin >> x >> y;
        ll tmp=sum - x*MAP[x];
        tmp += y*MAP[x];
        MAP[y] += MAP[x];
        MAP.erase(x);
        sum = tmp;
        cout << sum << endl;
    }

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

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

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

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

    cout << (c % 2 == 0 ? "YES" : "NO") << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = (int)3e5 + 10;
const int MOD = 998244353;
int col[N];
int cnt[8];

int main(){
  fastIO;
  int n;
  cin >> n;
  char s;
  int ans = 1;
  bool ok;
  cnt[0]=n;
  for(int i = 1; i <= 3 * n; i ++ ){
    cin >> s;
    if(s == 'R')
      col[i]=0;
    else if(s == 'G')
      col[i]=1;
    else
      col[i]=2;
    ok = false;
    for(int j = 6; j >= 0; j -- ){
      if((j & (1 << col[i])) == 0 && cnt[j] > 0){
        ok=true;
        ans = (ans * 1ll * cnt[j]) % MOD;
        cnt[j]--;
        cnt[(j|(1<<col[i]))]++;
        break;
      }
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
using namespace std;
 
int main()
{
  int N,cnt = 1;
  cin>>N;
  vector<int> a(N);
  
  for(int nj=0;nj<N;nj++)
  {
    cin>>a.at(nj);
  }
  int ni = 0;
  while(2 != a.at(ni))
  {
    cnt++;
    ni = a.at(ni)-1;
    if(N==cnt)
    {
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long
const int N = 2e5 + 1;
//ll int freq[100001];
ll int bigPower(ll int x, unsigned ll int y, ll int p)
{
    ll int res = 1;     // Initialize result

    x = x % p; // Update x if it is more than or
    // equal to p

    if (x == 0) return 0; // In case x is divisible by p;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res * x) % p;

        // y must be even now
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
void findAns()
{
    ll int n;
    cin >> n;

    string ans = "";

    char values[26];

    for (int i = 0; i < 26; i++) values[i] = 'a' + i;
    while (true)
    {
        if (n <= 0) break;
        ll int rem = n % 26;

        if (rem == 0) ans += values[25];
        else
            ans += values[rem - 1];

        if (rem == 0)
        {
            n = n / 26;
            n -= 1;
        }
        else
            n = n / 26;
    }
    reverse(ans.begin(), ans.end());

    cout << ans;

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

    fastio;

    // ll int t;
    // cin >> t;

    // while (t--)
    findAns();
}

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

int main(){
  int L, R;
  cin >> L >> R;
  int ans = 0;
  for (int a = 1; a < 10; a++) {
    for (int b = 0; b < 10; b++) {
      for (int c = 0; c < 10; c++) {
        int x = 10001 * a + 1010 * b + 100 * c;
        if (x >= L && x <= R) {
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define forr(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define oo 100000000000000000
using namespace std;



void _sol(){
    int h,w,m; cin >> h >> w >> m;
    vector<int> row(h+1,0) , col(w+1,0);
    unordered_map<int,map<int,int>> mp;
    forr(i,m){
        int u,v; cin >> u >> v;
        row[u]++;
        col[v]++;
        mp[u][v]++;
    }
    vector<pair<int,int>> v1,v2;
    for(int i=1;i<=h;i++){
        v1.push_back({row[i] , i});
    }
    for(int i=1;i<=w;i++){
        v2.push_back({col[i] , i});
    }
    sort(v1.rbegin(),v1.rend()); sort(v2.rbegin(),v2.rend());
    int ans = INT_MIN;
    for(int i=1;i<=w;i++){
        ans = max(ans , v1[0].first + v2[i-1].first - mp[v1[0].second][v2[i-1].second]);
    }
    for(int i=1;i<=h;i++){
        ans = max(ans , v1[i-1].first + v2[0].first - mp[v1[i-1].second][v2[0].second]);
    }
    cout << ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    _sol();
}


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

#define watch(x) (cout << #x << " = " << x << endl)

int dp[3001][3001];
char cf[3001][3001];

int32_t main() {
	string s, t;
	cin >> s >> t;

	for(int i = 1; i <= s.size(); i++){
		for(int j = 1; j <= t.size(); j++){
			if(s[i-1] == t[j-1]){
				dp[i][j] = dp[i-1][j-1] + 1;
				cf[i][j] = 'd';
			} else {
				if(dp[i][j-1] > dp[i-1][j]){
					dp[i][j] = dp[i][j-1];
					cf[i][j] = 'l';
				} else {
					dp[i][j] = dp[i-1][j];
					cf[i][j] = 'u';
				}
			}
		}
	}

	string res = "";
	for(int i = s.size(), j = t.size(); i > 0 and j > 0;){
		if(cf[i][j] == 'l')
			j--;
		else if(cf[i][j] == 'u')
			i--;
		else {
			i--;
			j--;
			res += s[i];
		}
	}

	reverse(res.begin(), res.end());
	cout << res << endl;

	return 0;
}


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

using namespace std;

typedef unsigned short ushort;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

template <typename T>
ostream &operator<<(ostream &cout, vector<T> &a){
    for(ull i = 0; i < a.size(); ++i)
        cout << a[i] << " ";
    return cout;
}

template <typename T>
ostream &operator<<(ostream &cout, vector<vector<T> > &a){
    for(ull i = 0; i < a.size(); ++i)
        cout << a[i] << endl;
    return cout;
}

int main()
{
    int a, b;
    char s;
    cin >> a >> s >> b;
    if(s == '+')
        cout << a + b << endl;
    else
        cout << a - b << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
c = [0 for _ in range(len(h))]

for i in range(len(h)):
    if i == 0:
        continue
    if i == 1:
       c[i] = abs(h[i] - h[0])
    else:
        c1 = abs(h[i] - h[i - 1])
        c2 = abs(h[i] - h[i - 2])
        c[i] = min(c[i - 1] + c1, c[i - 2] + c2)
print(c[-1])



Measured memory_bytes: 13980
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        long Q = Long.parseLong(sc.nextLine());
        boolean isLeadLeft = true;

        StringBuilder sb = new StringBuilder();
        StringBuilder sbLeft = new StringBuilder();
        StringBuilder sbRight = new StringBuilder();
        sb.append(S);

        for (int i = 0; i < Q; i++) {
            String queries = sc.next();
            if (queries.equals("1")) {
                isLeadLeft = !isLeadLeft;
            } else {
                int f = sc.nextInt();
                String chara = sc.next();
                if (f == 1) {
                    if (isLeadLeft) {
                        sbLeft.insert(0, chara);
                    } else {
                        sbRight.append(chara);
                    }
                } else {
                    if (isLeadLeft) {
                        sbRight.append(chara);
                    } else {
                        sbLeft.insert(0, chara);
                    }
                }
            }
        }

        sc.close();

        if (isLeadLeft) {
            System.out.println(sbLeft.toString() + sb.toString() + sbRight.toString());
        } else {
            sbRight.reverse();
            sb.reverse();
            sbLeft.reverse();
            System.out.println(sbRight.toString() + sb.toString() + sbLeft.toString());
        }

    }
}


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

int main(){
  int n;cin >> n;
  int x[n];rep(i,n)cin >> x[i];
  int ans = 100000000;
  for(int i=*min_element(x,x+n);i<=*max_element(x,x+n);++i){
    int sum = 0;
    for(int j=0;j<n;++j){
      sum += abs(i-x[j]) * abs(i-x[j]);
    }
    if(ans > sum)ans = sum;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256