akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int N, M, X, t;
  cin >> N >> M >> X;
  vector<bool> a(N+1, false);

  rep(i, M){
    cin >> t;
    a[t] = true;
  }

  int ans = 1000;
  int cnt = 0;
  rep(i, X){
     if(a[i]) cnt++;
  }
  ans = min(ans, cnt);
  cnt = 0;
  for(int i = X; i <= N; i++){
    if(a[i]) cnt++;
  }
  ans = min(ans, cnt);
  print(ans);

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define N 500000
bool vis[N];
ll dp[N];
vector<ll>a[N];
void dfs(ll node)
{
	vis[node]=true;
	for(int i=0;i<a[node].size();i++)
	{
		if(vis[a[node][i]]==false)
		dfs(a[node][i]);
		dp[node]=max(dp[node],dp[a[node][i]]+1);
	}
}
int main()
{
	ll n,m,k,x,y;
	cin>>n>>m;
	for(int i=0;i<=n;i++)
	{
		dp[i]=0;
		vis[i]=false;
	}
	k=m;
	while(k--)
	{
		cin>>x>>y;
		a[x].push_back(y);
	}
	for(int i=1;i<=n;i++)
	{
		if(vis[i]==false)
		dfs(i);
	}
	k=0;
	for(int i=1;i<=n;i++)
	{
		k=max(k,dp[i]);
	}
	cout<<k<<endl;
}

Measured memory_bytes: 19840
# include <iostream>
# include <cmath>
 
 
using namespace std;
 
 
int main() {
    int n; cin >> n;
    int ans = 0;
 
    for (int i=1; i<=n; ++i) {
        int d = log10(i)+1;
        if (d % 2 == 1) ans++;
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;

int main(){
    int n, cnt = 0;
    cin >> n;
    for(int i = 1; i <= n; i++){
        int tmp;
        cin >> tmp;
        if(i % 2 == 1){
            if(tmp%2 == 1) cnt++;
        }
    }
    cout << cnt << endl;
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef pair<int,int> P;

int main() {
    int N,X,L,p,c=1;
    cin >> N;
    vector<P> r(N);

    rep(i,N) {
        cin >> X >> L;
        r.at(i).first = X+L;
        r.at(i).second = X-L;
    }
    sort(r.begin(), r.end());

    p = r.at(0).first;
    rep(i,N-1)
        if(r.at(i+1).second >= p) {
            p = r.at(i+1).first;
            c++;
        }

    cout << c << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxN = 5010;
struct Node
{
	int h, p;
}a[maxN];
bool cmp(Node x, Node y)
{
	return x.p - y.h < y.p - x.h;
}
int n;
ll dp[maxN];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d %d", &a[i].h, &a[i].p);
	sort(a + 1, a + n + 1, cmp);
	for (int i = 0; i <= 5000; i++) dp[i] = 1e16;
	dp[0] = 0;
	for (int i = 1; i <= n; i++)
		for (int j = i - 1; j >= 0; j--)
			if (a[i].h >= dp[j])
				dp[j + 1] = min(dp[j + 1], dp[j] + a[i].p);
	int ans = 1;
	for (int i = 2; i <= n; i++)
		if (dp[i] != 1e16)
			ans = i;
	printf("%d\n", ans);
 	return 0;
}

Measured memory_bytes: 384
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]
b = [0]
p = 0
for i in range(N):
  p += A[i]
  a.append(p)
q = 0
for j in range(M):
  q += B[j]
  b.append(q)
ans = 0
j = M
for i in range(N+1):
  if a[i] > K:
    break
  while a[i] + b[j] > K:
    j -= 1
  ans = max(ans, i + j)
print(ans)

Measured memory_bytes: 132684
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::vector;

int main() {
  int64_t N, K;
  cin >> N >> K;

  vector<int> porters;
  porters.resize(N + 1);

  for (int i = 1; i <= N; i++) {
    int num;
    cin >> num;
    porters[i] = num;
  }

  int ans(1);
  std::set<int> set;
  std::vector<int> root;
  bool loop_not_found = true;
  root.push_back(1);
  while (K > 0) {
    ans = porters[ans];
    K--;
    if (loop_not_found && set.count(ans) > 0) {
      // ループ発見
      auto itr = std::find(root.begin(), root.end(), ans);
      int count = std::distance(root.begin(), itr);
      int loop_size = root.size() - count;
      K = K % loop_size;

      root.clear();
      loop_not_found = false;
    } else {
      set.insert(ans);
      root.push_back(ans);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 12116
#include<bits/stdc++.h>
// #include <boost/math/common_factor.hpp> 
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define int long long
#define double long double
#define pb push_back
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define diff(a,b) (a>b?a-b:b-a)
#define F first
#define S second
//#define tr(container, it) \
//for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
const int N=1e6+5;
int mod = 1e9+7;
void pairsort(int a[], int b[], int n){
    pair<int, int> pairt[n];
    for (int i = 0; i < n; i++) 
    {
        pairt[i].first = a[i];
        pairt[i].second = b[i];
    }
    sort(pairt, pairt + n);
    for (int i = 0; i < n; i++) 
    {
        a[i] = pairt[i].first;
        b[i] = pairt[i].second;
    }
}
ll pow1(ll n,ll p)
{
    if(p==0)    return 1;
    ll x=pow1(n, p/2);
    x=(x*x)%mod;
    if(p%2==0)
        return x;
    else
        return (x*n)%mod;
}
ll binarySearch(ll arr[], ll l, ll r,ll x) 
{ 
    if (r >= l) 
    { 
        ll mid = l + (r - l) / 2;  
        if (arr[mid] == x) 
        return mid; 
        if (arr[mid] > x) 
        return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    }
    return -1; 
}
bool compare(const pair<ll, ll>&p1, const pair<ll,ll>&p2)
{
    if(p1.F < p2.F) return true;
        if(p1.F == p2.F) return p1.S < p2.S;
        return false;
}
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b); 
}
int isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
long long C(int n, int r) {
    if(r>n-r) 
        r=n-r;
    long long ans=1;
    for(int i=1;i<=r;i++){
        ans*=n-r+i;
        ans/=i;
    }
    return ans;
}
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}
int32_t main()
{
    IOS;

    int n ;
    cin >> n;
    vector<int>a(n+1);

    for(int i = 1; i <= n; i++){
        cin>>a[i];
    }
    vector<int>dp(n+1);

    dp[0] = 0;
    dp[1] = 0;
    dp[2] = abs(a[2] - a[1]);
    int total = dp[2];
    for(int i=3;i<=n;i++){
        dp[i] = min(dp[i-1] + abs(a[i] - a[i-1]), dp[i-2] + abs(a[i] - a[i-2]));
    }
    // for(int i = 1;i<=n;i++)cout<<dp[i]<<" ";
    //     cout<<endl;
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
int a[214514];
int b[214514];
int c[214514];
signed main(){
	ic(n) 
	rep(0,i,n)cin>>a[i];
	for(int i=n-1;i>=0;i-=1){
		rep(0,j,n/(i+1)+1){
			if(b[(i+1)*j-1]==1){
				if(a[i]==1){
					a[i]=0;
				}
				else{
					a[i]=1;
				}
			}
		}				
		if(a[i]==1){
			b[i]=1;
			a[i]=0;
		}
		else{
			b[i]=0;
		}		
	}
	int sum=0;
	rep(0,i,n){
		if(b[i]==1){
			c[sum]=i;
			sum++;	
		}
	}	
	c(sum)
	rep(0,i,sum){
		cout<<c[i]+1<<" ";
	}	
}	


Measured memory_bytes: 2944
/*
秒単位の時間 S が与えられるので、h:m:s の形式へ変換して出力してください。ここで、h は時間、m は 60 未満の分、s は 60 未満の秒とします。
 */

#include <stdio.h>

int main(void)
{
    int S;
    int hour, minute, second;
    int hour_in_second, minute_in_second;

    hour = minute = second = 0;
    hour_in_second = 60 * 60; // 1 hour = 3600sec
    minute_in_second = 60;    // 1 minute = 60 sec
    scanf("%d", &S);

    if (S >= (hour_in_second))
        {
        hour = S / hour_in_second;
        S %= hour_in_second;
    }
    if (S < (hour_in_second) && S >= (minute_in_second))
    {
        minute = S / minute_in_second;
        S %= minute_in_second;
    }
    if (S < (minute_in_second))
    {
        second = S;
    }
    
    printf("%d:%d:%d\n", hour, minute, second);
    return (0);
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
#define ll long long
char buf[1<<20],*p1,*p2;
#define GC (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?0:*p1++)
template<class T> inline void read(T &n){
	char ch=GC;T w=1,x=0;
	while(!isdigit(ch)){if(ch=='-') w=-1;ch=GC;}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=GC;}
	n=x*w;
}
const int maxn=50005;
const int maxm=100005;
int T,n,m,x[maxm],y[maxm],res[maxm];
namespace solve1{
	bitset <maxn> f[maxn];
	int ok[maxn];
	void main(){
		bitset <maxn> tmp;
		for(int i=1;i<=n;i++) f[i][i]=1;
		for(int i=m;i>=1;i--){
			tmp=f[x[i]]|f[y[i]];
			f[x[i]]=f[y[i]]=tmp;
		}
		int pos=-1;
		tmp=f[1];
		for(int i=2;i<=n;i++) tmp&=f[i];
		for(int i=1;i<=n;i++) 
			if(tmp[i]){
				pos=i;
				break;
			}
		if(pos==-1) puts("-1"),exit(0);
		ok[pos]=1;
		for(int i=m;i>=1;i--){
			if(ok[x[i]]^ok[y[i]]) res[i]=ok[x[i]];
			ok[x[i]]=ok[y[i]]=(ok[x[i]]|ok[y[i]]);
		}
		for(int i=1;i<=m;i++) res[i]?putchar('^'):putchar('v');
	}
}
namespace solve2{
	int ed[maxn],cnt[maxn];
	void main(){
		if(n==2) puts("-1"),exit(0);
		for(int i=1;i<=n;i++) ed[i]=i,cnt[i]=1;
		for(int i=m;i>=1;i--){
			if(ed[x[i]]==ed[y[i]]) continue;
			if(cnt[ed[x[i]]]>=2){
				cnt[ed[x[i]]]--;
				cnt[ed[y[i]]]++;
				ed[x[i]]=ed[y[i]];
			}
			else{
				cnt[ed[x[i]]]++;
				cnt[ed[y[i]]]--;
				ed[y[i]]=ed[x[i]];
				res[i]=1;
			}
		}
		for(int i=1;i<=m;i++) res[i]?putchar('^'):putchar('v');
	}
}
int main(){
	read(n),read(m),read(T);
	for(int i=1;i<=m;i++) read(x[i]),read(y[i]); 
	if(T==1) solve1::main();
	if(T==2) solve2::main();
	return 0;
}

Measured memory_bytes: 308224
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void main() {
  int n, r;
  readf (" %d %d", &n, &r);
  writeln ( (n >= 10) ? r : r + (100 * (10 - n)));
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

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

	vector<int> a(n);
	cin >> a;

	vector<bool> deleted(n, false);
	vector<int> ans;
	rep(i,n){
		int num = -1, index;
		int cur = 1;
		rep(j,n){
			if(deleted[j]) continue;

			if(cur == a[j]){
				index = j;
				num = cur;
			}
			cur++;
		}

		if(num != -1){
			deleted[index] = true;
			ans.emplace_back(num);
		}else{
			break;
		}
	}
	
	if(ans.size() != n){
		cout << -1 << endl;
		return 0;
	}

	reverse(all(ans));
	for(auto i : ans){
		cout << i << endl;
	}
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>

#define sint(i) scanf("%d",&i);
#define sintt(i,j) scanf("%d%d",&i,&j);
#define sinttt(i,j,k) scanf("%d%d%d",&i,&j,&k);
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int mise[100002];

int main(){
	while(1){
		int d,n,m;
		sint(d);
		if(d==0)break;
		
		sintt(n,m);
		
		mise[0]=0;
		rep(i,n-1){
			sint(mise[i+1]);
		}
		
		mise[n]=d;
		n++;
		sort(mise,mise+n);
		
		int ans=0;
		rep(i,m){
			int aa;
			sint(aa);
			
			int *nn=lower_bound(mise,mise+n,aa);
			
			int kekka=min(aa-*(nn-1),*nn-aa);
			ans+=kekka;
		}
		
		
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 1264
s = input()

length = len(s)
f = 0

for p in range(length-1):
    for q in range(p+2,p+4):
        hikaku = s[p:q]
        #print(hikaku)
        for i in range(len(hikaku)):
            num = hikaku.count(hikaku[i])
            if num > len(hikaku)/2:
                print(str(p+1) + ' ' + str(q))
                f = 1
                break
        if f == 1:
            break
    if f == 1:
        break
if f == 0:
    print('-1 -1')


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

int func(int x)
{
    if(x%2==0)
    {
        return x/2;
    }
    else
    {
        return 3*x+1;
    }
}
int main()
{
    int x1,x2,y1,y2;
    cin>>x1>>y1>>x2>>y2;
    int d = x2-x1;
    int u = y2-y1;
    int x3 = x2-u;
    int y3 = y2+d;
    int x4 = x3-d;
    int y4 = y3-u;

    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
int N, A, B, C;
int l[1000];
int ans = 1e9;
void dfs(int n, int a, int b, int c, int s) {
	if (n == N) {
		if (a != 0 && b != 0 && c != 0) {
			int t = s - 30;
			t += abs(a - A) + abs(b - B) + abs(c - C);
			ans = min(ans, t);
		}
		return;
	}
	dfs(n + 1, a, b, c, s);
	dfs(n + 1, a + l[n], b , c, s + 10);
	dfs(n + 1, a, b + l[n], c, s + 10);
	dfs(n + 1, a, b, c + l[n], s + 10);
}
int main() {
	cin >> N >> A >> B >> C;
	for (int i = 0; i < N; ++i) {
		cin >> l[i];
	}
	dfs(0, 0, 0, 0, 0);
	cout << ans << endl;
	return 0;
}


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N; cin >> N;
	vector<int> L(2*N);
	REP(i,2*N) cin >> L[i];
	SORT(L);

	int ans = 0;
	REP(i,2*N){
		if(i % 2 == 0) ans += L[i];
	}

	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 256
s=list(input())

ans="Yes"

ki=0
gu=0
if len(s)%2==0:
  ki=len(s)//2
  gu=len(s)//2
else:
  ki=(len(s)//2)+1
  gu=len(s)//2
#print(ki)
#print(gu)
for i in range(ki):
  if s[2*i] == "L":
    ans="No"

for i in range(gu):
  if s[2*i+1] == "R":
    ans="No"

print(ans)

Measured memory_bytes: 39600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define sort(a) sort(all(a))
using P = pair<int, int>;
using ll = long long;
using ld = long double;
typedef vector<int> vi;
int dx[4] = { 0, 1, 0,-1 };
int dy[4] = { 1, 0,-1, 0 };
const ll MOD = 1000000007;

// 深さ優先探索
// vector<bool> seen;
vector<int> memo;

void dfs(int n, int level) {
    if(level>10) return;
    // seen[n] = true; // v を訪問済にする
    memo.push_back(n);
    level++;
    for (int i = -1; i <= 1; i++) {
      if ((n%10)+i>=0 && (n%10)+i<=9) dfs(10*n+(n%10)+i, level);
    }
}

signed main() {
  int K;
  cin >> K;
  for (int j = 1; j < 10; j++) {
    dfs(j, 1); 
  }
  sort(memo);
  // rep(i, memo.size()) {
  //   cout << memo[i] << endl;
  // }
  // cout << memo.size() << endl;
  cout << memo[K-1] << endl;
  return 0;
}

Measured memory_bytes: 2420
let[|n;k|] = stdin.ReadLine().Split() |> Array.map int

if n<=k then stdout.WriteLine 0
else
    stdin.ReadLine().Split()
    |> Array.map int64
    |> Array.sort
    |> fun x -> x.[0..(n-k-1)]
    |> Array.sum
    |> stdout.WriteLine

Measured memory_bytes: 35712
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();
            int ans = 0;
            for (int i = 0; i < 6; i++) {
                ans += S.charAt(i) - '0';
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 23764
s = int(input())

def f(n):
    if n%2==0:
        return n//2
    else:
        return 3*n+1

a = [s]
for i in range(1000000):
    a_nxt = f(a[i])
    if a_nxt in a:
        print(i+2)
        break
    a.append(a_nxt)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define pb push_back

using namespace std;

const int N=1e5+5;

ll x,y,A,B,C,a[N],b[N],c[N];

ll sum;

vector<ll>v;

int main()
{
    cin >> x >> y >> A >> B >> C;
    for (int i=0;i<A;i++)cin>>a[i];
    for (int i=0;i<B;i++)cin>>b[i];
    for (int i=0;i<C;i++)cin>>c[i];
    sort(a,a+A,greater<int>());
    sort(b,b+B,greater<int>());
    sort(c,c+C,greater<int>());
    for (int i=0;i<x;i++)v.pb(a[i]);
    for (int i=0;i<y;i++)v.pb(b[i]);
    for (int i=0;i<C;i++)v.pb(c[i]);
    sort(v.begin(),v.end(),greater<int>());
    for (int i=0;i<x+y;i++)
    {
        sum+=v[i];
    }
    cout << sum << endl;
}


Measured memory_bytes: 7792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  string s;
  ll a = 0;
  in(s);
  if(s.size() % 2 == 0){
    for(ll i = 0; i < s.size(); i= i + 2){
      if(s[i] != 'h' || s[i + 1] != 'i')
        a++;
    }
  }
  else
    a++;
  if(a)
    out("No");
  else
    out("Yes");
  memi;
}

Measured memory_bytes: 256
#include <stdio.h>
void zeros(int* a);
int p(int a,int b);

int main(void)
{
    int n=0,m=0,x=0,price=0,min=1200001,count=1;
    int c[12]={},A[12][12]={},total[12]={};

    scanf("%d %d %d",&n,&m,&x);
    for(int i=0;i<n;i++){
        scanf("%d",&c[i]);
        for(int j=0;j<m;j++){
            scanf("%d",&A[i][j]);
        }
    }
    for(int i=0;i<p(2,n);i++){
        zeros(total);
        price=0;
        count=1;
        for(int j=0;j<n;j++){
            if((i&count)==count){
                price+=c[j];
                for(int k=0;k<m;k++){
                    total[k]+=A[j][k];
                }
            }
            count*=2;
        }
        for(int l=0;l<m;l++){
            if(total[l]<x) break;
            if(l==(m-1) && min>price){
                min=price;
            }
        }
    }
    if(min==1200001){
        printf("-1");
    } else {
        printf("%d",min);
    }
    return 0;
}

void zeros(int* a){
    for(int i=0;i<12;i++){
        a[i]=0;
    }
}

int p(int a,int b){
    int temp=a;
    for(int i=0;i<b;i++){
        temp*=a;
    }
    return temp;
}


Measured memory_bytes: 1708
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int x,a;
  cin >> x >> a;
  if(x < a) cout << 0 << endl;
  else cout << 10 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if((int)s.size() < 4){
        cout << "No\n";
    }else{
        string t = s.substr(0,4);
        if(t == "YAKI"){
            cout << "Yes\n";
        }else{
            cout << "No\n";
        }
    }
    return 0;
}


Measured memory_bytes: 256
import numpy as np
N, W = map(int, input().split())
dp = np.zeros((N, W+1), dtype = "int64")
for i in range(N):
    w, v = map(int, input().split())
    dp[i,-w:] = dp[i-1, -w:] #残りの重さW-w以上にするためには、荷物を入れられない。
    dp[i, :W-w+1] = np.fmax(dp[i-1, :W-w+1], dp[i-1, w:]+v)
print(dp[N-1, 0])

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

int main(){
  int n,sum;
  cin >> n >> sum;
  int a=-1;
  int b=-1;
  int c=-1;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n-i;j++){
      if(10000*i+5000*j+1000*(n-i-j)==sum){
        a=i;
        b=j;
        c=n-i-j;
      }
    }
  }
  cout << a << " " << b << " " << c << endl;
}


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

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(a) a.begin(), a.end()
#define ll long long
#define mod 1e9+7

using namespace std;

int main()
{
  ll n, m;
  cin >> n;
  vector<ll> t(n);
  rep(i, n) {
    cin >> t[i];
  }

  cin >> m;
  vector<ll> p(m), x(m);
  rep(i, m) {
    cin >> p[i] >> x[i];
  }

  rep(i, m) {
    ll sec = 0;
    rep(j, n) {
      sec += (j + 1 == p[i] ? x[i] : t[j]);
    }
    cout << sec << endl;
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N = 103;

int s[N], n;

int main() {
	scanf("%d", &n);
	int sum = 0;
	for (int i = 1; i <= n; ++i) scanf("%d", s + i), sum += s[i];
	if (sum % 10 == 0) {
		int mx = 0x7fffffff;
		for (int i = 1; i <= n; ++i)
			if (s[i] % 10) mx = min(mx, s[i]);
		if (mx == 0x7fffffff) puts("0");
		else printf("%d\n", sum - mx);
		return 0;
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=1<<s.nextInt(),inf=999999999;
		int[]v=new int[n];
		Arrays.fill(v,inf);

		for(int m=s.nextInt();m>0;--m){
			int w=s.nextInt(),f=0;
			for(int k=s.nextInt();k>0;--k)
				f|=1<<(s.nextInt()-1);
			v[f]=Math.min(v[f],w);
		}

		for(int i=2;i<n;++i)
			for(int j=1;j<i;++j)
				v[i|j]=Math.min(v[i|j],v[i]+v[j]);

		System.out.println(v[n-1]<inf?v[n-1]:-1);
	}
}


Measured memory_bytes: 34520
ac = 0
wa = 0
tle = 0
re = 0
n = int(input())
for i in range(n):
    a = input()
    if a == "AC":
        ac += 1
    if a == "WA":
        wa += 1
    if a == "TLE":
        tle += 1
    if a == "RE":
        re += 1
        
print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x " + str(re))

Measured memory_bytes: 69852
# AGC112 D - Partition
from math import floor
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table


n,m=map(int,input().split())

n_max=floor(m/n)
div_m=divisor(m)
div_m.sort(reverse=True)
ans=0
for i in div_m:
    if i<=n_max:
        print(i)
        exit()


Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define rep(i,n) for (int i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
int a[305][305],now[305];    // now : ith  choose  now[i]th
int n,m,has[305],res=1000000,maxi=0,pos=0;
bool can[305];
int main()
{
	cin>>n>>m;
	memset(can,1,sizeof(can));
	rep(i,n){
		rep(j,m){
			scanf("%d",&a[i][j]);
		}
	}
	rep(i,n){
		has[a[i][1]]++;
		if (maxi<has[a[i][1]]){
			maxi=has[a[i][1]];
			pos=a[i][1];
		}
	}
	for (int i=1;i<=304;i++) now[i]=1;
	res=maxi;
	bool f=1;
	while (f){
		if (m==1) break;
		memset(has,0,sizeof(has));
		can[pos]=0;maxi=0;
		int nowpos;
		for (int i=1;i<=n;i++){
			if (a[i][now[i]]==pos){
				int jj=now[i]+1;
				while (jj<=m&&can[a[i][jj]]==0) jj++;
				if (jj>m){
					f=0;
					break;
				}
				now[i]=jj;
			}
			has[a[i][now[i]]]++;
			if (has[a[i][now[i]]]>maxi){
				maxi=has[a[i][now[i]]];
				nowpos=a[i][now[i]];
			}
		}
		if (!f) break;
		res=min(res,maxi);
		pos=nowpos;
	}
	cout<<res;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<vector<vector<int>>> v3int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef vector<vector<vector<ll>>> v3ll;
typedef list<int> liint;
typedef pair<int, int> pint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, int>> vpll_int;
typedef vector<pair<int, ll>> vpint_ll;
typedef set<pair<int, int>> spint;
typedef set<pair<ll, int>> spll;
typedef unordered_map<int, unordered_set<int>> Graph;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }


unordered_map<ll, unordered_map<int, ll>> save;
unordered_map<int, ll> fact(int x) {
    if (save.count(x) > 0) return save[x];
    int num = x;
   
    unordered_map<int, ll> ans;
    int a = 2;
    while (x >= a * a) {
        if (x % a == 0) {
            ans[a]++;
            x /= a;
        }
        else
        {
            a++;
        }
    }
    ans[x]++;
    save[num] = ans;
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    //N = 1000000;
    vint A(N);
    rep(i, N) cin >> A[i];
 
    //rep(i, N) A[i] = 994009;

    bool is_all_one = true;
    rep(i, N) {
        if (A[i] != 1) {
            is_all_one = false;
        }
    }

    if (is_all_one) {
        cout << "pairwise coprime" << endl;
        return 0;
    }
    unordered_map<int, ll> p_cnt;
    ll max_cnt = 0;
    rep(i, N) {
        if (A[i] == 1) {
            //p_cnt[1]++;
            continue;
        }
        auto primes = fact(A[i]);
        for (auto& p : primes) {
            p_cnt[p.first]++;
            max_cnt = max(max_cnt, p_cnt[p.first]);
        }
    }
    if (max_cnt == 1) {
        cout <<"pairwise coprime" << endl;
        return 0;
    }
    for (auto& p : p_cnt) {
        if (p.second == N) {
            cout << "not coprime" << endl;
            return 0;
        }
    }
    cout << "setwise coprime" << endl;
    return 0;
}

Measured memory_bytes: 227272
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include <unordered_map>
#include<map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n; ++i)
#define ALL(a) (a).begin(),(a).end()
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)

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

    vector<string> list(4);
    list[0] = "dream";
    list[1] = "dreamer";
    list[2] = "erase";
    list[3] = "eraser";
    rep(i, 4)reverse(ALL(list[i]));
    string tmp = "";
    reverse(ALL(s));
    rep(i, s.size()){
        tmp = tmp  + s[i];
        if(tmp.size() > 8){
            cout << "NO";
            return 0;
        }
        if(find(ALL(list), tmp) != list.end())tmp = "";
    }
    if(tmp.empty())cout << "YES";
    else cout <<  "NO";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
	int c[4] = {0, 0, 0, 0};
	cin >> N;
	for (int i = 0; i < N; i++) {
		string x;
		cin >> x;
		if (x == "AC") {
			c[0]++;
		} else if (x == "WA") {
			c[1]++;
		} else if (x == "TLE") {
			c[2]++;
		} else {
			c[3]++;
		}
	}
	cout << "AC x " << c[0] << endl;
	cout << "WA x " << c[1] << endl;
	cout << "TLE x " << c[2] << endl;
	cout << "RE x " << c[3] << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}

class BIT{
private:
    //[1,n]
    vector<int> bit;
    int n;

public:
    BIT(){}
    BIT(int size){
        n = size;
        bit = vector<int>(n+1,0);
    }
    //[0,i)のsum（内部実装は[1,i]）
    int sum(int i){
        int s = 0;
        while(i > 0){
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }

    void add(int i, int x){
        i++;
        while(i <= n){
            bit[i] += x;
            i += i & -i;
        }
    }
    void show(){
        for(int i = 1; i <= n; i++){
            cout << " " << bit[i];
        }
        cout << endl;
    }
    int num(int l, int r){//[l,r)の総和
        int ret = sum(r) - sum(l);
        return ret;
    }
    void look(int x){
        cout << "???" << bit[x] << endl;
    }
};

signed main(void) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<BIT> bit(26,BIT(n+1));
    rep(i,n){
        int a = s[i] - 'a';
        bit[a].add(i,1);
    }
    int q;
    cin >> q;
    while(q--){
        int a;
        cin >> a;
        if(a == 1){//b文字目をcに変更
            int b;
            string c;
            cin >> b >> c;
            int x = s[b-1]-'a';
            bit[x].add(b-1,-1);
            bit[c[0]-'a'].add(b-1,1);
            s[b-1] = c[0];
        }else{//[b,c]の種類数
            int b,c;
            cin >> b >> c;
            int ans = 0;
            rep(i,26){
                if(bit[i].sum(c) - bit[i].sum(b-1) > 0)ans++;
            }
            cout << ans << endl;
        }
    }

}


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

// #define int long long // intで書いたけど心配なときにlong longに変換する
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using plglg = pair<ll, ll>;
using tlglglg = tuple<ll, ll, ll>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << endl;}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
inline void yesno(bool ok, string yes = "Yes", string no = "No") {cout << (ok?yes:no) << endl;}


ll f[10000001];

signed main() {
    //my-code
    ll n; cin >> n;

    REPS(i, 1, n+1) {
        f[i] = 0;
    }

    ll num;
    REPS(i, 1, n+1) {
        num = i;
        while(num <= n) {
            f[num]++;
            num += i;
        }
    }

    ll ans = 0;
    REPS(i, 1, n+1) {
        ans += i*f[i];
    }

    print(ans);

    return 0;
}

// https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて
// http://www.creativ.xyz/dump-cpp-652 dump()について
// https://gist.github.com/rigibun/7905920 色々

Measured memory_bytes: 81732
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;
    int count = 0 ;
    // 標準入力から、空白や改行で区切られた整数と文字列を読み込む。
    cin >> s ;
    for (int i = 0 ;i < s.size();i++){
      if (s[i] == '1'){
        count += 1;
      }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int,int>q;
long long h,m;
char s;
int main()
{
    scanf("%lld %c %lld",&h,&s,&m);
    if(s=='+')
    {
        printf("%lld\n",h+m);
    }
    else
    {
         printf("%lld\n",h-m);
    }
    return 0;
}

Measured memory_bytes: 256
#ifndef Local
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse4,sse4.2,popcnt,abm,mmx,avx")
#endif
#include <bits/stdc++.h>

using namespace std;

#define popCnt(x) (__builtin_popcountll(x))
#define sz(x) ((int)(x.size()))
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)
typedef long long Long;
typedef double Double;

template <class U, class V>
istream& operator>>(istream& is, pair<U, V>& p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& x : v) {
    is >> x;
  }
  return is;
}

template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& x : v) {
    os << x << " ";
  }
  return os;
}

vector<int> a, b, res;

int n;
bool solve1() {
  multiset<int> ms_b(all(b));
  for (int i = 0; i < n; ++i) {
    auto it = begin(ms_b);
    if (*it <= a[i]) {
      ms_b.insert(*it + n);
      ms_b.erase(begin(ms_b));
      --i;
      continue;
    }
    res[i] = *it;
    ms_b.erase(it);
    if (res[i] > n) res[i] -= n;
    if (a[i] == res[i]) return false;
  }
  return true;
}
map<int, int> cnt_a, cnt_b;

bool solve2() {
  set<pair<int, int>> st;
  for (auto& x : cnt_b) {
    st.emplace(x.second, x.first);
  }
  for (int i = 0; i < n; ++i) {
    auto it = end(st);
    --it;
    if (it->second == a[i]) {
      if (it == begin(st)) return false;
      --it;
    }
    res[i] = it->second;
    auto tmp = *it;
    st.erase(it);
    --tmp.first;
    if (tmp.first != 0) {
      st.insert(tmp);
    }
  }
  return true;
}
const int RANDOM =
    chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(RANDOM);

bool validate() {
  bool valid = true;
  for (int i = 0; i < n; ++i) {
    valid &= (a[i] != res[i]);
  }
  return valid;
}

bool solve3() {
  res = b;
  reverse(all(res));
  for (int t = 0; t < 150; ++t) {
    if (validate()) return true;
    shuffle(all(res), rng);
  }
  res = b;
  for (int t = 0; t < 150; ++t) {
    rotate(begin(res), begin(res) + rng() % n, end(res));
    if (validate()) return true;
  }
  return false;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
#else
#define endl '\n'
#endif
  cin >> n;
  a.resize(n), b.resize(n), res.resize(n);
  cin >> a >> b;
  for (int x : b) ++cnt_b[x];
  for (int x : a) {
    ++cnt_a[x];
    if (cnt_b.count(x) && cnt_b[x] + cnt_a[x] > n) {
      cout << "No" << endl;
      return 0;
    }
  }

  bool (*habds[])() = {solve1, solve2, solve3};
  for (auto habd : habds) {
    if (habd()) {
      cout << "Yes" << endl;
      cout << res << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

//Ai分かかる本の列(1<=i<=N)とBi分かかる本の列(1<=i<=M)がある
//それぞれにおいて上(インデックスの小さいもの)から順に読める
//列を選びつつ読んでK分を超えない最大冊数を求める
int main(){
    int N,M;
    long long int K;
    cin >> N >> M >> K;
    long long int* A = new long long int[N];
    long long int* B = new long long int[M];
    for(int i=0;i<N;++i){
        cin >> A[i];
    }
    for(int i=0;i<M;++i){
        cin >> B[i];
    }

    long long int sum=0;
    int index=N-1;

    //Aから条件の範囲内で本をとる
    for(int i=0;i<N;++i){
        sum=sum+A[i];
        if(sum>K){
            sum=sum-A[i];
            index=i-1;
            break;
        }
    }

    //Aの本を減らしてBの本をとる
    int j=0;//Bのインデクス
    //Aが全部入る場合を考慮して、Bの追加を最初に行う
    while(true){
        if(j>=M){
            break;
        }
        if(sum+B[j] > K){
            break;
        }
        sum=sum+B[j];
        ++j;
    }
    int max=index+1+j;//最大冊数
    for(int i=index;i>=0;--i){
        sum=sum-A[i];//Aの本を減らす

        //Bの本をできるだけとる
        while(true){
            if(j>=M){
                break;
            }
            if(sum+B[j] > K){
                break;
            }
            sum=sum+B[j];
            ++j;
        }

        //この時点で、Aはi-1番目まで、Bはj-1番目まで入っている(0スタート)
        if(i+j > max){
            max=i+j;
        }
    }

    cout << max << endl;
    delete[] A;
    delete[] B;
}

Measured memory_bytes: 6340
N, M = map(int, input().split())
ac = [False] * N
wa = [0] * N
ac_count = 0
wa_count = 0
for i in range(M):
    p, S = input().split()
    p = int(p)
    p -= 1
    if ac[p]:
        continue
    if S == 'AC':
        ac[p] = True
        ac_count += 1
        wa_count += wa[p]
    else:
        wa[p] += 1
print(ac_count, wa_count)


Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<i64> p(N, K - Q);
    for(int i = 0; i < Q; i++) {
        int a;
        cin >> a;
        a--;
        p[a]++;
    }
    for(int i = 0; i < N; i++) {
        R_YesNo(p[i] > 0);
    }
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll x; cin >> x;
    ll cnt = 0;
    ll ans = 0;
    while(cnt < x){
        ans++;
        cnt += ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split(" ")))
dp=[0]*N
dp[1]=abs(A[0]-A[1])
for i in range(2,N):
  dp[i]=min((dp[i-1]+abs(A[i-1]-A[i]),dp[i-2]+abs(A[i-2]-A[i])))

print(dp[N-1])

Measured memory_bytes: 13980
#include<stdio.h>
int main()
{
	int i,d[31]={0},t;
	for(i=28;i;d[t]=1,i--)
		scanf("%d",&t);
	for(i=1;i<=30;i++)
		if(!d[i])
			printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define ubo upper_bound
#define lbo lower_bound
#define VI vector<int>
#define VL vector<ll>
#define VP vector<pii >
#define all(x) x.begin(), x.end()
#define M vector<VI >

using namespace std;

int h, w, k, ans;
string c[10];

int main(){

	cin >> h >> w >> k;

	VI ph(h), pw(w);

	for(int i=0; i<h; i++) cin >> c[i];
	for(int i=0; i<h; i++) ph[i] = i;
	for(int i=0; i<w; i++) pw[i] = i;

	for(int i=0; i<(1<<h); i++){
		for(int j=0; j<(1<<w); j++){
			
			int tot = 0;

			for(int x=0; x<h; x++){
				for(int y=0; y<w; y++){
					if(!((i>>x)&1) && !((j>>y)&1) && c[x][y] == '#') tot++;
				}
			}

			if(tot == k) ans++;

		}
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
#define int long long    // %d=>%lld
#define pb push_back
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;

int h;
int w;
int ans=INF;


signed main(){
    scanf("%lld", &h);
    scanf("%lld", &w);

    int a;
    int b;
    int c;


    if(h%3 == 0||w%3 == 0){
        cout<< 0;
        return 0;
    }
    ans = min(h,w);

    for(int i = 1;i < h;i++){
        a=i*w;
        b=(h-i)*(w/2);
        c=h*w-a-b;
        int buf=max(abs(b-c), max(abs(a-c),abs(a-b)));
        ans=min(ans,buf);
    }

    swap(w,h);

    for(int i = 1;i < h;i++){
        a=i*w;
        b=(h-i)*(w/2);
        c=h*w-a-b;
        int buf=max(abs(b-c), max(abs(a-c),abs(a-b)));
        ans=min(ans,buf);
    }


    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
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; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  cout << (1000 - n % 1000) % 1000 << endl;

  return 0;
}


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

int main() {
	string S;
	cin >> S;
	int cnt=0;
	int mm=0;
	
	if (S.at(0) == 'A') {
		for (int i = 2; i < S.size()-1; i++) {
			if (S.at(i) == 'C') {
				cnt++;
				mm = i;
			}
		}
		if (cnt == 1) {
			for (int j = 1; j < S.size(); j++) {
				if (j == mm || (S.at(j)>='a' && S.at(j)<='z')){
					cnt++;
				}
			}
			if (cnt == S.size()) {
				cout << "AC" << endl;
			}
			else {
				cout << "WA" << endl;
			}
		}
		else {
			cout << "WA" << endl;
		}
	}
	else {
			cout << "WA" << endl;
		}
			
			
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		int counter = 0;
		List<Integer> list = new ArrayList<>();

		for(int i=1;i<=a||i<=b;i++) {
			if(a%i == 0 && b%i == 0) {
				counter++;
				list.add(i);
			}
		}
		System.out.println(list.get(counter - k));
	}

}


Measured memory_bytes: 23124
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int a,b,c;cin>>a>>b>>c;
    if(a<=c && c<=b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

using namespace std;

// ちょうどk個の品物を買ってx円にすることが可能か
int buy_k(int k, int x) {
	if (x < 100 * k) return 0;
	x -= 100 * k;
	int c = x / 5;
	c += (x % 5) ? 1 : 0;
	return ((c <= k) ? 1 : 0);
}

signed main() {
	int x; cin >> x;
	for (int k = 1; k <= 1000; ++k) {
		if (buy_k(k, x)) {
			cout << 1 << endl;
			exit(0);
		}
	}
	cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    ll x, y;
    cin >> x >> y;
    ll count = 0;
    ll b = x;
    while(b <= y) {
        count++;
        b *= 2;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256