akhauriyash/Code-Regression huggingface dataset:
/*
 ▓█████▄  ▄████▄  ▓██   ██▓ ██▓███   ██░ ██ ▓█████  ██▀███
▒██▀ ██▌▒██▀ ▀█   ▒██  ██▒▓██░  ██▒▓██░ ██▒▓█   ▀ ▓██ ▒ ██▒
 ░██   █▌▒▓█    ▄   ▒██ ██░▓██░ ██▓▒▒██▀▀██░▒███   ▓██ ░▄█ ▒
 ░▓█▄   ▌▒▓▓▄ ▄██▒  ░ ▐██▓░▒██▄█▓▒ ▒░▓█ ░██ ▒▓█  ▄ ▒██▀▀█▄
 ░▒████▓ ▒ ▓███▀ ░  ░ ██▒▓░▒██▒ ░  ░░▓█▒░██▓░▒████▒░██▓ ▒██▒
  ▒▒▓  ▒ ░ ░▒ ▒  ░   ██▒▒▒ ▒▓▒░ ░  ░ ▒ ░░▒░▒░░ ▒░ ░░ ▒▓ ░▒▓░
  ░ ▒  ▒   ░  ▒    ▓██ ░▒░ ░▒ ░      ▒ ░▒░ ░ ░ ░  ░  ░▒ ░ ▒░
  ░ ░  ░ ░         ▒ ▒ ░░  ░░        ░  ░░ ░   ░     ░░   ░
    ░    ░ ░       ░ ░               ░  ░  ░   ░  ░   ░
  ░      ░         ░ ░
*/
//focus less on how much problem you should solve within a fixed time and focus more on getting the problem solved and
//learning something from it
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define per(i,a,b) for(ll i=a; i>=b; i--)
#define ll long long int
#define ld long double
#define vi vector<ll>
#define pi pair<ll,ll>
#define vii vector <pair<ll,ll> >
#define sedes set <ll, greater <ll> >
#define seasc set <ll>
#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define MOD 1000000007
#define prec(n) fixed<<setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define umap unordered_map<ll, ll>
#define map map<ll, ll>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define mems(a, i) memset(a, i, sizeof(a))
#define endl '\n'
#define all(v) v.begin(),v.end()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define deba(a) cout << #a << " " <<a << endl;
const int INF = 1000000000;
int N, Ma, Mb;
vector<int> a, b, c;

int dp(int curr, int wa, int wb, vector<vector<vector<int>>>& memo) {
	if (wa > 0 && wb > 0 && wb * Ma == wa * Mb) {
		return 0;
	}
	if (curr == N) {
		return INF;
	}

	if (memo[curr][wa][wb] >= 0) {
		return memo[curr][wa][wb];
	}

	int skip = dp(curr + 1, wa, wb, memo);
	int take = dp(curr + 1, wa + a[curr], wb + b[curr], memo) + c[curr];
	int ret = min(skip, take);
	memo[curr][wa][wb] = ret;
	return ret;
}
int main()
{
	fast;
#ifndef ONLINE_JUDGE
	freopen("D:\\input.txt", "r", stdin);
	freopen("D:\\output.txt", "w", stdout);
#endif
	int t = 1;
	// cin >> t;
	while (t--)
	{
		cin >> N >> Ma >> Mb;
		a = vector<int>(N, 0);
		b = vector<int>(N, 0);
		c = vector<int>(N, 0);
		for (int i = 0; i < N; ++i) {
			cin >> a[i] >> b[i] >> c[i];
		}

		vector<vector<vector<int>>> memo(N, vector<vector<int>>(410, vector<int>(410, -1)));
		int ans = dp(0, 0, 0, memo);
		if (ans == INF) {
			cout << -1 << endl;
		}
		else {
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 30648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll x;
  cin>>x;
  ll ans=x/11*2;
  x=x%11;
  if(x){
    ans++;
    if(x>=7) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var x = Console.ReadLine().ToLong();
		
		var k = x / 500;
		x -= k * 500;
		
		var l = x / 5;
		
		
		Console.WriteLine(k * 1000 + l * 5);
	}
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 13140
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
int a[100005];
int main(void)
{
    int n;
    while(cin>>n)
    {
        int mac=0,x;
        memset(a,0,sizeof(a));
        for(int i=1;i<=n;i++)
        {
            cin>>x;
            a[x]++;
            a[x-1]++;
            a[x+1]++;
            mac=max(mac,max(a[x],max(a[x-1],a[x+1])));
        }
        cout<<mac<<endl;
    }
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cstring>
using namespace std;
const int MAXN = 100000 + 10;
int par[MAXN];
int Find(int x){
	if (x == par[x])
		return par[x];
	return Find(par[x]);
}
int main(){
	int n, q;
	char ins[10];
	int v;

	while (~scanf("%d%d", &n, &q) && n && q){
		long long sum = 0;
		par[1] = 1;
		for (int i = 2; i <= n; i++){
			scanf("%d", &par[i]);
		}
		for (int i = 0; i < q; i++){
			scanf("%s%d", ins, &v);
			if (strcmp(ins, "M") == 0){
				par[v] = v;
			}
			else{
				sum += Find(v);
			}
		}
		printf("%lld\n", sum);
	}
	return 0;
}

Measured memory_bytes: 1580
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

std::vector<std::vector<int>> generate(int rank) {
  if (rank == 1) {
    return { 
      { 0, 0 }, 
      { 0, 1 }
    };
  }
  int size = 1 << rank;
  int half = 1 << (rank - 1);
  std::vector<std::vector<int>> res(size, std::vector<int>(size));
  auto lower = generate(rank - 1);
  for (int i = 1; i < half; ++i) {
    for (int j = 1; j < half; ++j) {
      res[i][j] = lower[i][j];
      res[i + half - 1][j] = lower[i][j];
      res[i][size - j - 1] = lower[i][j];
      res[i + half - 1][size - j - 1] = lower[i][j] ^ 1;
    }    
  }
  for (int k = 0; k < half; ++k) {
    res[size - 1][size - k - 1] = 1;
    res[size - k - 1][size - 1] = 1;
  }
  return res;
}

int main() {
  int N, M;
  std::cin >> N >> M;
  auto base = generate(std::max(N, M));
  if (N > M) {
    for (int i = 0; i < (1 << N); ++i) {
      for (int j = 0; j < i; ++j) {
        std::swap(base[i][j], base[j][i]);
      }
    }
  }
  for (int i = 1; i < (1 << N); ++i) {
    for (int j = 1; j < (1 << M); ++j) {
      std::cout << (base[i - 1][j - 1] ^ base[i - 1][j] ^ base[i][j - 1] ^ base[i][j]);
    }
    std::cout << '\n';
  }
  return 0;
}


Measured memory_bytes: 5760
# -*- coding: utf-8 -*-
X,Y,A,B,C = map(int, input().split())
P = sorted(map(int, input().split()), reverse=True)[:X]
Q = sorted(map(int, input().split()), reverse=True)[:Y]
R = sorted(P+Q+list(map(int, input().split())), reverse=True)[:X+Y]
print(sum(R))

Measured memory_bytes: 23956
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){


    while(1){
        int Sum = 0;
        char Num[1001];
        scanf("%s",&Num);
        if(Num[0] == '0'){
            break;
        }

        for(int i=0;i<1001;i++){
            if(48 <= Num[i] && Num[i] <= 57){
                Sum += Num[i] - 48;
            }else{
                break;
            }
        }

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

    }

    return 0;
}



Measured memory_bytes: 2688
#include <stdio.h>
#include <stdlib.h>

int main()
{
  int n,i,j,ans=0;
  int *a;

  scanf("%d",&n );

  a = calloc(n,sizeof(int));

  for(i=0; i<n; i++)
    scanf("%d", &a[i]);

  for(i=0; i<n-1; i++){
    for(j=i+1; j<n; j++){
      ans += a[i]*a[j];
    }
  }
  printf("%d", ans);
  free(a);
  return 0;
}


Measured memory_bytes: 1708
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

bool is_satisfied(int a, int n, int m, vector<int> C, vector<int> S){
    string s = to_string(a);
    if(s.size() != n) return false;
    for(int i=0; i<m; i++){
        for(int j=0; j<n; j++){
            if (S[i] == j && (s[j] - '0') != C[i])
                return false;
        }
    }
    return true;
}

void solve(){
    int n, m;
    vector<int> S(5), C(5);
    cin >> n >> m;
    for(int i=0; i<m; i++)
        cin >> S[i] >> C[i], S[i]--;

    for(int i=0; i<1000; i++){
        if(is_satisfied(i, n, m, C, S)){
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(16);
    
    solve();

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define pb push_back 
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b >= c)Yes;
    else No;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc147/tasks/abc147_f>
 問題文============================================================
 F - Sum Difference
 =================================================================
 解説=============================================================

 ================================================================
 */


template<class Type>
Type solve(Type res = Type()){
    ll N,X,D; cin >> N >> X >> D;

    if(D == 0){
        res = X==0?1:N+1;
    }else{
        if(D < 0){
            X = -X;
            D = -D;
        }
        
        auto MOD = [](ll x,ll m){
            return (x%m + m)%m;
        };
        map<ll,vector<pll>> secs;
        
        for(ll k = 0; k <= N;k++){
            // 取れる区間
            ll L = (k-1)*k/2;
            ll R = N*k - k*(k+1)/2;

            secs[MOD(k*X,D)].emplace_back(k*X/D+L,k*X/D+R);
        }
        
        for(auto& ps:secs){
            auto V = ps.second;
            sort(V.begin(),V.end());
            
            ll left = numeric_limits<ll>::min();
            
            for(auto sec:V){
                left = max(left,sec.first-1);
                res += max(0LL,sec.second-left);
                left = max(left,sec.second);
            }
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 22144
import copy
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

M = max(a)
b = a.count(M)
if b >=2:
    for i in range(n):
        print(M)
else:
    A = copy.copy(a)
    for i in range(b):
        a.remove(M)
        m = max(a)
    for i in A:
        if i == M:
            print(m)
        else:
            print(M)

Measured memory_bytes: 14556
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(ll i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,e) for (ll i = s; i < (ll)e; i++)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	string s; cin >> s;
	FOR(i, 1, s.size()) {
		if (s[i] == s[i - 1]) {
			cout << i << " " << i + 1 << endl;
			return 0;
		}
	}
	FOR(i, 2, s.size()) {
		if (s[i] == s[i - 2]) {
			cout << i - 1 << " " << i + 1 << endl;
			return 0;
		}
	}

	cout << -1 << " " << -1 << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;
unsigned long long int dp[31];

void solve()
{
	dp[0] = 1;
	dp[1] = 1;
	dp[2] = 2;
	for(int i = 3; i < 31; ++i)
	{
		dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
	}
	int n;
	while(cin >> n, n)
	{
		cout << dp[n] / 3650 + 1 << endl;
	}
}

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

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  int ab, bc, ca;
  cin >> ab >> bc >> ca;
  cout << ab*bc/2 << endl;
  return 0;
}

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

int main(void)
{
    string x,y;
    cin >> x >> y;

    int X, Y;
    X = stoi(x , nullptr , 16);
    Y = stoi(y , nullptr , 16);

    if(X > Y)
        cout << ">" << endl;
    else if(X < Y) 
        cout << "<" << endl;
    else if(X == Y)
        cout << "=" << endl;


}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  char c;
  cin >> c;
  if('A' <= c && c <= 'Z') {
    cout << "A\n";
  } else {
    cout << "a\n";
  }
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
using namespace std;
int is_palindrome(string S)
{
        int i = 0, j = S.size() - 1;
        while (i < j)
        {   
                if (S[i] != S[j])
                        return 0;
                i++;
                j--;
        }   
        return 1;

}
int main()
{
        string s1,s2,s3;
        cin >> s1; 
        s2 = s1.substr(0,(s1.size()-1)/2);
        s3 = s1.substr((s1.size()+2)/2,s1.size()-1);
        if (is_palindrome(s1) && is_palindrome(s2) && is_palindrome(s3))
                cout << "Yes" << endl;
        else 
                cout << "No" << endl;
        return 0;
}

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


#include <assert.h>    // LON
#include <math.h>    // sqrt()


using namespace std;
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;


class UnionFind {
public:
    // 親の番号を格納する。親だった場合-size
    vector<int> parents;

    UnionFind(int n) {
        parents = vector<int>(n, -1);
    }

    // aがどのグループに属しているか
    int root(int a) {
        if (parents[a] < 0) {
            return a;
        }
        return parents[a] = root(parents[a]);
    }

    int size(int a) {
        return -parents[root(a)];
    }

    // aとbをくっつける
    bool connect(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        if (ra == rb) {
            return false;
        }
        // 大きいほうにA
        if (size(ra) < size(rb)) {
            swap(ra, rb);
        }
        parents[ra] += parents[rb];
        parents[rb] = ra;
        return true;
    }

};


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

    vector<P> vectors;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        vectors.emplace_back(a, b);
    }
    int ans = 0;
    for (int i = 0; i < vectors.size(); i++) {
        UnionFind uf(n);
        for (int j = 0; j < vectors.size(); j++) {
            if (j == i) continue;
            P p = vectors[j];
            uf.connect(p.first, p.second);
        }
        bool ok = [&] {
            for (int j = 1; j < n; j++) {
                if (uf.root(0) != uf.root(j)) {
                    return false;
                }
            }
            return true;
        }();

        if (!ok) {
            ans++;
        }

    }

    cout << ans << endl;
}


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

int main() {
int a , b ;
cin >> a >> b ;

  if (  ( a+b) % 2 == 0 ){
    cout << ( a+b) / 2 << endl;
  }
 
  else {
    cout << ( a+b) / 2 +1 << endl;
  }

}

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

#define ll long long
typedef vector< string > mp;
typedef vector<ll> vi;

int main(){
    ll N, tmp, ans=10000000000;
    ll K;
    ll l;
    cin >> N >> K;
    vi vec(N);
    vi Lef;
    vi Rig;
    Rig.push_back(0);
    for(int i = 0; i < N; i++){
        cin >> tmp;
        if(tmp < 0){
            Lef.push_back(abs(tmp));
        }else{
            Rig.push_back(tmp);
        }
    }
    Lef.push_back(0);
    reverse(Lef.begin(), Lef.end());
    l = min((ll)Lef.size()-1, K);
    for(ll i = 0; i <= l; i++){
        if(K-i < (ll)Rig.size()){
            // cout << Lef[i] << Rig[K-i] << endl;
            ans = min(ans, 2*Lef[i]+ Rig[K-i]);
            ans = min(ans, Lef[i]+ 2*Rig[K-i]);
        }
        // cout << "i:" << i << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2424
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

typedef long long int lli;

void swap(int* a, int* b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void ll_swap(lli* a, lli* b)
{
    lli tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int gcd(int a, int b)
{
    if (a < b)
        swap(&a, &b);

    if (a % b == 0)
        return b;
    else
        return gcd(b, a % b);
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

long power(long x, int n) {
    long ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

lli comb(lli n, lli r)
{
    if (n == 0)
        return 0;

    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (comb(n - 1, r - 1) + comb(n - 1, r));
}

/*
#define MAX 100000
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;
}
*/   

int main()
{
    int M, N, K, L;
    int a[100000];
    lli count = 0;
    lli temp, temp2;
    char S[10];
  
    lli X;

    scanf("%lld", &X);

    int ans = 0;

    ans += (X / 500) * 1000;
    X %= 500;

    ans += (X / 5) * 5;

    printf("%lld", ans);


}


Measured memory_bytes: 256
//
//  AIZU_small_large.c
//  prg2018
//
//  Created by x18033xx on 2018/04/25.
//

#include <stdio.h>
int main(int argv, const char * argc[]){
    int a,b;
    scanf("%d %d",&a,&b);
    if (a<b){
        printf("a < b\n");
    }
    else if (a>b){
        printf("a > b\n");
    }
    else{
        printf("a == b\n");
    }
    return 0;
}



Measured memory_bytes: 2040
#include <stdio.h>

int main() {
    char a[4];
    scanf("%s", a);
    int n=0;
    for(int i=0;i<=3;i++)
    {
        if(a[i]=='-')
        {
            n=n-1;
        }else n=n+1;
    }
    printf("%d",n);
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動產生的方法 Stub
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int H;
		int u=0;
		int[] x=new int [n];
		int[] y=new int [n];
		int[] h=new int [n];
		for(int i=0;i<n;i++) {
			x[i]=sc.nextInt();
			y[i]=sc.nextInt();
			h[i]=sc.nextInt();
			if(h[i]>0) u=i;
		}
		int t;
		for(int i=0;i<=100;i++) {
			for(int j=0;j<=100;j++) {
				H=h[u]+Math.abs(i-x[u])+Math.abs(j-y[u]);
				t=0;
				for(int k=0;k<n;k++) {
					int Hh=Math.max(H-Math.abs(i-x[k])-Math.abs(j-y[k]),0);
					if(Hh!=h[k]) {
						t=1;
						break;
					}
				}
				if(t==0)
					System.out.println(i+" "+j+" "+H);
					
			}
			
		}
	}

}

Measured memory_bytes: 22100
using System;
class Program
{
    static void Main(string[] args)
    {
        // スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        int w = int.Parse(input[0]);
        int h = int.Parse(input[1]);
        int x = int.Parse(input[2]);
        int y = int.Parse(input[3]);
        int r = int.Parse(input[4]);
        //出力
        if (x < w && y < h && r < x && r < y) Console.WriteLine("Yes");
        else if (x < w && y < h && r == x && r < y) Console.WriteLine("Yes");
        else if (x < w && y < h && r < x && r == y) Console.WriteLine("Yes");
        else if (x < w && y < h && r == x && r == y) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}


Measured memory_bytes: 17936
d,g=map(int,input().split())
p,c=[],[]
for i in range(d):
    P,C=map(int,input().split())
    p.append(P)
    c.append(C)
cnt=10**5
for i in range(1<<d):
    tmp=0
    ans=0
    for j in range(d):
        if i&(1<<j):
            tmp+=c[j]+p[j]*100*(j+1)
            ans+=p[j]
    for j in range(d-1,-1,-1):
        if tmp>=g:
            break
        if i&(1<<j):
            continue
        for k in range(p[j]-1):
            tmp+=100*(j+1)
            ans+=1
            if tmp>=g:
                break
    if tmp>=g: #最後も確認
        cnt=min(ans,cnt)
print(cnt)

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

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

for(int i = 0; i < (1 << 3); i++){
    string now;
    now += C[0]; 
         for(int j = 0; j < 3; j++){ 
            if(i & (1 << j)) now += "+";
            else now += "-";
            now +=  C[1 + j];
                 } 
// cout << now << endl;
int sum = 0;
bool mat = true;
for(int i = 0; i < now.size(); i++){ 
     if(now[i] == '+') mat = true;
     else if(now[i] == '-') mat = false;
     else if(mat == true) sum += now[i] - '0';
     else if(mat == false) sum -= now[i] - '0';
}

// cout << sum << endl;
if(sum == 7) {
    cout << now << "=7" << endl;
    break;
} 

}

 
}


Measured memory_bytes: 256
from collections import deque

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

path = [[] for _ in range(n)]

for i in range(m):
    a,b = map(int, input().split())
    path[a-1].append(b)
    path[b-1].append(a)
    
d = deque([0])
dis = [-1 for _ in range(n)]
dis[0] = 0

while d:
    hop = d.popleft()
    for i in path[hop]:
        if dis[i-1] == -1:
            d.append(i-1)
            dis[i-1] = hop+1
            
if -1 in dis:
    print('No')
else:
    print('Yes')
    for i in range(1,len(dis)):
        print(dis[i])

Measured memory_bytes: 37276
from collections import Counter

H, W, M = map(int, input().split())
dh, dw = Counter(), Counter()
used = set()

for _ in range(M):
    h, w = map(int, input().split())
    dh[h] += 1
    dw[w] += 1
    used.add((h, w))

ih = dh.most_common()
iw = dw.most_common()
s = ih[0][1] + iw[0][1]
ans = 0

for h, sh in ih:
    for w, sw in iw:
        if sh+sw < s or ans == s:
            break
        b = sh + sw - ((h, w) in used)
        ans = max(ans, b)
print(ans)


Measured memory_bytes: 240320
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	string s; cin >> s;
	int n=s.size();
	int p=0;
	REP(i,n){
		p+=s[i]-'0';
		p%=9;
	}
	if(p==0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3724
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n;
  cin >> n;
  vector<ll>a(n);
  vector<ll>b(n);
  vector<ll>c(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) cin >> c[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  
  ll ans=0;
  rep(i,n){
    ll num1=lower_bound(a.begin(),a.end(),b[i])-a.begin();
    ll num2=upper_bound(c.begin(),c.end(),b[i])-c.begin();
    ans+=num1*(n-num2);
  }
  cout << ans << endl;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    long long sum1 = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        A[i] = a;
        sum1 += a;
    }

    long long sum2 = 0;
    for (int i = 1; i < N; i += 2) {
        sum2 += A[i];
    }

    vector<long long> res(N);
    res[0] = sum1 - 2 * sum2;

    for (int i = 1; i < N; i++) {
        res[i] = 2 * A[i - 1] - res[i - 1];
    }

    for (int i = 0; i < N; i++)
        cout << res[i] << " ";
    cout << endl;
    return 0;
}

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

#define int long long
//#define uint __int128_t

#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define fill(i,n) memset(i,n,sizeof(i))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N;int a[100010];
int flag=0;

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    cin>>N;
    int tmp;
    int ans=1;
    rep(i,0,N){
        cin>>a[i];
        if(i){
            if(flag==0){
                if(tmp<a[i])flag=1;
                else if(a[i]<tmp) flag=2;
                else flag=0;
            }else if(flag==1){
                if(a[i]<tmp){
                    flag=0;
                    ans++;
                }
            }else if(flag==2){
                if(tmp<a[i]){
                    flag=0;
                    ans++;
                }
            }
        }
        tmp=a[i];
    }
    
    cout<<ans<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    




















































    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>

using namespace std;

int main()
{
    double x,y,z,S,L,h;
    int a;
    double PI = acos(-1);
    cin >> x >> y >> a;
    z = a*PI/180;
    S = y*sin(z)*x*1/2;
    h = y*sin(z);
    L = x + y + sqrt(pow(x,2)+pow(y,2)-2*x*y*cos(z));
    cout << fixed << setprecision(8);
    cout << S << endl << L << endl << h;

    return 0;
}


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

    for (int i=0; i < N ;i++) {
      a[i] =  sc.nextInt();
      b[i] =  a[i];
    }
    Arrays.sort(a);

    for (int i=0; i < N ;i++) {
      if(b[i] == a[N-1]){
        System.out.println(a[N-2]);
      }else{
        System.out.println(a[N-1]);
      }
    }
  }
}





Measured memory_bytes: 92308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int a,b,k; cin >> a >> b >> k;
	std::vector<int> v;
	for (int i = 0; i < min(a,b); ++i)
	{
		if (a%(i+1)==0 && b%(i+1)==0)
		{
			v.push_back(i + 1);
		}
	}

	sort(v.rbegin(), v.rend());

	cout << v[k - 1] << endl;
}



Measured memory_bytes: 256
def main():
    n = int(input())
    a_s = list(map(int, input().split(' ')))
    b_s = list(map(int, input().split(' ')))
    count = 0
    carry_over = 0
    for i, a in enumerate(a_s):
        count += min(carry_over, a)
        a = max(a-carry_over, 0)
        b = b_s[i] if i < n else 0
        count += min(a, b)
        carry_over = max(0, b-a)
    print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19116
from functools import lru_cache

N,P = map(int, input().split())
A_list = [int(e) for e in input().split()]

A_odd_list = list()
A_even_list = list()

for A in A_list:
    if A%2 == 0:
        A_even_list.append(A)
    else:
        A_odd_list.append(A)

#######################################################################
#https://note.nkmk.me/python-math-factorial-permutations-combinations/
from operator import mul
from functools import reduce

@lru_cache(maxsize=100000000)
def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom
#######################################################################

choice_odd = 0
choice_even = 0
odds = len(A_odd_list)
evens = len(A_even_list)

if P == 1:
    #奇数の中から奇数個選ぶ
    for i in range(1,odds+1,2):
        choice_odd += combinations_count(odds,i)
    #偶数の中から好きな個数を選ぶ
    for i in range(0,evens+1,1):
        choice_even += combinations_count(evens,i)
else:
    #奇数の中から偶数個選ぶ
    for i in range(0,odds+1,2):
        choice_odd += combinations_count(odds,i)
    #偶数の中から好きな個数を選ぶ
    for i in range(0,evens+1,1):
        choice_even += combinations_count(evens,i)
        
print(choice_odd*choice_even)

Measured memory_bytes: 3684
#include <math.h>

#include <algorithm>  //sort,二分探索,など
#include <array>
#include <bitset>         //固定長bit集合
#include <cmath>          //pow,logなど
#include <complex>        //複素数
#include <deque>          //両端アクセスのキュー
#include <functional>     //sortのgreater
#include <iomanip>        //setprecision(浮動小数点の出力の誤差)
#include <iostream>       //入出力
#include <map>            //map(辞書)s
#include <numeric>        //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>          //キュー
#include <set>            //集合
#include <stack>          //スタック
#include <string>         //文字列
#include <unordered_map>  //イテレータあるけど順序保持しないmap
#include <unordered_set>  //イテレータあるけど順序保持しないset
#include <utility>        //pair
#include <vector>         //可変長配列

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())  // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main() {
  int k, s, x, y;
  cin >> k >> s;
  int ans = 0;
  for (x = 0; x <= k; ++x) {
    for (y = 0; y <= k; ++y) {
      int z = s - x - y;
      if (z <= k && z >= 0) ans++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

int main(){
    vector<int> cards;
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        int q;
        cin >> q;
        cards.push_back(q);
    }
    set<int> norep(cards.begin(),cards.end());
    int diff = 0;
    diff = cards.size()-norep.size();
    if(diff%2==0){
        cout << norep.size();
    }
    else{
        cout<<norep.size()-1;
    }
}

Measured memory_bytes: 5368
#include<bits/stdc++.h>
using namespace std;
int flag[1001];
map<int,int>mp;
map<int,int>mp1;

int main()
{
    string s,s1;
    int c=0,f=0,i;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        c=i+1;
        if(c%2!=0)
        {
            if(s[i]=='R'||s[i]=='U'||s[i]=='D')
             continue;
            else
                f=1;

        }
       else  if(c%2==0)
        {
            if(s[i]=='L'||s[i]=='U'||s[i]=='D')
                continue;
            else
                f=1;

        }
    }
    if(f==1)
        cout<<"No"<<"\n";
    else
        cout<<"Yes"<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define PI 3.14159265359

int main(){
    int n; cin >> n;
    int k; cin >> k;
    int result = 1;
    rep(i, n){
        if(result*2 < result+k){
            result *= 2;
        }else{
            result += k;
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3440
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int A, B; cin >> A >> B;
    if(A < B) swap(A, B);

    cout << A + max(A - 1, B) << endl;

    return 0;
}


Measured memory_bytes: 384
// 2013/11/10 Tazoe

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	while(true){
		int n, k;
		cin >> n;
		cin >> k;

		if(n==0 && k==0)
			break;

		string S[10];
		for(int i=0; i<n; i++){
			cin >> S[i];
		}

		vector<string> V;

		for(int i0=0; i0<n; i0++){
		for(int i1=0; i1<n; i1++){
			if(i1==i0)
				continue;

			if(k==2){
				string T = S[i0]+S[i1];
				if(find(V.begin(), V.end(), T)==V.end()){
					V.push_back(T);
				}
				continue;
			}
		for(int i2=0; i2<n; i2++){
			if(i2==i0 || i2==i1)
				continue;

			if(k==3){
				string T = S[i0]+S[i1]+S[i2];
				if(find(V.begin(), V.end(), T)==V.end()){
					V.push_back(T);
				}
				continue;
			}
		for(int i3=0; i3<n; i3++){
			if(i3==i0 || i3==i1 || i3==i2)
				continue;

			if(k==4){
				string T = S[i0]+S[i1]+S[i2]+S[i3];
				if(find(V.begin(), V.end(), T)==V.end()){
					V.push_back(T);
				}
				continue;
			}
		}
		}
		}
		}

		cout << V.size() << endl;
	}

	return 0;
}

Measured memory_bytes: 1360
#include <vector>
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
int numberOfSetBits(uint32_t i){
     i = i - ((i >> 1) & 0x55555555);
     i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
     return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
}
int findBit(int x, int N){
    for(int i=0;i<N;i++)
        if((x>>i)&1){
            return i;
        }
    throw(1);
}
int first=1;
int print(int x){
    if(first){
        first=0;
        cout<<x;
    }else{
        cout<<" "<<x;
    }
}
void solve(int sizeOfFix, int N, int free, int A, int B){
    // printf("solve(%d,%d,%x,%x,%x);\n",sizeOfFix,N,free,A,B);
    int sizeOfRest=N-sizeOfFix;
    if(sizeOfRest==1){
        print(A);
        print(B);
    }else{
        int freeDifferBit=findBit(free&(A^B),N);
        int freeBit=findBit(free&(~(1<<freeDifferBit)), N);
        int A1=A^(1<<freeBit);
        int B1=A1^(1<<freeDifferBit);
        solve(sizeOfFix+1,N,free^(1<<freeDifferBit),A,A1);
        solve(sizeOfFix+1,N,free^(1<<freeDifferBit),B1,B);
    }
}
int main(){
    int N,A,B;
    cin>>N>>A>>B;
    if((numberOfSetBits(A) - numberOfSetBits(B))%2==0){
        cout<<"NO"<<endl;
    }else{
        cout<<"YES"<<endl;
        solve(0,N,(1<<N)-1, A, B);
        cout<<endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
    ll x;
    cin>>x;
    ll f = 360;
    ll g = gcd(f,x);
    ll l = (f*x)/g;
    ll ans = l/x;
    cout<<ans<<"\n";
}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 3608
import java.util.*;
import java.io.*;

class Main {

    public static void main(String[] args) {

	Scanner stdin = new Scanner(System.in);

	while ( stdin.hasNextDouble() ) {

	    final double weight = stdin.nextDouble();
	    if ( weight <= 48.00 ) {
		System.out.println("light fly");
	    } else if ( 48.00 < weight && weight <= 51.00 ) {
		System.out.println("fly");
	    } else if ( 51.00 < weight && weight <= 54.00 ) {
		System.out.println("bantam");
	    } else if ( 54.00 < weight &&  weight <= 57.00 ) {
		System.out.println("feather");
	    } else if ( 57.00 < weight &&  weight <= 60.00 ) {
		System.out.println("light");
	    } else if ( 60.00 < weight &&  weight <= 64.00 ) {
		System.out.println("light welter");
	    } else if ( 64.00 < weight &&  weight <= 69.00 ) {
		System.out.println("welter");
	    } else if ( 69.00 < weight &&  weight <= 75.00 ) {
		System.out.println("light middle");
	    } else if ( 75.00 < weight &&  weight <= 81.00 ) {
		System.out.println("middle");
	    } else if ( 81.00 < weight && weight <= 91.00 ){
		System.out.println("light heavy");
	    } else {
		System.out.println("heavy");
	    } 
	    
	    
	}
	
    }
    
}

Measured memory_bytes: 19256
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
//long long num[100000];
int main(){
	int n,k,c,p,ans=0;
	cin>>n>>k;
	int x[n];
	for(int i=0;i<n;i++){
		cin>>x[i];
		ans+=2*min(x[i],k-x[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#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;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

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

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n;
  cin>>n;
  bool ok = false;
  REP(i,10){
    if(n%1000 == i*111)ok=true;
    if(n/10 == i*111)ok=true;
  }
  puts(ok?"Yes":"No");
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        for (int i = 1; i <= 5; i++) {
            int num = sc.nextInt();
            if (num == 0) {
                System.out.println(i);
                return;
            }
        }
    }
}


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

using namespace std;

int main() {
    int q, x, n, d;
    list<int> l;
    scanf("%d", &q);
    list<int>::iterator it;
    list<int>::iterator it2;
    it = l.end();
    for (int i = 0; i < q; i++) {
        scanf("%d", &n);
        if (n == 0) {
            scanf("%d", &x);
            l.insert(it, x);
            it--;
        } else if (n == 1) {
            scanf("%d", &d);
            if (d > 0) {
                advance(it, d);
            }
            if (d < 0) {
                for (int k = 0; k < ((-1) * d); k++) {
                    it--;
                }
            }
        } else if (n == 2) {
            it2 = it;
            it2++;
            l.erase(it);
            it = it2;
        }
    }
    for (it = l.begin(); it != l.end(); it++) {
        cout << *it << endl;
    }
    return 0;
}




Measured memory_bytes: 18684
namespace Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Test
    {
        public static void Main(string[] args)
        {
            var test = new Test();
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            Console.WriteLine(test.CountContainWords(s, "ABC"));
        }


        public int CountContainWords(string source, string word)
        {
            var count = 0;
            for(var i = 0; i<source.Length - 2; i++)
            {
                if(source.Substring(i,word.Length) == word)
                {
                    count++;
                }
            }
            return count;
        }
    }
}

Measured memory_bytes: 11092
from collections import deque
def main():
    s = list(input().rstrip())
    s = deque(s)
    q = int(input())
    f = True
    for _ in range(q):
        a = list(map(str, input().rstrip().split()))
        if a[0] == "1":
            if f:
                f = False
            else:
                f = True
        else:
            if a[1] == "1":
                if f:
                    s.appendleft(a[2])
                else:
                    s.append(a[2])
            else:
                if f:
                    s.append(a[2])
                else:
                    s.appendleft(a[2])
    if f:
        for c in s:
            print(c, end="")
    else:
        for c in reversed(s):
            print(c, end="")

if __name__ == "__main__":
    main()

Measured memory_bytes: 7776
n = int(input())
s = []
for i in range(n):
    s.append(str(input()))

ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
 
    if str(s[i]) == 'AC': 
        ac += 1
    if str(s[i]) == 'WA': 
        wa += 1
    if str(s[i]) == 'TLE': 
        tle += 1
    if str(s[i]) == 'RE': 
        re += 1
    
print('AC x ',ac)
print('WA x ',wa)
print('TLE x ',tle)
print('RE x ',re)


Measured memory_bytes: 16348