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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  int P,Q;
  P = abs(A-B);
  Q = abs(A-C);
  
  if (A == B && A == C && A%2 == 0) {
    cout << -1 << endl;
    return 0;
  }
  if (A == B && A == C && A%2 == 1) {
    cout << 0 << endl;
    return 0;
  }
  
  int ans = 0;
  for (;;) {
    if (P % 2 == 1 || Q % 2 == 1) {
      break;
    }
    ans++;
    P = P/2;
    Q = Q/2;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
// %:pragma GCC optimize("Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
#define fir first
#define sec second
#define rep(i,a,b) for (int i = (a) ; i <= (b) ; ++ i)
#define rrp(i,a,b) for (int i = (a) ; i >= (b) ; -- i)
#define gc() getchar()
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc() ; !isdigit(tmp) ; tmp = gc())
    key = (tmp == '-');
  for ( ; isdigit(tmp) ; tmp = gc())
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}

const int N = 500010, MOD = (int)(1e9 + 7);
int power(int a,int b) {
  int ret = 1;
  while (b) {
    if (b & 1) ret = 1ll * ret * a % MOD;
    a = 1ll * a * a % MOD;
    b >>= 1;
  }
  return ret;
}
inline void Add(int& x,int y) {
  x = x + y >= MOD ? x + y - MOD : x + y;
}
inline int fit(int x) {
  return x >= MOD ? x - MOD : x;
}
int n,num[2][N],ans,lp[N],rp[N],lim[N];
struct data {
  int b,k;
  bool operator < (const data& a) const {
    return b < a.b;
  }
} dat[N];
int mn[N], mx[N], sum[N << 2], tag[N << 2];
void puttag(int x) {
  sum[x] = 0; tag[x] = 1;
}
void push_down(int x) {
  puttag(x<<1), puttag(x<<1|1);
  tag[x] = 0;
}
void push_up(int x) {
  sum[x] = fit(sum[x<<1] + sum[x<<1|1]);
}
int query(int l,int r,int x=1,int lp=0,int rp=n) {
  if (l > rp || lp > r) return 0;
  if (lp >= l && rp <= r) return sum[x];
  int mid = (lp + rp) >> 1;
  if (tag[x]) push_down(x);
  return fit(query(l, r, x<<1, lp, mid) + query(l, r, x<<1|1, mid+1, rp));
}
void clear(int l,int r,int x=1,int lp=0,int rp=n) {
  if (l > rp || lp > r) return;
  if (lp >= l && rp <= r) {
    puttag(x);
    return;
  }
  int mid = (lp + rp) >> 1;
  if (tag[x]) push_down(x);
  clear(l, r, x<<1, lp, mid), clear(l, r, x<<1|1, mid+1, rp);
  push_up(x);
}
void setval(int p,int v,int x=1,int lp=0,int rp=n) {
  if (lp == rp) {
    Add(sum[x], v);
    return;
  }
  int mid = (lp + rp) >> 1;
  if (tag[x]) push_down(x);
  if (p <= mid) setval(p, v, x<<1, lp, mid);
  else setval(p, v, x<<1|1, mid+1, rp);
  push_up(x);
}
int main() {
  int x,y;
  read(n);
  rep (i, 1, n) {
    read(x), read(y);
    dat[i] = (data) {x, y};
  }
  sort(dat+1, dat+n+1);
  mn[n] = dat[n].k;
  rrp (i, n-1, 1) mn[i] = min(mn[i+1], dat[i].k);
  mx[1] = dat[1].k;
  rep (i, 2, n) mx[i] = max(mx[i-1], dat[i].k);
  rep (i, 1, n) {
    lp[i] = upper_bound(mx+1, mx+i+1, dat[i].k) - mx;
    lp[i] = min(lp[i], i);
    rp[i] = lower_bound(mn+i, mn+n+1, dat[i].k) - mn - 1;
    rp[i] = max(rp[i], i);
  }
  rep (i, 1, n) lim[i] = n + 1;
  rep (i, 1, n) lim[lp[i]] = min(lim[lp[i]], rp[i]);
  setval(0, 1);
  rep (i, 1, n) {
    x = query(0, n);
    if (lim[i] <= n) {
      y = query(0, 0);
      Add(y, query(lim[i], n));
      clear(lim[i], n);
      setval(lim[i], y);
      clear(0, 0);
    }
    setval(0, x);
    clear(i, i);
  }
  ans = query(0, n);
  ans = (ans % MOD + MOD) % MOD;
  printf("%d\n", ans);
  return 0;
}


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

long long GCD(long long x, long long y) {
    if (y == 0) return x;
    else return GCD(y, x%y);
}

int main() {
    ll k,ans=0;
    cin >> k;
    for(ll a=1;a<=k;a++){
        for(ll b=1;b<=k;b++){
            ll hoge = GCD(a,b);
            for(ll c=1;c<=k;c++){
                ans+=GCD(hoge,c);
            }
        }
    }
    cout << ans << endl;
}


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


int main(){
	int n;
	while(cin>>n&&n){
		int maxp,maxd=-1;
		for(int i=0;i<n;i++){
			int p,d1,d2;
			cin>>p>>d1>>d2;
			if(maxd<d1+d2){
				maxd=d1+d2;
				maxp=p;
			}
		}
		cout<<maxp<<' '<<maxd<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	aa := make([]int, n)
	for i := 0; i < n-1; i++ {
		a := getNextInt(scanner) - 1
		aa[a]++
	}

	for i := 0; i < n; i++ {
		fmt.Fprintln(writer, aa[i])
	}
}


Measured memory_bytes: 6124
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;

using namespace std;

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

    return 0;
}
    



Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		if(a <= 8 && b <= 8)System.out.println("Yay!");
		else System.out.println(":(");
	}
}


Measured memory_bytes: 21844
#include <stdio.h>

int main(){
  int a=0,b,c[20],d;
  while(1){
    scanf("%d",&a);
    if(a==-1) break;
    if(a==0) printf("0");
    for(b=0;a>0 && b<10;b++){
      c[b]=a&3;
      a=a>>2;
    }
    for(d=b-1;d>=0;d--){
      printf("%d",c[d]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <string>
#include <iostream>
#include <math.h>

using namespace std;





int main(void){

    

    long n;
    cin >>n;
    string ans = "";

    long *a = new long[n];


    long t = 0;
    for(int i = 0; i < n; i++) {
        cin>>a[i];
        t = t^a[i];
    }

    for(int i = 0 ; i < n; i++) {
        cout<<(t^a[i])<<" ";
    }



    


    return 0;
}

Measured memory_bytes: 5180
N=int(input())
a=[]
for i in range(N):
    a.append(int(input()))

chk={}

for sa in a:
    if sa in chk:
        if chk[sa]==1:
            chk[sa]=0
        else:
            chk[sa]=1
    else:
        chk[sa]=1


print(sum(chk.values()))


Measured memory_bytes: 16272
// JAI SHREE RAM
#pragma GCC optimize("O3")
typedef long long int ll;
typedef unsigned long long int ull;
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define sz(a) int((a).size())
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
#define loop for(int i=0;i<n;i++)
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max3(a,max(b,c),d)
#define max5(a,b,c,d,e) max4(a,max(b,c),d,e)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min3(a,min(b,c),d)
#define min5(a,b,c,d,e) min4(a,min(b,c),d,e)
#define sec second
#define fir first
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repe(i,m,n) for(ll (i)=(m);(i)<(n);(i)++)
// #define all(a) (a).begin(),(a).end()
#define vec vector<int>
#define M_PI           3.14159265358979323846  /* pi */
#define pb push_back
#define pii pair<int,int>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fast
	ll n, m, x;
	cin>>n>>m>>x;
	ll mat[n][m];
	ll price[n];
	rep(i, n)
	{
		cin >> price[i];
		rep(j, m)
		cin >> mat[i][j];
	}
	ll ans = 1 << 30;
	for(ll i=1;i<(1<<n);i++)
	{

		ll cost = 0;
		std::vector<ll> v(m,0);
		rep(j, n)
		{
			if (i & (1 << j))
			{
				cost += price[j];
				rep(k, m)
				v[k] += mat[j][k];
			}
		}
		rep(l, m)
		{
			if (v[l] < x)
				cost = (1 << 30);
		}
		ans = min(ans, cost);
	}
	cout << (ans<(1<<30)?ans:-1);


	return 0;
}


Measured memory_bytes: 3656
// Problem: D - Road to Millionaire
// Contest: AtCoder - M-SOLUTIONS Programming Contest 2020
// URL: https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_d
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*
 *   ﷽
 * In the name of Allah, the Most Gracious, the Most Merciful
 */

#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <climits>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> arr(n);
	for(auto &e : arr) cin >> e;
	arr.push_back(0);
	
	unsigned long long yen = 1000;
	unsigned long long int stocks = 0;
	for(int t=1;t<n+1;t++)
	{
		int today = arr[t-1];
		int tomor = arr[t];
		
		if(today < tomor)
		{
			if(stocks != 0)
			{
				yen += stocks * today;
				stocks = 0;
			}
			stocks += yen/today;
			yen = yen - ( stocks * today );
			// cerr << "Buy\n";
		}
		else
		{
			if(today == tomor) continue;
			yen += today * stocks;
			stocks = 0;
			// cerr << "Sell\n";
		}
	}
	cout << yen;
	return 0;
}

Measured memory_bytes: 3120
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<Integer> one = nextIntArray();
		int N = one.get(0);
		int X = one.get(1);
		int T = one.get(2);
		myout((N + X - 1) / X * T);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 32804
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let x:u32 = read();
    let n1 = x / 500;
    let n2 = (x - n1 * 500) / 5;
    println!("{}", n1*1000+n2*5);
}



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

int main(){
    int n,q;
    cin >> n >> q;
    vector<int> data(100);
    int m;
    int x;
    int ans;
    bool flag;
    while (n!=0 || q!=0){
        for (int i = 0; i<100; i++) data[i] = 0;
        for (int i = 0; i<n; i++){
            cin >> m;
            for (int j = 0; j<m; j++){
                cin >> x;
                data[x]++;
            }
        }
        ans = 0;
        flag = false;
        for (int i = n; i>=q; i--){
            for (int j = 0; j<100; j++){
                if (data[j]==i){
                    ans = j;
                    flag = true;
                    break;
                }
                if (flag) break;
            }
        }
        cout << ans << endl;
        cin >> n >> q;
    }
}



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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
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);
}

int main()
{
    cout << fixed << setprecision(15);
    ll K;
    string S;
    cin >> K;
    cin >> S;

    ll N = S.length();

    if(N <= K){
        cout << S << endl;
    }
    else{
        REP(i, K){
            cout << S[i];
        }
        cout << "..." << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

int main(){
    vector<bool> game(400,true);
    int n,m; cin>>n>>m;
    int a[310][310]={};
    rep(i,n){
        rep(j,m){
            cin>>a[i][j];
        }
    }
    int ans=INF;
    vector<int> idx(n,0);
    rep(g,m){
        multiset<int> c;
        rep(i,n){

            c.insert(a[i][idx[i]]);
        }
        int tmp=0,nxt;
        rep(i,301){
            if(tmp<c.count(i)){
                tmp=c.count(i);
                nxt=i;
            }
        }
        game[nxt]=false;
        ans=min(tmp,ans);
        rep(i,n){
            if(idx[i]>=m) continue;
            while(!game[a[i][idx[i]]]) idx[i]++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[100];
signed main(){
    int n;
    cin>>n;
    for(int j=0;j<n;j++){
        cin>>a[j];
    }
    int sum,ans=9999999;
    for(int i=-100;i<101;i++){
        sum=0;
        for(int k=0;k<n;k++){
            sum+=abs(a[k]-i)*abs(a[k]-i);
        }
        if(sum<ans){
            ans=sum;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;//namespace

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define SANKOU(n,a,b) cout << ((n) ? (a) : (b) ) << endl;

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);// warshall-floyd

#define CIN(x) int x;cin>>x;
#define SCIN(x) string x;cin>>x;
#define COUT(x) cout<<(x)<<endl;
#define SCOUT(x) cout<<(x)<<" ";
#define ENDL cout<<endl;

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_;
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl;

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end());

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    CIN(n);
    V s(n);
    VECCIN(s);
    sort(ALL(s));
    vector<V> dp(n+1); // i番目までの要素を選んだ中で1の位がjになる数の最大値
    V tesvec(10,-1);
    FOREACH(x,dp){x=tesvec;}
    int max_=0;
    REP(i,10)dp[0][i]=0;
    REP(i,n){
        int val=s[i];
        int mod=s[i]%10;
        REP(j,10){
            if(dp[i][j]!=-1){
                dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
                dp[i+1][(dp[i][j]+mod)%10]=max(dp[i][j]+val,dp[i+1][(dp[i][j]+mod)%10]);
            }
        }
    }
    REP(i,n+1){FOR(j,1,10){
       // SCOUT(dp[i][j]);
        max_=max(max_,dp[i][j]);
    }}//ENDL;}
    COUT(max_);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long LL;
typedef pair<int,int> pr;

const int maxn=2e5+5;

char s[maxn];
int n;

int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	
	fo(i,1,n) if (s[i]=='?') s[i]='D';
	
	printf("%s\n",s+1);
}

Measured memory_bytes: 3956
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
int main(){
ll a,b;
cin>>a>>b;
  if(a+b==15)
cout <<"+";
  else if(a*b==15)
cout<<"*";
  else
    cout<<"x";
return 0;
}

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

long N, M;

int main(void) {

    cin >> N >> M;

    for (long i = 0; i < M; i++) {
        long a; cin >> a;
        N -= a;
    }

    cout << (N < 0 ? -1 : N) << endl;

    return 0;

}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define place 31
using namespace std;

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int>cnt1(place,0),cnt0(place,0);
	for(int i=0,a;i<n;++i){
		cin>>a;
		for(int j=0,p=1;j<place;++j,p<<=1){
			if(p&a)++cnt1.at(j);
			else ++cnt0.at(j);
		}
	}
	bool yes=true;
	for(int i=0;i<place;++i){
		if(cnt1.at(i)%2!=0||(cnt1.at(i)!=0&&cnt1.at(i)%2==0&&cnt0.at(i)==0)){
			yes=false;
		}
	}
	cout<<(yes?"Yes"s:"No"s)<<"\n"s;
}

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


int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  vector<vector<int>> cnt(h, vector<int>(w));
  rep(i,h) {
    vector<int> done(w);
    rep(j,w) {
      if (s[i][j] == '#') continue;
      if (done[j]) continue;
      int l = 0;
      while (j+l < w) {
        if (s[i][j+l] == '#') break;
        ++l;
      }
      rep(k,l) {
        cnt[i][j+k] += l;
        done[j+k] = 1;
      }
    }
  }
  rep(j,w) {
    vector<int> done(h);
    rep(i,h) {
      if (s[i][j] == '#') continue;
      if (done[i]) continue;
      int l = 0;
      while (i+l < h) {
        if (s[i+l][j] == '#') break;
        ++l;
      }
      rep(k,l) {
        cnt[i+k][j] += l;
        done[i+k] = 1;
      }
    }
  }
  int ans = 0;
  rep(i,h)rep(j,w) ans = max(ans, cnt[i][j]-1);
  cout << ans << endl;
  return 0;
}    


Measured memory_bytes: 20096
#include<bits/stdc++.h>
using namespace std;
const int N=110000;
int n;
int a[N];
int main()
{
	scanf("%d",&n);
	int x,ca=0,cb=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if(x%2==0) ca++;
		else cb++;
	}
	if(ca==0||cb==0) printf("0\n");
	else
	{
		if(cb%2==0) printf("%d\n",n-2);
		else printf("%d\n",n-1);
	} 
	return 0;
}


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

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

    if (a == b && b != c)
    {
        cout << "Yes\n";
        return 0;
    }
    if (c == b && b != a)
    {
        cout << "Yes\n";
        return 0;
    }
    if (a == c && b != a)
    {
        cout << "Yes\n";
        return 0;
    }
    cout << "No\n";
    return 0;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  string s; cin >> s;

  vvll dp(n, vll(n, 0));
  for(int i=0;i<n;++i) {
    dp[0][i] = 1;
  }

  for(int i=0;i<n-1;++i) {
    vll su(n+1, 0);
    for(int j=0;j<n;++j) {
      su[j+1] = su[j] + dp[i][j];
      su[j+1] %= MOD;
    }

    if(s[i] == '<') {
      for(int j=0;j<n;++j) {
        dp[i+1][j] = (su[n] + MOD - su[j+1]) % MOD;
      }
    } else {
      for(int j=0;j<n-i-1;++j) {
        dp[i+1][j] = (su[j+1] + MOD - su[0]) % MOD;
      }
    }
    

/*     for(int j=0;j<n;++j) {
      if(s[i] == '<') {
        for(int k=0;k<j;++k) {
          dp[i+1][k] += dp[i][j];
          dp[i+1][k] %= MOD;
        }
      } else {
        for(int k=j;k<n-i-1;++k) {
          dp[i+1][k] += dp[i][j];
          dp[i+1][k] %= MOD;
        }
      }
    } */
  }

  ll ans = 0;
  for(int i=0;i<n;++i) {
    ans += dp[n-1][i];
    ans %= MOD;
  }
  cout << ans << endl;

}


Measured memory_bytes: 70784
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  int a,b,tmp,sqr,sum=0;
  cin >> a >> b;
  vector<vector<int>> data(a, vector<int>(b));
  rep(i,a){
    rep(j,b){
      cin >> data.at(i).at(j);
    }
  }
  for(int i = 0;i<a-1;i++){
    for(int j = i+1;j<a;j++){
      tmp = 0;
    for(int h = 0;h<b;h++){
    tmp += (data.at(i).at(h)-data.at(j).at(h))*(data.at(i).at(h)-data.at(j).at(h));
    }
     sqr = sqrt(tmp);
    if(tmp==sqr*sqr)sum++;
    }
  }
  cout << sum;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b) cout << c << endl;
  if(b == c) cout << a << endl;
  if(c == a) cout << b << endl;

  return 0;
}

Measured memory_bytes: 256
/*input
314159265 3

*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int> vii;
#define pb push_back
#define print(a) for(auto x:a){cout<<x<<' ';}cout<<endl;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void solve(){
  int n,k;cin>>n>>k;
  int ans=0;
  while(n>0){
    ans++;
    n/=k;
  }
  cout<<ans<<endl;
}

signed main(){
  IOS
  int t=1;
  //cin>>t;
  while(t--)
    solve();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
typedef long long ll ;
int main()
{
    int x,k;
    cin>>x>>k;
    for(int i=k-x+1;i<=k+x-1;i++)
        printf("%d ",i);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
using namespace std;
const int N = 3007;
int vs[N][N];

int main(){
    ///preprocessing
    #ifndef ONLINE_JUDGE
    freopen("test.inp", "r", stdin);
    #endif // ONLINE_JUDGE
    fio;
    ///code below
    string s, t;
    cin >> s >> t;
    for (int i = 0; i <= s.length(); i++){
        for (int j = 0; j <= t.length(); j++){
            if (i != 0 && j != 0){
                if (s[i - 1] == t[j - 1]){
                    vs[i][j] = vs[i - 1][j - 1] + 1;
                }else{
                    vs[i][j] = max(vs[i - 1][j], vs[i][j - 1]);
                }
            }else{
                vs[i][j] = 0;
            }
        }
    }
    string o = "";
    int i = s.length();
    int j = t.length();
    while (i > 0 && j > 0){
        if (s[i - 1] == t[j - 1]){
            o = s[i - 1] + o;
            i--;
            j--;
        }else{
            if (vs[i - 1][j] > vs[i][j - 1]){
                i--;
            }else{
                j--;
            }
        }
    }
    cout << o;
}


Measured memory_bytes: 38956
using System;
using System.Linq;


namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var h = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(Count(h, 0, N));
        }

        static int Count(int[] arr, int start, int end)
        {
            if (end <= start) return 0;
            int min = int.MaxValue;
            for (int i = start; i < end; i++)
                if (arr[i] < min)
                    min = arr[i];
            for (int i = start; i < end; i++) arr[i] -= min;
            int count = min;
            int indexBuf = start;
            for (int i = start; i <= end; i++)
            {
                if (i == end || arr[i] == 0)
                {
                    count += Count(arr, indexBuf, i);
                    indexBuf = i + 1;
                }
            }

            return count;
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

int main()
{
	int A, B, C, D, E, F, x = 1, y = 1;
	cin >> A >> B >> C >> D >> E >> F;
	for (int i = 0; i <= F / (100 * A); ++i)
	{
		int a = i * 100 * A;
		if (a > F) break;
		for (int j = 0; j <= F / (100 * B); ++j)
		{
			int b = j * 100 * B;
			if (a + b > F) break;
			for (int k = 0; k < F / C; ++k)
			{
				int c = k*C;
				if (a + b + c>F) break;
				for (int l = 0; l < F / D; ++l)
				{
					int d = l*D;
					if (a + b + c + d>F || (c + d)>(a + b) / 100 * E) break;
					int rz = c + d, rj = a + b;
					if (x*(rz + rj) <= rz*(x + y))
					{
						x = rz;
						y = rj;
					}
				}
			}
		}
	}
	cout << x + y << " " << x;
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
        #include<iostream>
        #include<cstdio>
        #include<vector>
        #include<queue>
        #include<map>
        #include<cstring>
        #include<string>
        #include <math.h>
        #include<algorithm>
        #include<functional>
       #define int long long
        #define inf  1000000007
        #define pa pair<int,int>
#define ll long long
        #define pal pair<ll,ll>
        #define ppa pair<int,pa>
        #define EPS (1e-10)
        #define equals(a,b) (fabs((a)-(b))<EPS)

        using namespace std;

        class Point{
        	public:
        	double x,y;
        	Point(double x=0,double y=0):x(x),y(y) {}
        	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
        	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
        	Point operator * (double a) {return Point(x*a,y*a);}
        	Point operator / (double a) {return Point(x/a,y/a);}
        	double absv() {return sqrt(norm());}
        	double norm() {return x*x+y*y;}
        	bool operator < (const Point &p) const{
        		return x != p.x ? x<p.x: y<p.y;
        	}
        	bool operator == (const Point &p) const{
        		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
        	}
        };
        typedef Point Vector;

        struct Segment{
        Point p1,p2;
        };

    double hen(Vector a){
    if(fabs(a.x)<EPS && a.y>0) return acos(0);
    else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
    else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
    else if(fabs(a.y)<EPS && a.x>0) return 0.0;
    else if(a.y>0) return acos(a.x/a.absv());
    else return 2*acos(0)+acos(-a.x/a.absv());

    }

        double dot(Vector a,Vector b){
        	return a.x*b.x+a.y*b.y;
        }
        double cross(Vector a,Vector b){
        	return a.x*b.y-a.y*b.x;
        }
        int dx[4] = {1, 0, -1, 0};
        int dy[4] = {0, 1, 0, -1};
        //----------------kokomade temple------------
int n,m;
int l;
int a[10]={0};

int ch(int n){
	int u=n;
	while(1){
		if(u==0) break;
		if(a[u%10]==1) return false;
		u /=10;
	}
	return true;
	
}

signed main(){
int n,k;
	cin>>n>>k;
	for(int i=0;i<k;i++){
		int l;
		cin>>l;
		a[l]=1;
	}
	
	
	while(ch(n)==false) n++;
	cout<<n<<endl;
	
	
	return 0;
        }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	ll t1, t2, a1, a2, b1, b2;
	scanf("%lld%lld%lld%lld%lld%lld", &t1, &t2, &a1, &a2, &b1, &b2);
	if (a1 < b1) {
		swap(a1, b1);
		swap(a2, b2);
	}
	a1 -= b1;
	a2 -= b2;
	assert(a1 > 0);
	ll d = a1 * t1 + a2 * t2;
	if (d > 0) {
		printf("0\n");
	} else if (!d) {
		printf("infinity\n");
	} else {
		assert(a2 < 0);
		ll g = a1 * t1;
		// d * k + g >= 0.
		// g >= -d * k.
		ll k = g / (-d);
		ll ans;
		if (g % (-d) == 0) {
			ans = 2 * k;
		} else {
			ans = 1 + 2 * k;
		}
		printf("%lld\n", ans);
	}
}


Measured memory_bytes: 256
def input():
    import sys
    return sys.stdin.readline().rstrip()


def main():
    import math
    import collections
    import itertools

    n, k = map(int, input().split())
    a_b = [tuple(map(int, input().split())) for _ in range(n)]
    a_b.sort()

    sum_add_value = 0
    for v in a_b:
        sum_add_value += v[1]
        if sum_add_value >= k:
            print(v[0])
            break

if __name__ == '__main__':
    main()

Measured memory_bytes: 17296
#include <iostream>

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) sort(a.rbegin(),a.rend())
#define Sort(a) sort(a.begin(),a.end())
#define Sum(a)  accumulate(a.begin(), a.end(), 0)
#define rep(i,n) for(UI i=0;i<n;i++)

int main(int argc, const char * argv[]) {

	cin.tie(0);
	ios::sync_with_stdio(false);

	LL N, M;
	LL calc = 0;
	LL sum = 0;
	LL ans = 0;

	cin >> N >> M;

	vector<LL>X((UI)M);

	rep(i, M) {
		cin >> X[i];
	}

	Sort(X);
	vector<LL>Y;

	rep(i,X.size() - 1) {
		Y.push_back(X[i + 1] - X[i]);
		sum += Y[i];
	}

	rSort(Y);

	if (N>=M) {
		ans = 0;
	}
	else {
		
		rep (i,N - 1) {
			calc += Y[i]; // 除去する分
		}
		ans = sum - calc;
	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 2168
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[][] A = new int[3][3];
    String res = "";

    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        A[i][j] = sc.nextInt();
      }
    }
    int N = sc.nextInt();

    for (int k = 0; k < N; k++) {
      int b = sc.nextInt();

      for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
          if (b == A[i][j]) {
            A[i][j] = 0;
          }
        }
      }
    }
    if (A[0][0] == A[1][1] && A[1][1] == A[2][2] || A[0][2] == A[1][1] && A[1][1] == A[2][0] || A[0][0] == A[0][1] && A[0][1] == A[0][2] || A[1][0] == A[1][1] && A[1][1] == A[1][2] || A[2][0] == A[2][1] && A[2][1] == A[2][2] || A[0][0] == A[1][0] && A[1][0] == A[2][0] || A[0][1] == A[1][1] && A[1][1] == A[2][1] || A[0][2] == A[1][2] && A[1][2] == A[2][2]) {
      res = "Yes";
    } else {
      res = "No";
    }
    System.out.println(res);
  }
}

Measured memory_bytes: 23764
def main():
    inf = 1 << 30

    N = int(input())

    dp = [inf] * (N + 1)
    dp[0] = 0

    for i in range(1, N + 1):
        t = inf
        x = 1
        while x <= i:
            t = min(t, dp[i - x])
            x *= 6
        x = 1
        while x <= i:
            t = min(t, dp[i - x])
            x *= 9
        dp[i] = t + 1

    print(dp[N])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
#include "iostream"
#include "string"
#include "vector"
#include "algorithm"
#include "functional"
#include "cmath"

using namespace std;

int main() {
    // get values from input
    int K, S;
    cin >> K >> S;

    // main procedure
    int answer = 0;
    
    for (int A = max(S - 2*K, 0); A <= min(K, S); A++) {
        answer += min(K, S - A) - max(S - A - K, 0) + 1;
    }

    // output
    cout << answer << endl;
    return 0;
}

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

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N;
  string ans = "No";
  cin >> N;
  int sum = findSumOfDigits(N);
  if (N % sum == 0) {
    ans = "Yes";
  }
  
  
  cout << ans << endl;
}

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

a = [(int(i)) for i in range(m, m+n)]
t=100000
ne = False
for i in range(len(a)):
    if t>abs(a[i]):
        inde = i
        t=abs(a[i])
a[inde]=0
print(sum(a))


Measured memory_bytes: 3060
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

bool in[110];
int main() {
    int L; cin >> L;
    stack<int> st;
    
    int ng = -1;
    for(int i=0; i<L; i++) {
        int v; cin >> v;
        if(v < 0) {
            v = -v;
            if(!in[v]) ng = i+1;
            if(st.empty() or st.top() != v) ng = i+1;
            in[v] = false;
            st.pop();
        }
        else {
            if(in[v]) ng = i+1;
            in[v] = true;
            st.push(v);
        }
        
        if(ng != -1) break;
    }

    if(ng < 0) cout << "OK" << endl;
    else cout << ng << endl;
    return 0;
}



Measured memory_bytes: 3120
s = input()

S = []

A = 'A'
BC = 'BC'
X = 'X'

cursor = 0
while cursor < len(s):
    if s[cursor] == 'A':
        S.append(A)
        cursor += 1
        continue
    if cursor < len(s) - 1 and s[cursor] == 'B' and s[cursor+1] == 'C':
        S.append(BC)
        cursor += 2
    else:
        if len(S) > 0 and S[-1] == X:
            pass
        else:
            S.append(X)
        cursor += 1


score = 0
a_count = 0
for elm in S:
    if elm == A:
        a_count += 1
    elif elm == BC:
        score += a_count
    else:
        a_count = 0
print(score)


Measured memory_bytes: 53088
n = input()
s = input()
s_list = s.split()
s_list = [int(elem) for elem in s_list]
res = 0
for index in range(len(s_list)):
    left_list = s_list[:index+1]
    right_list = s_list[index+1:]
    left_sum = sum(left_list)
    right_sum = sum(right_list)
    if index == 0:
        res = abs(left_sum - right_sum)
    elif abs(left_sum - right_sum) < res:
        res = abs(left_sum - right_sum)
print(res)

Measured memory_bytes: 3064
from itertools import accumulate

N,W=map(int,input().split())

W0=[]
W1=[]
W2=[]
W3=[]

w,v=map(int,input().split())
W0.append(v)

for i in range(1,N):
  a,b=map(int,input().split())
  if a-w==0:
    W0.append(b)
  elif a-w==1:
    W1.append(b)
  elif a-w==2:
    W2.append(b)
  else:
    W3.append(b)

W0.sort(reverse=True)
W1.sort(reverse=True)
W2.sort(reverse=True)
W3.sort(reverse=True)
W0=list(accumulate(W0))
W0=[0]+W0
W1=list(accumulate(W1))
W1=[0]+W1
W2=list(accumulate(W2))
W2=[0]+W2
W3=list(accumulate(W3))
W3=[0]+W3

ans=0
for i in range(len(W0)):
  for j in range(len(W1)):
    for k in range(len(W2)):
      for l in range(len(W3)):
        if w*i + (w+1)*j + (w+2)*k + (w+3)*l <= W:
          ans=max(ans,W0[i]+W1[j]+W2[k]+W3[l])
print(ans)

Measured memory_bytes: 3064
n,a,b,c = map(int,input().split())
l =[int(input()) for i in range(n)]
inf = float("inf")

def dfs(cur,A,B,C):
  if cur == n:
    return abs(a-A) + abs(b-B)+abs(c-C)-30 if min(A,B,C)>0 else inf
  ret0 = dfs(cur+1,A,B,C)
  ret1 = dfs(cur+1,A+l[cur],B,C)+10
  ret2 = dfs(cur+1,A,B+l[cur],C)+10
  ret3 = dfs(cur+1,A,B,C+l[cur])+10
  return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))
  

Measured memory_bytes: 73992
// Your day breaks, your mind aches
// You find that all the words of kindness linger on
// When she no longer needs you
//#pragma GCC optimize ("Ofast,unroll-loops")
//#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <unistd.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0)
#define debug(x) cout << #x << " = " << x << endl
#define For(i,a,b) for (int i = a; i < b; i++)
#define roF(i,a,b) for (int i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int N = 1e6;
const ll INF = 1e18;
const ld EPS = 10e-9;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll random(ll a, ll b) { return uniform_int_distribution<ll> (a, b) (rng); }

long long LCM(long long a, long long b) {
	return a / __gcd(a, b) * b;
}

void solve() {
	long long n, m;
	cin >> n >> m;
	long long a[n];
	For(i,0,n) cin >> a[i];
	For(i,0,n) a[i] /= 2LL;
	long long lcm = a[0];
	if (lcm > m) {
		cout << 0 << endl;
		return;
	}
	For(i,1,n) {
		lcm = LCM(lcm, a[i]);
		if (lcm > m) {
			cout << 0 << endl;
			return;
		}
	}
	if (lcm % 2 == 0) {
		For(i,0,n) {
			long long falta = lcm / a[i];
			if (falta % 2 == 0) {
				cout << 0 << endl;
				return;
			}
		}
	}
	long long ans = m / lcm;
	ans = (ans + 1LL) / 2LL;
	cout << ans << endl;
}

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


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main()
{
	char s1[20],s2[20];
	int l1,l2,i;
	gets(s1);
	gets(s2);
	l1=strlen(s1);
	l2=strlen(s2);
	if(l1+1!=l2) {
		printf("No");
	}
	for(i=0;s1[i]!='\0';i++)
	{
		if(s1[i]!=s2[i]){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 1600
/*
senさんのブログ
*/

#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int N, T;

vector<pair<int, int>> AB;
int dp[3000 + 10][3000 + 10];

int main() {
	cin >> N >> T;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		AB.push_back(make_pair(a, b));
	}
	
	sort(AB.begin(), AB.end());
	
	int ans = 0;
	dp[0][0] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= T - 1; j++) {
			dp[i][j] = dp[i - 1][j];
			ans = max(ans, dp[i][j] + AB[i - 1].second);
			if (j - AB[i - 1].first >= 0)
				dp[i][j] = max(dp[i][j], dp[i - 1][j - AB[i - 1].first] + AB[i - 1].second);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 35584
def main():
    X = int(input())
    ans = 1
    for b in range(1,X+1):
        for p in range(2,10):
            a = b**p
            if a > X:
                break
            elif ans < a and a <= X:
                ans = a
            # print(b,p,a,ans)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 62532
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main(void)
{
    string s, t;
    cin >> s >> t;
    vector<int> pos[26];
    int N = s.size();
    lpn(i, N) pos[s[i]-'a'].push_back(i);
    ll ans = 0;
    vector<int>::iterator itr;
    int i;
    int count = 0;
    int now = -1;
    fa(c, t)
    {
        i = c - 'a';
        itr = upper_bound(all(pos[i]), now);
        if (itr == pos[i].end())
        {
            itr = upper_bound(all(pos[i]), -1);
            if (itr == pos[i].end())
            {
                cout << -1 << endl;
                return 0;
            }
            count++;
        }
        now = *itr;
    }
    cout << (ll)count * N + now + 1 << endl;
    return 0;
}

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

int main() {
  string a;
  cin>>a;
  string b="CODEFESTIVAL2016";
  int c=0;
  
  for(int i=0;i<16;i++){
    if(a.at(i)!=b.at(i)){
      c++;
    }
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())

if (B-A)%2 == 0:
    print((B-A)//2)
else:
    C =(A-1)+(B-A+1)//2
    D =(N-B)+(B-A+1)//2
    print(min(N-A,B-1,C,D))

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);

//二分累乗法 modを設定すること

ll dp[2100][2100];

signed main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> s(n,0),t(m,0);

    for(int i=0;i < n;i++)
    {
        cin>>s.at(i);
    }
    for(int i=0;i < m;i++)
    {
        cin>>t.at(i);
    }

    memset(dp, 0, sizeof(dp));
    dp[0][0]=1;

    for(int i=0;i < n+1;i++)
    {
        for(int j=0;j < m+1;j++)
        {
            if (i>0 && j>0 && s[i-1] == t[j-1]) dp[i][j] += dp[i-1][j-1];
            if(j>0)dp[i][j]+=dp[i][j-1];

            if(i>0)dp[i][j]+=dp[i-1][j];
            
            if (i-1 >= 0 && j-1 >= 0) dp[i][j] += mod-dp[i-1][j-1]%mod;
          
            dp[i][j]%=mod;
        }
    }
    cout << dp[n][m]%mod << endl;
}
/*共通文字列のDPは、それぞれの文字列をどこまで見たかに対応する二つの添え字をもってやる */


Measured memory_bytes: 34816
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const auto INF = (ll)1e9;
using v = vector<ll>;
using m = map<int,int>;
using vv = vector<v>;


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

    for (int i = 0; i < 1<<4; i++)
    {
        int ans=a_d[0]-'0';
        string s;
        s.push_back(a_d[0]);
        for (int j=1; j < 4; j++)
        {
            if(1&(i>>j)){
                ans += a_d[j]-'0';
                s.push_back('+');
            }else{
                ans -= a_d[j]-'0';
                s.push_back('-');
            }
            s.push_back(a_d[j]);
        }
      	if(ans == 7){
            cout << s<< "=7";
            break;
        }
    }
    
}


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

using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using Pint = pair<int, int>;
const ll mod = 1e9+7;


int main(int argc, char const* argv[])
{
  int n;
  ll d, a;
  cin>>n>>d>>a;
  vector<pair<ll,ll>> enemies;
  REP(i,n) {
    ll x, h;
    cin>>x>>h;
    enemies.emplace_back(x, h);
  }
  sort(ALL(enemies));

  ll ans = 0;
  ll total = 0;
  queue<pair<ll,ll>> q;
  for (int i = 0; i < n; i++) {
    ll x = enemies[i].first;
    ll h = enemies[i].second;
    while (q.size() && q.front().first < x) {
      total-=q.front().second;
      q.pop();
    }
    h -= total;
    if (h>0) {
      ll count = (h+a-1)/a;
      ll damage = count * a;
      ans += count;
      total+=damage;
      q.emplace(x+2*d, damage);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6256
line = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(line[k-1])

Measured memory_bytes: 3060