akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>

using namespace std;

main(){
  string S,T;
  cin>>S>>T;
  bool t=true;
  for(int i=0;i<S.size();i++){
    t=t&&(S[i]==T[i]);
  }
  if(t)printf("Yes");else printf("No");
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

using Graph=vector<vector<int>>;
Graph G;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  string s,t;
  cin >> s>> t;
  rep(i,n){
    cout<<s[i]<<t[i];
  }
  cout<<endl;
}
    


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int[][][] info = new int[4][3][10];
        
        int num = Integer.parseInt(br.readLine());
        
        //data input
        for(int i = 0; i < num; i++){
            String[] input = br.readLine().split(" ");
            int b = Integer.valueOf(input[0])-1;
            int f = Integer.valueOf(input[1])-1;
            int r = Integer.valueOf(input[2])-1;
            int v = Integer.valueOf(input[3]);
            info[b][f][r] += v;
        }

        //data output
        StringBuilder sb = new StringBuilder();
        for(int b = 0; b < 4; b++){
            for(int f = 0; f < 3; f++){
                for(int r = 0; r < 10; r++){
                    sb.append(" " + info[b][f][r]);
                }
                sb.append("\n");
            }
            if(b != 3)  sb.append("####################\n");
        }

        System.out.print(sb);
    }
}


Measured memory_bytes: 24764
d =int(input())
c = list(map(int, input().split())) 
s = []
t = []

d_l = []
score = 0
soft = 0

for i in range(d):
    s.append(0)
    s[i] = list(map(int, input().split()))

for i in range(26):
    d_l.append(0)
    
for i in range(d):
    t_max = max(s[i])
    t = s[i].index(t_max)
    print(t + 1)
    
    


Measured memory_bytes: 9324
#include <iostream>
using namespace std;
int main(){
	int a,b,c,d,e,f;
	cin>>a;
	e=0;
	for(d=1 ;d<=a ;d++){
		cin>>b>>c;
		e=e+c-b+1;
	}
	cout<<e;
	return 0;
}

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

int main() {
	int n;
	cin >> n;
	int res = 100000;
	while(n-- > 0){
		res = res * 1.05;
		if(res % 1000)
			res = res / 1000 * 1000 + 1000;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"
using namespace std;
int main()
{
	int64_t okane = 0, ureshisa = 0, temp = 0;
	cin >> okane;
	temp = (okane / 500) * 1000;
	ureshisa = ((okane % 500) / 5) * 5 + temp;
	cout << ureshisa << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	
	Scanner sc = new Scanner(System.in);
	int a;
	String op;
	int b;
	
	void cp3(){
		while(true){
			a = sc.nextInt();
			op = sc.next();
			b = sc.nextInt();
			if(op.equals("?"))break;
		
		
		
			if ( op.equals("+")){
				System.out.println(a+b);
			} else if ( op.equals ("-")){
				System.out.println(a-b);
			} else if ( op.equals("*")){
				System.out.println(a*b);
			} else if ( op.equals("/")){
				System.out.println(a/b);
			}
		}

	
	}
		
		public static void main(String[]agrs){
			new Main().cp3();
		}
	}

Measured memory_bytes: 18252
#include <stdio.h>
#define MAX(a, b) ((a) > (b)) ? (a) : (b)

int main()
{
    int c[10] = {0, 2, 5,5,4,5,6,3,7,6};

    int n, m;
    int dp[1<<14];
    int keta[1<<14];
    int a[9];
    int i, j;
    scanf("%d %d", &n, &m);
    for (i = 0; i < m; i++) scanf("%d", a+i);
    dp[0] = 0; keta[0] = 0;
    for (i = 1; i < n+1; i++) {
	dp[i] = -1; keta[i] = -1;
	for (j = 0; j < m; j++) {
	    if (i < c[a[j]]) continue;
	    if (dp[i-c[a[j]]] == -1) continue;
	    if (keta[i-c[a[j]]] + 1 > keta[i] ||
		(keta[i-c[a[j]]] + 1 == keta[i] && a[j] > dp[i])) {
		keta[i] = keta[i-c[a[j]]] + 1;
		dp[i] = a[j];
	    }
	}
    }
    i = n;
    while (i > 0) {
	printf("%d", dp[i]);
	i -= c[dp[i]];
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
template<class T>inline void MAX(T &x,T y){if(y>x)x=y;}
template<class T>inline void MIN(T &x,T y){if(y<x)x=y;}
template<class T>inline void rd(T &x){
	x=0;char o,f=1;
	while(o=getchar(),o<48)if(o==45)f=-f;
	do x=(x<<3)+(x<<1)+(o^48);
	while(o=getchar(),o>47);
	x*=f;
}
const int M=5005;
int n,m,A[M],mxL[M][M],mxR[M][M];
bool dpL[M][M],dpR[M][M];

int main(){
#ifndef ONLINE_JUDGE
//	freopen("jiedai.in","r",stdin);
//	freopen("jiedai.out","w",stdout);
#endif
	rd(n),rd(m);
	for(int i=1;i<=n;i++)rd(A[i]);
	dpL[0][0]=dpR[n+1][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<m;j++){
			if(dpL[i-1][j])dpL[i][j]=1;
			if(dpL[i-1][j]&&j+A[i]<m)dpL[i][j+A[i]]=1;
		}
	}
	for(int i=n;i>=1;i--){
		for(int j=0;j<m;j++){
			if(dpR[i+1][j])dpR[i][j]=1;
			if(dpR[i+1][j]&&j+A[i]<m)dpR[i][j+A[i]]=1;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<m;j++){
			mxL[i][j]=mxL[i][j-1];
			mxR[i][j]=mxR[i][j-1];
			if(dpL[i][j])mxL[i][j]=j;
			if(dpR[i][j])mxR[i][j]=j;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		int res=0;
		for(int j=0;j<m;j++)MAX(res,mxL[i-1][j]+mxR[i+1][m-1-j]);
		if(res+A[i]<m)ans++;
	}
	printf("%d\n",ans);
	return (0-0);
}

Measured memory_bytes: 244864
import java.util.*;
class Main{
	public static void main(String[]args){
    	Scanner in = new Scanner(System.in);
      	int h = in.nextInt(), n = in.nextInt(),s=0;
      	int[] a = new int[n];
      	for(int i = 0 ; i < n ; i++){
          a[i] = in.nextInt();s+=a[i];}
      	System.out.println((s>=h)?"Yes":"No");
    }
}

Measured memory_bytes: 48696
'use strict'
function Main(input) {
  const arr = input.split(" ");
  let count5 = 0, count7 = 0;
  
  arr.forEach(a => {
    if(a == 5){
      count5++;
    }else if(a == 7){
      count7++;
    }
  });

  console.log(count5 === 2 && count7 === 1 ? 'YES' : 'NO');
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long a, b;
    cin >> a >> b;
    int ans = 1;
    long long x = __gcd(a,b);
    for(long long i=2; i*i<=x; i++)
        if(x%i==0)
        {
            ans++;
            while(x%i==0) 
                x/=i;
        }
    
    cout<<(x==1?ans:ans+1);

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define INF 2000
#define NIL -1
#define WHITE 1
#define BLACK 3
int n,a[101][101],d[101],color[101],pi[101],adj[101];

void prim(int r){
  int i;
  for(i=1;i<=n;i++){
    d[i]=INF;
    pi[i]=NIL;
    color[i]=WHITE;
  }
  d[r]=0;
}
int main(){

  int i,j,min,sum=0,u,min2,f;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      scanf("%d",&a[i][j]);
      adj[i]=j;
    }
    prim(i);
  }

  while(1){

    min=INF;

    for(i=1;i<=n;i++){
      if(color[i] !=BLACK  && d[i]<min){
	if(0<=d[i]){
	  min=d[i];
	  u=i;
	}
      }
    }
      
      if(min==INF) break;

      color[u]=BLACK;

      for(j=1;j<=n;j++){
	if(color[j]!=BLACK && a[u][j]<d[j]){
	  if(0<=a[u][j]){
	  pi[j]=u;
	  d[j]=a[u][j];
	  }
	}

      }
    }
  
  for(i=1;i<=n;i++){
    if(pi[i]!=NIL){
      sum+=a[i][pi[i]];
    }
      
  }

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




  return 0;
}

Measured memory_bytes: 640
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N, M = ni()
    val ans = map(N) { i =>
      val k = ni()
      val A = na(k)
      A.toSet
    }.reduce(_ intersect _)
    out.println(ans.size)
  }


  def debug(as: Array[Boolean]): Unit = {
    System.err.println(as.map(x => if(x) "1" else "0").mkString)
  }

  def debug(as: Array[Int]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(as: Array[Long]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(s: String): Unit = {
    System.err.println(s)
  }

  def debug(num: Long): Unit = {
    System.err.println(num)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }


  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}


Measured memory_bytes: 25536
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<vector>
#include<map>
#include<list>
#include<set>
#include<cstring>

#define forn(a,n) for(int i=(a);i<(n);i++)
using namespace std;
const long long N=2000+3;
typedef long long ll;

int c[55];
int v[55];
int main()
{
//    ios::sync_with_stdio(false);
//    freopen("a.in","r",stdin);
//    freopen("a.out","w",stdout);

    int n;
    cin>>n;
    forn(0,n) cin>>v[i];
    forn(0,n) cin>>c[i];
    int sum=0;
    forn(0,n)
        if(v[i]-c[i]>0) sum=sum+v[i]-c[i];
        cout<<sum;
return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2 * 10**6)


def inpl():
    return list(map(int, input().split()))


def count_v(last_d, C, S, t, d):
    ret = S[t - 1]
    last_d[t - 1] = d
    for i in range(len(last_d)):
        ret -= C[i] * (d - last_d[i])
    return ret


def count_v_virtual(last_d, C, S, t, d):
    ret = S[t - 1]
    tmp = last_d[t - 1]
    last_d[t - 1] = d
    for i in range(len(last_d)):
        ret -= C[i] * (d - last_d[i])
    last_d[t - 1] = tmp
    return ret


def main():
    D = int(input())
    C = inpl()
    Ss = [inpl() for _ in range(D)]
    last_d = [-1] * len(C)

    for d in range(D):
        tmp_t, tmp_v = -1, -float('inf')
        for i in range(len(C)):
            tmp_score = count_v_virtual(last_d, C, Ss[d], i + 1, d)
            if tmp_score > tmp_v:
                tmp_v = tmp_score
                tmp_t = i
        last_d[tmp_t] = d
        print(tmp_t + 1)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 68996
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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

int main()
{
  int N;
  cin >> N;
  vector<ll> v(N);
  bool eq = true;
  REP(i, N) {
    cin >> v[i];
    if (i != 0) {
      if (v[i] != v[i-1]) {
        eq = false;
      }
    }
  }
  if (eq) {
    cout << v[0] << endl;
    return 0;
  }
  ll ans = v[0];

  for(int i = 1; i < N; i++) {
    ans = gcd(ans, v[i]);
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int N; cin >> N;
  priority_queue<ll,vector<ll>,greater<ll>> Q;
  rep(i, 0, N) {
    ll a; cin >> a;
    Q.push(a);
  }
  ll m = Q.top(); Q.pop();
  int ans = 0;
  while(!Q.empty()) {
    ll v = Q.top();
    if(2 * m < v) {
      ans = Q.size();
    }
    Q.pop();
    m += v;
  }
  if(ans == 0) ans = N;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
# -*- coding: utf-8 -*-
# 標準入力を取得
X = int(input())

# 求解処理
ans = int()
if X <= 599:
    ans = 8
elif X <= 799:
    ans = 7
elif X <= 999:
    ans = 6
elif X <= 1199:
    ans = 5
elif X <= 1399:
    ans = 4
elif X <= 1599:
    ans = 3
elif X <= 1799:
    ans = 2
elif X <= 1999:
    ans = 1

# 結果出力
print(ans)

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n,m,r;cin>>n>>m>>r;
  vector<ll> a(m),b(m),c(m),k(r);
  for(i=0;i<r;i++)cin>>k[i];
  for(i=0;i<m;i++){
    cin>>a[i]>>b[i]>>c[i];
  }

  ll MAX_V=201;
  vector<vector<ll>> matrix(MAX_V,vector<ll>(MAX_V,INF));
  for(i=0;i<MAX_V;i++)matrix[i][i]=0;
  for(i=0;i<m;i++){
    matrix[a[i]][b[i]]=c[i];
    matrix[b[i]][a[i]]=c[i];
  }
  for(j=0;j<MAX_V;j++){
    for(i=0;i<MAX_V;i++){
      for(o=0;o<MAX_V;o++){
        chmin(matrix[i][o],matrix[i][j]+matrix[j][o]);
      }
    }
  }

  sort(ALL(k));
  do{
    buf=0;
    for(i=0;i<r-1;i++){
      buf+=matrix[k[i]][k[i+1]];
    }
    chmin(res2,buf);
  }while(next_permutation(ALL(k)));
  cout<<res2<<endl;


  

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <set>
using namespace std;
using ll = long long;
using ld = long double;

const ll MOD = 1000000000 + 7;
const ll INF = 1e+9;
const ld PI = acos((ld)(-1));

#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define Fixed(n) std::fixed << std::setprecision(n)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define print(x) cout << x << endl;
#define next '\n'
#define sp " "
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(elem, _list) for(auto& (elem) : (_list))
#define view(_list) foreach(e, _list){ cout << e << sp; } cout << endl
#define SIZE(s) (s).size()
#define ALL(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e)
#define eb(e) emplace_back(e)

int main() {
    FAST;

    int n, k;
    cin >> n >> k;

    int ans = 1;
    while(n / k != 0){
        ans++;
        n /= k;
    }

    print(ans);
}



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

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

typedef long long ll;
using namespace std;

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

  ll N, Y;
  cin >> N >> Y;

  for (ll i = 0; i <= N; ++i) {
    for (ll j = 0; j <= N - i; ++j) {
      ll k = N - i - j;
      if (i * 10000 + j * 5000 + k * 1000 == Y) {
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }

  cout << "-1 -1 -1" << endl;

  return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

struct data{
  ll i,j,k;
  vector<ll> v;
  ll ooo(set<ll> ok){
    ll cnt = 0,part,flag = 0;
    v.resize(3);
    v[0] = i;
    v[1] = j;
    v[2] = k;
    for(auto n:ok){
      rep(i,3){
        if(v[i] == n){
          flag |= (1 << i);
          ++cnt;
        }
      }
    }
    if(cnt == 2){
      rep(i,3){
        if(!(flag & (1 << i))){
          return v[i];
        }
      }
    }
    return -1;
  }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c;
  while(cin >> a >> b >> c && a && b && c){
    ll n;
    set<ll> ok;
    set<ll> wrong;
    vector<data> qes;
    cin >> n;
    ll x,y,z,w;
    rep(i,n){
      cin >> x >> y >> z >> w;
      --x,--y,--z;
      if(w == 1){
        ok.insert(x);
        ok.insert(z);
        ok.insert(y);
      }
      else{
        qes.push_back({x,y,z});
      }
    }
    rep(i,qes.size()){
      wrong.insert(qes[i].ooo(ok));
    }
    rep(i,a+b+c){
      if(find(all(ok),i) != ok.end()){
        cout << 1<<endl;
      }
      else if(find(all(wrong),i) != wrong.end()){
        cout << 0 <<endl;
      }
      else
        cout << 2 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(auto i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
const ll INF = ~(1<<31);
#define fs first
#define sc second
#define pb push_back

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T> T smod(T a, T b) {
    return (a % b + b) % b;
}

ll DP[105][100'050];

int main() {
    cin.sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    vi A(n);
    rep(i,0,n) cin >> A[i];

    memset(DP,0,sizeof(DP));

    DP[0][0] = 1;

    ll md = 1000000000+7;
    for(ll i = 1; i <= n; i++) {
        vi PRE;
        PRE.pb(0);
        for(ll j = 0; j <= k; j++) {
            PRE.pb((PRE.back() + DP[i-1][j]) % md);
        }
        for(ll j = 0; j <= k; j++) {
            ll l = max(j-A[i-1],0ll), r = j;
            DP[i][j] = (PRE[r+1]-PRE[l]+md)%md;
        }
    }

    cout << DP[n][k] << endl;
    return 0;
}


Measured memory_bytes: 84260
n = int(input())
a = list(map(int, input().split()))

acc = [0 for i in range(n+1)]
for i in range(n):
    acc[i+1] = a[i] + acc[i]

ans = {}
for x in acc:
    ans.setdefault(x, 0)
    ans[x] += 1
cnt = 0
for i in ans:
    cnt += ans[i]*(ans[i]-1)//2

print(cnt)

Measured memory_bytes: 41148
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String s=sc.next();
if((s.charAt(2)==s.charAt(3)) && (s.charAt(4)==s.charAt(5)))
System.out.println("Yes");
else
System.out.println("No");
}

}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
using namespace std;
struct T{
    int key,priority;
    T *parent,*left,*right;
};
    T *root=NULL;
T* rightRotate(T *t){
    T *s=t->left;
    t->left=s->right;
    s->right=t;
    if(t==root){
        root=s;
    }
    return s;
}
T* leftRotate(T *t){
    T *s=t->right;
    t->right=s->left;
    s->left=t;
    if(t==root){
        root=s;
    }
    return s;
}
T* insert(T *t,int key,int priority){
    if(t==NULL){
        T *r= new T();
        r->key=key;
        r->priority=priority;
        r->left=r->right=NULL;
        return r;
    }
    if(key==t->key){
        return t;
    }
    if(key < t->key){
        t->left=insert(t->left,key,priority);
        if(t->priority < t->left->priority){
            t=rightRotate(t);
        }
    }
    else{
        t->right=insert(t->right,key,priority);
        if(t->priority < t->right->priority){
            t=leftRotate(t);
        }
    }
    return t;
}
T* Tfind(T *x,int k){
    T *z=new T();
    *z={NULL};
    z->key=k;
    while(x!=NULL){
        if(z->key==x->key){
            return x;
        }
        if(z->key < x->key){
            x=x->left;
        }
        else{
            x=x->right;
        }
    }
    return NULL;
}
T* Tdelete(T *t, int key);
T* _delete(T *t,int key){
    if(t==NULL){
        return NULL;
    }
    if(key < t->key){
        t->left=_delete(t->left,key);
    }
    else if(key > t->key){
        t->right=_delete(t->right,key);
    }
    else{
        return Tdelete(t,key);
    }
    return t;
}
T* Tdelete(T *t,int key){
    if(t->left==NULL && t->right==NULL){
        return NULL;
    }
    else if(t->left==NULL){
        t=leftRotate(t);
    }
    else if(t->right==NULL){
        t=rightRotate(t);
    }
    else{
        if(t->left->priority > t->right->priority){
            t=rightRotate(t);
        }
        else{
            t=leftRotate(t);
        }
    }
    return _delete(t,key);
}
void Preorder(T *root){
    if(root!=NULL){
        cout<<" "<<root->key;
        Preorder(root->left);
        Preorder(root->right);
    }
}
void Inorder(T *root){
    if(root!=NULL){
        Inorder(root->left);
        cout<<" "<<root->key;
        Inorder(root->right);
    }
}
int main(){
    int n,key,priority;
    string s;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        if(s=="insert"){
            cin>>key>>priority;
            T *t=insert(root,key,priority);
            if (root == NULL) {
				root = t;
			}
        }
        else if(s=="find"){
            cin>>key;
            if(Tfind(root,key)!=NULL){
                cout<<"yes"<<endl;
            }
            else{
                cout<<"no"<<endl;
            }
        }
        else if(s=="delete"){
            cin>>key;
            _delete(root,key);
        }
        else{
            Inorder(root);
            cout<<endl;
            Preorder(root);
            cout<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 12516
def calc_d1(n, x, y)
  d1 = 0
  n.times{ |i|
    d1 += (x[i] - y[i]).abs
  }
  return d1
end

def calc_d2(n, x, y)
  d2 = 0
  n.times{ |j|
    d2 += ((x[j] - y[j]).abs)**2
  }
  d2 = d2**(1/2.0)
  return d2
end

def calc_d3(n, x, y)
  d3 = 0
  n.times{ |k|
    d3 += ((x[k] - y[k]).abs)**3
  }
  d3 = d3**(1/3.0)
  return d3
end

def d_max(n, x, y)
  d = []
  n.times{ |m|
    d[m] = (x[m] - y[m]).abs
  }
  return d.max
end

n = gets.to_i
x = gets.split.map(&:to_f)
y = gets.split.map(&:to_f)

puts calc_d1(n, x, y)
puts calc_d2(n, x, y)
puts calc_d3(n, x, y)
puts d_max(n, x, y)

Measured memory_bytes: 8860
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;

int main(){
  ll n;
  cin >> n;
  ll m;
  cin >> m;
  if(n == 1){
    cout << m << endl;
    return 0;
  }
  ll b = 2;
  vector<ll> d;
  while(m >= b * b) {
    if(m % b == 0) {
      d.push_back(b);
      d.push_back(m / b);
    }
    b++;
  }
  ll maxi = 1;
  for(int i = 0; i < d.size(); i++){
    if((m - d[i] * n) >= 0 && (m - d[i] * n) % d[i] == 0) {
      maxi = max(maxi, d[i]);
    }
  }
  cout << maxi << endl;
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

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

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}"<<endl;
  return o;
}

//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m; 
  if (u < 0) u += m;
  return u;
}
ll const mod = 1e9+7;

// combination
const int MAX = 510000;
const ll MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// べき乗
ll modpow(ll x, ll n) {
    x = x%MOD;
    if(n==0) return 1;  //再帰の終了条件

    else if(n%2==1) {
        return (x*modpow(x, n-1))%MOD;  //nが奇数ならnを1ずらす
    }
    else return modpow((x*x)%MOD, n/2)%MOD;  //nが偶数ならnが半分になる
}

int main() {
  int N;
  ll T;
  cin >> N >> T;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  ll mi = A[0];
  map<ll,int> d;
  rep(i,N) {
    chmin(mi,A[i]);
    d[A[i]-mi]++;
  }
  cout << max_element(d.begin(),d.end())->second << endl;
}


Measured memory_bytes: 10304
#include <bits/stdc++.h>
#define inp ".inp"
#define out ".out"

using namespace std;

long long n,w,V[105],W[105],v_max=0,f[105][100005],ans=0;

void Enter ()
{
    cin>>n>>w;
    for (long long i=1; i<=n; i++)
    {
        cin>>W[i]>>V[i];
        v_max+=V[i];
    }
}

void solve ()
{
    for (long long i=0; i<=v_max; i++)
        for (long long j=0; j<=n; j++)
        {
            f[j][i]=1000000000;
        }
    f[0][0]=0;
    for (long long j=1; j<=n; j++)
        for (long long i=v_max;i>=0;i--)
        {
            if (i>=V[j])
                f[j][i]=min(f[j-1][i],f[j-1][i-V[j]]+W[j]);
                else f[j][i]=f[j-1][i];
        }
    for (long long i=0; i<=v_max; i++)
    {
        if (f[n][i]<=w&&f[n][i]!=0)
            ans=i;
    }
    cout<<ans;
}
main()
{
    Enter();
    solve();
    return 0;
}


Measured memory_bytes: 80128
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
int zonbi[1<<17];
priority_queue<pair<long,int> > Q;
vector<int> G[1<<17];
long p,q;
long d[1<<17];
main()
{
	int n,m,k,s;cin>>n>>m>>k>>s;
	cin>>p>>q;
	for(int i=0;i<k;i++)
	{
		int a;cin>>a;a--;Q.push(make_pair(0,a));
		zonbi[a]=-1;
	}
	for(int i=0;i<m;i++)
	{
		int u,v;cin>>u>>v;
		u--,v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	while(!Q.empty())
	{
		pair<int,int> a=Q.top();Q.pop();
		int u=a.second,v=-a.first;
		if(v>=s)continue;
		v++;
		for(int i=0;i<G[u].size();i++)
		{
			int next=G[u][i];
			if(zonbi[next]!=0)continue;
			zonbi[next]=1;
			Q.push(make_pair(-v,next));
		}
	}
	for(int i=0;i<n;i++)d[i]=1LL<<60;
	Q.push(make_pair(0,0));
	d[0]=0;
	while(!Q.empty())
	{
		pair<long,int> a=Q.top();Q.pop();
		long u=a.second,v=-a.first;
		if(d[u]<v)continue;
		for(int i=0;i<G[u].size();i++)
		{
			int next=G[u][i];
			if(zonbi[next]==-1)continue;
			long cost=(zonbi[next]?q:p);
			if(next==n-1)cost=0;
			if(d[next]<=v+cost)continue;
			d[next]=v+cost;
			Q.push(make_pair(-d[next],next));
		}
	}
	cout<<d[n-1]<<endl;
}

Measured memory_bytes: 11780
x = [str(_) for _ in input().split()]
x[0].upper()
x[1].upper()
if len(x) == 2:
    if x[0] < x[1]:
        print('<')
    elif x[0] == x[1]:
        print('=')
    else:
        print('>')
else:
    print('hoge!')

Measured memory_bytes: 3060
N = int(input())
S = {}
for _ in range(N):
    i = input()
    if i in S:
        S[i] += 1
    else:
        S[i] = 1

M = int(input())
for _ in range(M):
    i = input()
    if i in S:
        S[i] -= 1

ans = 0
for v in S.values():
    ans = max(ans, v)

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
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 (a>b) { a=b; return 1; } return 0; }

int main() {
  int N; cin >> N;
  vel a(N),b(N); rep(i,N) cin >> a[i] >> b[i];
  
  int maxa = 0; int index;
  rep(i,N) {
    if(maxa < a[i]) {maxa = a[i]; index = i;}
  }
  cout << maxa + b[index] << endl;
  return 0;
}

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

#define int long long

int32_t main(){ 

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

    int k,a,b;
  cin >> k >> a >> b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout << "OK\n";
            return 0;
        }
    }
    cout << "NG\n";
    
    return 0;
} 

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define inc(i,a,b) for(register int i=a;i<=b;i++)
using namespace std;
long long a[100010],sum[100010];
int n,m,v,p;
bool check(int mid){
	if(a[mid]+m<a[p]) return 0;
	long long tmp=v-p-n+mid;
	if(tmp*m+sum[mid-1]-sum[p-1]>(a[mid]+m)*(mid-p)) return 0;
	return 1;
}
bool cmp(int x,int y){
	return x>y;
}
int main()
{	
	cin>>n>>m>>v>>p;
	inc(i,1,n) scanf("%lld",&a[i]);	
	sort(a+1,a+1+n,cmp);
	inc(i,1,n) sum[i]=sum[i-1]+a[i];
	//cout<<(upper_bound(a+1,a+1+n,2)-a)<<endl;
	int L=p,R=n;
	while(L<R){
		int mid=(L+R+1)/2;
		if(check(mid)){
			L=mid;
		}
		else{
			R=mid-1;
		} 
	}
	cout<<R;
}
/*
10 4 8 5
1 2 3 4 5 5 6 6 6 7

6 1 2 2
2 1 1 3 0 2

6 1 5 2
2 1 1 3 0 2
*/

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define N 1000010
using namespace std;
int cnt=0;
void insertionSort(int *A,int n,int g){
  for(int i=g;i<n;i++){
    int v = A[i];
    int j = i - g;
    while(j>=0 && A[j]>v){
      A[j+g] = A[j];
      j = j - g;
      cnt++;
    }
    A[j+g] = v;
  }
}



void shellSort(int *A,int n){
  cnt = 0 ;
  int m = 1;//
  int G[25] = {1};
  for(int i=1;G[i-1]*2<=n;i++)G[i] = G[i-1]*2,m++;
  for(int i=0;i<m;i++) insertionSort(A,n,G[m-1-i]);
  
  cout<<m<<endl;
  for(int i=0;i<m;i++){
    if(i)printf(" ");
    printf("%d",G[m-1-i]);
  }
  cout<<endl;
}

int main(){
  int n,A[N];
  cin>>n;
  for(int i=0;i<n;i++)scanf("%d",&A[i]);
  
  shellSort(A,n);
  
  cout<<cnt<<endl;
  for(int i=0;i<n;i++) printf("%d\n",A[i]);
  
  return 0;
}

Measured memory_bytes: 7176
#include<cstdio>
#include<algorithm>
using namespace std;
static const int MAX_N = 100;
static const int MAX_T = 100;

int N, T, L, B;
bool is_lose[MAX_N + 1], is_back[MAX_N + 1];
double memo[MAX_T + 1][MAX_N + 1];

int main(){
	for(;;){
		scanf("%d %d %d %d", &N, &T, &L, &B);
		if(N == 0 && T == 0 && L == 0 && B == 0) break;
		fill(is_lose, is_lose + N + 1, false);
		fill(is_back, is_back + N + 1, false);
		fill(memo[0], memo[N + 1], 0.0);
		for(int i = 0; i < L; i++){
			int lose;
			scanf("%d", &lose);
			is_lose[lose] = true;
		}
		for(int i = 0; i < B; i++){
			int back;
			scanf("%d", &back);
			is_back[back] = true;
		}
		memo[0][0] = 1.0;
		for(int i = 0; i < T; i++){
			for(int j = 0; j < N; j++){
				double next_probability = memo[i][j] * 1.0 / 6.0;
				for(int k = 1; k <= 6; k++){
					int next_position = (j + k >= N ? 2 * N - (j + k) : j + k);
					if(is_lose[next_position] && i != T - 1) memo[i + 2][next_position] += next_probability;
					else if(is_back[next_position]) memo[i + 1][0] += next_probability;
					else memo[i + 1][next_position] += next_probability;
				}
			}
			memo[i + 1][N] += memo[i][N];
		}
		printf("%.10lf\n", memo[T][N]);
	}
	return 0;
}


Measured memory_bytes: 2780
from collections import defaultdict


def main():
    N = int(input())
    D = defaultdict(int)
    for i in range(1, 200):
        for j in range(1, 200):
            for k in range(1, 200):
                D[i**2+j**2+k**2+i*j+j*k+k*i] += 1
    for i in range(1, N+1):
        print(D[i])


if __name__ == "__main__":
    main()

Measured memory_bytes: 107700
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n;
    map<ll,ll> mp;
    cin >> n;
    vll a(n);
    rep(i,n){
        cin >> a[i];
        if(a[i]%4==0) mp[4]++;
        else if(a[i]%2==0) mp[2]++;
        else mp[1]++;
    }
    if(mp[2]==0) cout << (mp[1]<=mp[4]+1?"Yes\n":"No\n");
    else cout << (mp[1]<=mp[4]?"Yes\n":"No\n");
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  long double ans;
  ans = sqrt(A * A + B * B - 2 * A * B * cos((11 * M / 360 - H / 6) * M_PI));
  cout << fixed << setprecision(20) << ans << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline void fastio () {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
}

#define whats(x) cerr << #x << " = " << (x) << "\n"; 

using LL = long long;
using LD = long double;

const LL INF = LLONG_MAX;
const LL MOD = 998244353;
const LL N = 2e5+1;

int main() {
	fastio();

	LL a, b = 0;
	cin >> a;
	string s;
	cin >> s;
	for (auto e : s) {
		if (e != '.') {
			b += (e-'0');
			b *= 10;
		}
	}
	b /= 10;

	cout << a*b/100 << "\n";

}


Measured memory_bytes: 3620
using System;
using System.Text;


public class C{
	
	public static void Main(){
	
		StringBuilder s = 
			new StringBuilder( Console.ReadLine() );
		StringBuilder t = 
			new StringBuilder( Console.ReadLine() );
		bool[] fix = new bool[32];
		for( int i = 0; i < 32; i++ )
			fix[i] = false;
		
		bool result = true;
		for(int i = 0; i < s.Length; i++){

			if( s[i] == t[i] ){
				fix[s[i] - 'a'] = true;
				continue;
			}
			
			if( fix[s[i] - 'a'] || fix[t[i] - 'a'] ){
				result = false;
				break;
				
			}else{				
				StringBuilder newS = new StringBuilder();
				for(int j = 0; j < i; j++) 
					newS.Append(s[j]);
				for(int j = i; j < s.Length; j++){
					if( s[j] == t[i] ){
						newS.Append(s[i]);
					}else if( s[j] == s[i] ){
						newS.Append(t[i]);
					}else{
						newS.Append(s[j]);
					}
				}
				s = newS;
				fix[newS[i] - 'a'] = true;
			}		
			
		}
		
		Console.WriteLine( result ? "Yes" : "No" );
		
	}
	
}

Measured memory_bytes: 17632
N , A , B , C , D = map(int,input().split())
x=N%A
if x==0:
    X=(N//A)*B
else:
    X=(N//A+1)*B

y=N%C
if y==0:
    Y=(N//C)*D
else:
    Y=(N//C+1)*D

print(min(X,Y))


Measured memory_bytes: 5596
/*
* @Author: Kabid
* @Date:   {{create_time}}
* @Last Modified by:   Kabid
* @Last Modified time: 2020-09-19 13:59:26
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define  in(x) scanf("%d",&x);
#define out(x) printf("%d",x);
#define  ins(x)  scanf("%s",x);
#define outs(x) printf("%s",x);
#define lin puts("");
#define _ putchar(' ');

int t;       //test cases
ll i, j;	 //iterators
ll n, k , p, q,  d, m, c, c1, c2, d1; //variables;
ll mx = LLONG_MIN, mn = LLONG_MAX;		// max min
string s, s1, s2;		// string
ll a [1000001], b [200001] , mox [200001];	// array
map <int, int > mp;
vector <vector<ll>> vc;
vector <ll> v;
set <ll> st;
bool r;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//cin >> t; q = t;
	t = 1;
	
	while (t--) {


		/*cin >> s;
		n = s.size();
		for (i = n - 1; i > 0; i--) {
			for (j = i - 1; j >= 0; j--) {
				if (s[i] > s[j]) {
					swap(s[i], s[j]);
					cout << s << endl;
					break;
				}
			}
			if(j!=-1) break;
		}
		if (i == 0) {
			cout << "no answer" << endl;
		}*/
		cin >> s;
		cout<<s[0];
		cin >> s;
		cout<<s[1];
		cin >> s;
		cout<<s[2];
		//n=s.size();
		
		cout<<endl;
	}


	return 0;

}

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

using namespace std;

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

    int n, k, s;

    cin >> n >> k;
    for(int i = 1; i <= n; ++i)
    {
        int x;
        cin >> x;
        if(x == 1)
            s = x;
    }

    int l = s, r = s;
    --k;
    int ans = 0;

    if(l > 1 && l - k <= 1)
    {
        ++ans;
        r += k - (l - 1);
        l = 1;
    }
    if(r < n && r + k >= n)
    {
        ++ans;
        l -= k - (n - r);
        r = n;
    }

    while(l > 1)
    {
        ++ans;
        l -= k;
    }
    while(r < n)
    {
        ++ans;
        r += k;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#51 C - Many Medians
N = int(input())
X = list(map(int,input().split()))
Xsrt = sorted(X,reverse = False)
XL = set(Xsrt[:N//2])
XR = set(Xsrt[N//2:])

ans = []
for x in X:
    if x in XR:
        ans.append(Xsrt[N//2-1])
    elif x in XL:
        ans.append(Xsrt[N//2])
for a in  ans:
    print(a)

Measured memory_bytes: 30824
# coding: utf-8

n,k = list(map(int,input().split()))

if k%2 == 1:
    print((n//k)**3) 

else:
    mod0 = (n//k)
    if n%k < k/2:
        modhalf = n//k
    else:
        modhalf = n//k+1
    print(mod0**3+modhalf**3)

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

void solve(const string&s){
    int l=s.length();
    bool flag[26]={0};
    for(int i=0;i<l;i++){
        if(flag[s[i]-'a']){
            cout<<"no"<<endl;
            return;
        }
        flag[s[i]-'a']=1;
    }
    cout<<"yes"<<endl;
}
int main(){
    string s;
    cin>>s;
    solve(s);
    return 0;
}


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

#define INF 1100000
using namespace std;

int par[110000];
int rnk[110000];

void init(int n) {
  for (int i = 0; i <= n; i++) {
    par[i] = i;
    rnk[i] = 0;
  }
}

int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return ;

  if (rnk[x] < rnk[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (rnk[x] == rnk[y]) rnk[x]++;
  }
}

bool same(int x, int y) {
  return find(x) == find(y);
}

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<pair<int, int>> e(M);
  for (int i = 0; i < M; i++) {
    cin >> e[i].first >> e[i].second;
  }

  int ans = 0;
  for (int i = 0; i < M; i++) {
    init(N);
    for(int j = 0; j < M; j++) {
      if (j == i) continue;
      unite(e[j].first, e[j].second);
    }
    if (same(e[i].first, e[i].second) == false)
      ans++;
  }
  cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

const lint mod = 998244353;
inline lint emod(lint a, lint p = mod) { return (a % p + p) % p; }

inline lint invm(lint a, lint p = mod) { a %= p; return a == 1 ? 1 : -p / a * invm(p % a) % p; }

inline lint powm(lint a, lint n, lint p = mod) { return !n ? 1 : powm(a * a % p, n >> 1, p) * (n & 1 ? a : 1) % p; }

V<lint> fact, ifact;
void init_fact(int n) {
  fact.assign(n + 1, 1), ifact.assign(n + 1, 1);
  for (int i = 2; i < n + 1; i++) fact[i] = i * fact[i - 1] % mod;
  ifact[n] = invm(fact[n]);
  for (int i = n; i > 2; i--) ifact[i - 1] = i * ifact[i] % mod;
}

lint comb(lint n, lint r) {
  if (n < 0 or r < 0 or r > n) return 0;
  return fact[n] * ifact[r] % mod * ifact[n - r] % mod;
}

lint mulcomb(lint n, lint r) {
  if (n < 1 or r < 0) return 0;
  return fact[r + n - 1] * ifact[r] % mod * ifact[n - 1] % mod;
}

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  lint k, n; cin >> k >> n;
  init_fact(k + n);
  auto calc = [&](lint m, lint k, lint n) {
    lint res = 0;
    for (lint j = 0; j < m + 1; j++) {
      res = (res + comb(m, j) * powm(2, j) % mod * mulcomb(k - 2 * m + j, n - j)) % mod;
    }
    return res;
  };
  V<> res(k);
  for (int i = 2; i < k + 2; i++) {
    if (i & 1) res[i - 2] = emod(calc(i / 2, k, n));
    else res[i - 2] = emod(calc(i / 2 - 1, k - 1, n) + calc(i / 2 - 1, k - 1, n - 1));
  }
  for (auto&& i : res) cout << i << '\n';
  for (int i = k - 2; i >= 0; i--) cout << res[i] << '\n';
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N;
string s, t;

bool check(int x) {
  return (s[x] == 'o') ^ (t[x] == 'S') ^ (t[(x - 1 + N) % N] == t[(x + 1) % N]);
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> s;
  for (int bit = 0; bit < 4; bit++) {
    t.resize(N);
    t[0] = (bit >> 0 & 1 ? 'W' : 'S');
    t[1] = (bit >> 1 & 1 ? 'W' : 'S');
    for (int i = 1; i + 1 < N; i++) {
      if ((s[i] == 'o') ^ (t[i] == 'S') ^ 1) {
        t[i + 1] = t[i - 1];
      } else {
        t[i + 1] = (t[i - 1] == 'S' ? 'W' : 'S');
      }
    }
    if (check(0) && check(N - 1)) {
      cout << t << endl;
      return 0;
    }
  }  
  cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>


long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){
int N;
cin>>N;
long long A;
bool ans=false;
for(int i=0;i<N;i++){
    cin>>A;
    if(A%2!=0){
        ans=true;
    }
}

if(ans){
    cout<<"first"<<endl;
}
else{
    cout<<"second"<<endl;
}
 return 0;
}
/*
2
1
2

first

3
100000
30000
20000

second
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;
	Vi  h(n),now(n,0);
	rep(i,n){
		cin>>h[i];
	}
	int at=0;
	rep(i,n){
		if(h[i] >at){
		
			ans+=h[i]-at;
			at = h[i];
		}
		chmin(at,h[i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
N=int(input())
A=[ int(input()) - 1 for _ in range(N) ]
B=[ False ] * N

ans = 0
i=0
while True:
  if B[i]:
    ans = -1
    break
  if i == 1:
    break
  B[i] = True
  i = A[i]
  ans += 1
print(ans)


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

int main(){
  string s;
  cin >> s;
  if(s[0] == s[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 1010101010;

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

    int K, T;
    cin >> K >> T;
    vector<int> a(T);
    REP(i, T) cin >> a[i];
    int mx = *max_element(All(a));
    int sm = accumulate(All(a), 0) - mx;
    cout << max(0, mx-sm-1) << endl;


    return 0;
}

Measured memory_bytes: 256
Sa=list(str(input()))
Sb=list(str(input()))
Sc=list(str(input()))
card=Sa.pop(0)
while 1:
  if card=='a':
    if len(Sa)==0:
      print('A')
      break
    card=Sa.pop(0)
  elif card=='b':
    if len(Sb)==0:
      print('B')
      break
    card=Sb.pop(0)
  elif card=='c':
    if len(Sc)==0:
      print('C')
      break
    card=Sc.pop(0)


Measured memory_bytes: 9016