akhauriyash/Code-Regression huggingface dataset:
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>
#include <iostream> // cout, endl, cin
#include <map>      // map
#include <math.h>
#include <numeric>
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <string>        // string, to_string, stoi
#include <tuple>         // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a.at(i);
    }

    for (int i = 0; i < N; i++)
    {
        if (a.at(i) % 2 == 0)
        {
            if ((a.at(i) % 3 == 0) || (a.at(i) % 5 == 0))
            {
            }
            else
            {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int n, a;

int main()
{
    int a;
    cin >> n >> a;
    int d = n % 500;
    if(d <= a){
        puts("Yes");
    }
    else{
        puts("No");
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n, m;
    string s;
    cin >> n >> m >> s;

    reverse(all(s));

    vl ans;
    ll now = 0;
    while(now != n) {
        bool ok = false;
        for(ll x = m; x >= 1; x--) {
            if(now + x > n) {
                continue;
            }
            if(s[now + x] == '1') {
                continue;
            }
            ans.pb(x);
            now += x;
            ok = true;
            break;
        }
        if(ok == false) {
            out(-1);
            re0;
        }
    }

    reverse(all(ans));

    for(auto p : ans) {
        cout << p << " ";
    }
    
    cout << endl;
    re0;
}

Measured memory_bytes: 1528
#include <cstdio>
#include <algorithm>
using namespace std;
int p[8], t[8], u[8], c[8] = { 1, 4, 1, 4, 1, 2, 1, 2 };
bool comp() {
	for(int j = 0; j < 8; j++) {
		if(t[j] > u[j]) return true;
		if(t[j] < u[j]) return false;
	}
	return false;
}
int main() {
	while(~scanf("%d%d%d%d%d%d%d%d", &p[0], &p[1], &p[2], &p[3], &p[4], &p[5], &p[6], &p[7])) {
		int ret = 999999999;
		for(int i = 0; i < 8; i++) t[i] = 5;
		for(int i = 0; i < 8; i++) {
			int res = 0;
			for(int j = i; j < i + 8; j++) res += max(p[j - i] - c[j % 8], 0), u[j - i] = c[j % 8];
			if(res < ret) {
				ret = res;
				for(int j = 0; j < 8; j++) t[j] = u[j];
			}
			else if(res == ret && comp()) {
				for(int j = 0; j < 8; j++) t[j] = u[j];
			}
		}
		for(int j = 0; j < 8; j++) printf(j ? " %d" : "%d", t[j]);
		printf("\n");
	}
	return 0;
}

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

#define visit fuckitwholefamily
#define ll long long
#define MAXN 100005
#define Int int

int n,ans;ll s[MAXN];
map <ll,int> tot;
map <ll,bool> vis;

template <typename T> inline void read (T &t){t = 0;char c = getchar();int f = 1;while (c < '0' || c > '9'){if (c == '-') f = -f;c = getchar();}while (c >= '0' && c <= '9'){t = (t << 3) + (t << 1) + c - '0';c = getchar();} t *= f;}
template <typename T,typename ... Args> inline void read (T &t,Args&... args){read (t);read (args...);}
template <typename T> inline void write (T x){if (x < 0){x = -x;putchar ('-');}if (x > 9) write (x / 10);putchar (x % 10 + '0');}

int cnt,prime[3405],visit[3405];

void Euler (int up){
	for (Int i = 2;i <= up;++ i){
		if (!visit[i]) prime[++ cnt] = i;
		for (Int j = 1;j <= cnt && i * prime[j] <= up;++ j){
			visit[i * prime[j]] = 1;
			if (i % prime[j] == 0) break; 
		}
	}
}

signed main(){
	read (n);Euler (3400);
	for (Int i = 1;i <= n;++ i){
		read (s[i]);
		for (ll p = 2;p * p * p <= s[i];++ p) while (s[i] % (p * p * p) == 0) s[i] /= p * p * p; 
		if (s[i] != 1) tot[s[i]] ++;
		else ans = 1;
	}
	for (Int i = 1;i <= n;++ i) 
		if (vis[s[i]] || s[i] == 1) continue;
		else{
			ll now = s[i],nowto = 1;
			for (Int j = 1;1ll * prime[j] * prime[j] * prime[j] <= now;++ j){
				if (now % prime[j] == 0){
					nowto *= (now % (prime[j] * prime[j]) == 0 ? prime[j] : prime[j] * prime[j]);
					while (now % prime[j] == 0) now /= prime[j];
				}
			}
			ll w = sqrt (now);
			if (w * w == now) nowto *= w;
			else nowto *= now * now;
			vis[s[i]] = vis[nowto] = 1,ans += max (tot[s[i]],tot[nowto]);
		}
	write (ans),putchar ('\n');
	return 0;
}

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

public class Main {
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int A = in.i();
        int B = in.i();
        int K = 50;
        int L = K * 2;
        char[][] s = new char[L][L];
        for (int i = 0; i < K; i++) {
            Arrays.fill(s[i], '#');
        }
        for (int i = K; i < L; i++) {
            Arrays.fill(s[i], '.');
        }
        for (int i = 0, j = 0, k = 0; i < A - 1; i++, k += 4) {
            if (L <= k) {
                k = (++j & 1) * 2;
            }
            s[j][k] = '.';
        }
        for (int i = 0, j = K + 1, k = 0; i < B - 1; i++, k += 4) {
            if (L <= k) {
                k = (1 - (++j & 1)) * 2;
            }
            s[j][k] = '#';
        }

        out.print(L);
        out.print(' ');
        out.println(L);
        for (int i = 0; i < L; i++) {
            out.println(s[i]);
        }
        out.flush();
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        int k = next() - '0';
        boolean minus = k == -3;
        long n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; (c = next()) != ' ' && c != '\n'; i++) cbuf[i] = c;
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, d;
  cin >> n >> d;
  vint x(n), y(n), b(n);
  rep(i, n) {
    cin >> x[i] >> y[i] >> b[i];
  }
  vint id(n);
  iota(all(id), 0);
  sort(all(id), [&](int i, int j){
      return b[i] < b[j];
    });
  int ans = 0;
  priority_queue<Pi> maxX, maxY;
  priority_queue<Pi, vector<Pi>, greater<Pi> > minX, minY;
  for(int i : id) {
    maxX.emplace(x[i], i);
    minX.emplace(x[i], i);
    maxY.emplace(y[i], i);
    minY.emplace(y[i], i);
    while(llabs(b[maxX.top().second]-b[i]) > d) maxX.pop();
    while(llabs(b[minX.top().second]-b[i]) > d) minX.pop();
    while(llabs(b[maxY.top().second]-b[i]) > d) maxY.pop();
    while(llabs(b[minY.top().second]-b[i]) > d) minY.pop();
    int a = maxX.top().first;
    int b = minX.top().first;
    int c = maxY.top().first;
    int d = minY.top().first;
    chmax(ans, (a-b)*(c-d));
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 21752
#include <stdio.h>
 
int main(void) { 
    int s;
    int count=0;
    scanf("%d",&s);
    for(int i=0;i<3;i++){
        if(s%10==1){
            count++;
        }
        s/=10;
    }
    printf("%d",count);
    return 0;
}


Measured memory_bytes: 888
#include<iostream>

#define rep(i,n) for(int i = 1; i <= n; i++)
#define MAX (90)

using namespace std;

int field[MAX+2][MAX+2];
int l;

void search(int y, int x, int hosu)
{
  field[y][x] = 0;
  if(field[y][x+1]){ search(y,x+1,hosu+1); }
  if(field[y][x-1]){ search(y,x-1,hosu+1); }
  if(field[y+1][x]){ search(y+1,x,hosu+1); }
  if(field[y-1][x]){ search(y-1,x,hosu+1); }
  if(hosu > l) l = hosu;
  field[y][x] = 1;
}

int main(void)
{

  int m, n;

  while(cin >> m >> n && m){
    rep(i,n) rep(j,m){
      cin >> field[i][j];
    }
    l = 0;
    rep(i,n) rep(j,m){
      if(field[i][j])
	search(i,j,0);
    }
    cout << l+1 << endl;
  }

  return 0;
}

Measured memory_bytes: 0
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	var ans = 0
  input = input.trim().split("\n");
	const [N, M] = input[0].split(" ").map((n) => parseInt(n));
	const hw = input[1].split(' ').map(n => parseInt(n))

	function arrsum(arr) {
		return arr.reduce((c, a, i, self) => {
			return c + a
		})
	}
	const d = arrsum(hw)
	if (d > N) {
		ans = -1
	} else {
		ans = N - d
	}

  //出力
  console.log(ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require("fs").readFileSync("./input.txt", "utf-8"));


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

int main() {
	int N;
	cin >> N;
	for (int i = 0;i < N; i++) {
		int a,b,c;
		cin >> a >> b >> c;
		if (2 * max(max(a,b),c) * max(max(a,b),c) == a*a+b*b+c*c ) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[200],n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
	{
		if(a[i]%2==0)
		{
			if(a[i]%3!=0&&a[i]%5!=0)
			{
			cout<<"DENIED";
			return 0;
			}
		}	
	}
	cout<<"APPROVED";
	return 0;
}

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

		long x = sc.nextLong();

		long a = 100l;

		int y = 0;
		while ( a<x ) {
			y++;
			a = a + a/100;
		}
		System.out.println(y);
	}
}

Measured memory_bytes: 35804
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;

int main(){
  int N;
  cin >> N;
  ll sa = 0;
  ll sb = 0;
  vector<ll> a(N),b(N);
  REP(i,N){
    cin >> a[i];
    sa += a[i];
  }
  REP(i,N){
    cin >> b[i];
    sb += b[i];
  }
  if(sa > sb){
    cout << "No" << endl;
    return 0;
  }
  ll o = sb - sa;
  ll oa = 0;
  ll ob = 0;
  REP(i,N){
    if(a[i] > b[i]) ob += a[i] - b[i];
    if(a[i] < b[i]){
      oa += (b[i] - a[i])/2;
      ob += (b[i] - a[i])%2;
    }
  }
  if(oa <= o && ob <= o) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
void AorB(int a,string b,string c) {if(a){cout<<b<<endl;}else{cout<<c<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
//    int a,b;
//    cin>>a>>b;
    string s;
    cin>>s;
//    if(a%b==0) cout<<-1<<endl;
//    else cout<<a<<endl;
    REP(i,0,s.size()-1) if(s[i]=='A' && s[i+1]=='C'){cout<<"Yes"<<endl;return 0;}
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    int A, B;
    cin >> A >> B;

    int result = max(A+B, max(A+A-1, B+B-1));
    cout << result << endl;
}

Measured memory_bytes: 256
<?php 

  $S = trim(fgets(STDIN));

  $tap = str_split($S);

  $count = count($tap);

  $result = "Yes";


  for ($i=0; $i < $count; $i++) {
      if ($i % 2 == 0 && $tap[$i] == "L") {
          $result = "No";
      } elseif (! ($i % 2) == 0 && $tap[$i] == "R") {
          $result = "No";
      }
  }

  echo $result;

?>

Measured memory_bytes: 4728
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int n, k;
  cin >> n >> k;
  cout << (n % k != 0) << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    vector<int> r(3, 3), c(3, 3);
    int d1 = 3, d2 = 3;
    int a[3][3];
    map<int, pair<int, int> > m;
    for(int i = 0; i < 3; i++) {
        for(int j = 0; j < 3; j++) {
            cin >> a[i][j];
            m.insert({a[i][j], {i, j}});
        }
    }
    int n, temp, flag = 0;
    pair<int, int> x;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> temp;
        if(m.find(temp) != m.end()) {
            x = m[temp];
            r[x.first]--;
            if(!r[x.first]) {
                flag = 1;
            }
            c[x.second]--;
            if(!c[x.second]) {
                flag = 1;
            }
            if(x.first + x.second == 2) d1--;
            if(!d1) {
                flag = 1;
            }
            if(x.first == x.second) d2--;
            if(!d2) {
                flag = 1;
            }
        }
    }
    if(flag) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxn=2e3+1000;
ll n,m;
string s;
int main(){
    //freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>n;
    cout<<10-n/200<<endl;
    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

unordered_map<long long, int, custom_hash> safe_map;

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    int n, shift;
    string s;
    cin>>shift>>s;
    n = s.size();
    for(int i=0;i<n;i++)
    {
        s[i] = ('A' + mod(s[i]-'A'+shift,26) );
    }
    cout<<s,nl;

    return 0;
}

Measured memory_bytes: 256
// AOJ ITP1_11_B Dice II
// 2018.4.29 bal4u
 
#include <stdio.h>
 
int face[7][7][4] = {
{{0},{0},{0},{0},{0},{0},{0}},
{{0},{0},{0,1,2,3},{0,1,3,5},{0,1,4,2},{0,1,5,4},{0}},
{{0},{0,2,1,4},{0},{0,2,3,1},{0,2,4,6},{0},{0,2,6,3}},
{{0},{0,3,1,2},{0,3,2,6},{0},{0},{0,3,5,1},{0,3,6,5}},
{{0},{0,4,1,5},{0,4,2,1},{0},{0},{0,4,5,6},{0,4,6,2}},
{{0},{0,5,1,3},{0},{0,5,3,6},{0,5,4,1},{0},{0,5,6,4}},
{{0},{0},{0,6,2,4},{0,6,3,2},{0,6,4,5},{0,6,5,3},{0}}};
int assign[7];
 
int main()
{
    int q, i, t, f;
 
    for (i = 1; i <= 6; i++) scanf("%d", assign+i);
    scanf("%d", &q);
    while (q--) {
        scanf("%d%d", &t, &f);
        for (i = 1; i <= 6; i++) {
            if (assign[i] == t) t = i;
            if (assign[i] == f) f = i;
        }
        printf("%d\n", assign[face[t][f][3]]);
    }
    return 0;
}


Measured memory_bytes: 2052
import numpy as np
input()
S = input()
X = np.zeros((26, ), dtype=np.int64)
Y = np.zeros((26, ), dtype=np.int64)

for c in S:
    Y[ord(c) - ord("a")] += 1

ans = 0
for c in S:
    X[ord(c) - ord("a")] += 1
    Y[ord(c) - ord("a")] -= 1
    ans = max(ans, (X.astype(bool) * Y.astype(bool)).sum())

print(ans)


Measured memory_bytes: 12872
#include<iostream>
#include<cstring>

long long k,len,x;
std::string s;

int main()
{
	std::cin>>s>>k;
	len=s.size();
	while(x<len&&s[x]=='1')x++;
	if(x+1<=k)std::cout<<s[x];
	else std::cout<<'1';
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <functional>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
typedef long long ll;

template<class T = ll>
struct Edge {
	int to;
	T cost;
	Edge() {}
	Edge(int to, T cost) : to(to), cost(cost) {}
	bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

template<class T = ll>
vector<T> Dijkstra(vector<vector<Edge<T>>> &edges, int st) {

	int V = (int)edges.size();
	const int INF = numeric_limits<T>::max();
	vector<T> dist(V, INF);
	dist[st] = 0;

	priority_queue<Edge<T>, vector<Edge<T>>, greater<Edge<T>>> p_que;
	p_que.emplace(dist[st], st);

	while (!p_que.empty()) {

		Edge<T> now(p_que.top().to, p_que.top().cost);
		p_que.pop();

		if (dist[now.to] < now.cost) continue;
		for (const Edge<T> &e : edges[now.to]) {
			T tmp_cost = now.cost + e.cost;
			if (dist[e.to] > tmp_cost) {
				dist[e.to] = tmp_cost;
				p_que.emplace(e.to, dist[e.to]);
			}
		}
	}

	return dist;
}

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

	int N;
	cin>>N;

	int u,v,len;
	vector<vector<Edge<int> > > edges(N);
	for(int i=0;i<N-1;i++){
		cin>>u>>v>>len; u--; v--;
		edges[u].emplace_back(v,len);
		edges[v].emplace_back(u,len);
	}

	auto ans = Dijkstra<int>(edges,0);

	for (auto& i : ans) {
		if(i%2){
      cout<<1<<"\n";
    }else{
      cout<<0<<"\n";
    }
	}
}

Measured memory_bytes: 6912
s=readline(STDIN)
sa=10000000000000000
for i in range(1,length(s)-2)
  num=s[i:i+2]
  #@show(num)
  tmp = 753-parse(Int64,num)
  if(tmp<0)
    tmp=tmp*-1
  end
  #@show(tmp)
  if(tmp<sa)
    sa=tmp
  end
end
println(sa)


Measured memory_bytes: 110340
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto & in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;


template<typename T, typename U>
std::enable_if_t<std::rank<T>::value == 0> fill_all(T & arr, const U & v) {
	arr = v;
}
template<typename ARR, typename U>
std::enable_if_t<std::rank<ARR>::value != 0> fill_all(ARR & arr, const U & v) {
	for (auto& i : arr) {
		fill_all(i, v);
	}
}

int64_t N;
int64_t T[2][3];
int64_t v[3];
int64_t cost[3];
int64_t dp[3][5000*5000+1];
//int32_t func(int i, int w) {
//	if (i == 3) { return w; }
//	if (dp[i][w] > 0) {
//		return dp[i][w];
//	}
//	dp[i][w] = std::max(0, func(i + 1, w));
//	if (w >= cost[i] && v[i]>cost[i]) {
//		dp[i][w] = std::max(dp[i][w], func(i, w - cost[i]) + v[i]);
//	}
//	return dp[i][w];
//}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (size_t i = 0; i < 2; i++)
	{
		in >> T[i][0] >> T[i][1] >> T[i][2];
	}

	for (size_t i = 0; i < 3; i++)
	{
		v[i] = T[1][i];
		cost[i] = T[0][i];
	}
	for (int i = 2; i >= 0; --i)
	{
		for (int w = 0; w <= N; ++w) {
			if (i == 2) {
				if (v[i] > cost[i]) {
					dp[i][w] = w % cost[i] + v[i] * (w / cost[i]);
				}
				else {
					dp[i][w] = w;
				}
			}
			else {
				dp[i][w] = 0;
				dp[i][w] = std::max(dp[i][w], dp[i + 1][w]);
				if (w >= cost[i]) {
					dp[i][w] = std::max(dp[i][w], dp[i][w - cost[i]] + v[i]);
				}
			}
		}
	}
	//N = func(0, N);
	N = dp[0][N];
	fill_all(dp, 0);
	for (size_t i = 0; i < 3; i++)
	{
		v[i] = T[0][i];
		cost[i] = T[1][i];
	}
	for (int i = 2; i >= 0; --i)
	{
		for (int w = 0; w <= N; ++w) {
			if (i == 2) {
				if (v[i] > cost[i]) {
					dp[i][w] = w % cost[i] + v[i] * (w / cost[i]);
				}
				else {
					dp[i][w] = w;
				}
			}
			else {
				dp[i][w] = 0;
				dp[i][w] = std::max(dp[i][w], dp[i + 1][w]);
				if (w >= cost[i]) {
					dp[i][w] = std::max(dp[i][w], dp[i][w - cost[i]] + v[i]);
				}
			}
		}
	}
	//N = func(0, N);
	N = dp[0][N];

	out << N << endl;

	return 0;
}
#endif


Measured memory_bytes: 586240
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    ll S;
    cin >> S;

    ll x1 = 1000000000;
    cout << 0 << " " << 0 << " " << x1 << " ";

    ll y1 = (S + x1 - 1) / x1;

    cout << x1 * y1 - S << " " << 1 << " " << y1 << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
#define rep(i,a,b) for(ll i=a;i<b;i++)
int main(){
    ll n,m;
    cin>>n>>m;
    vector<pair<ll,ll>> p(n);
    rep(i,0,n) {
        cin>>p[i].first>>p[i].second;
    }
    sort(p.begin(),p.end());
    ll ans=0,cnt=0,i=-1;
    while(cnt<m){
        i++;
        ans+=p[i].first*p[i].second;
        cnt+=p[i].second;
    }
    if(cnt>m){
        while(cnt>m){
            ans-=p[i].first;
            cnt--;
        }
    }
    cout<<ans;
}

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

#define ll long long
#define pb push_back

vector<int>g[100003];
vector<int>v(100003);
queue<int>q;

int main()
{
    int k,a,b;
    cin>>k>>a>>b;
    if((b/k)*k>=a)
    {
        cout<<"OK"<<endl;
    }
    else
    {
        cout<<"NG"<<endl;
    }
}









Measured memory_bytes: 5984
n,y = map(int,input().split())
for i in range(n+1):
    if (y-1000*n-9000*i) % 4000 == 0:
        b = (y-1000*n-9000*i) // 4000
        if b >= 0 and n >= i+b >= 0:
            print(i,b,n-i-b)
            exit()
print(-1,-1,-1)


Measured memory_bytes: 3060
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<sstream>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
#include <cstdio>
using namespace std;

int main() {
	int i, j=0;
	int N;
	int seq = 0;
	int res[100000] = {};
	i=0;
	cin >> N;
	while (seq < N) {
		seq = i * i;
		res[i] = seq;
		if (seq <= N) {
			++i;
		}

	}
	cout << res[i-1];
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
int a[90000];

int readTime(void) {
    int h, m, s;
    scanf("%d:%d:%d", &h, &m, &s);
    return h*3600+m*60+s;
}

int main(void)
{
    int n;
    while (scanf("%d", &n), n) {
        int i, res=0;
        memset(a, 0, sizeof(a));
        while (n--) {
            int s=readTime();
            int e=readTime();
            for(i=s;i<e;++i) ++a[i];
        }
        for(i=0;i<86400;++i) res=res<a[i]?a[i]:res;
        printf("%d\n", res);
    }
    return 0;
}

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

#define int long long
#define vi vector<int>
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) FOR (i, 0, n)

int mod = 1000000;

vector<int> g[1005];

int nCr[1005][1005];
int nCrinit() {
    nCr[0][0] = 1;
    FOR (i, 1, 1005) {
        rep (j, i+1) {
            if (j == 0 || j == i) {
                nCr[i][j] = 1;
            } else {
                nCr[i][j] = nCr[i-1][j-1] + nCr[i-1][j];
                nCr[i][j] %= mod;
            }
        }
    }
}

pair<int, int> dfs(int u) {
    int sz = 1, res = 1;
    vector<pair<int, int>> sub;
    for (auto& to : g[u]) {
        pair<int, int> st = dfs(to);
        sz += st.first;
        sub.push_back(st);
    }

    int remsz = sz - 1;
    for (auto& nxt : sub) {
        res *= nCr[remsz][nxt.first] * nxt.second % mod;
        res %= mod;
        remsz -= nxt.first;
    }
    return {sz, res};
}

signed main() {
    nCrinit();
    int n; cin >> n;
    int a[n], b[n];
    vi cnt(n, 0);
    rep (i, n-1) {
        cin >> a[i] >> b[i];
        cnt[b[i]-1]++;
    }
    int winner;
    rep (i, n) {
        if (!cnt[i]) winner = i + 1;
    }
    a[n-1] = 1007, b[n-1] = winner;
    rep (i, n) {
        rep (j, n) {
            if (b[i] == a[j]) {
                g[i].push_back(j);
            }
        }
    }

    cout << dfs(n-1).second << endl;
}


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


int main(){
    int max = INT_MAX;
    
    int n, k;
    cin >> n >> k;
    vector<int> h(10000010);

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

    vector<int> dp(10000000);
    for(int i = 0; i < 1000000; i++){
        dp.at(i) = max;
    }

    dp.at(0) = 0;
    //dp.at(1) = abs(h.at(0) - h.at(1));
    /*for(int i = 1; i < k; i++){
        dp.at(i) = abs(h.at(i) - h.at(0));
    }*/

  
    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k; j++){
            dp.at(i + j) = min(dp.at(i + j), dp.at(i) + abs(h.at(i) - h.at(i + j)));
        }
    }

    cout << dp.at(n - 1) << endl;
}

Measured memory_bytes: 78464
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(); 
		int k = sc.nextInt(); 
		int denkou = 1;
		for(int i = 0; i < n; i++) {
			if(denkou+k > denkou*2) {
				denkou *= 2;
			} else {
				denkou += k;
			}
		}
		System.out.println(denkou);
	}
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N, K; cin >> N >> K;
	vector<int>A(N); rep(i, 0, N) { cin >> A[i]; }

	loop(K) {
		vector<int>B(N + 1);
		rep(i, 0, N) {
			B[max(0ll, -A[i] + i)]++;
			B[min(N, i + A[i] + 1)]--;
		}
		rep(i, 1, N + 1) {
			B[i] += B[i - 1];
		}
		if (A == B)break;
		swap(A, B);
	}
	rep(i, 0, N) {
		cout << A[i] << (i == N - 1 ? '\n' : ' ');
	}

	return 0;
}


Measured memory_bytes: 6288
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b) {a = b; return true;}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b) {a = b; return true;}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
    set<ll> se;
    ll n; cin >> n;
    vl a(n); rep(i,n) cin >> a[i];
    rep(i,n){
        if(se.find(a[i]) == se.end()) se.insert(a[i]);
        else{
            puts("NO");
            return 0;
        }
    }
    puts("YES");
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define endl '\n'
#define pi 3.1415926535897932384626433832
#define ll long long
using namespace std;
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / __gcd(a, b); }
bool isPrime(int n) {if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false;
    return true;}



int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a;
    cin>>a;
    vector<int> tba(a,0);
    int ans;
    for(int i=1;i*i*6<=a;i++){
        for (int j = i;i*i+j*j*3+i*j*2<=a; j++) {
            for (int l = j;; l++) {
                ans = i * i + j * j + l * l + i * l + i * j + j * l;
                if (ans > a) {
                    break;
                }
                if (i==l) {
                    tba[ans-1]++;
                } else if (j==l || j==i) {
                    tba[ans-1] += 3;
                } else tba[ans-1] += 6;

            }
        }
    }
    for(auto po:tba){
        cout<<po<<endl;
    }
    return 0;
}


Measured memory_bytes: 3636
def main():
  X, Y, A, B, C  = map(int, input().split())
  aka_list = sorted([int(t) for t in input().split()],reverse=True)[:X]
  midori_list = sorted([int(t) for t in input().split()],reverse=True)[:Y]
  mu_list = sorted([int(t) for t in input().split()],reverse=True)
  
  sum_list = sorted(aka_list + midori_list + mu_list ,reverse=True)[:X+Y]
  print(sum(sum_list))

main()

Measured memory_bytes: 22544
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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()
{
    int n; cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;

    rep(i, n-1){
        ans += a[i]/2;
        a[i] %= 2;

        if(a[i]==0) continue;

        if(a[i+1]>0){
            a[i]--;
            a[i+1]--;
            ans += 1;
        }
    }

    ans += a[n-1]/2;
    pr(ans);
    return 0;}

Measured memory_bytes: 3784
#include <iostream>
using namespace std;
int main(){

    int D, G, p[11], c[11];
    cin >> D >> G;
    for(int i = 0; i < D; ++i){
        cin >> p[i] >> c[i];
    }
    
    int ans = 1e9;
    for(int mask = 0; mask < (1 << D); ++mask){
        
        int s = 0, num = 0, rest_max = -1;
        
        for(int i = 0; i < D; ++i){//完全にとく、全くとかないでnum
            if(mask >> i & 1){//完全に溶けたら次のif文とばしてminに
                s += 100 * (i+1) * p[i] + c[i];
                num += p[i];
            }else{
                rest_max = i;//使わない問題のうち一番点数が高い問題の添え字
            }
        }
        
        if(s < G){//完全にとく、とかないで足りなかった場合、中途半端にとく問題を考える
            int s1 = 100 * (rest_max + 1);//一問の点数
            int need = (G - s + s1 - 1) / s1;
            //int need = (G-s)/s1;
            if(need >= p[rest_max]){//needが上限までだった場合違う
                continue;
            }
            num += need;
        }
        
        ans = min(ans, num);
    }
    cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
n = int(input())

dp = [[10**10] * (n+1) for _ in range(4)]
for i in range(4):
    dp[i][0] = 0

for i in range(1,4):
    for j in range(n+1):
        if i == 1:
            if j > 0:
                dp[i][j] = min(dp[i-1][j], dp[i-1][j-1]+1, dp[i][j-1]+1)
        elif i == 2:
            for k in range(1,10):
                if j - 6**k >= 0:
                    dp[i][j] = min(dp[i][j],dp[i-1][j], dp[i-1][j-6**k]+1, dp[i][j-6**k]+1)
                else:
                    dp[i][j] = min(dp[i-1][j],dp[i][j])
        else:
            for k in range(1,10):
                if j - 9**k >= 0:
                    dp[i][j] = min(dp[i][j],dp[i-1][j], dp[i-1][j-9**k]+1, dp[i][j-9**k]+1)
                else:
                    dp[i][j] = min(dp[i-1][j], dp[i][j])

print(dp[-1][-1])



Measured memory_bytes: 47836
/**************************
*                         *
*  Nothing Is Impossible  *
*                         *
**************************/
#include <algorithm>
#include <iostream>
#include <fstream>
#include <ctype.h>
#include <string>
#include <vector>
#include <math.h>
#include <cmath>
#include <map>
#define GetRand(Min, Max) ((rand()%(int)(((Max) + 1)-(Min))) + (Min))
#define Rep(i, min, max) for (int i = min; i < max; ++i)
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef long double ld; 
using namespace std;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll M1,D1,M2,D2;
	cin >> M1 >> D1 >> M2 >> D2;
	if(M2 == M1)
	{
		cout << 0 << endl;
	}
	else{
		cout << 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
def solve(K, A, B):
    if B - A <= 2:
        return K + 1
    elif K <= A:
        return K + 1
    else:
        K -= (A - 1)
        if K <= 2:
            return (K // 2) * B
        else:
            if K % 2 == 0:
                return B + (K // 2 - 1) * (B - A)
            else:
                return B + (K // 2 - 1) * (B - A) + 1


if __name__ == "__main__":
    K, A, B = tuple(map(int, input().split(" ")))
    print(solve(K, A, B))


Measured memory_bytes: 3060
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repbit(n) for(ll bit=0,bit<(1<<n),bit++)
inline constexpr int intpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans*(b&1?a:1);
}
inline constexpr int modpow(ll a,ll b){
    if(b==0) return 1;
    ll ans=intpow(a,b/2);
    return ans*ans%MOD*(b&1?a:1)%MOD;
}
int main(){
    ll n,k;
    cin>>n;
    string s,t;
    cin>>s;
    cin>>k;
    rep(i,0,n){
        if(s[i]==s[k-1]) t[i]=s[k-1];
        else t[i]='*';
    }
    rep(i,0,n) cout<<t[i];

}

Measured memory_bytes: 256
# 1行目の入力を数値として扱う
n = int(input())

# 剰余算の準備
ans = False

# ループ
for i in range(1, 10):
    m = n % i
    if m == 0:
        d = n / i
        if d <= 9:
            ans = True
            break

# 答えの出力
if ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
   int n,d;
   cin >> n >>d;
   int x[n][d];
   rep(i,n) {
       rep(j,d){
           cin >> x[i][j];
       }
   }
   double sum = 0;
   int count =0;
   for(int i=0;i<n-1;i++){
       for(int k=i+1;k<n;k++){
          for (int j=0 ; j < d; j++){
             sum += pow(x[i][j]-x[k][j],2);
          }
       sum = sqrt(sum);
       if(ceil(sum)==floor(sum)) count ++;
       sum =0;
}
   }

   cout << count << endl;



    return 0;
}


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

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int n;
    int flag=0, ans=0;
    
    scanf("%d", &n);
    
    for (int i=1; i<=n; i=i+2) {
        flag=0;
        for (int j=1; j<=n; j++) {
            if (i%j==0) {
                flag++;
            }
        }
        if (flag==8) {
            ans++;
        }
    }
    
    printf("%d", ans);
    
    return 0;
}


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

int main(){
	int r, c;
	while ( cin >> r >> c , r || c ){
		int s[10001] = {0};
		for(int y=0 ; y < r ; y++ ){
			for(int x=0 ; x < c ; x++ ){
				int e;
				cin >> e;
				if( e ) s[x] |= (1 << y);
			}
		}
		int ans = 0;
		for(int bits=0 ; bits < (1<<r) ; bits++ ){
			int a = 0;
			for(int x=0 ; x < c ; x++ ){
				int n=0, m = s[x] ^ bits;
				while( m != 0 ){
					n++;
					m &= m-1;
				}
				a += max( n , r-n );
			}
			ans = max( ans , a );
		}
		cout << ans << endl;
	}
}

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

int main(){
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	long long e=0, f=0, g=0, h=0, i=0, j=0, k=0, l=0, m=0, n=0, o=0, p=0, x=c, y=d;
	if(a%c==0)
		e=a/c-1;
	else
		e=a/c;
	f=b/c;
	g=f-e;
	if(a%d==0)
		h=a/d-1;
	else
		h=a/d;
	i=b/d;
	j=i-h;
	if(x<y){
		k=x;
		x=y;
		y=k;
	}
	int t=0;
	while(y!=0){
		t=x%y;
		x=y;
		y=t;
	}
	l=c*d/x;
	if(a%l==0)
		m=a/l-1;
	else
		m=a/l;
	n=b/l;
	o=n-m;
	p=b-a+1;
	cout<<p-g-j+o<<endl;
	return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const int N = 1e6+5;
string s;
vector<int> v[N];
int n;
ll a[N];

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  cin >> s;
  rep(i, s.length()) {
    s[i] = s[i] + n;
    if(s[i] > 'Z') s[i] = s[i] - ('Z' - 'A' + 1);
  }
  cout << s << endl;
}


Measured memory_bytes: 25344
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;

signed main(void){
    
    long long S;
    cin >> S;
    
    //dp[i]:=i桁の数列で条件を満たすものの数
    vector<long long> dp(S+1,0);
    vector<long long> dp_sum(S+1,0);
    
    for(long long i=3;i<=S;i++){
        //dp[i]=sum(dp[0],..,dp[i-3])+1
        
        dp[i] = (dp_sum[i-3]+1)%MOD;
        dp_sum[i] = (dp[i]+dp_sum[i-1])%MOD;
    }
    
    cout << dp[S] << endl;
    
    return 0;
}


Measured memory_bytes: 3652
#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 n;
int cards[2521];
int dp[2521][2521]; // dp[i][j] := X has i, Y has j, (i<j ? max : min) score

int mxs[2521], mns[2521];

void upd(int i,int j){
  int v = dp[i][j];
  // mxs[j] = max dp[j+1~][j]
  if(i>j)CHMAX(mxs[j], v);
  if(i<j)CHMIN(mns[i], v);
}

int main(){
  cin>>n;
  cin>>cards[0]>>cards[1];
  REP(i,n)cin>>cards[i+2];
  n += 2;
  // init
  REP(i,n){
    mxs[i] = -1;
    mns[i] = (int)2e9;
  }
  REP(i,n)REP(j,n){
    dp[i][j] = i<j ? -1 : (int)2e9;
    if(i==n-1 || j==n-1){
      dp[i][j] = abs(cards[i]-cards[j]);
      upd(i,j);
    }
  }
  FORR(i,0,n-1)FORR(j,0,n-1)if(i!=j){
    if(i<j){
      int mx = mxs[j];
      dp[i][j] = mx;
    }else{
      int mn = mns[i];
      dp[i][j] = mn;
    }
    upd(i,j);
  }
  printf("%d\n",dp[0][1]);
  return 0;
}


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

#define INF 1000000009
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N;i++){
        cin >> h[i];
    }
    vector<int> dp(N,INF);
    dp[0] = 0;
    for (int i = 0; i < N;i++){
        for (int j = 1; j <= K;j++){
            if(i+j<N){
                dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
            }
        }
    }
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1024