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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N; cin >> N;
  vector<ll> v(N);
  ll sum = 0;
  for(int i = 0; i < N; i++){
    cin >> v[i];
    sum ^= v[i];
  }

  vector<ll> ans(N);
  for(int i = 0; i < N; i++){
    ll tmp = sum ^ v[i];
    ans[i] = tmp;
  }

  for(int i = 0; i < N; i++){
    if(i == N-1){
      cout << ans[i] << endl;
    } else { 
      cout << ans[i] << " ";
    }
  }

}


Measured memory_bytes: 6332
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	map<int, int>mp;
	rep(i, n) {
		cin >> a[i];
		mp[a[i]]++;
	}
	ll ans = 0;
	for (auto p : mp) {
		int x = p.second;
		if (x% 2 != 0)ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5376
line = gets
data = line.split(" ")
N = data[0].to_i
M = data[1].to_i
first = Array.new
second = Array.new
M.times do |i|
  line = gets
  data = line.split(" ")
  data.map!{|item| item.to_i}
  if data[0] == 1
    first << data[1]
  elsif data[1] == N
    second << data[0]
  end
end
loot = first & second
if loot.empty?
  puts "IMPOSSIBLE"
else
  puts "POSSIBLE"
end

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

using namespace std;

int main(void)
{
  int A, B, C;
  int K;
  
  cin >> A >> B >> C >> K;
  
  int card_point = 0;
  
  if( (K-A) >= 0 )
  {
    K -= A;
    card_point += A;
  }
  else
  {
    card_point += K;
    cout << card_point << endl;
    return 0;
  }
    
  if ( (K != 0) && (K-B) >= 0 )
  {
      K -= B;
  }
  else
  {
    cout << card_point << endl;
    return 0;
  }
    
  if ( (K != 0) && (K-C) >= 0)
  {
      K -= C;
      card_point += -C;
  }
  else
  {
      card_point += -K;
  }
  cout << card_point << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>

#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

typedef long long int64;

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	int cur = 0;
	for (int i = 0; i < n; ++i) {
	    if (a[i] == cur + 1) ++cur;
	}
	if (cur == 0) {
	    cout << "-1" << endl;
		return 0;
	}
	cout << n - cur << endl;

    return 0;
}


Measured memory_bytes: 1024
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

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

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

const ll MOD = 1e9 + 7;
inline ll addmod(ll a, ll b){
	if(a+b<MOD)return a+b;
	return a+b-MOD;
}
inline ll mulmod(ll a, ll b){
	return (a*b)%MOD;
}
inline ll expmod(ll a, ll e){
	ll ret = 1;
	while(e){
		if(e&1)ret = mulmod(ret, a);
		a = mulmod(a, a);
		e >>= 1;
	}
	return ret;
}
inline ll divmod(ll a, ll b){
	return mulmod(a, expmod(b, MOD-2));
}

const int N = 2e5 + 5;

int fac[N];
inline int C(int n, int r){
	return divmod(fac[n], mulmod(fac[r], fac[n-r]));
}

int h,w,a,b;

inline int ways(int x1, int y1, int x2, int y2){
	int x = x2-x1;
	int y = y2-y1;
	return C(x+y, x);
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);

    fac[0] = 1;
    REP(i,1,N-1)fac[i] = mulmod(fac[i-1], i);

    cin>>h>>w>>a>>b;

    int ans = 0;
    int i = h - a;
    REP(j,b+1,w){
    	ans = addmod(ans, mulmod(ways(1, 1, i, j), ways(i+1, j, h, w)));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int X;

    scanf("%d", &X);

    int d = 0;
    int t = 0;

    while(1){
        if(d >= X){
            break;
        }else{
            t++;
            d += t;
        }
    }

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

    return 0;
}

Measured memory_bytes: 1700
import std.stdio;
import std.string;

void main() {
  int n;
  readf("%d\n", &n);
  char[] s = readln.chomp.dup;
  foreach (i; 0 .. s.length) {
    s[i] = (s[i] - 'A' + n) % 26 + 'A';
  }
  writeln(s);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e5;
const long mod=1e9+7;
long dp[N+2][2];
vector<int>adj[N+2];
long dfs(int node,int par,int cl)
{
  if(dp[node][cl]!=-1)return dp[node][cl];
  long now=1;
  for(auto x:adj[node])
  {
    if(x==par)continue;
    if(!cl)
    {
      dfs(x,node,0);dfs(x,node,1);
      now=(now*(dp[x][0]+dp[x][1]))%mod;
    }
    else
    {
      dfs(x,node,0);
      now=(now*dp[x][0])%mod;
    }
  }
  return dp[node][cl]=now;
}
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  int n;cin>>n;
  for(int i=1;i<n;i++)
  {
    int u,v;cin>>u>>v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  memset(dp,-1,sizeof(dp));
  cout<<(dfs(1,-1,0)+dfs(1,-1,1))%mod<<endl;
  return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n;
  string s, t, ans;
  cin >> n >> s >> t;
  for (int i = 0; i < n; i++) {
    ans += s[i];
    ans += t[i];
  }

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

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))
INF = 10 ** 9

dp = [INF] * N
dp[0] = 0

for i in range(N - 2): 
    dp1 = dp[i] + abs(h[i + 1] - h[i])
    dp[i + 1] = min(dp[i + 1], dp1)
    dp2 = dp[i] + abs(h[i + 2] - h[i])
    dp[i + 2] = min(dp[i + 2], dp2)
dp1 = dp[-2] + abs(h[-1] - h[-2])
dp[-1] = min(dp[-1], dp1)

print(dp[-1])

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

int main()
{
  std::string s;
  std::cin >> s;
  for (int i = 0; i < s.size(); ++i)
  {
    for (int j = i; j <= s.size(); ++j)
    {
      if (s.substr(0, i) + s.substr(j, s.size() - j) == "keyence")
      {
        puts("YES");
        return 0;
      }
    }
  }
  puts("NO");
  return 0;
}

Measured memory_bytes: 256
### main

loop do
  a, b = gets.strip.split(' ').map{|s| s.to_i}
  break if (a | b) == 0

  n = gets.strip.to_i

  rts = b.times.map{a.times.map{nil}}

  n.times do
    x, y = gets.strip.split(' ').map{|s| s.to_i - 1}
    rts[y][x] = 0
  end

  rts[b - 1][a - 1] = 1

  (a + b - 3).downto(0) do |xy|
    for x in (0..xy)
      y = xy - x
      if (x >= 0 && x < a && y >= 0 && y < b)
        if rts[y][x].nil?
          rt = 0
          rt += rts[y][x + 1] if x < a - 1
          rt += rts[y + 1][x] if y < b - 1
          rts[y][x] = rt
        end
      end
    end
  end

  puts rts[0][0]
end

Measured memory_bytes: 6132
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int[] c = new int[256];
		boolean ok = true;
		String a = sc.next(), b = sc.next();
		for (char ch : b.toCharArray()) c[ch]++;
		for (char ch : a.toCharArray()) {
			if (c[ch]>0) c[ch]--;
			else ok=false;
		}
		if (ok) ok = a.length()<b.length();
		if (!ok) {
			StringBuilder f = new StringBuilder();
			StringBuilder g = new StringBuilder();
			char[] d = a.toCharArray(), e = b.toCharArray();
			Arrays.sort(d); Arrays.sort(e);
			for (char ch : d) f.append(ch);
			for (char ch : e) g.append(ch);
			ok=f.compareTo(g.reverse())<0;
		}
		System.out.println(ok ? "Yes" : "No");
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 35620
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

#define P 1000000007

using namespace std;

int main() {
  int n;
  cin >> n;
  set<long long> s;
  for(int i = 0; i < n; i++) {
    long long a;
    cin >> a;
    if(s.find(a) == s.end()) s.insert(a);
    else s.erase(s.find(a));
  }
  cout << s.size() << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    cout << setprecision(20);
    ll x;
    cin >> x;

    rep(i, x/100+1)
    rep(j, 2+1)
    rep(k, 2+1)
    rep(l, 5+1)
    rep(m, 5+1)
    rep(n, 20+1){
        if(100*i+101*j+102*k+103*l+104*m+105*n==x){
            cout << 1 << endl;
            return 0;
        }
    }
    cout << 0 << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
#define MOD 1000000007
#define MAXE9 1000000000

int i, j, k, l = 0;
    int N, v;
    int A[1001];

void InsSRT(void){
    for(i=1;i<N;i++){
        v = A[i];
        j = i-1;
        while(j>=0 && A[j] > v){
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
                for(k=0;k<N;k++){
            printf("%d", A[k]);
            if(k!=N-1) printf(" ");
        }
        printf("\n");
    }
}

int main(){
    scanf("%d", &N);
    for(i=0;i<N;i++){
        scanf("%d", &A[i]);
    }
    for(i=0;i<N;i++){
        printf("%d", A[i]);
        if(i!=N-1) printf(" ");
    }
    printf("\n");
    InsSRT();
    
    return 0;
}


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

int main() {
  int A, B, X=0;
  cin >> A >> B;
  
  for(int i=0; i<2; i++){
    if(A > B){
  		X += A;
        A--;
  	}else{
      X += B;
      B--;
    }
  }
  
    cout << X << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

const double PI = acos(-1.0);
const double EPS = 1e-6;
const int INF = 0x3f3f3f3f;

void solve() {
    int n, m, a[10][2], ans[10];
    bool flag = true;

    cin >> n >> m;
    for (int i = 0; i < m; ++i) cin >> a[i][0] >> a[i][1];

    set<int> s;
    for (int i = 1; i <= n; ++i) {
        s.clear();
        for (int j = 0; j < m; ++j) {
            if (a[j][0] == i) s.insert(a[j][1]);
        }

        if (s.size() > 1) flag = false;
        else if (s.size() == 1) {
            if (*s.begin() == 0 && i == 1 && n != 1) flag = false;
            else ans[i] = *s.begin();
        }
        else {
            if (i == 1 && n != 1) ans[i] = 1;
            else ans[i] = 0;
        }

        if (!flag) {
            cout << -1 << endl;
            return;
        }
    }

    for (int i = 0; i < n; ++i) cout << ans[i + 1];
    cout << endl;

}


int main() {
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int n,i;
	cin>>n;
    if(n==1)
    {
        cout<<1<<endl;
        return 0;
    }
	for(i=2;;i*=2)
	{
		if(i*2>n)
		{
			cout<<i<<endl;
			return 0;
		}
	}
}

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

int main(){
  int N,S;
  cin >> N;

  if(N < 10){
    S = N;
  }else{
    N = N % 10;
    if(N < 10){
      S = N;
      }else{
        N = N % 10;
        S = N;
      }
  }
  if(S == 3){
    cout << "bon";
  }else{
    if(S == 0 || S == 1 || S == 6 || S == 8){
      cout << "pon";
    }else{
      cout <<"hon";
    }
  }

  cout << endl;

}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int num[10]={0},n;
int memo[10][2][10][10][10]={0};
int dfs(int kt,int sr,int c3,int c5,int c7,int zr){
  //cout<<kt<<" "<<sr<<" "<<c3<<" "<<c5<<" "<<c7<<endl;
  if(kt>=n&&c3>0&&c5>0&&c7>0&&zr>0) {
    //cout<<sr<<" "<<c3<<" "<<c5<<" "<<c7<<endl;
    return 1;
  }
  if(kt>=n) return 0;
  if(sr==0){
    int res=0;
    if(zr==0) res+=dfs(kt+1,sr,c3,c5,c7,0);
    res+=dfs(kt+1,sr,c3+1,c5,c7,1);
    res+=dfs(kt+1,sr,c3,c5+1,c7,1);
    res+=dfs(kt+1,sr,c3,c5,c7+1,1);
    return res;
  }
  else{
    int sev[]={3,5,7},ret=0;
    for(int i=0;i<3;i++){
      bool f=true;
      int gr=0;
      if(sev[i]>num[kt]) f=false;
      if(sev[i]==num[kt]) gr++;
      if(f){
        if(i==0) ret+=dfs(kt+1,gr,c3+1,c5,c7,1);
        if(i==1) ret+=dfs(kt+1,gr,c3,c5+1,c7,1);
        if(i==2) ret+=dfs(kt+1,gr,c3,c5,c7+1,1);
      }
    }
    if(zr==0) ret+=dfs(kt+1,0,c3,c5,c7,0);
    return ret;
  }
}
int main(){
  string s;
  cin>>s;
  n=s.length();
  for(int i=0;i<n;i++) num[i]=s[i]-'0';
  cout<<dfs(0,1,0,0,0,0)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template<class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main() {
    
    int n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++){
        if(i%3==0||i%5==0)continue;
        else ans+=i;
    }
    fin(ans);
}




Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vp;
typedef vector<vp> vpp;
typedef vector<vector<ll> > graph;
#define pb push_back
#define mp make_pair
#define maxi INT_MAX
#define mini INT_MIN
#define endl '\n'
void set_val(vector<ll>& v, ll val){for(ll i=0;i<v.size();i++) v[i]=val;}

ll mod = pow(10,9) + 7;
ll modulo = 998244353;
ll i_mov[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
ll j_mov[8] = {1, 1, 1, 0, -1, -1, -1, 0};

vector<vector<int>> g;
vector<int> parent, depth, subsize;

ll power(ll a, ll n)
{
    if(n==0)
    return 1;
    ll temp = power(a,n/2);
    if(n%2==0)
    return (temp*temp)%mod;
    return (((temp*temp)%mod)*a)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // cout<<fixed;
    // cout<<setprecision(18);
    ll n;
    cin>>n;
    ll ans = 0;
    for(int i=1;i<=n;i++)
    {
        if(i%3==0 || i%5==0)
        continue;
        ans+=i;
    }
    cout<<ans<<endl;
} 

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

int main(){
    int ans=0;
    int n,p=9,q=1;
    
    cin >>n;

    if(n < 10){
        ans = n;
    }else if(n < 1000){
        ans = 9 + max(0,n-99);
    }else if(n < 100000){
        ans = 9 + 900 + max(0,n-9999);
    }else{
        ans = 90909;
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


vector<ll>adj[Max+10];

bool vis[Max+10];

void dfs(ll s)
{
    vis[s]=true;

      for(auto   x  : adj[s])
      {
          if(!vis[x])
            dfs(x);
      }
}

int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;

      cin>>n>>m;


      for(i=0; i<m; i++)
      {
          cin>>a>>b>>c;

          adj[a].eb(b);

          adj[b].eb(a);
      }

      for(i=1; i<=n; i++)
      {
          if(!vis[i])
          {
              dfs(i);
              ans++;
          }
      }


      cout<<ans<<endl;














}



Measured memory_bytes: 56812
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

int main() {
	int x;
	cin >> x;
	cout << x*x*x << endl;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
#define  st first
#define  nd second
#define int long long

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef cc_hash_table<int, int, hash<int > > ht;
#define TIMES_PER_SEC (CLOCKS_PER_SEC)



double get_absolute_time()
{
	return (double)clock()/TIMES_PER_SEC;
}
double starttime_acrush;
void starttime()
{
	starttime_acrush=get_absolute_time();
}
double gettime()
{
	return get_absolute_time()-starttime_acrush;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define MOD   1000000007
#define maxn 100002
#define inf 1e18


int32_t main(){

  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  int n,x;
  cin >> n >>x;
  int c = 0;
  for(int  i = 0 ; i < x ; i++){
    int t ;
    cin >> t ;
    c+=t;
  }
  if(n>c){
    cout <<"No";
  }
  else
    cout <<"Yes";
}



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

vector<int> arr;

int main( void ) {
    
    int n;
    cin >> n;
    
    for( int i = 1; i <= n; n -= i ++ )
        arr.push_back( i );

    reverse( arr.begin(), arr.end() );
    for( int i = 0; i < n; i ++ )
        arr[i] ++;
    
    reverse( arr.begin(), arr.end() );
    for( int i = 0; i < arr.size(); i ++ )
        cout << arr[i] << '\n';
    
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2")
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define pb push_back
#define X first
#define Y second
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e18+1;
const ll MOD = 1000000007L;
#ifdef umang99m
    #include "/home/umang/Desktop/folder/home/.templates/header.h"
#else
    #define dbg(args...)
    #define timer()
#endif
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    vi a(n);
    rep(i,n) cin>>a[i];
    vector<bool> win(k+1,false);
    for(int i=0; i<n; i++){
        win[a[i]] = true;
    }
    for(int i=0; i<=k; i++){
        for(int j=0; j<n; j++){
            if(a[j] < i && !win[i-a[j]]){
                win[i] = true;
                break;
            }
        }
    }
    if(win[k]) cout<<"First";
    else cout<<"Second";

    cout<<endl;
    timer();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <functional>
#include <chrono>
#include <cstring>
#include <limits.h>

using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<lint> vl;
typedef pair<lint,lint> pll;

lint mypow(lint a, lint n){
    lint res = 1;
    lint base = a;
    while(n > 0){
        if (n%2) res = res*base;
        base = base*base;
        n = n/2;
    }
    return res;
}

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

    lint n; cin>>n;

    vl a(n);
    vl cnt(1e5+1, 0);
    lint sum = 0;
    for (int i=0; i<n; ++i){
        cin>>a[i];
        sum += a[i];
        cnt[a[i]]++;
    }
    int q; cin>>q;
    while(q--){
        lint b, c; cin>>b>>c;

        lint cntb = cnt[b];
        cnt[b] = 0;
        cnt[c] += cntb;
        sum -= cntb*b;
        sum += cntb*c;
        cout<<sum<<"\n";
    }





}


Measured memory_bytes: 4776
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    int n, l; cin >> n >> l;
    vector<string> S(n);
    rep(i,n) {
        string s; cin >> s;
        S[i] = s;
    }
    sort(all(S));
    rep(i,n) cout << S[i];
    cout << endl;
}

Measured memory_bytes: 3648
Scanf.scanf "%d %d" (fun x y ->
    List.fold_left (fun acc (x, y, v) ->
        if x <= y then min acc (y - x + v) else acc) max_int
        [ (x, y, 0); (-x, y, 1); (x, -y, 1); (-x, -y, 2) ] |> Printf.printf "%d\n"
)

Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}


int main(void) {
	
	map<string, bool> m;
	int N;
	cin >> N;

	char c = 0;

	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;

		if (m[s] == false && (c == 0 || s[0] == c)) {
			m[s] = true;
			c = s[s.size() - 1];
		}
		else {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ls = [list(map(int, input().split())) for _ in range(M)]

maps = {i:0 for i in range(1, N+1)}

for load in ls:
    maps[load[0]] += 1
    maps[load[1]] += 1

for i in range(1, N+1):
    print(maps[i])

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
vector<pair<int,int>> V;

void solve() {
	int i,j,k,l,r,x,y; string s;
	V.push_back({0,0});
	cin>>N;
	FOR(i,N) {
		cin>>x;
		if(V.back().first!=x) V.push_back({x,0});
		V.back().second++;
	}
	
	int ret=0;
	FORR(v,V) ret+=v.second/2;
	cout<<ret<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#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 VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };

int N, M;
bool graph[51][51];
bool ok = false;
bool visited[51];
void dfs(int n) {
	if (visited[n])return;
	visited[n] = true;
	FOR(i, 1, N + 1) {
		if (graph[n][i])dfs(i);
	}
}
int main() {

	cin >> N >> M;
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		graph[a][b] = true;
		graph[b][a] = true;
	}
	int ans = 0;
	FOR(i, 1, N + 1) {
		FOR(j, 1, N + 1) {
			if (graph[i][j]) {
				FOR(k, 1, N + 1)visited[k] = false;
				graph[i][j] = false;
				graph[j][i] = false;
				dfs(1);
				ok = true;
				FOR(k, 1, N + 1)if (!visited[k])ok = false;
				if (!ok)ans++;
				graph[i][j] = true;
				graph[j][i] = true;
			}
		}
	}
	cout << ans/2 << endl;
}

Measured memory_bytes: 256
#ALDS1_1-C Prime Numbers
def prime(n):
    s=3
    while(s*s <= n):
        if(n%s==0):
            return False
        s+=2
    return True

n=int(input())
num=0
for i in range(n):
    x = int(input())
    if prime(x) and x%2!=0:
        num+=1
    if x==2:
        num+=1
print(num)

Measured memory_bytes: 7700
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  var P = parseInt(input[1].split(" ").join(""));
  var Q = parseInt(input[2].split(" ").join(""));
  (function() {
    var generatePermutation = function(perm, pre, post, n) {
      var elem, i, rest, len;
      if (n > 0)
        for (i = 0, len = post.length; i < len; ++i) {
          rest = post.slice(0);
          elem = rest.splice(i, 1);
          generatePermutation(perm, pre.concat(elem), rest, n - 1);
        }
      else
        perm.push(pre);
    };
  
    /*
    extend Array.prototype
    e.g. [0, 1, 2].permutation(2)
    => [[0, 1], [0, 2], [1, 0], [1, 2], [2, 0], [2, 1]]
    */
    Array.prototype.permutation = function(n) {
      if (n == null) n = this.length;
      var perm = [];
      generatePermutation(perm, [], this, n);
      return perm;
    };
  })();
  var x = new Array(N);
  for(var i =0;i<N;i++){
    x[i]=i+1;
  }
  var y = x.permutation();
  y=y.map(i => parseInt(i.join("")));
  y.sort(function(a,b){return a-b});
  var pp;
  var qq;
  for(var i =0;i<y.length;i++){
    if(y[i]==P){
      pp=i;
    }
    if(y[i]==Q){
      qq=i;
    }
    if(pp!=undefined&&qq!=undefined){
      var ans = Math.abs(pp-qq);
    }
  }

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 30864
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    ll n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=1000000;++i){
        if(n%i==0){
            ll ret=n/i-1;
            if(ret>i)ans+=ret;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
s=[[0 for _ in range(2)] for _ in range(n)]
for i in range(n):
    cnt=0
    now=i
    while True:
        now=(p[now]-1)
        s[i][0]+=c[now]
        cnt+=1
        if now==i:
            break
    s[i][1]=cnt
ans=-(10**16)
for j in range(n):
    if s[j][0]>0 and k//s[j][1]>0: #何回か回る
        cnt1,cnt2=k,k
        a=k//s[j][1] #最大周回数
        score1=(a*s[j][0])
        score2=((a-1)*s[j][0])
        cnt1-=a*s[j][1]
        now=j
        pscore1=0
        pscore_max1=0
        for x in range(cnt1):
            now=(p[now]-1)
            pscore1+=c[now]
            pscore_max1=max(pscore_max1,pscore1)
        score1+=pscore_max1
        now=j
        pscore2=0
        pscore_max2=0
        for y in range(s[j][1]):
            now=(p[now]-1)
            pscore2+=c[now]
            pscore_max2=max(pscore_max2,pscore2)
        score2+=pscore_max2
        score_max=max(score1,score2)
    else:
        now=j
        score=0
        score_max=c[p[now]-1]
        for x in range(min(k,s[j][1])):
            now=(p[now]-1)
            score+=c[now]
            score_max=max(score_max,score)
    ans=max(ans,score_max)
print(ans)


Measured memory_bytes: 69836
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
#define MP make_pair
#define PB push_back
#define ll long long
#define int long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define ld long double
#define mod 1000000007

int a[100005];
int an[100005];
map <int,int> mp;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	f(i,0,n)
		cin>>a[i];
	sort(a,a+n);
	if(n==3)
	{
		if((a[0]^a[1]^a[2])==0)
			cout<<"Yes\n";
		else
			cout<<"No\n";
		return 0;
	}
	f(i,0,n)
	{
		mp[a[i]]++;
	}
	an[0]=a[0];
	mp[a[0]]--;
	an[1]=a[n-1];
	mp[a[n-1]]--;
	f(i,2,n)
	{
		int va=an[i-1]^an[i-2];
		if(mp[va]>0)
		{
			mp[va]--;
			an[i]=va;
		}
		else
		{
			cout<<"No\n";
			return 0;
		}
	}
	if((an[0]^an[n-1]^an[n-2])==0&& (an[0]^an[n-1]^an[1])==0 )
	{
		cout<<"Yes\n";
	}
	else
		cout<<"No\n";
	return 0;
}

Measured memory_bytes: 5760
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define test(s) \
  if (!(s))     \
    cout << "Line " << __LINE__ << ": [" << #s << "] is false" << endl;
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

signed main() {
  int A, B;
  cin >> A >> B;
  int ans = max({A + B, A - B, A * B});
  cout << ans << endl;
}

Measured memory_bytes: 3604
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)


n, m = map(int, input().split())
P = [int(p) - 1 for p in input().split()]

GRAPH = [[] for _ in range(n)]
for _ in range(m):
    x, y = [int(xy) - 1 for xy in input().split()]
    GRAPH[x].append(y); GRAPH[y].append(x)

def dfs(now):
    searched[now] = True
    p = P[now]
    A[now] = B[p] = color
    for next in GRAPH[now]:
        if searched[next]:
            continue
        dfs(next)

A = [0] * n; B = [0] * n
searched = [False] * n
color = 1
for i in range(n):
    if searched[i]:
        continue
    dfs(i)
    color += 1

ans = sum(A[i] == B[i] for i in range(n))

print(ans)


Measured memory_bytes: 86020
import sys

N, W = map(int, input().split())
WEIGHTS = list(list(map(int, input().split())) for _ in range(N))
M = len(WEIGHTS)
MAX_VALUE = sum(value for (weight, value) in WEIGHTS)

INF = sys.maxsize
DP = [[INF for _ in range(MAX_VALUE + 1)] for _ in range(M + 1)]

for i, (weight, value) in enumerate(WEIGHTS):
    for v in range(MAX_VALUE + 1):
        if v - value >= 0:
            DP[i+1][v] = min(DP[i][v - value] + weight, DP[i][v])
        else:
            DP[i+1][v] = min(DP[i][v], weight)

res = 0
for v, w in enumerate(DP[M]):
    if w <= W:
        res = max(res, v)

print(res + 1)

# dp_ij := 1~jまでのアイテムからいくつかを選んで総価値iを超えないようにしたときの最少重量

Measured memory_bytes: 171248
#include <bits/stdc++.h>
#define DEBUG(x) cout << #x << " = " << x << endl
#define pb push_back
using namespace std;
typedef long long ll;


const int MAXN = 100005;
const ll MOD = 1000000007;
vector<int> v;
int main()
{
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    string s, huj;
    cin >> s;
    cin >> huj;
    s += '1';
    for (int i = 0; i < n;)
    {
        if (s[i] == s[i+1])
        {
            v.pb(1);
            i += 2;
        }
        else
        {
            v.pb(0);
            i += 1;
        }
    }

    ll ans = (v[0] == 0) ? 3 : 6;

    for (int i = 1; i < v.size(); i++)
    {
        if (v[i-1] == 0 && v[i] == 0)
            ans *= 2;
        if (v[i-1] == 0 && v[i] == 1)
            ans *= 2;
        if (v[i-1] == 1 && v[i] == 1)
            ans *= 3;
        ans %= MOD;
    }

    cout << ans;
    return 0;
}




Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

inline ll floor(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return a / llb;
	}
	else
	{
		return - ( (-a + llb - 1) / llb);
	}
}

inline ll ceil(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return (a + llb - 1) / llb;
	}
	else
	{
		return - (-a / llb);
	}
}

inline ll getLowestOneBit(ll a)
{
	return a & (-a);
}

inline ll getHighestOneBit(ll a)
{
	while ((a & (a - 1)) != 0)
	{
		a = a & (a - 1);
	}
	return a;
}

inline bool isPower2(ull a)
{
	if (a == 0)
	{
		return false;
	}
	return !(a & (a - 1));
}

inline ll getSpecifiedBit(ll a, unsigned bit)
{
	return (a & (1LL << bit)) >> bit;
}

// computational complexity: o(log(max(a, b))) 
inline ull getGcd(ull a, ull b)
{
	if (b == 0)
	{
		return a;
	}
	return getGcd(b, a % b);
}

template<class Integer>
inline Integer getPower(Integer base, ull exponential)
{
	Integer result = 1;
	while (exponential >= 1)
	{
		if (exponential & 1)
		{
			result = result * base;
		}
		base = base * base;
		exponential >>= 1;
	}

	return result;
}

ll dfs(ll currNode, const vector<set<ll>>& edges, vector<ll>& lengths, vector<bool>& haveChecked)
{
	if (lengths[currNode] != -1)
	{
		return lengths[currNode];
	}

	haveChecked[currNode] = true;
	ll length = 0;
	for (auto& node : edges[currNode])
	{
		if (haveChecked[node])
		{
			continue;
		}
		length = max(length, dfs(node, edges, lengths, haveChecked) + 1);
	}
	lengths[currNode] = length;

	return length;
}

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

	ll N;
	cin >> N;

	if (isPower2(N))
	{
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
	cout << 1 << " " << 2 << endl;
	cout << 2 << " " << 3 << endl;
	cout << 3 << " " << N + 1 << endl;
	cout << N + 1 << " " << N + 2 << endl;
	cout << N + 2 << " " << N + 3 << endl;

	for (ll i = 4; i + 1 <= N; i += 2)
	{
		cout << i << " " << i + 1 << endl;
		cout << i + 1 << " " << 1 << endl;
		cout << N + 1 << " " << i + N << endl;
		cout << i + N << " " << i + N + 1 << endl;
	}

	if (N % 2 == 0)
	{
		auto pow2 = getHighestOneBit(N);
		cout << N << " " << pow2 + N << endl;
		cout << (pow2 ^ N ^ 1) << " " << N * 2 << endl;
	}

	return 0;
}


Measured memory_bytes: 2560
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var N = long.Parse(Console.ReadLine());
        var cities = new long[5];
        var X = long.MaxValue;
        for (int i = 0; i < cities.Length; i++)
        {
            cities[i] = long.Parse(Console.ReadLine());
            X = Math.Min(cities[i], X);
        }

        // 切り上げ
        long t = (N + X - 1)/X + 4;
        Console.WriteLine(t);
    }

}



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

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

    int target = in;
    int d = 0;
    while(in / 10 != 0){
        d += in % 10;
        in = in / 10;
    }
    d += in % 10;

    if(target % d == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func round(f float64) float64 {
	return math.Floor(f + .5)
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()

	x := float64(n) / 1.08
	x2 := math.Ceil(x)
	x3 := math.Floor(x)

	n2 := int(x2 * 1.08)
	n3 := int(x3 * 1.08)
	if n == n2 {
		fmt.Println(x2)
	} else if n == n3 {
		fmt.Println(x3)
	} else {
		fmt.Println(":(")
	}
}


Measured memory_bytes: 640
import collections
N=int(input())
L=list(map(int,input().split()))
E=[i for i in L[::2]]
O=[i for i in L[1::2]]
e = collections.Counter(E).most_common()
o = collections.Counter(O).most_common()
if e[0][0] != o[0][0]:
    print(N - e[0][1] - o[0][1])
else:
    if len(e) == 1 or len(o) == 1:
        print(N // 2)
    else:
        a = N - e[1][1] - o[0][1]
        b = N - e[0][1] - o[1][1]
        print(min(a, b))

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

ll pre[100001],suff[100001],ans[100001];
int main()
{
    string s;
    cin>>s;

    ll n=s.length();
    pre[0]=1;
    for(ll i=1;i<s.length();i++){
        if(s[i]=='R')
        pre[i]+=(pre[i-1]+1);
    }
    suff[n-1]=1;
    for(ll i=n-2;i>=0;i--){
        if(s[i]=='L')
        suff[i]+=(suff[i+1]+1);
    }

    for(ll i=0;i<(n-1);i++){
        if((s[i]=='R')&&(s[i+1]=='L')){
            ll ss=(pre[i]+suff[i+1]);
                ans[i]=ss/2;
                ans[i+1]=ss/2;
            if(ss%2!=0){
                ans[i]+=1;
                if(pre[i]>suff[i+1]){
                    if(pre[i]%2==0)
                    swap(ans[i],ans[i+1]);
                }
                else
                {
                    if(suff[i+1]%2!=0)
                    swap(ans[i],ans[i+1]);
                }
                
            }
        }
    }

    for(ll i=0;i<n;i++)
    cout<<ans[i]<<" ";
}

Measured memory_bytes: 3072
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

typedef vector<int> vi;

const int N = 100010;

vi operator*(const vi& a, const vi& b)
{
	vi res(a.size());
	for (int i = 1; i < a.size(); ++i) res[i] = a[b[i]];
	return res;
}

vi inv(const vi& a)
{
	vi res(a.size());
	for (int i = 1; i < a.size(); ++i) res[a[i]] = i;
	return res;
}

/*vi qpow(const vi& a, int y)
{
	vi res(a.size());
	static vector<bool> vis(a.size(), false);
	for (int i = 1; i < a.size(); ++i)
	{
		if (vis[i]) continue;
		vi cycle(1, a[i]);
		for (int u = a[i]; u != i; u = a[u])
		{
			cycle.push_back(u);
			vis[u] = true;
		}
		for (int j = 0; j < cycle.size(); ++j) res[cycle[j]] = cycle[(j + y) % cycle.size()];
	}
	return res;
}*/

vi qpow(vi x, int y)
{
	vi out(x.size());
	for (int i = 1; i < x.size(); ++i) out[i] = i;
	while (y)
	{
		if (y & 1) out = out * x;
		x = x * x;
		y >>= 1;
	}
	return out;
}

int n, k;
vi f[10], g, ans;

int main()
{
	scanf("%d%d", &n, &k);
	
	f[1].resize(n + 1);
	f[2].resize(n + 1);
	
	for (int i = 1; i <= n; ++i) scanf("%d", &f[1][i]);
	for (int i = 1; i <= n; ++i) scanf("%d", &f[2][i]);
	for (int i = 3; i <= 5; ++i) f[i] = f[i - 1] * inv(f[i - 2]);
	f[0] = inv(f[2]) * f[1];
	g = f[1] * inv(f[0]) * inv(f[1]) * f[0];
	
	ans = qpow(g, k / 6) * f[k % 6] * qpow(inv(g), k / 6);
	
	for (int i = 1; i <= n; ++i) printf("%d%c", ans[i], " \n"[i == n]);
	
	return 0;
}

Measured memory_bytes: 5880
program abc163a
  implicit none
  integer n, i, a(200005)
  integer :: ct(200005) = 0
  read *, n
  read *, (a(i), i=2, n)
  do i=2, n
    ct(a(i)) = ct(a(i)) + 1
  end do
  do i=1, n
    print '(i0)', ct(i)
  end do
end program abc163a


Measured memory_bytes: 4600
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll i, temp,t, n,j, a, b, c, d, ans;
bool cond;
string s;
int main()
{
    //I am Monim, a tiny creature of Allah
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> a >> b >> c>> d;
    cout << max({a*c,a*d,b*c,b*d}) << endl;
    return 0;
}


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

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

  set<int> s;
  rep(i, 10) rep(j, 10) s.insert(i*j);

  cout << (s.count(n) ? "Yes" : "No") << endl;

}


Measured memory_bytes: 256