akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;



int main(){
  char b;
  cin >> b;
  char ans;
  if(b == 'A') ans = 'T';
  if(b == 'G') ans = 'C';
  if(b == 'C') ans = 'G';
  if(b == 'T') ans = 'A';

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3596
"use strict";
function main(input) {
    const args = input.split('\n');

    const N = parseInt(args[0]);
    const second = args[1];

    const Hs = second.split(' ');

    let hotels = [];

    let ans = 0;

    for(let i = 0; i < N; i++) {
        hotels.push(parseInt(Hs[i]))
    }

    let max_height = hotels[0];

    for(let i = 0; i < N; i++) {
        if(max_height <= hotels[i]) {
            ans++;
            max_height = hotels[i];
        }
    }
    console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7500
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        ArrayDeque<Long> q = new ArrayDeque<>();
        q.add(1L); q.add(2L); q.add(3L); q.add(4L); q.add(5L);
        q.add(6L); q.add(7L); q.add(8L); q.add(9L);
        for (int i = 0; i < k-1; i++) {
            long x = q.poll();
            long y = x%10L;
            if(y != 0) q.add(10*x + (y-1));
            q.add(10*x + y);
            if(y != 9) q.add(10*x + (y+1));
        }
        System.out.println(q.poll());
        sc.close();

    }

}


Measured memory_bytes: 32084
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    long long n,m;
         cin>>n;
   m=sqrt(n);
   cout<<n<<":";
    for(int i=2;i<=n;i++)
     {
      while(n%i==0){
        cout<<" "<<i;
        n/=i;
         }
   if(n==1)
     break;
      if(i>=sqrt(n))
        {
        cout<<" "<<n;
        break;
        }
}
    cout<<endl;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,l,r;
	scanf("%d",&n);
	int res=0;
	for(int i=1; i<=n; i++)
	{
		scanf("%d %d",&l,&r);
		res=res+r-l+1;
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
s = set(map(int, [input() for _ in range(m)]))
MOD = 10 ** 9 + 7
a = 1 if not 0 in s else 0
b = 1 if not 1 in s else 0
for i in range(2, n + 1):
    if i in s:
        a, b = b, 0
    else:
        a, b = b, (a + b) % MOD
print(b)

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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int main(){
  int N,K;
  cin>>N>>K;
  int cnt[101] = {0};
  for(int i(0);i<K;i++){
    int d;
    cin>>d;
    for(int j(0);j<d;j++){
      int a;
      cin>>a;
      cnt[a]++;
    }
  }
  int ans(0);
  for(int i(1);i<=N;i++){
    if(cnt[i] == 0) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
#define endl "\n"
#define int long long
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
#define mem(a,b) memset((a),(b),sizeof (a))
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF long long(1e18)
#define MOD 1000000007


void solve(){
	int x,y,a,b,c,sum=0;
	cin>>x>>y>>a>>b>>c;
	int red[a],green[b],cl[c];
	for(int i=0;i<a;i++){
		cin>>red[i];
	}
	for(int i=0;i<b;i++){
		cin>>green[i];
	}
	for(int i=0;i<c;i++){
		cin>>cl[i];
	}
	sort(red,red+a,greater<int>());
	sort(green,green+b,greater<int>());
	sort(cl,cl+c,greater<int>());
	vector<int> ans;
	for(int i=0;i<a&&i<x;i++){
		ans.pb(red[i]);
	}
	for(int i=0;i<b&&i<y;i++){
		ans.pb(green[i]);
	}	
	for(int i=0;i<c;i++){
		ans.pb(cl[i]);
	}
	sort(ans.rbegin(),ans.rend());
	for(int i=0;i<x+y;i++){
		sum+=ans[i];
	}
	cout<<sum<<endl;
}

int32_t main(){
    int t=1;
    while(t--)
        solve();
    return 0;
}




Measured memory_bytes: 9712
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<i64>();
    let mut sum = vec![0; n];
    sum[0] = a[0];
    for i in 1..n {
        sum[i] = a[i] + sum[i - 1];
    }
    let mut ans = std::i64::MAX;
    for i in 1..n {
        ans = min(ans, (sum[i - 1] - (sum[n - 1] - sum[i - 1])).abs());
    }
    println!("{}", ans);
}

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 read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

int NumberDigits(long long X){
	string NumStr = to_string(X);
	return NumStr.size();
}

int SumOfEachDigits(long long X){
	int S = NumberDigits(X);
	int sum = 0;
	for(int i = 0; i < S; i++){
			sum += X % 10;
			X /= 10;
	}
	return sum;
}

int main(){
	int N, A, B;
	cin >> N >> A >> B;
	long long sum = 0;
	for(int i = 1; i <= N; i++){
		int chc = SumOfEachDigits(i);
		if(chc >= A && chc <= B) sum += i;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val ls = in.map(_.split(' ').map(_.toInt).toArray)
  val N = ls(0).head
  val s = ls(1).sorted
  val min = s.head
  val max = s.last
  val span = max - min
  val diffs = (1 until s.size).map(i => s(i) - s(i-1)).sorted
  val r = diffs.takeRight(N-1).sum
  val ret = span - r
  println(ret)
}


Measured memory_bytes: 46712
#include <stdio.h>
#define MIN(a,b) ((a>b) ? b:a)
int main(void){
    int n,m,x,y,z;
    while(1){
        scanf("%d",&n);
        if(!n){break;}
        m=1e9;
        for(z=0;z*z*z<=n;z++){
            for(y=0;y*y<=n-z*z*z;y++){
                x=n-y*y-z*z*z;
                m=MIN(m,x+y+z);
            }
        }
        printf("%d\n",m);
    }
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_b() {
	ll n, m;
	//ll x, y;
	//ll a, b, c;
	//ll k;
	string s;
	ll l_ans = 0;
	float f_ans = 0;
	string s_ans;

	string o, e;
	cin >> o >> e;
	s_ans += o[0];
	rep(i, e.size()) {
		s_ans += e[i];
		if (i + 1 < o.size()) {
			s_ans += o[i + 1];
		}
	}

	cout << s_ans << "\n";
}

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

	solve_abc_b();

	return 0;
}


Measured memory_bytes: 256
# 文字列の結合は+,+=か、a.join(b)を使う
# 文字列のリストのソート。数字のリストのソートと変わらない。list.sort()でOK
n,l = map(int,input().split())
s = [ input() for _ in range(n)]
s.sort()
ans = "" #empty string
for i in range(n):
  ans += s[i]
print(ans)


Measured memory_bytes: 38256
from itertools import combinations_with_replacement

n, m, q = map(int, (input().split()))
lst = [list(map(int, input().split())) for i in range(q)]
ptn = combinations_with_replacement(range(1, m + 1), n)
ans = 0

for p in ptn:
    s = 0
    for l in lst:
        if p[l[1] - 1] - p[l[0] - 1] == l[2]:
            s += l[3]
    ans = max(ans, s)

print(ans)

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

int main() {

    double r;
    cin >> r;
    double menseki = r * r * 3.14159265358979323846;
    double ensyu = r * 2 * 3.14159265358979323846;
    printf("%f %f\n", menseki, ensyu);

}


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

#ifndef LOCAL
#define cerr dolor_sit_amet
#endif

#define mp make_pair
#define sz(x) ((int)((x).size()))
#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int , int > ipair;
typedef pair < ll , ll > lpair;
const int IINF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1000000007;
const double EPS = 1e-9;
const int DX[] = { 1,  0, -1,  0,  1, -1,  1, -1};
const int DY[] = { 0,  1,  0, -1,  1, -1, -1,  1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll sqr(ll x) { return x*x; } ll sqr(int x) { return (ll)x*x; }
double sqr(double x) { return x*x; } ld sqr(ld x) { return x*x; }
mt19937 mmtw(960172);
ll rnd(ll x, ll y) { static uniform_int_distribution<ll> d; return d(mmtw) % (y - x + 1) + x; }

// ========================================================================= //

const int N = 100179;

int main() {
    ios::sync_with_stdio(false);

    string n;
    cin >> n;
    int ans = (sz(n) - 1) * 9;
    int cans = 0;
    for (int i = 0; i < sz(n); ++i) {
        if (n[i] != '0')
            ans = max(ans, cans + (n[i] - '0' - 1) + 9 * (sz(n) - 1 - i));
        cans += n[i] - '0';
    }
    ans = max(ans, cans);
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

#define rep(i, n) for (long long i = 0; i < n; i++)

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

void solve() {
    ini(a, b, c);
    if (b - a == c - b)
        out("YES");
    else
        out("NO");
}


Measured memory_bytes: 3624
//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define Ryuga ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back

using namespace std;

const ll sz=1e5+5;
const ll szz=1e6+6;
const ll mod=1e9+7;

int main()
{
	Ryuga;

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("op.txt","w",stdout);
	// #endif

	clock_t startTime=clock();

	string s,t;
	cin>>s>>t;
	ll cnt=0;
	rep(i,0,(ll)s.size())
	{
		if(s[i]!=t[i])
		{
			cnt++;
		}
	}
	cout<<cnt;

	cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;

}//Goodbye...

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

#define t_case ll test;cin>>test;while(test--)
#define left(nod) 2*nod
#define right(nod) 2*nod+1
#define ss second
#define ff first
#define pb push_back
#define pll pair<ll,ll>
#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define deb(a) cout<<#a<<": "<<a;cout<<endl;
#define deba(a...) cout<<endl;cout<<#a<<": ";for(auto it:a)cout<<it<<" ";cout<<endl;

int main()
{
	FAST;//not faster than scanf printf
	ll d,t,s;cin>>d>>t>>s;
	
	if(s>=((double)d/t))cout<<"Yes";
	else cout<<"No";
	
	
}


Measured memory_bytes: 3584
def main():
    s = str(input())
    q = int(input())
    lst = [list(map(str, input().split())) for _ in range(q)]
    switch = 0  # 0が通常　1が前

    str_lst = [s]
    front_lst = []
    for i in range(q):

        if lst[i][0] == '1':
            switch = 1 - switch

        else:
            f = lst[i][1]
            c = lst[i][2]

            if f == '1':  # 先頭に追加

                if switch == 0:
                    front_lst.append(c)

                else:
                    str_lst.append(c)

            else:

                if switch == 0:
                    str_lst.append(c)

                else:
                    front_lst.append(c)

    front = ''.join(front_lst)
    front = front[::-1]
    after = ''.join(str_lst)
    answer = front + after

    if switch == 1:
        answer = answer[::-1]

    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 35184
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x; cin >> x;
  for(int i = 1; i < 10; i++){ 
   if( x%i == 0 && x/i <= 9){ cout << "Yes" << endl; return 0;
                }
    
  }
  cout << "No" << endl; return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f; 
typedef long long ll;

char a[200],b[200];
 
int main(){
    cin>>a>>b;
    int len=strlen(a);
    for(int i=0;i<len;i++){
    	if(a[i]!=b[i]){
    		printf("No");
    		return 0;
		}
	}
	printf("Yes");
    return 0;
}
 

Measured memory_bytes: 3684
n=input()
ans=0
for i in range(2**(len(n)-1)):
  l=[0]
  for j in range(len(n)-1):
    if i>>j&1:
      l.append(j+1)
  l.append(len(n))
  for j in range(len(l)-1):
    ans+=int(n[l[j]:l[j+1]])
print(ans)

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

int main(){
    int h,w;
    cin>>h>>w;
    string s[h];
    rep(i,h)cin>>s[i];
    vector<int> res(26);
    rep(i,h)for(auto c : s[i])res[c-'a']++;
    vector<int> cnt(4);
    rep(i,26){
        cnt[res[i]%4]++;
    }
    if(h%2&&w%2){
        int odd=cnt[1]+cnt[3];
        int even=cnt[3]+cnt[2];
        if(odd<=1&&even<=(h+w-1)/2)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else if(h%2){
        int odd=cnt[1]+cnt[3];
        int even=cnt[3]+cnt[2];
        if(odd==0&&even<=w/2)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else if(w%2){
        int odd=cnt[1]+cnt[3];
        int even=cnt[3]+cnt[2];
        if(odd==0&&even<=h/2)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else {
        int odd=cnt[1]+cnt[3];
        int even=cnt[3]+cnt[2];
        if(odd==0&&even==0)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int i[100];
	int x,n;
	scanf("%d",&x);
	for(n=0;n<x;n++){
		scanf("%d",&i[n]);
	}
	for(n=x-1;n>=0;n--){
		printf("%d",i[n]);
	
		
		if(n!=0){printf(" ");
		}
	}
	printf("\n");
	// your code goes here
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int h[n];
    int dp[n]={0};
    for(int i=0;i<n;i++)
    cin>>h[i];
    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; i++)
	 {
	 	
        dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]), dp[i-2]+abs(h[i-2]-h[i])) ;
    }
    cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; ++i) cin >> v[i];
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    int c;
    cin >> c;
    if (c < v[i]) sum += v[i] - c;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())

string STR;
vector<string> S;

bool bye_bye_paren(int b, int e){
  int cnt = 0;
  FOR(i, b, e){
    if(S[i] == "(") ++cnt;
    if(S[i] == ")") --cnt;
    if(cnt < 0) return false;
  }
  return (cnt == 0);
}

set<int> calc(int b, int e){
  //cout <<"-------" <<endl;
  //cout <<"begin = " <<b <<", end = " <<e <<endl;
  //FOR(i, b, e) cout <<S[i]; cout <<endl;
  set<int> ret;
  if(e - b == 1) ret.insert(atoi(S[b].c_str()));
  else if(S[b] == "(" && S[e - 1] == ")" && bye_bye_paren(b + 1, e - 1)) ret = calc(b + 1, e - 1);
  else {
    int cnt = 0;
    FOR(i, b, e){
      if(S[i] == "(") ++cnt;
      else if(S[i] == ")") --cnt;
      else if(cnt == 0 && (S[i] == "+" || S[i] == "-" || S[i] == "*" || S[i] == "/")){
        set<int> left = calc(b, i), right = calc(i + 1, e);
        for(set<int>::iterator it1 = left.begin(); it1 != left.end(); ++it1){
          for(set<int>::iterator it2 = right.begin(); it2 != right.end(); ++it2){
            if(S[i] == "+") ret.insert((*it1) + (*it2));
            if(S[i] == "-") ret.insert((*it1) - (*it2));
            if(S[i] == "*") ret.insert((*it1) * (*it2));
            if(S[i] == "/" && (*it2) != 0) ret.insert((*it1) / (*it2));
            //if(b == 1 && e == 14){
            //  cout <<"insert " <<endl;
            //  for(set<int>::iterator it = left.begin(); it != left.end(); ++it) cout <<(*it) <<", "; cout <<endl;
            //  for(set<int>::iterator it = right.begin(); it != right.end(); ++it) cout <<(*it) <<", "; cout <<endl;
            //  cout <<S[i] <<", " <<ret.size() <<endl;
            //  for(set<int>::iterator it = ret.begin(); it != ret.end(); ++it) cout <<(*it) <<", "; cout <<endl;
            //}
          }
        }
      }
    }
  }
  //cout <<"ret = ";
  //for(set<int>::iterator it = ret.begin(); it != ret.end(); ++it) cout <<(*it) <<", "; cout <<endl;
  return ret;
}

int main() {
  while(cin >>STR && STR != "#"){
    S = vector<string>();
    string tmp = "";
    REP(i, STR.length()){
      if(isdigit(STR[i])) tmp += STR[i];
      else{
        if(tmp != "") S.push_back(tmp);
        tmp = STR[i];
        S.push_back(tmp);
        tmp = "";
      }
    }
    if(tmp != "") S.push_back(tmp);
    //REP(i, S.size()) cout <<S[i] <<" | "; cout <<endl;
    set<int> ans = calc(0, S.size());
    cout <<ans.size() <<endl;
    //for(set<int>::iterator it = ans.begin(); it != ans.end(); ++it) cout <<(*it) <<", "; cout <<endl;
  }
  return 0;
}

Measured memory_bytes: 1256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8

using namespace std;
typedef pair<llong, llong> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

// 素因数分解 : O(√n)
vector<ipair> get_pfactors(llong n) {
    vector<ipair> res;
    for(llong i = 2; i * i <= n; ++i) {
        int j = 0;
        for(; n % i == 0; ++j)
            n /= i;
        if(j > 0)
            res.push_back(make_pair(i, j));
    }
    if(n != 1)
        res.push_back(make_pair(n, 1));
    return res;
}

llong A, B;
int main(int argc, char **argv) {
    cin >> A >> B;

    vector<ipair> A_pfac = get_pfactors(A);
    vector<ipair> B_pfac = get_pfactors(B);

    set<llong> pfac;
    for(int i = 0; i < A_pfac.size(); ++i)
        pfac.insert(A_pfac[i].first);
    
    llong res = 0;
    for(int i = 0; i < B_pfac.size(); ++i)
        if(pfac.find(B_pfac[i].first) != pfac.end())
            ++res;
    
    cout << res + 1 << endl;
}

Measured memory_bytes: 256
import sys
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

l1 = sys.stdin.readline()
N = int(l1.strip())
l2 = sys.stdin.readline()
l2 = l2.strip()
M = [int(x) for x in l2.split()]

X = lcm_list(M) - 1
Y = 0

for x in M:
  Y += X % x

print(Y)



Measured memory_bytes: 5460
#include <stdio.h>
int n;
char s[5];
int a, b, c, d;
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf(" %s", s);
		if (s[0] == 'A')a++;
		if (s[0] == 'W')b++;
		if (s[0] == 'T')c++;
		if (s[0] == 'R')d++;
	}
	printf("AC x %d\n", a);
	printf("WA x %d\n", b);
	printf("TLE x %d\n", c);
	printf("RE x %d\n", d);
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9 + 7, A = 2e3 + 2;
 
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
  	int n, m;
  cin >> n >> m;
  int x = 0;
  if (n < 10) 
    x = 100 * (10 - n);
  cout << m + x;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text.RegularExpressions;

namespace AtCoder_Core
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            MatchCollection matches = Regex.Matches(S, "ABC");
            Console.WriteLine(matches.Count);
           
        }
    }
}


Measured memory_bytes: 16184
/*i-=-1*/
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define in(n) for(int i=0;i<n;i++)
#define inj(n) for(int j=0;j<n;j++)
#define itn int
#define ll long long 
#define ull unsigned ll
#define int ll int
#define S second 
#define F first 
#define mod 1000000007
#define globalbool 2000000
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
using namespace std;
using namespace std::chrono;
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	auto start = high_resolution_clock::now();
	int n,k;
	cin>>n>>k;
	int A[k];
	in(k)
		cin>>A[i];
	if(accumulate(A,A+k,0)>=n)
		cout<<"Yes";
	else
		cout<<"No";

	auto stop = high_resolution_clock::now();
    //auto duration = duration_cast<microseconds>(stop - start); 
  
    //cout << "Time taken by function: "
    //<< duration.count() << " microseconds" << endl;
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var seqA = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var q = int.Parse(Console.ReadLine());
        var queries = new (long B, long C)[q];
        for (int i = 0; i < queries.Length;  ++i)
        {
            var bc = Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray();
            queries[i] = (bc[0], bc[1]);
        }

        var max = queries.Max(x => Math.Max(x.B, x.C));
        var bucket = new int[max + 1];
        for (int i = 0; i < seqA.Length; ++i)
        {
            ++bucket[seqA[i]];
        }

        var sum = 0L;
        for (int i = 0; i < seqA.Length; ++i)
        {
            sum += seqA[i];
        }

        var answers = new List<long>();
        for (int i = 0; i < queries.Length; ++i)
        {
            sum += bucket[queries[i].B] * (queries[i].C - queries[i].B);
            bucket[queries[i].C] += bucket[queries[i].B];
            bucket[queries[i].B] = 0;
            answers.Add(sum);
        }

        Console.WriteLine(string.Join(Environment.NewLine, answers));
    }
}


Measured memory_bytes: 49372
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <set>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;


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

   cout << a + a*a + a*a*a << endl;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mst(a, b) memset((a), (b), sizeof(a))
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)
#define pii pair<int, int>
#define pb push_back
const int INF = 0x3f3f3f3f;
const double eps = 1e-10;
const int maxn = 1e5 + 7;
const int maxm = 5e5 + 10;
ll w[maxn], v[maxn];
ll dp[maxn];
ll ans = 0;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    mst(dp, INF);
    for (int i = 0; i < n; ++i)
        cin >> w[i] >> v[i];
    dp[0] = 0;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 1e5; j >= v[i]; --j)
        {
            dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
            if (dp[j] <= m)
                ans = max(ans, (ll)j);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b,c=sort(parseMap(split(readline())))
    println(ifelse(a+b==c,"Yes","No"))
end
main()

Measured memory_bytes: 167876
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: int, B: int, C: int, K: int):
    r = A
    g = B
    b = C
    # r < g < b
    for i in range(K):
        if r >= g:
            g *= 2
        elif g >= b:
            b*=2
    if r<g<b: print(YES)
    else:print(NO)
   
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, C, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61920
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　 |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int N, M; string S;
set<int> E[201010];
int ok[201010], ok2[201010];
int acnt[201010], bcnt[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M >> S;
    rep(i, 0, M) {
        int a, b; cin >> a >> b;
        a--; b--;
        E[a].insert(b);
        E[b].insert(a);
    }

    rep(cu, 0, N) {
        int a = 0, b = 0;
        fore(to, E[cu]) {
            if (S[to] == 'A') a++;
            else b++;
        }
        if (0 < a and 0 < b) ok[cu] = 1;
    }

    rep(cu, 0, N) if (ok[cu]) {
        fore(to, E[cu]) if(ok[to]) {
            if (S[to] == 'A') acnt[cu]++;
            else bcnt[cu]++;
        }
    }

    queue<int> ng;
    rep(cu, 0, N) if (ok[cu]) {
        if (acnt[cu] == 0 or bcnt[cu] == 0) {
            ng.push(cu);
            ok[cu] = 0;
        }
    }

    while (!ng.empty()) {
        int cu = ng.front(); ng.pop();

        fore(to, E[cu]) if (ok[to]) {
            if (S[cu] == 'A') acnt[to]--;
            else bcnt[to]--;

            if (acnt[to] == 0 or bcnt[to] == 0) {
                ng.push(to);
                ok[to] = 0;
            }
        }
    }

    rep(cu, 0, N) if (ok[cu]) {
        printf("Yes\n");
        return;
    }
    
    printf("No\n");
}

Measured memory_bytes: 30544
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll mod = 10e9+7;

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prtd(n, var)  cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl
#define prt3(var1, var2, var3) cout << var1 << " " << var2 << " " << var3 << endl

//----------------------------------------------------------------
string digit(int n, int k){
  string s;
  if(k==0){s="0";}
  while(k>0){
    if(k%2==0){
      s.push_back('0');
    } else {
      s.push_back('1');
      k -= 1;
    }
    k/=2;
  }

  while(s.size()<n){
    s.push_back('0');
  }
  return s;
}

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

  vector<vector<int>> sw;
  rep(i,m){
    int k;
    cin >> k;
    vector<int> s(k);
    sw.push_back(s);
    rep(j,k){
      int tmp;
      cin >> tmp;
      sw[i][j]=tmp-1;
    }
  }
  vec cond(m);
  rep(i,m){
    cin >> cond[i];
  }
/*
  rep(i,m){
    prt2("-sw-", i);
    rep(j,sw[i].size()){
      prt(sw[i][j]);
    }
  }
*/
  //prt2("----------", m);
  ll ans=0;
  rep(i,pow(2,n)){
    int light=0;
    string pattern = digit(n, i);
    //prt2("pattern", pattern);

    rep(k,m){
      int on = 0;
      //prt2("light", k);
      rep(j,sw[k].size()){
        //prt2(" check",pattern[sw[k][j]]);
        if(pattern[sw[k][j]]=='1'){on++;}
      }
      if(on%2==cond[k]){
        light++;// prt("!");
      }
    }
    //prt2("light--->", light);
    if(light==m){
      ans++;
    }
  }

  //prt2("Answer--->", ans);
  prt(ans);
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) rep2(i,0,n-1)
int MOD=1000000000+7;
int INF=1e6;
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    rep(i,2){
        rep(j,2){
            int a[n]={};
            a[0]=i;
            a[1]=j;
            //1:正直　2:嘘
            rep2(k,1,n-2){
                if(s[k]=='o'){
                    if(a[k]) a[k+1]=a[k-1];
                    else a[k+1]=a[k-1]^1;
                }
                else{
                    if(a[k]) a[k+1]=a[k-1]^1;
                    else a[k+1]=a[k-1];
                }
            }
            bool flag=true;
            if(s[n-1]=='o'){
                if(a[n-1]){
                    if(a[n-2]!=a[0]) flag=false;
                }
                else {
                    if(a[n-2]==a[0]) flag=false;
                }
            }
            else{
                if(a[n-1]){
                    if(a[n-2]==a[0]) flag=false;
                }
                else {
                    if(a[n-2]!=a[0]) flag=false;
                }
            }
            if(s[0]=='o'){
                if(a[0]){
                    if(a[1]!=a[n-1]) flag=false;
                }
                else{
                    if(a[1]==a[n-1]) flag=false;
                }
            }
            else{
                if(a[0]){
                    if(a[1]==a[n-1]) flag=false;
                }
                else{
                    if(a[1]!=a[n-1]) flag=false;
                }
            }
            if(flag){
                rep(k,n){
                    if(a[k]) cout<<"S";
                    else cout<<"W";
                }
                return 0;
            }
        }
    }
    cout<<-1;
    return 0;
}


Measured memory_bytes: 896
#include <iostream>

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;

    long long ans = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] != t[i]) {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3860
s = input()
count_odd = 0
for i in range(len(s)): #010101のようにする
    if s[i] != str(i % 2):
        count_odd += 1
count_even = 0
for i in range(len(s)):
    if s[i] == str(i % 2):
        count_even += 1

print(min(count_odd, count_even))


Measured memory_bytes: 3188
import java.util.Scanner;

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

        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int goal_0 = 0;
        int goal_n = 0;

        int[] a = new int[m];
        for (int i = 0; i < m; i++) {
            a[i] = sc.nextInt();
            if (a[i] < x) {
                goal_0++;
            }
            if (a[i] > x) {
                goal_n++;
            }
        }
        System.out.println(Math.min(goal_0,goal_n));
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define INF 10000000000000000
#define MAX 200001
#define MOD 1000000007  

int main(){
    int M, K;
    cin >> M >> K;
    if(K == 0){
        for(int i = 0; i < pow(2,M); i++){
            if(i != pow(2,M) - 1) cout << i << ' ' << i << ' ';
            else cout << i << ' ' << i << endl;
        }
    }
    else if(K <= pow(2, M) - 1 && M != 1){
        for(int i = 0; i < pow(2,M); i++){
            if(i == K) continue;
            cout << i << ' ';
        }
        cout << K << ' ';
        for(int i = pow(2,M)-1; i >= 0; i--){
            if(i == K) continue;
            cout << i << ' ';
        }
        cout << K << endl;
    }
    else{
        cout << - 1 << endl;
    }
}

Measured memory_bytes: 4032
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void 
debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

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

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;

int ar[100005];

struct uf{
  static const int MAXN=100005;
  int par[MAXN];
  int size[MAXN];
  vector<int> ch[MAXN],val[MAXN];
  void init(){
    memset(par,-1,sizeof(par));
    REP(i,MAXN){
      size[i]=1;
      ch[i].pb(i);
      val[i].pb(ar[i]);
    }
  }
  int root(int a){
    if(par[a]==-1) return a;
    return par[a]=root(par[a]);
  }
  void unite(int a,int b){
    a=root(a);b=root(b);
    if(a==b) return;
    if(size[a]<size[b]) swap(a,b);

    par[b]=a;
    size[a]+=size[b];
    for(auto e:val[b]){
      val[a].pb(e);
    }
    for(auto e:ch[b]){
      ch[a].pb(e);
    }
  }
  bool same(int a,int b){
    return root(a)==root(b);
  }
};

uf u;
pi br[100005];
int n,m;
int main(){
  cin>>n>>m;
  REP(i,n) cin>>ar[i],--ar[i];

  u.init();

  REP(i,m){
    cin>>br[i].fr>>br[i].sc;
    --br[i].fr;--br[i].sc;
    u.unite(br[i].fr,br[i].sc);
  }
  int cnt=0;
  REP(i,n) if(u.root(i)==i){
    vector<int> A=u.val[i],B=u.ch[i];
    sort(ALL(A));
    for(auto e:B) if(binary_search(ALL(A),e)) ++cnt;
  }
  cout<<cnt<<endl;
  return 0;
}





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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> foods(M, 0);
	rep(i, N) {
		int K;
		cin >> K;
		rep(j, K) {
			int A;
			cin >> A;
			foods.at(A - 1)++;
		}
	}
	int ans = 0;
	rep(i, M) {
		if (foods.at(i) == N) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  double n, d;
  cin >> n >> d;
  double count = 0;
  for(int i = 0; i < n; i++){
    double x, y;
    cin >> x >> y;
    if(x*x + y*y <= d*d){
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 3752
#include<iostream>
using namespace std;
const int N=1e6+5;
const int p=998244353;
int cnt[N];
int ans[N];
int qpow(int a,int b){
    int res=1;
    while(b){
        if(b&1){
            res=1ll*res*a%p;
        }
        a=1ll*a*a%p;
        b>>=1;
    }
    return res;
}
int main()
{
    int n;
    cin>>n;
    int mx=0;
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        cnt[t]++;
        mx=max(mx,t);
    }
    for(int i=mx;i>=1;i--){
        int s1=0,s2=0;
        for(int j=i;j<=mx;j+=i){
            s1=(s1+1ll*cnt[j]*j%p)%p;
            s2=(s2+1ll*cnt[j]*j%p*j%p)%p;
        }
        ans[i]=(1ll*s1*s1%p-s2+p)%p;
        for(int j=i+i;j<=mx;j+=i){
            ans[i]=(ans[i]-ans[j]+p)%p;
        }
    }
    const int inv2=qpow(2,p-2);
    int s=0;
    for(int i=1;i<=mx;i++){
        s=(1ll*ans[i]*qpow(i,p-2)%p+s)%p;
    }
    s=1ll*s*inv2%p;
    cout<<s;
}

Measured memory_bytes: 8064
#include<stdio.h>

int main(void){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  a-=b;
  while(a>0){
    a--;;
    c--;
    if(c==0){
      break;
    }
  }
  printf("%d\n",c);
}


Measured memory_bytes: 1732
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pt;

#define fi first
#define se second
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

li n, d;

int main () {
    fastIO;
    cin >> n >> d;
    cout << (n+d*2)/(d*2+1);
}


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

#define to first
#define dist second

const int INF = 1e9;

int main() {
    int c, n, m, s, d;
    while (cin >> c >> n >> m >> s >> d, c) {
        s--, d--;
        vector <vector <pair <int, int>>> G(n);
        rep (i, m) {
            int a, b, f;
            cin >> a >> b >> f;
            a--, b--;
            G[a].emplace_back(b, f);
            G[b].emplace_back(a, f);
        }

        // state -> (dist, now, num of ticket)
        using state = tuple <int, int, int>;
        priority_queue <state> que;
        vector <vector <int>> dp(n, vector <int> (c + 1, INF));
        dp[s][0] = 0;
        que.emplace(0, s, 0);

        while (!que.empty()) {
            state p = que.top(); que.pop();
            int dist, now, numOfTicket;
            tie(dist, now, numOfTicket) = p;

            for (auto & next : G[now]) {
                if (numOfTicket < c && dp[next.to][numOfTicket + 1] > dist + next.dist / 2) {
                    dp[next.to][numOfTicket + 1] = dist + next.dist / 2;
                    que.emplace(dp[next.to][numOfTicket + 1], next.to, numOfTicket + 1);
                }
                if (dp[next.to][numOfTicket] > dist + next.dist) {
                    dp[next.to][numOfTicket] = dist + next.dist;
                    que.emplace(dp[next.to][numOfTicket], next.to, numOfTicket);
                }
            }
        }
        int ans = INF;
        rep (i, c + 1) ans = min(ans, dp[d][i]);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  REP(i,50000){
    if(int((double)i*1.08)==N){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<":("<<endl;
  return 0;
}


Measured memory_bytes: 256
#define L long long
m[31][50];main(n,p,d,x){L a[50],b;for(;scanf("%d",&n),n;){memset(m,0,6200);for(p=0;p<n;a[p]=1LL<<p,p++)for(scanf("%d",&x);x;x--)scanf("%d",&d),m[d][p]=1;for(d=1;d<31;d++){for(b=p=0;p<n;p++)if(m[d][p])b|=a[p];for(p=0;p<n;p++)if(m[d][p]&&(a[p]=b)==(1L<<n)-1){printf("%d\n",d);goto s;}}puts("-1");s:;}exit(0);}

Measured memory_bytes: 616
import java.util.*;

public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		long debt = 100000;
		for(int i = 0; i < n; ++i)
		{
			debt *= 1.05;
			long lessThanThousand = debt % 1000;
			if(lessThanThousand > 0)
			{
				debt += 1000 - lessThanThousand;
			}
		}
		System.out.println(debt);
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
#define INF (1ll<<60)
#define MAX 100005
typedef long long ll;
using namespace std;

int n;
int a[200000];

bool check(int bset, int a){
    return (bset ^ a) == (bset + a);
}

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

    int l = 0, r = 0;
    long long num = 0, bset = 0;
    for(;l < n;l++){
        while (r < n && check(bset, a[r])){
            bset += a[r];
            r++;
        }
        num += (r-l);

        if (r == l) r++;
        else {
            bset -= a[l];
        }
    }
    cout << num << endl;
}


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

ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

int main() {
    const int MAX_N = 305;
    const int INF = 1001001001;
    ll n, m, l; cin >> n >> m >> l;
    vector<vector<ll>> dist(MAX_N, vector<ll>(MAX_N, INF));
    rep(i, m) {
        ll a, b, c; cin >> a >> b >> c;
        a--;
        b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }
    rep(k, n) rep(i, n) rep(j, n) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }

    rep(i, n) rep(j, n) {
            if (dist[i][j] <= l) {
                dist[i][j] = 1;
            } else {
                dist[i][j] = INF;
            }
        }

    rep(k, n) rep(i, n) rep(j, n) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }

    int q; cin >> q;
    rep(i, q) {
        int s, t; cin >> s >> t;
        s--;
        t--;
        ll ans = dist[s][t] == INF ? -1 : dist[s][t]-1;
        cout << ans << endl;
    }

}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
    int i, o, t, j, l, s, z;
    cin >> i >> o >> t >> j >> l >> s >> z;
    long long int res = 0;
    if (i % 2 + l % 2 + j % 2 >= 2 && i > 0 && l > 0 && j > 0) {
        i--, l--, j--;
        res += 3;
    }
    res += i / 2 * 2;
    res += j / 2 * 2;
    res += l / 2 * 2;
    res += o;
    cout << res << endl;
}




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

typedef long long ll;
const int N = 104;

int ans[N][N];

int a[4][3] = {{1,2,3},{2,3,0},{3,1,0},{0,2,1}};

void solve(int l, int r, int move = 0){
	int len = r - l;	
	if(len == 4){
		for(int i = move; i < move + len - 1; ++i){
			for(int j = l; j < r; ++j){
				ans[j][i] = a[j-l][i - move] + l;
			}
		}
	}
	else if(len & 1){
		for(int i = move; i < move + len - 1; ++i){
			for(int j = l; j < r; ++j){
				ans[j][i] = (j + i - move + 1) % len + l;
			}
		}
	}
	else{
		solve(l,l + len/2,move);
		solve(l + len/2,r,move);
		for(int i = len/2 - 1; i < len - 1; ++i){
			for(int j = l; j < l + len/2; ++j){
				ans[j][i] = ((j + i - (len/2 - 1)) % (len/2) +len/2) % (len/2)  + l + len/2;
			}
			for(int j = l + len/2; j < r; ++j){
				ans[j][i] = ((j - (i - (len/2 - 1)) + 1) % (len/2) + len/2) % (len/2) + l;
			}
		}
	}
}

int main(){
	cout.precision(13);
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	if(n == 2){
		cout << -1 << '\n';
	}
	else{
		solve(0, n);	
		for(int i = 0;i < n; ++i){
			for(int j = 0;j < n -1 ; ++j){
				cout << ans[i][j] + 1 << ' ';	
			}
			cout << '\n';
		}
	}
}


Measured memory_bytes: 384
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
ll A[int(2e5 + 5)], B[int(2e5 + 5)];
priority_queue <Pli> que;

int main(){
  scanf("%d", &N);
  for (int i = 0; i < N; i++) scanf("%lld", A + i);
  for (int i = 0; i < N; i++){
    scanf("%lld", B + i);
    que.push({B[i], i});
  }

  ll ans = 0;
  while (!que.empty()){
    Pli Q = que.top(); que.pop();
    int now = Q.se; ll sum = 0;

    if (B[now] == A[now]) continue;

    if (now == 0) sum = B[N - 1] + B[1];
    else if (now == N - 1) sum = B[N - 2] + B[0];
    else sum = B[now - 1] + B[now + 1];

    if (sum >= B[now]){
      printf("-1\n"); return 0;
    }

    ll turn;
    if (A[now] >= sum){
      turn = (B[now] - A[now]) / sum;
    }else{
      turn = (B[now] / sum);
      if (B[now] % sum == 0) turn--;
    }

    ans += turn;
    B[now] -= turn * sum;

    if (turn <= 0){
      printf("-1\n"); return 0;
    }

    if (A[now] == B[now]) continue;
    if (A[now] > B[now]){
      printf("-1\n"); return 0;
    }
    que.push({B[now], now});
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 10048