akhauriyash/Code-Regression huggingface dataset:
/* ex3_2
    riverstone*/

#include<stdio.h>
 
int main(void){
    //Nをint型で定義して入力する。
    int N;
    scanf("%d", &N);
 
    // Nを10で割った余りでswitchで場合分け
    switch (N % 10){
    case 2: case 4: case 5: case 7: case 9:
        printf("hon\n");
        break;
    
    case 0: case 1: case 6: case 8:
        printf("pon\n");
        break;
 
    case 3:
        printf("bon\n");
        break;
    }
    return 0;
}

Measured memory_bytes: 1596
#include <iostream>
#include <math.h>

using namespace std;

long my_round(long value, int near);

int main(){
  int n;
  long debt = 100000;
  cin >> n;

  for(int i=0; i<n; i++){
    debt = my_round(debt,1000);
  }
  cout << debt << endl;
}

long my_round(long value, int near){
  int a, b;
  long loan;
  
  loan = value*0.05;
  value += loan;
  a = value / near;
  b = value % near;
  if(b != 0){
    a++;
  }
  return a*near;
}

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

int n, m;
int main()
{
    cin >> n;
    if (n%2 == 0) {
        m = n/2;
    } else {
        m = n/2 + 1;
    }
    printf ("%.9f", 1.0*m/n);
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long int a,b,c;
    long long int n,i;
    scanf("%lld",&n);
    if(n<=1000){
    for(i=1;i<=n;i++){
        scanf("%lld %lld %lld",&a,&b,&c);
        if((a>=1&&a<=1000)&&(b>=1&&b<=1000)&&(c>=1&&c<=1000)){
        if((a*a)+(b*b)== (c*c) || (b*b)+(c*c)==(a*a) || (a*a)+(c*c)==(b*b)){
            printf("YES\n");
            }
        else{
            printf("NO\n");
    }
    }
    }
    }
    return 0;
}

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

using namespace std;
using ll = long long;


int main(){
    string s;
    cin >> s;
    map<string, string> t{};
    t["Sunny"] = "Cloudy";
    t["Cloudy"] = "Rainy";
    t["Rainy"] = "Sunny";

    cout << t[s] << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b;cin>>a>>b;
  if(a==b){
    cout << "Draw" << endl;
  }else{
    if(a==1)cout << "Alice" << endl;
    else if(b==1)cout << "Bob" << endl;
    else cout << (a<b?"Bob":"Alice") << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using ProCon.Util;

namespace ProCon
{
    class Program
    {
        static void Main(string[] args)
        {
            AC136B();
        }

        static void AC136B()
        {
            //https://atcoder.jp/contests/abc136/tasks

            var n = int.Parse(Console.ReadLine());
            int count;

            if(n < 10)
            {
                count = n;
            }
            else if(n < 100)
            {
                count = 9;
            }
            else if(n < 1000)
            {
                count = n - 100 + 1 + 9;
            }
            else if (n < 10000)
            {
                count = 900 + 9;
            }
            else if( n < 100000)
            {
                count = n - 10000 + 1 + 900 + 9;
            }
            else
            {
                count = 90000 + 900 + 9;
            }

            Console.WriteLine(count);
            Console.ReadKey();

        }

    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  string s;
  cin >>s;
  ll ss=s.size();
  ll ans=0;
  for(ll i=0;i<ss-1;i++) if(s[i]!=s[i+1]) ans++;
  cout <<ans<<endl;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007

int now,n,k;

int main(){
  int ans=0;//No
  cin >> n;
  vector<int> a(n);
  vector<pair<int, int> > pairs(n);

  REP(i,n) cin>>a[i];
  sort(a.begin(), a.end());
  
  if (a[n-1]==0){
    cout<<"Yes"<<endl;
    return 0;
  }

  ans=a[0]-1;
  int w=-1;
  int ansxor=0;
  REP(i,n){
      if (ans!=a[i]){
        w++;
        ansxor=ansxor^a[i];
        pairs[w].first=a[i];
        pairs[w].second=1;
        ans=a[i];
      }else{
        pairs[w].second++;
      }
  }
  w++;

  if (w>3){
    cout<<"No"<<endl;
    return 0;
  }
  if (n%3!=0){
    cout<<"No"<<endl;
    return 0;
  }

    if (w==2){
      if ((pairs[0].second==pairs[1].second*2)|(pairs[0].second*2==pairs[1].second)){
        cout<<"Yes"<<endl;
      }else{
        cout<<"No"<<endl;
      }
      return 0;
  }

  
  if (ansxor!=0){
    cout<<"No"<<endl;
    return 0;
  }

  if (w==3){
      if ((pairs[0].second==pairs[1].second)&(pairs[1].second==pairs[2].second)){
        cout<<"Yes"<<endl;
      }else{
        cout<<"No"<<endl;
      }
      return 0;
  }


if (w==1){
    cout<<"No"<<endl;
    return 0;
}


  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 1408
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        s: chars
    }

    println!("{}", if s[..n/2] == s[n/2..] { "Yes" } else { "No" });
}

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

int main() {
    int m1, d1, m2, d2; cin >> m1 >> d1 >> m2 >> d2;

    if (d2 == 1)
        puts("1");
    else
        puts("0");

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    long long N;
    cin >> N;
    cout << (N - 1) * N / 2 << endl;
    return 0;
}

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

int main() {
  int a, b; cin >> a >> b;
  if (a > b) cout << a-1 << endl;
  else       cout << a << endl;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	ll S, C;
	cin >> S >> C;

	ll kotae;
	if (S * 2 >= C) {
		kotae = C / 2;
	}
	else {
		kotae = S + (C - S * 2) / 4;
	}
	co(kotae);

	Would you please return 0;
}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    int N;
    std::cin >> N;

    if(N == 1) {
        std::cout << "Hello World" << std::endl;
    }
    else {
        int A, B;
        std::cin >> A >> B;
        std::cout << A + B << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int func(int x)
{
	if (x > 0)
		return x;
	return -x;
}

int div(int x1, int y1, int x2, int y2)
{
	return func(x1 - x2) + func(y1 - y2);
}

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

	bool ans = true;

	int t_mae = 0;
	int x0 = 0, y0 = 0;

	for (int i = 0; i < n; i++)
	{
		int t, x, y;

		cin >> t >> x >> y;

		int d = div(x, y, x0, y0);

		if (t < d)
		{
			ans = false;
			break;
		}
		int xx = t - d;

		if (xx % 2 == 1)
		{
			ans = false;
			break;
		}
	}

	if (ans == true)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
    int a, b;
    int n = 0;
    string ans = "No";
    cin >> a >> b;
    if(b < 10) n += (a*10 + b);
    else if(b < 100) n += (a*100 + b);
    else n += (a * 1000 + b);

    for(int i = 0; i <=n; i ++){
        if(i*i == n) ans = "Yes";
    }
    cout << ans;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    long long A[N];
    int flag = 0;
    rep(i, N) {
        cin >> A[i];
        if(A[i] == 0) {
            flag = 1;
        }
    }

    long long answer = A[0];
    if(flag == 1) {
        answer = 0;
    } else {
        for(int i = 1; i < N; i++) {
            if(1000000000000000000 / answer < A[i]) {
                answer = -1;
                break;
            } else {
                answer *= A[i];
            }
        }
    }
    cout << answer << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

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

    std::map<std::string, ll> s;
    {
        std::string tmp;
        for (ll i = 0; i < N; ++i) {
            cin >> tmp;
            std::sort(tmp.begin(), tmp.end());
            ++s[tmp];
        }
    }

    ll ans = 0;
    for (const auto &x : s) {
        ans += (x.second) * (x.second - 1) / 2;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define mod 1000000007
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define inp_vecN for(int i=0;i<n;i++)cin>>v[i]; 
vector<int> get_Factors(ll n)
{
      vector <int> v;
      for(ll i=2; i<=sqrt(n)+1; i++)
      {
            if(n%i==0)
            {
                  v.push_back(i);
                  v.push_back(n/i);
            }
      }

      v.push_back(1);

      return v;
}
string get_bin(ll n)
{
    string s = "";
    while(n > 0)
    {
        s += ('0' + n%2);
        n /= 2;
    }
    reverse(s.begin(), s.end());
    return s;
}

ll bin_to_dec(string s)
{
    ll ans = 0;
    for(auto ch: s)
    {
        ans *= 2;
        ans += (ch - '0');
    }
    return ans;
}
void PrintVector(vector<int> v,int n)
{

    for(int i=0;i<n;i++)
    {
        cout<<v[i]<<" ";
    }
    cout<<endl;
}
int no_of_primeFactors(int n)  
{ 
    int count=0;
    while (n % 2 == 0)  
    {  
        count++;
        n = n/2;  
    }  
   
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    { 
        while (n % i == 0)  
        {  
           count++;
            n = n/i;  
        }  
        
    }  
    if (n > 2)  
        count++;
    return count;
} 
 ll gcd(int a, int b)
{ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
} 
   
  ll lcm(int a, int b)  
{  
    return (a/gcd(a, b)*b);  
}  



ll pwr(ll base,ll expo,ll m)
{
    if(base==0) return 0LL;
    if(expo==0) return (1LL%m);
    if((expo&1)==0) {ll temp=pwr(base,expo>>1,m); return (temp*temp)%m;}
    return ((base%m)*pwr(base,expo-1,m))%m;
}

int main(int argc, char const *argv[])
{
    ios;
    
    string s;
    cin>>s;
    if(s=="ABC")
      cout<<"ARC";

      else
            cout<<"ABC";
    return 0;
}

Measured memory_bytes: 3588
num_lines = int(input())
if num_lines<1 or num_lines>2*10**5:
	print ('Illegal')
	exit()
a=[]
for i in range(num_lines):
	x,y=map(int,input().split(" "))
	if x<1 or y <=0 or y>10**9:
		print ('Illegal')
		exit()
	a.append([y,x,i])
a.sort()
r='Yes'
s=0
for i in range(num_lines):
	s+=a[i][1]
	if(s>a[i][0]):
		r='No'
		break;
print(r)


Measured memory_bytes: 42024
#include<stdio.h>

int	main(){
	int A, B, C, D, P,	X,	Y;
	scanf("%d%d%d%d%d",	&A,	&B,	&C,	&D,	&P);
	X	=	A	*	P;
	Y	=	B;
	if(P	>	C)Y	+=	D	*	(P	-	C);
	if(X	>=	Y)printf("%d\n",	Y);
	if(Y	>	X) printf("%d\n",	X);
	return	0;
}

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


int main()
{
    int a,b;
    cin>>a>>b;
    if(a<=9 && b<=9)
    {
        cout<<a*b<<endl;
    }
    else
    {
        cout<<"-1"<<endl;
    }
    return 0;
    
}

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

typedef long long int LLI;

int n;
bool is_composite[1000000];
LLI imos[1000000];
vector<LLI> primes;

int main() {
  for (int i=2; i<1000000; i++) {
    if (!is_composite[i]) {
      primes.push_back(i);
      for (int j=i+i; j<1000000; j+=i) is_composite[j] = true;
    }
  }

  for (int i=0; i<10000; i++) {
    imos[i+1] = imos[i] + primes[i];
  }

  while (1) {
    scanf("%d", &n);
    if (n == 0) return 0;

    printf("%lld\n", imos[n]);
  }
}

Measured memory_bytes: 4064
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<time.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


int n, t[101];
string s[101], x;

int main(){
	cin >> n;
	i64 ans = 0;
	for(int i = 0; i < n; i++){
		cin >> s[i] >> t[i];
		ans += t[i];
	}
	cin >> x;
	
	for(int i = 0; i < n; i++){
		ans -= t[i];
		if(x == s[i]){
			cout << ans << endl;
			return 0;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int n,w,so,e;
int main(){
 string s;
 cin >>s;
 for(int i=0;i<s.size();i++){
   if(s[i]=='N') n++;
   if(s[i]=='W') w++;
   if(s[i]=='S') so++;
   if(s[i]=='E') e++;
 }
if(n==0&&so!=0){
  cout <<"No"<<endl;
  return 0;
}
if(n!=0&&so==0){
  cout <<"No"<<endl;
  return 0;
}
if(w==0&&e!=0){
  cout <<"No"<<endl;
  return 0;
}
if(w!=0&&e==0){
  cout <<"No"<<endl;
  return 0;
}
cout <<"Yes"<<endl;
}


Measured memory_bytes: 256
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line
}

fn main() {
    let v: Vec<i32> = get_line().trim()
        .split_whitespace()
        .map(|e| e.parse().unwrap())
        .collect();
    let (a, b, c): (i32, i32, i32) = (v[0], v[1], v[2]);

    let mut count: u32 = 0;
    for i in a..b+1 {
        if c % i == 0 {
            count += 1;
        }
    }
    println!("{}", count);
}



Measured memory_bytes: 5024
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define fio ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;

int b,a[4]={},n;
vector<int> v;

int main() {	
	scanf("%d",&n);
	for(int i = 0; i < n; ++i) {
		scanf("%d",&b);
		++a[b%4];
	}
	a[1] += a[3];
	bool ls = 0;
	while(a[0] + a[1] + a[2]) {
		if(a[0] + a[1]) {
			if(a[0] && a[1]) {
				ls  = !ls;
				v.pb(ls);
				--a[ls];
			} else if(a[0])
				v.pb(0),--a[0];
			else
				v.pb(1),--a[1];
		} else {
			v.pb(2),--a[2];
		}
	}
	for(int i = 1; i < n; ++i) {
		if(v[i] * v[i-1] % 4 != 0) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
}

Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;
int main(){
	cout<<fixed<<setprecision(5);

	int a,b,d,r;
	double f;
	cin>>a>>b;
	d=a/b;
	r=a%b;
	f=(double)a/b;
	cout<<d<<" "<<r<<" "<<f<<endl;

	return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll mod = 998244353;
const ll maxn = 2000005;
int main(){  
	cin.tie(0);
    ios::sync_with_stdio(false);
	ll k,lun[100005]={0},a=10,j=1,one;
    scanf("%lld",&k);
    for(int i=1;i<=9;i++) lun[i]=i;
    while(a<=k){
        one=lun[j]%10;
        if(one!=0) lun[a++]=(lun[j]*10)+one-1;
        lun[a++]=(lun[j]*10)+one;
        if(one!=9) lun[a++]=(lun[j]*10)+one+1;
        j++;
    }
    printf("%lld",lun[k]);
    return 0;
}





Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int dp[105][4][2];

int main(){
  string s;
  cin >> s;
  int K;
  cin >> K;
  dp[0][0][0]=1;
  rep(i,s.size())rep(j,4)rep(k,2){
    int nd = s[i]-'0';
    rep(d,10){
      int ni,nj,nk;

      ni = i+1;

      if(d!=0)nj=j+1;
      else nj = j;
      if(nj>3)continue;

      if(k==1)nk=1;
      else if(nd<d)continue;
      else if(d==nd)nk = 0;
      else nk = 1;
      dp[ni][nj][nk] += dp[i][j][k];
    }
  }
  cout << dp[s.size()][K][0] + dp[s.size()][K][1] << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
A=list(map(int,input().split()))
R=[]
now=0
for i in range(n):
    now=(now+A[i])%m
    R.append(now)
R.sort()

cnt=1
now=0
Ans=[]
for i in range(n):
    if now==R[i]:
        cnt+=1
    else:
        if cnt>1:
            Ans.append(cnt)
        cnt=1
        now=R[i]
if cnt>1:
    Ans.append(cnt)
ans=0
for a in Ans:
    ans+=a*(a-1)//2
print(ans)

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

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

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

map<ll, ll> prime_factor(ll n) {
    ll a = 2;
    map<ll, ll> ans;
    while (n >= a * a) {
        if (n % a == 0) {
            ++ans[a];
            n /= a;
        } else {
            a++;
        }
    }
    if (n > 1) ++ans[n];
    return ans;
}

signed main() {
    ll N, P;
    cin >> N >> P;
    auto mp = prime_factor(P);
    ll ans = 1;
    for(auto& e : mp) {
        ll s = e.second/N;
        if(s >= 1) {
            ans *= pow(e.first, s);
        }
    }
    cout << ans << nl;
}


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

bool f(int a,int b)
{
  bool ret = (a==1 && b==2);
  return (ret);
}

bool g(int a,int b)
{
  bool ret =(a ==2 && b==3);
  return (ret);
}

bool h(int a, int b)
{
  bool ret = (a == 1 && b==3);
  return (ret);
}

int main()
{
  int a,b;cin>>a>>b;
  int x;
  if (f(a,b) || f(b,a))
    cout<<3<<endl;
  else if (g(a,b) || g(b,a))
    cout<<1<<endl;
  else if (h(a,b) || h(b,a))
    cout<<2<<endl;
  
}

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

using ll = long long;
 #define int long long
using P = pair<int, int>;
using PP = pair<P,int>;
#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
    int a, b, m;
    cin >> a >> b >> m;
    int fri[a];
    int ele[b];
    int fri_min = 1000000;
    int ele_min = 1000000;
    vector<PP> discounts(m);
    REP(i,a) {
        cin >> fri[i];
        fri_min = min(fri[i], fri_min);
    }
    REP(i,b) {
        cin >> ele[i];
        ele_min = min(ele[i], ele_min);
    }
    int min_price = fri_min + ele_min;
    REP(i,m) {
        int a_i, b_i;
        int dis;
        cin >> a_i >> b_i >> dis;
        --a_i;
        --b_i;
        discounts[i] = PP(P(a_i,b_i),dis);
    }
//    int ans = 2000000;
    REP(i,m) {
        int a_i = discounts[i].first.first;
        int b_i = discounts[i].first.second;
        int dis = discounts[i].second;
        min_price = min(min_price, fri[a_i] + ele[b_i] - dis);
    }
    cout << min_price;


    cout << "\n";
    return 0;
}
/***** MAIN *****/


Measured memory_bytes: 4096
def fd(n)
  cnt = ((n+1) / 2)
  if n % 2 == 0
    return cnt % 2 == 0 ? n : (1 ^ n)
  else
    return cnt % 2 == 0 ? 0 : 1
  end
end
a, b = gets.split.map(&:to_i)
puts fd(a-1) ^ fd(b)

Measured memory_bytes: 3836
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
const ll MOD = 998244353;

#define fr first
#define sc second

int main(){
	int m,d;
	cin >> m >> d;
	int cnt = 0;
	for(int i = 1 ; i <= m ; i ++){
		for(int j = 22 ; j <= d ; j ++){
			int x = j%10;
			int y = j/10;
			if(x >= 2 && y >= 2 && i == x*y)cnt ++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 768
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Created: Jul, 12, 2020 21:40:45 by Nobody
# $Author$
# $Date$
# $URL$
__giturl__ = "$URL$"


from collections import defaultdict
from collections import deque
from collections import OrderedDict
import itertools
from sys import stdin
input = stdin.readline


def main():
  H, W = list(map(int, input().split()))
  G = ['#'+input()[:-1]+'#' for _ in range(H)]
  G = ['#'*(W+2)] + G + ['#'*(W+2)]

  # print(G)
  U = [[0]*(W+2) for _ in range(H+2)]
  D = [[0]*(W+2) for _ in range(H+2)]
  L = [[0]*(W+2) for _ in range(H+2)]
  R = [[0]*(W+2) for _ in range(H+2)]
  # U and L
  for h in range(1, H+1):
    for w in range(1, W+1):
      if G[h][w] == '#':
        continue
      U[h][w] = U[h-1][w] + 1
      L[h][w] = L[h][w-1] + 1

  for h in range(H, 0, -1):
    for w in range(W, 0, -1):
      if G[h][w] == '#':
        continue
      D[h][w] = D[h+1][w] + 1
      R[h][w] = R[h][w+1] + 1

  max_ = 0
  for h in range(1, H+1):
    for w in range(1, W+1):
      max_ = max(max_, U[h][w]+L[h][w]+D[h][w]+R[h][w])

  print(max_ - 3)


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 196776
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T x=0,f=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=1e7+9,mod=998244353;
	inline int add(int x,int y){return x+y>=mod?x-mod+y:x+y;}
	inline int sub(int x,int y){return x>=y?x-y:x+mod-y;}
	int fac[N],ifac[N],t,x,y;
	inline int C(int _n,int _m){
		if(_n<0 || _m<0 || _n<_m) return 0;
		return 1LL*fac[_n]*ifac[_m]%mod*ifac[_n-_m]%mod;
	}inline int Cho(int a,int b){
		return sub(C(a+b-1,a-1),C(a+b-1,b-1));
	}

	int main(){
		t=read<int>(),x=read<int>(),y=read<int>();
		if(!x && !y) puts("1"),exit(0);

		fac[0]=ifac[0]=ifac[1]=1;
		for(int i=1;i<=t;i++) fac[i]=1LL*fac[i-1]*i%mod;
		for(int i=2;i<=t;i++) ifac[i]=1LL*(mod-mod/i)*ifac[mod%i]%mod;
		for(int i=2;i<=t;i++) ifac[i]=1LL*ifac[i-1]*ifac[i]%mod;
		assert(1LL*fac[t]*ifac[t]%mod==1);

		int ans=0;
		if(y+x==t) ans=Cho(y,x);
		for(int i=0;i<=min(t-y-1,x);i++){
			int ret=Cho(y,i);
			ret=1LL*ret*C(t-y-i-1 +x-i+1 -1,x-i+1 -1)%mod;
			ans=add(ret,ans);
		}
		printf("%d\n",ans);
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 78336
use std::io::Read;
use itertools::Itertools;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    return iterator.next().unwrap()
        .chars()
        .map(|c| if c == '1' { '9' } else { '1' })
        .join("");
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vii=vector<vi>;
const int MAX = 510000;
const int MOD = 1000000007;
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
int main() {
    ll N;    
  cin >> N;
  if(N==1){
        cout<<0<<endl;
        return 0;
    }
  vector<ll> a;
  vector<ll> b;
  for(auto p : prime_factor(N)) {
    while(p.second--)a.push_back(p.first);
  }
  ll k=1;
  rep(i,a.size()-1){
      if(a[i]==a[i+1])k++;
      else{
          b.push_back(k);
          k=1;
      }
  }
  b.push_back(k);
  ll ans=0;
    rep(i,b.size()){
        int j=1;
        ll l=-1;
        while(b[i]>=0){
            l++;
            b[i]-=j;j++;
        }
        ans+=l;
    }
  cout <<ans<< endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <random>

using ll = long long;

//各種nil
template <class T>
constexpr T nil = static_cast<T>(-1);

constexpr int nil_i = nil<int>;
constexpr int nil_ll = nil<ll>;
constexpr double nil_d = nil<double>;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
struct Vec2D
{
    T x, y;
};

void solve()
{
    using namespace std;
    string s;
    cin >> s;
    
    set<char> se;
    for (auto c : s) se.emplace(c);

    if (s.size() == se.size())
        cout << "yes" << endl;
    else
        cout << "no" << endl;
    
}

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
#define f first
#define s second
int main()
{
	int x,y;
	cin>>x>>y;
	if(y%2==1)
	{cout<<"No";return 0;}
	y=y/2;
	if(y-x>=0&&2*x-y>=0)
	{cout<<"Yes";}
	else
	cout<<"No";
   return 0;	
}

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

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    int max1 = max(max(A,B),max(B,C));
    int min1 = min(min(A,B),min(B,C));
    int mid = A + B + C - max1 - min1;
    int num = max1 - mid + ((mid - min1 + 1) / 2) + (mid - min1) % 2;
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256
from operator import itemgetter
n = int(input())

list_res = []
for i in range(n):
    a, b = map(str, input().split())
    list_res.append([a,int(b) * -1, i + 1])

list_res = sorted(list_res, key = itemgetter(0, 1))


for i in list_res:
    print(i[2])

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

int main ()
{
    int n,k,ans=0;
    cin>>n>>k;
    int a[n+10];
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<k;i++)
        ans+=a[i];
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3640
n, m = map(int, input().split())

swich = [0] * n

for i in range(m):
    _, *s = map(int, input().split())
    for j in range(len(s)):
        # swich[s[j] - 1] += 1 << (i)
        swich[s[j] - 1] ^= 1 << (i)
        # swich[s[j] - 1] |= 1 << (i)
    


p_list = list(map(int, input().split()))
p = 0
for i in range(m):
    if p_list[i] == 1: 
        p += 1 << i
    # p |= p_list[i] << i #上の処理と同じ

# print("++++++++++++++++++++++++")
# print(swich)
ans = 0
for i in range(1 << n):
    state_on_off = 0
    for index in range(n):
        if i >> index & 1 == 1:
            state_on_off ^= swich[index]
    if state_on_off == p:
        ans += 1
    # print(p, state_on_off,bin(i))
print(ans)

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

typedef long lint;
typedef long long llint;

static const llint MAX = 1e5+100;
// static const int NIL = -1;
// static const ll INF = 1<<21;
static const llint MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

vector<pair<llint, llint> > factorizebyPrimenum(llint n) {
    vector<pair<llint, llint> > res;
    llint num;

    for(llint p=2;p*p<=n;p++) {
        if (n%p!=0) continue;
        num = 0;
        while (n%p==0) { ++num; n /= p; }
        res.push_back(make_pair(p,num));
    }
    if (n!=1) res.push_back(make_pair(n,1));
    return res;
}

llint fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

llint COM(llint n, llint k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void) {
    llint n, m;
    cin >> n >> m;

    COMinit();

    auto pvec = factorizebyPrimenum(m);

    llint ans = 1, k;
    for(auto p:pvec) {
        k = p.second;
        ans *= COM(n+k-1, k);
        ans %= MOD;
    }
    cout << ans << endl;
    
    return 0;
}


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

int main()
{
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;

    bool ret = ((std::abs(a-b) <= d && std::abs(b-c) <= d) || std::abs(a-c) <= d);
    std::cout << ((ret) ? "Yes" : "No") << std::endl;

    return 0;
}

Measured memory_bytes: 256
n, x = map(int, input().split())
a = list(map(int, input().split()))

ans = 0

for i in range(n - 1):
    if a[i] + a[i + 1] > x:
        diff = a[i] + a[i + 1] - x
        a[i + 1] = max(a[i + 1] - diff, 0)
        ans += diff

print(ans)


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

using namespace std;

typedef int64_t i64;
typedef uint64_t ui64;

const int64_t N = 510, MOD = 998244353;

int32_t main()
{
#ifdef AT_MH_PC
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(nullptr);

    int n;
    cin >> n;
    unordered_map<string, int> ump;
    ui64 ans = 0;
    for(int i = 0; i < n; ++i)
    {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        if(ump.find(s) != ump.end())
            ans += ump[s], ++ump[s];
        else
            ump[s] = 1;
    }
    cout << ans;

    return 0;
}


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

int main() {
	long long h, w; cin >> h >> w;
	long long s1, s2, s3;
	long long res = 1LL<<60;

	for (int i = 1; i < h; i++)
	{
		long long H = (h-i) / 2, W = w / 2;
		s1 = w * i;
		s2 = w * H;
		s3 = w * h - s1 - s2;
		res = min(res, max({s1, s2, s3}) - min({s1, s2, s3}));
		s2 = (h-i) * W;
		s3 = w * h - s1 - s2;
		res = min(res, max({s1, s2, s3}) - min({s1, s2, s3}));
	}
	swap(h, w);
	for (int i = 1; i < h; i++)
	{
		long long H = (h-i) / 2, W = w / 2;
		s1 = w * i;
		s2 = w * H;
		s3 = w * h - s1 - s2;
		res = min(res, max({s1, s2, s3}) - min({s1, s2, s3}));
		s2 = (h-i) * W;
		s3 = w * h - s1 - s2;
		res = min(res, max({s1, s2, s3}) - min({s1, s2, s3}));
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

template<typename type> vector<type> divisor(type n)
{
    vector<type> res;
    for(type i = 1; i * i <= n; i++)
    {
        if(n % i == 0)
        {
            res.push_back(i);
            if(i * i != n) res.push_back(n / i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}


void solve()
{
    int n; cin >> n;
    vector<int> A(n);
    for(int i = 0; i < n; i++) cin >> A[i];
    sort(A.begin(), A.end());
    set<int> st[n];
    for(int i = 0; i < n; i++)
    {
        vector<int> divisors = divisor(A[i]);
        for(const auto &x : divisors) st[i].insert(x);
    }
    set<int> B;
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        bool is_ok = true;
        for(const auto &x : st[i])
        {
            if(B.count(x)) is_ok = false;
        }
        if(is_ok)
        {
            if(i + 1 < n && A[i + 1] != A[i])
            {
                ans++;
            }
            else if(i == n - 1)
            {
                ans++;
            }
        }
        B.insert(A[i]);
    }
    cout << ans << "\n";
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 472860
def inpl(): return [int(i) for i in input().split()]


N, K = inpl()
ab = [inpl() for _ in range(N)]
ab = sorted(ab,key=lambda x: x[0])
for i in range(N):
    K -= ab[i][1]
    if K <= 0:
        break
print(ab[i][0])

Measured memory_bytes: 23640
# coding:utf-8

def main():
    N = int(input())
    S = input()
    K = int(input())
    change = S[K-1]
    # print(change)
    str_list = list(S)
    ans = []
    for i in str_list:
        if i != change:
            ans.append("*")
        else:
            ans.append(i)
    str_changed = "".join(ans)
    print(str_changed)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    T = input()
    result = []
    bef = ""
    for i in range(len(T)-1):
        if T[i] == "?":
            if bef == "P":
                result.append("D")
            elif T[i+1] == "?" or T[i+1] == "D":
                result.append("P")
            else:
                result.append("D")
        else:
            result.append(T[i])
        bef = result[-1]
    if T[-1] == "?":
        result.append("D")
    else:
        result.append(T[-1])
    print("".join(result))

if __name__ == '__main__':
    main()


Measured memory_bytes: 12420
#include <iostream>
#include <cstring>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  cout << 6 - a - b;
  return 0;
}


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

int main(){
	
	int n,T;
	cin>>n>>T;
	int ans=1000000000;
	for (int i=0;i<n;i++){
		int c,t;
		cin>>c>>t;
		if (t<=T){
			if (c<=ans){
				ans=c;
			}
		}
	}
	
	if (ans==1000000000) cout<<"TLE"<<endl;
	else cout<<ans<<endl;
}
 

Measured memory_bytes: 256
N, M = map(int, input().split())
l = []
for i in range(M):
  l.append(list(map(int, input().split())))
ans = [0]*N

for i in range(M):
  for j in range(2):
    ans[l[i][j]-1] += 1

for i in range(N):
  print(ans[i])

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

void print(Pil A){
    cout << A.first.first << " " << A.first.second << " " << A.second << '\n';
}

long long dist(const Pil &A, int x, int y) {
    long long res = (long long)abs(A.first.first-x)+abs(A.first.second-y);
    return res;
}

int main() {
    int N;
    scanf("%d", &N);
    vector<Pil> A;
    Pil base;
    
    for (int i = 0; i < N; i++) {
        int x, y; long long h; cin >> x >> y >> h;
        A.emplace_back(make_pair(x, y), h);
        if (h != 0) base = A[i];
        if (N == 1) { print(A[0]); return 0; }
    }

    Pil ans = make_pair(make_pair(-1, -1), -1LL);
    for (int x = 0; x <= 100; x++) for (int y = 0; y <= 100; y++) {
        bool ok = true;
        long long H = base.second + dist(base, x, y);
        for (int i = 0; i < N; i++) {
            long long high = max(H-dist(A[i], x, y), 0LL);
            if (high != A[i].second) ok = false;
        }
        if (ok && ans.second < H) ans = make_pair(make_pair(x, y), H);
    }
    
    print(ans);
    return 0;
}

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

int main() {
  long long N; cin >> N;
  int D[N][2];
  for (int i = 0; i < N; i++) cin >> D[i][0] >> D[i][1];
  bool flag = false;
  for (int i = 0; i < N - 2; i++){
    if (D[i][0] == D[i][1]){
      if (D[i + 1][0] == D[i + 1][1]){
        if (D[i + 2][0] == D[i + 2][1]){
          flag = true;
        }
      }
    }
  }
  if (flag == false) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3616
import sys
from itertools import accumulate, product
from operator import itemgetter
read = sys.stdin.read

N, W, *wv = map(int, read().split())
w1 = wv[0]
V = [[0] for _ in range(4)]

for w, v in sorted(zip(*[iter(wv)] * 2), key=itemgetter(1), reverse=True):
    V[w - w1].append(v)


V = list(map(list, map(accumulate, V)))
n = [len(V[i]) for i in range(4)]
answer = 0
for a, b, c, d in product(range(n[0]), range(n[1]), range(n[2]), range(n[3])):
    if b + c * 2 + d * 3 + (a + b + c + d) * w1 > W:
        continue

    v = V[0][a] + V[1][b] + V[2][c] + V[3][d]
    if v > answer:
        answer = v

print(answer)

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

int main() {
    int n; cin >> n;
    int count = 0;
    int max_h = 0;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        if (max_h <= x) {
            max_h = x;
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    int ans = 0;
    rep(i,3){
        if(N%2 == 1) ++ans;
        N/=10;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,nn,s=0;
	cin>>n;   
	nn=n;
	while(nn!=0){
		s+=nn%10;
		nn=nn/10;
	}
	if(n%s==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

ll mn,n;
const int coin[4]={10,50,100,500};
int ans[4],v[4],use[4];

void rec(int div,int sum){
	if(div==4){
		if(sum>=n){
			int ret=0;
			int usum=0;
			sum-=n;
			rrep(i,4){
				int u=sum/coin[i];
				sum-=u*coin[i];
				ret+=u;
				usum+=use[i];
			}
			ret-=usum;
			if(chmin(mn,(ll)ret)){
				rep(i,4)ans[i]=use[i];
			}
		}
	}
	else{
		rep(i,v[div]+1) {
			use[div]=i;
			rec(div+1,sum+coin[div]*i);
		}
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	bool fl=false;
	while(cin>>n,n){
		if(fl)cout<<"\n";
		fl=true;
		rep(i,4)cin>>v[i];
		mn=LINF;
		rec(0,0);
		rep(i,4){
			if(ans[i]==0)continue;
			cout<<coin[i]<<" "<<ans[i]<<endl;
		}
	}
}


Measured memory_bytes: 3172
import java.util.*;
class Main{
    public static void main(String[]args) {
        Scanner sc = new Scanner(System.in);

        int x = sc.nextInt();
        int y = sc.nextInt();
        System.out.println(gcd(x, y));
    }

    public static int gcd(int x, int y){
        if(x%y==0)
            return y;
        else
            return gcd(y,x%y);


    }
}


Measured memory_bytes: 26432
#include <stdio.h>
#include <algorithm>

const int N_MAX = 100;
const int A_MAX = 1000000000;

int main(){
  int N,x;
  int a[N_MAX],b[N_MAX];
  int answer=0;
  scanf("%d %d",&N,&x);
  for(int i=0;i<N;i++){
    scanf("%d",&a[i]);
    b[i] = a[i];
  }
  std::sort(b,b+N);

  int i;
  for(i=0;i<N;i++){
    if(x<=0 || x<b[i]){break;}
    x -= b[i];
    answer += 1;
  }
  if(x>0 && i==N){answer-=1;}

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

}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
	double d, w, h;
	while(cin >> d >> w >> h, d || w || h){
		d = (d/2)*(d/2);
		w = (w/2)*(w/2);
		h = (h/2)*(h/2);
		
		int n;
		cin >> n;
		
		int r;
		for(int i = 0; i < n; i++){//input
			cin >> r;
			if(d+w < r*r || d+h < r*r || w+h < r*r ){
				cout << "OK" << endl;
			}else{
				cout << "NA" << endl;
			}
		}
	}
	return 0;
}


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

using i64 = long long int;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i=0;i<n;++i){
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
/*
struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
*/
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

vector<vector<int>> d(10, vector<int>(10, INT_INF));

void warshallFloyd(int n)
{
    for (int k = 0; k < n; k++) // 経由する頂点
    {
        for (int i = 0; i < n; i++) // 始点
        {
            for (int j = 0; j < n; j++) // 終点
            {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]); // 距離
            }
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            int c;
            cin >> c;
            d[i][j] = c;
        }
    }

    vector<int> cnt(10);
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            int A;
            cin >> A;
            if (A == -1)
                continue;
            else
            {
                cnt[A]++;
            }
        }
    }

    for (int i = 0; i < 10; i++)
        d[i][i] = 0;
    warshallFloyd(10);

    int ans = 0;

    for (int i = 0; i < 10; i++)
    {
        ans += d[i][1] * cnt[i];
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define CHMIN(a, b) (a) = min((a), (b))
#define CHMAX(a, b) (a) = max((a), (b))

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()



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

    ll MOD = 1000000007;

    vector<int> dp(N+1,0); //0段目からN段目
    dp[0]=1;

    vector<int> a(N+2,1);
    for(int i=0;i<M;i++){
        int tmp;
        cin >> tmp;
        a[tmp] = -1;
    }

    a[N+1]=-1;

    for(int i=0;i<N;i++){
        if(a[i+1]!=-1)dp[i+1]+=dp[i]%MOD;
        if(a[i+2]!=-1)dp[i+2]+=dp[i]%MOD;
    }

    cout << dp[N]%MOD << endl;


}



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

int a[110];

int main()
{
	int n,m;cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	cin>>m;
	while (m--)
	{
		long long ans=0;
		int ai,bi;cin>>ai>>bi;
		for(int i=1;i<=n;i++)
		{
			if(i!=ai) ans+=a[i];
			else ans+=bi;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 256