akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;
using ll = long long;
using ull = unsigned long long;

#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define MAP map<int,int>
#define QUE queue<int>
#define DEQ deque<int>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;
const ll INF = (ll)1e17;


void ANS(bool flag) {
	cout << ((flag) ? "YES" : "NO") << endl;
}

void Ans(bool flag) {
	cout << ((flag) ? "Yes" : "No") << endl;
}

void ans(bool flag) {
	cout << ((flag) ? "yes" : "no") << endl;
}

int main() {
	int N; ull K;
	cin >> N >> K;
	vector<ull> A(N), B(N);
	REP(i, N) cin >> A[i] >> B[i];
	bool bit1[30] = {};
	REP(i, 30) if (K & (1 << i)) bit1[i] = true;

	ull sum = 0,value = 0;

	REP(j, N) if (K == (K | A[j])) sum += B[j];
	value = max(sum, value);

	REP(i, 30) {
		if (!bit1[i]) continue;
		ull K_ = K;
		bitset<30> bit(K_);
		bit.reset(i);
		REP(j, i) bit.set(j);
		K_ = bit.to_ullong();
		sum = 0;
		REP(j, N) if (K_ == (K_ | A[j])) sum += B[j];
		value = max(sum, value);
	}
	cout << value << endl;
	
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>

using ll = long long;
int main(int argc, char ** argv)
{
  //
  int k;
  std::cin >> k;
  int ary[] = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
               1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  std::printf("%d\n", ary[k-1]);
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	a--
	n := lcm(c, d)

	ac := a / c
	ad := a / d
	acd := a / n

	bc := b / c
	bd := b / d
	bcd := b / n

	fmt.Println((b - a) - (bc + bd - bcd) + (ac + ad - acd))
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}

func gcd(x, y int) int {
	for x%y != 0 {
		x, y = y, x%y
	}
	return y
}


Measured memory_bytes: 512
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>


using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, std::string S){
  stack<char> st;
  for(auto x: S) {
    if(x == '(') {
      st.push(x);
    } else {
      if(!st.empty() and st.top() == '(')
	st.pop();
      else
	st.push(x);
    }
  }
  ll l = 0;
  ll r = 0;
  while(!st.empty()) {
    char x = st.top();
    if(x == '(')
      r++;
    else
      l++;
    st.pop();
  }
  for(int i=0; i<l; i++)
    std::cout << '(';
  std::cout << S ;
  for(int i=0; i<r; i++)
    std::cout << ')';
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::string S;
  std::cin >> S;
  solve(N, S);
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

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

    String s = sc.next() + sc.next();

    if (isSquareRoot(Integer.parseInt(s))) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }

  private static boolean isSquareRoot(int num) {

    int i = 1;

    while ((i * i) <= num) {

      if ((i * i) == num) {
        return true;
      }

      i++;

    }

    return false;
  }
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> a(N);

  for(int i=0; i < N; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  int sum = 0;
  for(int i=0; i<N; i++){
    
    if(i%2 == 0){
      //alice
      sum += a[i];
    }else{
      sum -= a[i];
    }
  }
  cout << sum<< endl;
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readInteger()
    val a = readLine()!!
    val b = readLine()!!
    val c = readLine()!!
    
    var ans = 0
    for (i in 0 until n) {
        val tmp = listOf(a[i], b[i], c[i]).distinct().size
        if (tmp == 2) {
            ans++
        } else if (tmp == 3) {
            ans += 2
        }
    }
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 35888
#include<iostream>
#include <cstdio>
#include<cstring>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) {if (x % y == 0) return y;else return LGCD(y, x % y);}
ll LLCM(ll x, ll y) {return x * y / LGCD(x, y);}

int GCD(int x, int y) {if (x % y == 0) return y;else return GCD(y, x % y);}
int LCM(int x, int y) {return x * y / GCD(x, y);}
ll dp[10000][10000];
ll combination(ll n, ll r) {
         if (n == r){dp[n][n] = 1;}
	else if (r == 0) {return dp[n][0] = 1;}
	else if (r == 1) {return dp[n][1]=n;}
	else {dp[n][r]=dp[n - 1][r - 1] % 1000000007 + dp[n - 1][r] % 1000000007;
	return dp[n][r]=combination(n - 1, r - 1) % 1000000007 + combination(n - 1, r) % 1000000007;}
}

int top, S[1000];

void push(int x) {
	S[++top] = x;
}

int pop() {
	top--;
	return S[top + 1];
}
int main() {
	int a, b;
	top = 0;
	char s[100];
	while (scanf("%s",s)!= EOF) {
		if (s[0] == '+') { a = pop();b = pop();push(a + b); }
		else if (s[0] == '-') { b = pop();a = pop();push(a - b); }
		else if (s[0] == '*') { a = pop();b = pop();push(a*b); }
		else { push(atoi(s)); }
	}

	printf("%d\n", pop());
		return 0;
}


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

using namespace std;

using ll = long long;

int main() {

    ll a, b, x;

    cin >> a >> b >> x;
    ll ans = b / x - a / x;
    if(a % x == 0)
        ans++;

    cout << ans << endl;

    return 0;


}

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

int main() {
    ll k,a,b;
    cin>>k;
    ll ans=0;
    ll y;

    while(k>100)
    {
        y = ceil( k / 1.01);
        y=k-y;
        //cout<<y<<endl;
        k -=y;
        ans++;
    }
    
    cout<<ans;
}

Measured memory_bytes: 3752
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String n = saori.nextHayami();
		String ans = "ABC" + n;
		System.out.println(ans);
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
 
int main(){ 
long long a,b;
cin>>a>>b;
  int s;
for(int i=1; i<=b; i++){
  s=(a*i)%b;
  if(s==0){
  cout<<a*i<<endl;
  break;
  }
}
}

Measured memory_bytes: 256
#include <stdio.h>

int i, H, A[2000000];

int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}

void maxHeapify(int *A, int i){
  int largest, tmp;
  int l = left(i), r = right(i);
  if(l <= H && A[l] > A[i]){
    largest = l;
  }
  else{
    largest = i;
  }
  if(r <= H && A[r] > A[largest]){
    largest = r;
  }
  if (largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(A, largest);
  }
}

void buildMaxHeap(int *A){
  for(i=H/2; i>=1; i--){
    maxHeapify(A, i);
  }
}

int main(){
 
  scanf("%d",&H);
  for(i=1; i<=H; i++){
    scanf("%d",&A[i]);
  }
  buildMaxHeap(A);
  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");

  return 0;
}
 

Measured memory_bytes: 2560
import bisect
N = int(input())
L = list(map(int, input().split()))
ans = 0
L.sort()
for a_i in range(N-2):
    for b_j in range(a_i+1, N-1):
        c_idx = bisect.bisect_left(L, L[a_i]+L[b_j])
        if c_idx > b_j:
            ans += c_idx - b_j - 1
print(ans)

Measured memory_bytes: 74492
//?????´????????????0???n-1?????´????????????
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
#define int long long
using namespace std;

const int inf = 1e+12;

int n, m, c;
vector<int> et[100000];
vector<int> ec[100000];
int cost[100000];

int allCost;				//allCost = ??¨???????????????
map<int, int> ecost;		//ecost[x] = ??´??°x??????????????¨?????????????????????????????´??°x-1??\?????????????????¨??????????????????????????????????????????

void Dijkstra(){
	typedef pair<int, int> P;
	static priority_queue<P, vector<P>, greater<P> > que;
	int i;
	
	for( i = 0; i < n; i++ ) cost[i] = inf;
	que.push(P(0, 0));
	while(!que.empty()){
		P now = que.top();
		int dist = now.first;
		int pos = now.second;
		que.pop();
		if( cost[pos] <= dist )
			continue;
		cost[pos] = dist;
		
		for( i = 0; i < et[pos].size(); i++ ){
			int npos = et[pos][i];
			int ndist = dist + ec[pos][i];
			que.push(P(ndist, npos));
		}
	}
}

void set_allCost(){
	int i, j;
	
	//?????????2???????????????1?????¨????????±??????????????????????????????2??§?????? 
	allCost = 0;
	for( i = 0; i < n; i++ ){
		for( j = 0; j < et[i].size(); j++ ){
			allCost += ec[i][j];
		}
	}
	allCost /= 2;
}

void set_ecost(){
	int i, j;
	
	//?????????2???????????????1?????¨????????±??????????????????????????????2??§??????
	ecost[0] = 0;
	for( i = 0; i < n; i++ ){
		for( j = 0; j < et[i].size(); j++ ){
			int u = i;
			int v = et[i][j];
			int x = max(cost[u], cost[v]);
			if( ecost.find(x) == ecost.end() ){ ecost[x] = 0; }
			ecost[x] += ec[i][j];
		}
	}
	for( map<int, int>::iterator it = ecost.begin(); it != ecost.end(); it++ ){
		(*it).second /= 2;
	}
}

signed main()
{
	int i;
	
	cin >> n >> m >> c;
	for( i = 0; i < m; i++ ){
		int a, b, d;
		cin >> a >> b >> d;
		a--; b--;
		et[a].push_back(b);
		et[b].push_back(a);
		ec[a].push_back(d);
		ec[b].push_back(d);
	}
	Dijkstra();
	set_allCost();
	set_ecost();
	
	int ans = inf;
	int cst = 0;
	
	//x?????¢?´¢??????
	for( map<int, int>::iterator it = ecost.begin(); it != ecost.end(); it++ ){
		int x = (*it).first;
		cst += (*it).second;
		ans = min(ans, allCost + c * x - cst);
	}
	cout << ans << endl;
}

Measured memory_bytes: 27284
#include<bits/stdc++.h>
using namespace std;
int n,l;
string s[105];
int main()
{
    cin>>n>>l;
    for(int i=0;i<n;i++)
    {
        cin>>s[i];
    }
    sort(s,s+n);
    for(int i=0;i<n;i++)
    cout<<s[i];
    return 0;
}

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

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
//

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

  int n;
  cin >> n;
  vector<int> p(n), q(n), s(n);
  for (int i = 0; i < n; i++) s[i] = i + 1;
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int i = 0; i < n; i++) cin >> q[i];

  int a = 0, b = 0, cnt = 1;
  do {
    bool ok = true;
    for (int i = 0; i < n; i++) {
      if (p[i] != s[i]) ok = false;
    }
    if (ok) a = cnt;

    ok = true;
    for (int i = 0; i < n; i++) {
      if (q[i] != s[i]) ok = false;
    }
    if (ok) b = cnt;
    cnt++;
  } while (next_permutation(s.begin(), s.end()));

  cout << abs(a - b) << endl;

  return 0;
}

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(int i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const ll powll = 1LL<<1;

int main(void){
   int n,m; cin >> n >> m;
   int s[n];
   rep(i,0,n) s[i] = -1;
   vector<vector<int>> p(n);
   rep(i,0,m){
       int a,b; cin >> a >> b;
       if(a > b) swap(a,b);
       p[a-1].push_back(b-1);
       p[b-1].push_back(a-1);
   }
   queue<int> que;
   que.push(0);
   while(que.size()){
       int i = que.front();
       que.pop();
       rep(j,0,p[i].size()){
        //    cout << i << " " << p[i][j] << "\n";
           if(s[p[i][j]] == -1){
               s[p[i][j]] = i+1;
               que.push(p[i][j]);
           }
           
       }
   }
   cout << "Yes\n";
   rep(i,1,n){
       cout << s[i] << "\n";
   }
}

Measured memory_bytes: 10332
k = int(input())
ok = [0]*k
x=7 % k
ok[x] = 1
if x == 0:
  print(1)
else:
  now = 1
  while 1:
    now += 1
    x = (x*10 +7) % k
    if ok[x] == 1:
      print(-1)
      break
    elif x == 0:
      print(now)
      break
    else:
      ok[x] = 1


Measured memory_bytes: 16668
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout);
using namespace std;
const int MAXN = 100005;
int n, s[MAXN];

bool cmp(const int &x, const int &y) {
    return x > y;
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &s[i]);
    sort(s + 1, s + n + 1, cmp);
    int x = 1, y = 1, a, b;
    while (x < n && y < s[x + 1])
        x++, y++;
    a = 0, b = (s[x++] - y) & 1;
    while (x <= n)
        if (y <= s[x++])
            a ^= 1;
        else
            break;
    printf(a || b ? "First" : "Second");
    return 0;
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main(void)
{
	int N,K;
  
  cin>>N;
  cin>>K;
  
  int ans=K;
  
  for(int i=0;i<N-1;i++)
  {
    ans*=(K-1);
  }
  
  cout<<ans<<endl;
}
  
 
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n, m;
  cin >> n >> m;
  ll ans;
  if (n == 1 && m == 1) ans = 1;
  else if (n == 1) ans = m-2;
  else if (m == 1) ans = n-2;
  else ans = (ll)(n-2)*(m-2);
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int d[101]; //1-origin

int main(void){
	int s,t;
	bool ok = true;
	vector<pair<int,int> > v;
	
	while(cin >> s >> t){
		if(s == 0 && t== 0){
			ok = true;
			for(int i=1;i<=100;i++){
				//cout << "d[" << i << "] = " << d[i] << endl;
				if(i <= 2){
					if(d[i] % 2 == 0){
						cout << "NG" <<endl;
						ok = false;
						break;
					}
				}else{
					if(d[i] % 2 == 1){
						cout << "NG" <<endl;
						ok = false;
						break;
					}
				}
			}
			if(ok) cout << "OK" << endl;
			fill(d, d+101, 0);
		}else{
			d[s]++;
			d[t]++;
		}
	}
	
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	std::cin >> a;
}
template<class _T> static void getint(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

static void exec()
{
	LLONG N, A, B, C, D;
	getint(N, A, B);
	getint(C, D);
	
	LLONG sumYi = B - A;
	for (LLONG m = 1; m < N; m++) {
		LLONG left = C * (N - 1 - m) - D * m;
		LLONG right = D * (N - 1 - m) - C * m;

		if ((left <= sumYi) && (sumYi <= right)) {
			printf("YES\n");
			return;
		}
	}
	printf("NO\n");
}


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

int main(){
  int n; cin >>n;
  int ans = 0;
  map<int, int> mp;
  rep(i,n){
    int a = 0; cin >>a;
    mp[a]++;
  }
  for(auto p : mp){
    if(p.second %2 != 0) ans++;
  }
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 8088
from itertools import permutations
n,m=map(int,input().split())
con=[[0]*n for _ in range(n)]
for _ in range(m):
	a,b=map(int,input().split())
	con[a-1][b-1]=con[b-1][a-1]=1
ans=0
for p in permutations(range(n)):
	if p[0]!=0:
		continue
	if all(con[x][y] for x,y in zip(p,p[1:])):
		ans+=1
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>

long gcd(long a, long b)
{
	if (b == 0) {
		return (a);
	}
	
	gcd(b, a % b);
}
int main(void)
{
	long a;
	long b;
	long c[100000][2];
	int n;
	int i;
	
	n = 0;
	
	while (scanf("%ld %ld", &a, &b) != EOF) {
		c[n][0] = gcd(a, b);
		c[n][1] = a / gcd(a, b) * b;
		n++;
	}
	
	for (i = 0; i < n; i++) {
		printf("%ld %ld\n", c[i][0], c[i][1]);
	}
	
	return (0);
}

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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define ABS(x, y) ((x) > (y) ? ((x) - (y)) : ((y) - (x)))

#define DIVUP(x, y) (((x) + ((y) - 1)) / (y))
#define DIVOFF(x, y) (((x) + ((y) / 2)) / (y))
#define REMAINDER(x, y) ((x) % (y))

#define MAX_N 100000
int A[MAX_N], B[MAX_N], C[MAX_N];

int main() {
  int N; scanf("%d", &N);
  for (int i{}; i < N; ++i) scanf("%d", &A[i]);
  for (int i{}; i < N; ++i) {
    scanf("%d", &B[i]);
    C[i] = A[i] - B[i];
  }
  sort(C, C + N);

  set<int> mod;
  int i{}, j{N - 1};
  while (i < N && j >= 0 && C[i] < 0 && C[j] > 0) {
    int move = MIN(-C[i], C[j]);
    C[i] += move;
    C[j] -= move;
    mod.insert(i);
    mod.insert(j);
    if (C[i] == 0) ++i;
    if (C[j] == 0) --j;
  }

  printf("%d\n", i < N && C[i] >= 0 ? mod.size() : -1);
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1)
  {
    sz = 1;
    while (sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x)
  {
    seg[k + sz] = x;
  }

  void build()
  {
    for (int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x)
  {
    k += sz;
    seg[k] = x;
    while (k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b)
  {
    Monoid L = M1, R = M1;
    for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if (a & 1) L = f(L, seg[a++]);
      if (b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const
  {
    return seg[k + sz];
  }
};

void solve() {
  int N, Q; cin >> N >> Q;
  SegmentTree<int> seg(N, [](int a, int b){ return a + b; }, 0);
  string s;
  cin >> s;
  rep(i, N - 1) {
    if (s.substr(i, 2) == "AC") seg.update(i + 1, 1);
  }
  rep(_, Q) {
    int l, r; cin >> l >> r;
    cout << seg.query(l, r) << '\n';
  }
}


Measured memory_bytes: 2128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k,a,b;
  cin>>k>>a>>b;
  int r;
  r=(b/k)*k;
  if(a<=r){
    cout<<"OK"<<endl;
  }
  else{
    cout<<"NG"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin>>N;
  vector<int> v(N);
  vector<int> c(N);
  for(int i=0;i<N;i++){
  cin>>v.at(i);
  }
  for(int i=0;i<N;i++){
  cin>>c.at(i);
  }
  
  int ans=0;
  for(int i=0;i<N;i++){
  if(v.at(i)>c.at(i)) {
        ans+=v.at(i)-c.at(i);
      }
  }
  
  
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	cout << (T / A) * B << endl;
}

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

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

  vector<vector<int>> d(C+1,vector<int> (C+1));
  vector<vector<int>> c(N+1,vector<int> (N+1));

  for (int i = 1; i <= C; i++)
  {
    for (int j = 1; j <= C; j++)
    {
      cin >> d[i][j];
    }
  }

  for (int i = 1; i <= N; i++)
  {
    for (int j = 1; j <= N; j++)
    {
      cin >> c[i][j];
    }
  }

  vector<vector <int>> cost(3,vector<int> (C+1));  //グループ(0,1,2)のマスの色をCに変えたときのコストを記録
  for (int i = 1; i <= N; i++)
  {
    for (int j = 1; j <= N; j++)
    {
      int g = (i+j)%3;       //(i,j)が属するグループ
      int color = c[i][j];   //(i,j)の色
      for (int k = 1; k <= C; k++)
      {
        cost[g][k]+=d[color][k];    //(i,j)の色をkに変えたときのコストを取ってきて、グループごとに和で管理
      }      
    }
  }
  
  int ans = 1000000000;
  for (int i = 1; i <= C; i++)
  {
    for (int j = 1; j <= C; j++)
    {
      if (i==j) continue;
      for (int k = 1; k <= C; k++)
      {
        if (i==k||j==k) continue;
        int res = cost[0][i]+cost[1][j]+cost[2][k];
        ans = min(ans,res);
      }
    }
  }
  
  cout << ans << endl;  
}

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

int main() {
    int N, W; cin >> N >> W;
    ll w[N], v[N];
    for (int i=0; i<N; i++){
        cin >> w[i] >> v[i];
    }
    ll dp[N+1][W+1];
    for (int i=0; i<=W; i++){
        dp[0][i] = 0;
    }
    for (int i=0; i<N; i++){
        for (int j=0; j<=W; j++){
            if (j-w[i] < 0){
                dp[i+1][j] = dp[i][j];
            }
            else{
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
            }
        }
    }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 79104
import math
N = int(input())
l = len(str(N))
K = int(input())
def calc(a, b, c):
    t = 0
    if a-b-1>=0:
        t = (math.factorial(a-1) // (math.factorial(a-b-1) * math.factorial(b)))*(9**(b))
    if b==1:
        t2 = int(str(c)[0])
    else:
        t2 = (math.factorial(a-1) // (math.factorial(a-b) * math.factorial(b-1)))*(9**(b-1))*(int(str(c)[0])-1)
    t3 = 0
    try:
        n = int(str(c)[1:])
        if 2<=b<=len(str(n))+1:
            t3 = calc(len(str(n)), b-1, n)
    except:
        pass
    return t+t2+t3

if l>=K:
    print(calc(l, K, N))
else:
    print(0)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String s = sc.next();
		char[] sArray = s.toCharArray();
		sc.close();
		int passStudent = 0;
		int passStrudentAbroad = 0;
		for (int i = 0; i < n; i++) {
			String ans = "No";
			if (sArray[i] == 'a' && a + b > passStudent) {
				passStudent++;
				ans = "Yes";
			} else if (sArray[i] == 'b' && a + b > passStudent && passStrudentAbroad < b) {
				passStudent++;
				passStrudentAbroad++;
				ans = "Yes";
			}
			System.out.println(ans);
		}
	}

}


Measured memory_bytes: 35544
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int K, X;
    cin >> K >> X;

    for (int i = X - K + 1; i < X + K; ++i)
    {
        if (i != X - K + 1) cout << " ";
        cout << i;
    }

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
 using namespace std;
 int main(){
     string a1,a2,a3,a4,a5,a6,a7,a8;
     cin>>a1>>a2>>a3;
     a4=a1+a2+a3;
     int i;
     for(i=0;i<a4.length();i++){
        a5=a4[0];
        a6=a4[4];
        a7=a4[8];
        a8=a5+a6+a7;
     }
     cout<<a8<<endl;

     return 0;
 }


Measured memory_bytes: 256
import copy
D,G = map(int, input().split())
m = [0]*D
for i in range(D):
    m[i] = list(map(int,input().split()))
score = 0
count = 0
ans = 0

for i in range(1 << D):
    l = copy.deepcopy(m)
    score = 0
    count = 0
    for j in range(D):
        if i >> j & 1 == 1:
            score += l[j][1] + l[j][0]*(j+1)*100
            count += l[j][0]
            l[j][0] = 0
    k = D-1
    while score < G:
        if l[k][0] > 1:
            l[k][0] -= 1
            score += 100*(k+1)
            count += 1
        else:
            k -= 1
            if k < 0:
                break
    if score >= G:
        if ans > count or ans == 0:
            ans = count

print(ans)

Measured memory_bytes: 54492
import sys
[[print("{0:.3f} {1:.3f}".format(round((t[2] - t[1] * (t[0] * t[5] - t[2] * t[3]) / (t[0] * t[4] - t[1] * t[3])) / t[0], 3), round((t[0] * t[5] - t[2] * t[3]) / (t[0] * t[4] - t[1] * t[3]), 3))) for t in [[int(y) for y in x.split()]]] for x in sys.stdin]

Measured memory_bytes: 7572
// https://atcoder.jp/contests/abc105/tasks/abc105_b
"use strict";
function Main(input) {
  const n = Number(input);
  let ok = false;
  for (let i = 0; i <= 25; i++) {
    for (let j = 0; j <= 14; j++) {
      const sum = 4 * i + 7 * j;
      if (n - sum === 0) {
        ok = true;
      }
    }
  }

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


Measured memory_bytes: 7372
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define vul vector<ull>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi2d vector<vi >
#define vl2d vector<vl >
#define vpll vector<pll >

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rz resize
#define fr(i,n) for(i=0;i<(n);i++)
#define frr(i,n) for(i=(n-1);i>=0;i--)
#define fre(i,n) for(i=0;i<=(n);i++)
#define frre(i,n) for (i=(n);i>=0;i--)
#define frab(i,a,b) for(i=(a);i<(b);i++)
#define freab(i,a,b) for(i=(a);i<=(b);i++)
#define frrab(i,a,b) for(i=(b-1);i>=a;i--)
#define frreab(i,a,b) for(i=(b);i>=a;i--)

#define sz(a) int((a).size())
#define mset(a,b) (memset(a,b,sizeof(a)))
#define max3(a,b,c) (max((a),max((b),(c))))
#define min3(a,b,c) (min((c),min((a),(b))))
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector <ll> sprime;
vector<char> prime (1000000, true);
void sieve(ll n)
{
  //O(nloglogn) time
  sprime.pb(0);
  prime[0] = prime[1] = false;
  ll cnt = 0;
  for (ll i = 2; i <= n; ++i)
  {
    if (prime[i])
    {
      cnt++;
      sprime.pb(i);
      for (ll j = 2 * i; j <= n; j += i)
        prime[j] = false;
    }
  }
}
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll fastpowMOD(ll a, ll p, ll MOD) { if (p == 0) return 1; ll z = fastpowMOD(a, p / 2, MOD); z = (z * z) % MOD; if (p % 2) z = (z * a) % MOD; return z; }
ll fastpow(ll a, ll p) { if (p == 0) return 1; ll z = fastpow(a, p / 2); z = (z * z); if (p % 2) z = (z * a); return z; }

#define mod 1000000007
#define inf LLONG_MAX
#define minf LLONG_MIN
#define pi 3.14
#define ex 2.71

//*********************************************///
const int N = 1e5 + 5;
int i,j;
ll w[N];
ll v[N];


ll dp[105][N];
int n,wt;
ll knap(int i,int wj)
{
  if(wj<=0 || i<=0)
    return 0;
  if(dp[i][wj]!=-1)
    return dp[i][wj];

  if(w[i]>wj)
    return dp[i][wj]=knap(i-1,wj);
  else
    return dp[i][wj]=max(knap(i-1,wj),knap(i-1,wj-w[i])+v[i]);

}

void solve()
{
  cin>>n>>wt;
  freab(i,1,n)
    cin>>w[i]>>v[i];
  mset(dp,-1);
  cout<<knap(n,wt)<<endl;
}

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


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

using namespace std;

int main()
{
    int n, l;

    cin >> n >> l;

    vector<string> list;

    string word;
    for (int i = 0; i < n; i++)
    {
        cin >> word;
        list.push_back(word);
    }

    sort(list.begin(), list.end());
    for (auto const &s : list)
    {
        cout << s;
    }

    cout << endl;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main{
	static int n = 0;
	static Integer[] cardSet = null;

	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		n = stdIn.nextInt();
		cardSet = new Integer[2*n];

		for(int i=0;i<n*2;i++){
			cardSet[i] = i+1;
		}
		int m = stdIn.nextInt();
		for(int i=0;i<m;i++){
			int shuffle = stdIn.nextInt();
			if(shuffle != 0){
				hinduShuffle(shuffle);
			}else{
				riffleShuffle();
			}
		}
		for(int i=0;i<cardSet.length;i++){
			System.out.println(cardSet[i]);
		}
	}
	//++++++++++++++++++++++++++++++++++++++++++++++++++++
	//ヒンズーシャッフル
	//++++++++++++++++++++++++++++++++++++++++++++++++++++
	public static void hinduShuffle(int shufflePosition){
		Integer[] cardSetCopy = (Integer[])cardSet.clone();
		int i = 0;
		for(;i<cardSet.length-shufflePosition;i++){
			cardSet[i] = cardSetCopy[i+shufflePosition];
		}
		for(int j=0;j<shufflePosition;j++,i++){
			cardSet[i] = cardSetCopy[j];
		}
	}
	//++++++++++++++++++++++++++++++++++++++++++++++++++++
	//リフルシャッフル
	//++++++++++++++++++++++++++++++++++++++++++++++++++++
	public static void riffleShuffle(){
		Integer[] cardSetCopy = (Integer[])cardSet.clone();
		int x=1;
		for(int i=2;i<cardSet.length;i+=2){
			cardSet[i] = cardSetCopy[x];
			x++;
		}
		for(int i=1;i<cardSet.length;i+=2){
			cardSet[i] = cardSetCopy[x];
			x++;
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
typedef long long ll;
inline ll read() {ll x = 0;char ch = getchar(), w = 1;while(ch < '0' || ch > '9') {
if(ch == '-') w = -1;ch = getchar();}while(ch >= '0' && ch <= '9') {x = x * 10 + ch - '0';
ch = getchar();}return x * w;}
void write(ll x) {if(x < 0) putchar('-'), x = -x;if(x > 9) write(x / 10);putchar(x % 10 + '0');}
inline void writeln(ll x) {write(x);puts("");}
void setIO() {
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
using namespace std;
const int N = 9999;
char s[N];

int main() {
	int x = read();
	if(x < 3200) puts("red");
	else {
		cin>>s;
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math


def main():
    A, B, H, M = map(int, input().split())
    print((A**2 + B**2 - 2 * A * B *
           math.cos(math.radians(H * 30 + M * (1 / 2 - 6))))**0.5)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9476
#include <iostream>
#include <queue>

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

using namespace std;

int main(){
	int h,w;
	cin >> h >> w;
	bool s[52][52];
	char input;
	int black = 0;
	int white = 0;
	REP(i,h){
		REP(k,w){
			cin >> input;
			if (input=='.'){
				s[i][k] = true;
				white++;
			}else{
				s[i][k] = false;
				black++;
			}
		}
	}
	
	int memo[52][52];
	REP(i,h){
		REP(k,w) memo[i][k] = 0;
	}
	memo[0][0] = 1;
	
	queue<pair<int,int> > bfs;
	pair<int,int> start,goal,current,next;
	start = make_pair(0,0);
	goal = make_pair(h-1,w-1);
	
	vector<pair<int,int> > points(4);
	points[0] = make_pair(-1,0);
	points[1] = make_pair(1,0);
	points[2] = make_pair(0,-1);
	points[3] = make_pair(0,1);
	
	bfs.push(start);
	
	while(true){
		if (bfs.empty()){
			cout << "-1" << endl;
			return 0;
		}
		current = bfs.front();
		//cout << current.first << ":" << current.second << endl;;
		bfs.pop();
		if (current==goal) break;
		
		REP(i,4){
			next.first = current.first + points[i].first;
			next.second = current.second + points[i].second;
			//cout << next.first << " " << next.second << endl;
			if (next.first<0 || next.first>=h || next.second<0 || next.second>=w || !s[next.first][next.second] || memo[next.first][next.second]!=0){
				//cout << "continue" << endl;
				continue;
			}
			bfs.push(next);
			memo[next.first][next.second] = memo[current.first][current.second] + 1;
		}
	}
	
	int min = memo[goal.first][goal.second];
	
	cout << white - min << endl;
	return 0;
	
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
 
using namespace std;
using ll = long long int;
using vec = vector<int>;
 
#define rep(n) for(int i = 0; i < (n); ++i)
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(a)   sort(a.begin(), a.end(), greater<int>())
const int INF = 2147483647;
const ll  MOD = 1000000007;
 
int main() {
    string o, e; cin >> o >> e;
 
    int l = max(o.length(), e.length());
 
    string ans;
 
    for(int i = 0; i < l; i++) {
        if(i <= o.length()-1) ans += o[i];
        if(i <= e.length()-1) ans += e[i];
    }
    cout << ans;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Yes(bool Yes){cout << (Yes ? "Yes" : "No") << endl;};
void YES(bool YES){cout << (YES ? "YES" : "NO") << endl;};

int main(){

    ll N, L;
    cin >> N >> L;
    ll ans = 1145141919;
    ll SUM = 0;
    for(ll i = 1; i <= N; i++)SUM += (L + i - 1);
    for(ll i = 1; i <= N; i++){
        ll sum = 0;
        for(ll j = 1; j <= N; j++){
            if(i == j)continue;
            sum += (L + j - 1);
        }
        if(abs(SUM - ans) > abs(SUM - sum))ans = sum;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x,y,K,A,B;
  cin >> A >> B ;

  K = (A + B)/2;

if((A + B)%2 == 0){
  cout << K << endl;
}
else{
  cout << "IMPOSSIBLE" << endl;
}

}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){
    int N,L,i,j;
    scanf("%d %d",&N,&L);

    char s[N][L+1],temp[L+1];
    
    for(i=0;i<N;i++){
        scanf("%s",s[i]);
    }

    for(i=0;i<N;i++){
        for(j=1;j<N-i;j++){
            if(strcmp(s[i],s[i+j])>0){
                strcpy(temp,s[i]);
                strcpy(s[i],s[i+j]);
                strcpy(s[i+j],temp);
            }
        }
    }

    for(i=0;i<N;i++){
        printf("%s",s[i]);
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
//#define INF 1e18
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n;
vector<ll> a,b;

int main(){
  cin >> n;
  rep(i,0,n){
    ll A,B;
    cin >> A >> B;
    a.push_back(A);
    b.push_back(B);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  ll ans;
  if(n%2==1){
    ans = b[(n+1)/2-1] - a[(n+1)/2-1] + 1;
  }else{
    ans = (b[n/2-1]+b[n/2]) - (a[n/2-1]+a[n/2])+1;
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main(){
	int n,m;
	cin>>n>>m;
	map<int,long long> dp;
	vector<int> hole(m);
	for(int i=0;i<m;i++){
		cin>>hole.at(i);
		dp[hole.at(i)]=0;
	}

	for(int i=1;i<=n;i++){
		if(dp.count(i)) continue;

		if(i==1){
			dp[i]=1;
		}else if(i==2){
			dp[i]=dp[i-1]+1;
		}else{
			dp[i]=dp[i-1]+dp[i-2];
		}

		dp.at(i)=dp.at(i)%1000000007;
	}

	cout<<dp.at(n)<<endl;

	return 0;
}


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

int main(){
  long long int N ,ans = 0 ;
  string S ;
  cin >> N >> S;
  for(long long int i = 0; i < N -2; i++){
    if(S.substr(i,3) == "ABC") ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<climits>
using namespace std;

int main() {
  int A,B,N;
  int cnt=0;
  int ans=0;
  int tmp=0;

  cin >> N >> A >>B;
  for(int i=N; i>0; i--){
    cnt = i;
    while(cnt){
      tmp=tmp+cnt%10;
      cnt = cnt/10;
    }
    if(A <= tmp && tmp <= B){
      ans=ans+i;
    }
    tmp=0;
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextLong();
            if(a[i] == 0) {
                System.out.println(0);
                return;
            }
        }
        long res = 1;
        for(int i=0; i<n; i++) {
            if(1000000000000000000L / res < a[i]) {
                System.out.println("-1");
                return;
            }
            res *= a[i];
            if(res > 1000000000000000000L) {
                System.out.println("-1");
                return;
            }
        }
        System.out.println(res);

    }

}

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

typedef long long ll;

int main() {
  int N, Q;
  cin >> N >> Q;
  vector<int> a(N);
  for (int i{}; i < N; ++i) cin >> a[i];
  for (int q{}; q < Q; ++q) {
    ll x;
    cin >> x;

    ll ans{};
    ll sum{};
    int right{};
    for (int left{}; left < N; ++left) {

      while (right < N
        // rightを1進めるための満たすべき条件
        && sum + a[right] <= x
          ) {
        // 条件更新となる処理
        sum += a[right];
        ++right;
      }

      // 総和がx以上の条件の場合で、満たさなくなったときをガード
      // ex) if (sum < x)
      // ex)   break;

      // 条件を満たすright取得時の処理
      ans += (right - left);

      if (left == right) {
        ++right;
      } else {
        // leftを1進めるときの処理
        sum -= a[left];
      }
    }

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



Measured memory_bytes: 3172
main :: IO ()
main = do
  str <- getLine
  print $ solve str

solve :: String -> Int
solve (s:ss) = dfs [read [s]] ss
  where
    dfs :: [Int] -> String -> Int
    dfs res [] = sum res
    dfs ints@(i:is) (r:rs) =
      (dfs ((10*i + read [r]):is) rs) + (dfs ((read [r]):ints) rs)


Measured memory_bytes: 1020
//                https://arc070.contest.atcoder.jp/tasks/arc070_a

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vvi vector<vector<int>>

#define LP(i,n) for(ll i=0;i<n;i++)
#define LP1(i,n) for(ll i=1;i<=n;i++)
#define BLP1(i, n) for(ll i=n;i>0;i--)
#define BLP(i, n) for(ll i=n;i>=0;i--)
 
#define el '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define tc() testcases()
 
#define a1(a) cout<<a<<" ";
#define a2(a, b) cout<<a<<" "<<b<<" ";
#define a3(a, b, c) cout<<a<<" "<<b<<" "<<c<<" ";
#define a4(a, b, c, d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<" ";
#define a5(a, b, c, d, e) cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<" ";
 
#define b1(a) cout<<a<<"\n";
#define b2(a, b) cout<<a<<" "<<b<<"\n";
#define b3(a, b, c) cout<<a<<" "<<b<<" "<<c<<"\n";
#define b4(a, b, c, d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define b5(a, b, c, d, e) cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<"\n";
 
#define nl cout<<"\n"
 
const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);
 
ll a[MAXn], b[MAXn], c[MAXn], d[MAXn];
 
ll t=0, u=0, v=0, w=0, x=0, y=0, z=0;
ll sum=0, sum1=0, mul=0, subs=0, res=0, test=0, num=0, num1=0;
//ll aa=0, bb=0, cc=0, dd=0, ee=0;
//ll count=0, ctl=0, ctrl=0, divi=0, flag=0, cal=0, must=0, test=0;
string in;
int testcases(){ cin>>test; return test; }

int main(){
IOS();
    //t = tc();
    t = 1;
    while(t--){
        cin>>u;
        z = 0;
        while(z*(z+1)/2 < u){
            ++z;
        }
        cout<<z;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;
using Pos = std::pair<int, int>;
//cout<<fixed<<std:cout<<fixed<<setprecision(2)<<Max<<endl;
constexpr int mod = 1e9 + 7;

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

    if(a==1)a=14;
    if(b==1)b=14;

    if(a<b)cout<<"Bob"<<endl;
    else if(a>b)cout<<"Alice"<<endl;
    else cout<<"Draw"<<endl;

    return 0;
}

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

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

  ll a, b;
  cin >> a >> b;
  if (!(a < 10 && b < 10)) {
    cout << -1 << endl;
    return 0;
  }
  cout << a*b << endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

func intOfString(s string) int {
	x, _ := strconv.Atoi(s)
	return x
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	n := intOfString(sc.Text())
	a := make([]int, 0, n)
	for sc.Scan() {
		a = append(a, intOfString(sc.Text()))
	}

	v := a[0]
	c := 0
	for i := 0; i < n; i++ {
		if v == 2 {
			fmt.Println(c + 1)
			os.Exit(0)
		}
		v = a[v-1]
		c++
	}

	fmt.Println(-1)
}

Measured memory_bytes: 1920
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ios>//左右揃え
#include<iomanip>//setwで幅指定

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007LL

int main(void) {
    double L;
    cin >> L;
    printf("%8.6lf\n", L * L * L / 27);
}

Measured memory_bytes: 256