akhauriyash/Code-Regression huggingface dataset:
//28/03/2020
#include<bits/stdc++.h>
#include<cmath>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define debug printf("Debug\n");
#define en '\n'


#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};
struct OverloadedNode{
    ll val,pos;
    bool operator < (const OverloadedNode &rhs) const {
        if(val==rhs.val) return pos<rhs.pos;
        else return val<rhs.val;
    }
};
//Algos
template<typename T> using Pbds=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//typedef tree<OverloadedNode,null_type,less<OverloadedNode>,rb_tree_tag,tree_order_statistics_node_update>OverloadedPbds;

//Number Theory
template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

//Geometry
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan2( double(y1-y2) , double(x1-x2));}


/*Containers*/
//vector<ll>v;
//deque<ll>dq;
//stack<ll>stk;
//map<ll,ll>mp;
//unordered_map<ll,ll>ump;
//set<ll>st;
//multiset<ll>mst;
//unordered_set<ll>ust;
//unordered_multiset<ll>umst;
//priority_queue<ll,deque<ll>,greater<ll>>pq;
//Pbds<ll>ost;
/*OverLoaded Containers*/
//vector<OverloadedNode>v;
//deque<OverloadedNode>dq;
//stack<OverloadedNode>stk;
//map<OverloadedNode,OverloadedNode>mp;
//set<OverloadedNode>st;
//multiset<OverloadedNode>mst;
//priority_queue<OverloadedNode>pq;
//OverloadedPbds oost;
/*Global Variables*/

int main(){
    _fastio
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]) cout<<"Yes"<<en;
    else cout<<"No"<<en;



    return 0;
}


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

int H, W = 5;

vector<PP> check(vector< vector<int> > &v){
  vector<PP> res;
  REP(i, H){
    int j = 0;
    while(j < W){
      int cnt = 0, tar = v[i][j];
      while(j < W && v[i][j] == tar) { ++cnt; ++j; }
      if(tar != -1 && cnt >= 3) res.push_back(PP(cnt, P(i, j)));
    }
  }
  return res;
}

int remove(vector< vector<int> > &v, vector<PP> &ps){
  int res = 0;
  REP(i, ps.size()){
    int cnt = ps[i].first, y = ps[i].second.first, x = ps[i].second.second;
    REP(j, cnt){
      res += v[y][x - j - 1];
      v[y][x - j - 1] = -1;
    }
  }
  return res;
}

void drop(vector< vector<int> > &v){
  for(int i = H - 1; i >= 0; --i){
    REP(j, W){
      if(v[i][j] != -1) continue;
      for(int y = i - 1; y >= 0; --y){
        if(v[y][j] != -1){
          swap(v[y][j], v[i][j]);
          break;
        }
      }
    }
  }
}

int main() {
  while(cin >>H && H){
    vector< vector<int> > v(H, vector<int>(W));
    REP(i, H) REP(j, W) cin >>v[i][j];
    vector<PP> ps = check(v);
    int res = 0;
    while(ps.size()){
      res += remove(v, ps);
      drop(v);
      ps = check(v);
    }
    cout <<res <<endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
    int a,b,x;

    cin>>a>>b;

    x = a-(b*2);

    if(x<0)
    {
        cout<<"0"<<endl;
    }

    else
    {
        cout<<x<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  unsigned long long int k;
  unsigned long long int a[50];
  int n = 50;
  scanf("%llu",&k);
  for(int i=0; i<n; i++){
    a[i] = i+k/n;
  }
  for(int j=0; j<k%n; j++){
    for(int i=0; i<n; i++){
      if(i == j%n) a[i] = a[i] + n;
      else a[i] = a[i] - 1;
    }
  }
  printf("%d\n",n);
  for(int i=0; i<n; i++){
    printf("%llu ",a[i]);
  }
  return 0;
}

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

using namespace std;
#define INF 1000007
#define MOD 1000000007
#define maxn 101
#define maxh 1001
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
const int dx[4] = {0, 1, -1, 0}, dy[4] = {1, 0, 0, -1};
typedef std::pair<int, int> P;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

int a, b;

void f(int x) {
    while (x) {
        a++;
        b = x;
        x /= 10;
    }
}

signed main() {
    int A, B;
    cin >> A >> B;
    A += B;
    A %= 24;
    cout << A << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>

using namespace std;

int H, W;

int main(){
    cin >> H >> W;
    long long ans = 1e18;
    long long S[3];
    for(int i = 1;i < H;i++){
        S[0] = 1LL * i * W;
        long long h = H - i;
        S[1] = 1LL * (h / 2) * W;
        S[2] = 1LL * (h - h / 2) * W;
        sort(S, S + 3);
        ans = min(ans, S[2] - S[0]);
        S[0] = 1LL * i * W;
        h = H - i;
        S[1] = 1LL * h * (W / 2);
        S[2] = 1LL * h * (W - W / 2);
        sort(S, S + 3);
        ans = min(ans, S[2] - S[0]);
    }
    swap(H, W);
    for(int i = 1;i < H;i++){
        S[0] = 1LL * i * W;
        long long h = H - i;
        S[1] = 1LL * (h / 2) * W;
        S[2] = 1LL * (h - h / 2) * W;
        sort(S, S + 3);
        ans = min(ans, S[2] - S[0]);
        S[0] = 1LL * i * W;
        h = H - i;
        S[1] = 1LL * h * (W / 2);
        S[2] = 1LL * h * (W - W / 2);
        sort(S, S + 3);
        ans = min(ans, S[2] - S[0]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
void print(int x,int y)
{
    int n=x,m=y;
    while(n--)
        putchar('U');
    while(m--)
        putchar('R');
    n=x,m=y;
    while(n--)
        putchar('D');
    while(m--)
        putchar('L');
    putchar('L');
    n=x,m=y;
    while(n--)
        putchar('U');
    putchar('U');
    while(m--)
        putchar('R');
    putchar('R');
    putchar('D');
    putchar('R');
    n=x,m=y;
    while(n--)
        putchar('D');
    putchar('D');
    while(m--)
        putchar('L');
    putchar('L');
    putchar('U');
putchar('\n');
}
int main()
{
    int sx,sy,ex,ey;
    while(scanf("%d%d%d%d",&sx,&sy,&ex,&ey)!=-1)
        print(ey-sy,ex-sx);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N;
    cin >> N;
    // O(N^3)
    int M[300][300];
    for(int i = 0; i < N; i++) {
        string S;
        cin >> S;
        for(int j = 0; j < N; j++) {
            M[i][j] = S[j];
        }
    }
    int ans = 0;
    bool sym = true;
    for(int n = 0; n < N; n++) {
        for(int y = 0; y < N; y++) {
            for(int x = 0; x < N; x++) {
                if (M[(y + n) % N][x] != M[(x + n) % N][y]) {
                    sym = false;
                }
            }
        }
        if(sym) ans += N;
        sym = true;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    int a, b;
    a = b = 0;
    for (int i = 1; i <=k; i++) {
        if (i % 2 == 0)
            a++;
        else
            b++;
    }
    cout << a * b << endl;

    return 0;
}





Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val a, b, c, d = sc.nextLong

    val lcm = c * d / gcd(c, d)
    val ans =
      (b - (b / c) - (b / d) + (b / lcm)) - ((a - 1) - ((a - 1) / c) - ((a - 1) / d) + (a - 1) / lcm)

    println(ans)
  }


  def gcd(x: Long, y: Long): Long = {
    if (x == 0) y
    else gcd(y % x, x)
  }

}


Measured memory_bytes: 27168
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N, D = in.nextInt
  val Ps = Array.fill(N)((in.nextLong, in.nextLong))
  val sq = D.toLong * D

  println(Ps.count{case (x, y) => x * x + y * y <= sq})
}

Measured memory_bytes: 68076
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
s = S()
ans = ''
xx = int(s[0:2])
zz = int(s[2:4])
if xx < 13 and zz < 13 and xx != 0 and zz != 0:
    ans = 'AMBIGUOUS'
elif xx < 13 and xx != 0:
    ans = 'MMYY'
elif zz < 13 and zz != 0:
    ans = 'YYMM'
else:
    ans = 'NA'
print(ans)

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

int main() {
	// your code goes here
	int p,q,r;
	cin>>p>>q>>r;
	if(p<=q && q<=r){
		cout<<p<<" "<<q<<" "<<r<<endl;
	}
	else if(p<=r && r<=q){
		cout<<p<<" "<<r<<" "<<q<<endl;
	}
	else if(q<=p && p<=r){
		cout<<q<<" "<<p<<" "<<r<<endl;
	}
    else if(q<=r && r<=p){
		cout<<q<<" "<<r<<" "<<p<<endl;
	}
	else if(r<=p && p<=q){
		cout<<r<<" "<<p<<" "<<q<<endl;
	}
	else if(r<=q && q<=p){
		cout<<r<<" "<<q<<" "<<p<<endl;
	}
}

Measured memory_bytes: 3092
# -*- coding: utf-8 -*-
# モジュールのインポート
import collections

# 標準入力の取得
N = int(input())
A = list(map(int, input().split()))

# 求解処理
# A_i + i = -A_j + j (i < j)
left = [A[i] + i for i in range(N)]
right = collections.Counter([-A[j] + j for j in range(N)])
result = 0
for l in left:
    result += right[l]

# 結果出力
print(result)


Measured memory_bytes: 50552
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
struct apapun{
	int panjang,l,r;
	apapun(int _panjang,int _l,int _r)
	{
		panjang=_panjang;
		l=_l;
		r=_r;
	}
	apapun(){
	}
};
int tree[100005]={},n,m,ans[100005]={};
vector <apapun> daftar;
int lsone(int angka){
	return (angka&-angka);
}
void update(int indeks,int tambah){
	while(indeks<=m){
		tree[indeks]+=tambah;
		indeks+=lsone(indeks);
	}
}
int nilai(int indeks){
	int ret=0;
	while(indeks>0){
		ret+=tree[indeks];
		indeks-=lsone(indeks);
	}
	return ret;
}
bool cmp(apapun a,apapun b){
	return (a.panjang<b.panjang);
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		int l,r;
		scanf("%d%d",&l,&r);
		daftar.push_back(apapun(r-l+1,l,r));
	}
	sort(daftar.begin(),daftar.end(),cmp);
	int ind=0,sisa=daftar.size();
	for(int i=1;i<=m;i++){
		while(ind<daftar.size()&&daftar[ind].panjang<=i){
			update(daftar[ind].l,1);
			update(daftar[ind].r+1,-1);
			ind++;
			sisa--;
		}
		//cout<<"tai "<<i<<" "<<sisa<<" "<<ind<<endl;
		ans[i]=sisa;
		for(int j=i;j<=m;j+=i)
			ans[i]+=nilai(j);
	}
	for(int i=1;i<=m;i++)
		printf("%d\n",ans[i]);
}

Measured memory_bytes: 6512
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000;

using ll = long long;
using namespace std;

int main(){
    int n; cin >> n;
    int tri=3*n;
    ll a[tri];
    rep(i, tri) cin >> a[i];
    sort(a, a+tri, greater<int>());
    // rep(i, tri) cout << a[i] << endl;
    ll power_max=0;
    for(int i=1; i<2*n; i+=2){
        power_max += a[i];
    }
    cout << power_max << endl;
}

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

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

int main()
{
  int n, x;
  cin >> n >> x;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i] -= x;
    //a[i] = abs(a[i]);
  }
  int ans = a[0];

  for (int i = 1; i < n; i++) {
    ans = gcd(ans, a[i]);
  }

  cout << abs(ans) << endl;

}


Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))
ans=1
for i in range(n):
  if a[i]==0:
    ans=0
    break
if ans!=0:
  for i in range(n):
    ans*=a[i]
    if ans>10**18:
      ans=-1
      break
print(ans)

Measured memory_bytes: 21724
#include<bits/stdc++.h>
using namespace std;
int a[101][101];
int n;
int tt;
int color[101];
int nt[101];
int d[101],p[101];

int next(int u){
	for(int v=nt[u];v<n;v++){
		nt[u]=v+1;
		if(a[u][v])return v;
	}
	return -1;
}

void dfs_visit(int r){
	memset(nt,0,sizeof(nt));
	d[r]=++tt;
	color[r]=1;
	stack<int >s;
	s.push(r);
	while(!s.empty()){
		int u=s.top();
		int v=next(u);
		if(v!=-1){
			if(color[v]==0){
				d[v]=++tt;
				color[v]=1;
				s.push(v);
			}
		}
		else{
			s.pop();
			color[u]=2;
			p[u]=++tt;
		}
	}
}

void dfs(){
	int u;
	tt=0;
	for(u=0;u<n;u++)color[u]=0;
	for(u=0;u<n;u++){
		if(color[u]==0)dfs_visit(u);
	}
	for(u=0;u<n;u++)
	cout<<u+1<<" "<<d[u]<<" "<<p[u]<<endl;
}

int main(){
	cin>>n;
	memset(a,0,sizeof(a));
	for(int i=0;i<n;i++){
		int u;
		int k;
		cin>>u>>k;
		u--;
		for(int j=0;j<k;j++){
			int v;
			cin>>v;
			v--;
			a[u][v]=1;
		}
	}
	dfs();
} 


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int64_t count = 0;
    for (int64_t r=0; r<=3000; r++) {
        for (int64_t g=0; g<=3000; g++) {
            int64_t v = N - ((r * R) + (g * G));
            if (v >= 0 && v % B == 0) {
                count++;
            }
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(n,a,b) (a<=(n)&&(n)<b)
#define F first
#define S second
typedef long long ll;
using namespace std;

int main(){
	string s1,s2;
	cin>>s1>>s2;
	REP(i,0,(int)s1.size()+(int)s2.size()){
		if(i%2){
			cout<<s2[i/2];
		}else{
			cout<<s1[i/2];
		}
	}
	p("");
	return 0;
}


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

int main(){
	long long a,b,GCD,LCM,x,a2,b2;
	while(cin>>a>>b){
	a2=a;
	b2=b;
	while(a!=b){
		if(a>b){
			x=a-b;
			a=b;
			b=x;
		}
		else if(b>a){
			x=b-a;
			b=a;
			a=x;
		}
	}
	GCD=a;
	LCM=a2*b2/a;

	cout<<GCD<<" "<<LCM<<endl;
	}
	return 0;
}

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

#define fori(i,k,n) for(int i = k; i<n; i++)
#define ll long long
#define all(k) k.begin(),k.end()
#define ff first
#define ss second
#define pb push_back

const ll mod = 998244353;

const int mxn = 1e5+1;
ll n;
vector<int> a(n);

ll power(ll x,ll y,ll p){
    ll res = 1;
    x%=p;
    while(y>0){
        if(y&1)res = (res*x)%p;
        y>>=1;
        x = (x*x)%p;
    }
    return res;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int s,w;
	cin>>s>>w;
	if(w>=s)cout<<"unsafe\n";
	else cout<<"safe\n";
}

Measured memory_bytes: 3652
package main

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

func main() {
	n := nextInt()
	rt := int(math.Sqrt(float64(n)))
	minf := 100
	for i := 1; i < rt+1; i++ {
		if n%i == 0 {
			b := n / i
			ndigit := 0
			for b > 0 {
				b /= 10
				ndigit++
			}
			minf = min(minf, ndigit)
		}
	}
	fmt.Println(minf)
}

const size = 1000000

var reader = bufio.NewReaderSize(os.Stdin, size)

func nextLine() string {
	var line, buffer []byte
	isPrefix := true
	var err error
	for isPrefix {
		line, isPrefix, err = reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
	}
	return string(buffer)
}
func nextStringArray() []string {
	return strings.Split(nextLine(), " ")
}
func nextInt() int {
	n, _ := strconv.Atoi(nextLine())
	return n
}
func nextIntArray() []int {
	s := strings.Split(nextLine(), " ")
	n := len(s)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}

func min(i, j int) int {
	if i > j {
		return j
	}
	return i
}


Measured memory_bytes: 640
// B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;

int main()
{
    int n, l;

    cin >> n >> l;

    int saigo = n + l - 1;
    int ans = 0;
    if (l > 0) {
        for (int i = 1; i < n; i++) {
            ans += l + i;
        }
    }
    else {
        if (saigo >= 0) {
            for (int i = 0; i < n; i++) {
                ans += l + i;
            }
        }
        else {
            for (int i = 0; i < n - 1; i++) {
                ans += l + i;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3640
N,K = map(int,input().split())
A = [int(x) for x in input().split()]
A.sort()

mod = 10**9+7


l = 0
r = 0
t = 1
cnt = 1
for i in range(N-K+1)[::-1]:
	l = (l+(t*A[i])%mod)%mod
	t = (t*(cnt+K-1))%mod
	t = (t*pow(cnt,mod-2, mod))%mod
	cnt+=1
t = 1
cnt = 1
for i in range(K-1, N):
	r = (r+(t*A[i])%mod)%mod
	t = (t*(cnt+K-1))%mod
	t = (t*pow(cnt,mod-2, mod))%mod
	cnt+=1


ans = (r-l)%mod
if ans < 0:
	ans += mod
print(ans)


Measured memory_bytes: 63472
#include<stdio.h>

int prime(int x){
      int i;
      if(x==2)return 1;
      if(x<=1||x%2==0)return 0;
      for(i=3;i*i<=x;i+=2){
                if(x%i==0)return 0;
                }
      return 1;
      }
         

int main(){
      int i,n,A[10001];
      int count=0;
      scanf("%d",&n);
      for(i=0;i<n;i++){
               scanf("%d",&A[i]);
               }
      for(i=0;i<n;i++){
               if(prime(A[i]))count++;
               }
      printf("%d\n",count);
      return 0;
      }



Measured memory_bytes: 2108
loop {
    n = gets.to_i
    break if n == 0
    total = Hash.new(0)
    n.times {
        i, p, k = gets.split.map(&:to_i)
        total[i] += p * k
    }
    a = total.keys.select{|i| total[i] >= 1000000}
    puts a.empty? ? "NA" : a
}

Measured memory_bytes: 6112
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
        ArrayList<Integer> list = new ArrayList<>();
        list.addAll(Arrays.asList(sc.nextInt(), sc.nextInt(), sc.nextInt()));
        Collections.sort(list);
        int ans = list.get(0) + list.get(1);
    
		// 出力
		System.out.println(ans);
	}
}


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

vector<int> z_algorithm(const string &s) {
    int n = (int)s.size();
    vector<int> res(n);
    for (int i = 1, j = 0; i < n; i++) {
        if (i + res[i - j] < j + res[j]) {
            res[i] = res[i - j];
        } else {
            int k = max(0, j + res[j] - i);
            while (i + k < n && s[k] == s[i + k]) k++;
            res[i] = k;
            j = i;
        }
    }
    res[0] = n;
    return res;
}

int main() {
    int N;
    string S;
    cin >> N >> S;

    int res = 0;
    for (int i = 0; i < N; i++) {
        string t = S.substr(i, N - i);
        vector<int> Z = z_algorithm(t);
        for (int j = i + 1; j < N; j++) {
            res = max(res, min(j - i, Z[j - i]));
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int n,s;
    while(scanf("%d",&n)!=EOF)
    {
        s=0;
        for(int i=1;i<=n;i++)
        {
            s=s+i;
        }
        printf("%d\n",s);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int mod=1000000007;
const int INF=1001001001;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int64_t N;
  cin>>N;
  auto t=prime_factorize(N);
  int ans=0;
  for(auto c:t){
    auto p=c.first,e=c.second;
    int cnt=0;
    int s=1;
    while(e-s>=0){
      cnt++;
      e-=s;
      s++;
    }
    ans+=cnt;
  }
  cout<<ans<<endl;
  return 0;  
}


Measured memory_bytes: 3592
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  int n;
  cin >> n;

  n %= 1000;
  cout << (n ? 1000 - n : n) << '\n';

  




  
  return 0;
}

Measured memory_bytes: 3644
from collections import defaultdict

s = list(input())
n = len(s)

cnt = defaultdict(list)

for i in range(n):
    cnt[s[i]].append(i)
ans = float("inf")
for k, l in cnt.items():
    res = l[0]
    for i in range(1, len(l)):
        res = max(res, l[i] - l[i-1] - 1)
    res = max(res, n - l[-1] - 1)
    ans = min(ans, res)

print(ans)


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  int cnt = 0, s1 = -1, s2 = -1;
  vector<int> a(m);
  for ( int i = 0; i < m; ++ i) {
    cin >> a[i]; 
    if( a[i] & 1) {
      ++ cnt;
      if( cnt == 1) {
        s1 = i;
      } else {
        s2 = i;
      }
    }
  }
  if( cnt >= 3) {
    cout << "Impossible\n";
  } else {
    if( m == 1) {
      cout << a[0] << "\n";
      cout << 1 + (n != 1) << "\n" << 1;
      if( n != 1) {
        cout << " " << n-1 << "\n";
      }
    } else {
      if( ~ s1) {
        swap(a[s1], a[0]);
      } 
      if( ~ s2) {
        swap(a[s2], a[m-1]);
      }
      for ( auto v : a) {
        cout << v << " ";
      } 
      a[0] ++; a[m-1] --;
      if( !a[m-1]) {
        a.pop_back();
      }
      cout << "\n" << a.size() << "\n";
      for ( auto v : a) {
        cout << v << " ";
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
int N,Q,id[1<<17];
set<int>S;
main()
{
	cin>>N>>Q;
	int now=1;
	S.insert(1);
	S.insert(2);
	for(int i=1;i<=N;i++)id[i]=i;
	for(int i=0;i<Q;i++)
	{
		int a,b;cin>>a>>b;
		if(a==now)now=b;
		else if(b==now)now=a;
		swap(id[a],id[b]);
		if(now>1)S.insert(id[now-1]);
		if(now<N)S.insert(id[now+1]);
	}
	cout<<S.size()<<endl;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;
const int maxn=2e5+5;
int a[maxn];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	int ans=0;
	rep(i,0,n)
	{
		cin>>a[i];
		ans^=a[i];
	}
	rep(i,0,n) cout<<(ans^a[i])<<" ";
	return 0;
}

Measured memory_bytes: 4336
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define PB push_back
#define SP << " " <<

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;

__attribute__((constructor))
void initial(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed <<setprecision(15);
}


int main(void){
	int N;
    cin >> N;
    cout << (N+1)/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n, k, h[100000], dp[100000];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> k;
	for(int i = 0; i < n; i++) cin >> h[i], dp[i] = INT_MAX;
	dp[0] = 0;
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j <= i + k && j < n; j++) dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));
	cout << dp[n - 1] << "\n"; 
	return 0;
}

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

long long grid[501][501];
long long valu[31][31];

long long freq[3][31];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, c;

    cin >> n >> c;

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

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

    // Preprocess

    for(int offset = 0; offset < 3; ++offset){

        int X = 0, Y = offset;

        while(X < n || Y < n){
            int y = Y;
            int x = X;
            while(x < n && y >= 0){
                freq[offset][grid[x][y] - 1]++;
                y--; x++;
            }
            if(Y + 3 < n){
                Y += 3;
            } else {
                X += 3 - ((n - 1) - Y);
                if(X >= n)
                    break;
                Y = n - 1;
            }
        }

    }

    long long best = -1;

    for(int ca = 0; ca < c; ++ca){

        long long costa = 0;

        for(int other = 0; other < c; ++other)
            costa += valu[other][ca] * freq[0][other];

        for(int cb = 0; cb < c; ++cb){

            if(ca == cb)
                continue;

            long long costb = 0;

            for(int other = 0; other < c; ++other)
                costb += valu[other][cb] * freq[1][other];

            for(int cc = 0; cc < c; ++cc){

                if(ca == cc || cc == cb)
                    continue;

                long long costc = 0;

                for(int other = 0; other < c; ++other)
                    costc += valu[other][cc] * freq[2][other];

                if(best == -1){
                    best = costa + costb + costc;
                } else {
                    best = min(best, costa + costb + costc);
                    //cout << costa << " " << costb << " " << costc << endl;
                }

            }
        }
    }

    cout << best;

    return 0;
}


Measured memory_bytes: 2176
import java.util.Scanner;

//????????????

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

		//???????????????


		while (sc.hasNext()) {
			String line1 = sc.next();
			if(line1.equals("-")) {
				break;
			}

			int count = sc.nextInt();

			for(int i = 0; i < count;i++) {
				int num = sc.nextInt();
				//StringBuilder???????????§???????????????
				StringBuilder sb = new StringBuilder(line1);

				//?????????????????????????????????????????????
				//????????????????????????
				String cutLine = sb.substring(0 , num);
				line1 = sb.delete(0, num).toString();
				line1 += cutLine;
			}

			System.out.println(line1);



		}

	}
}

Measured memory_bytes: 26384
#include<iostream>

using namespace std;

int main() {
  int i,A,B;
  int temp;
  cin >> A >> B;
  
  if (B == 1) {
    cout << 0;
  }
  else if(A >= B){
    cout << 1;
  }else{
    for(i=2;i<=40;i++){
       temp = (A-1)*(i-1) + A;
       if (temp >= B) break;
    }
    cout << i;
  }
  return 0;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int INF = 1000000000; // 10^9

int main() {
    int s; cin >> s;
    set<int> S;
    while (S.insert(s).second)
        s = (s % 2) ? 3 * s + 1 : s / 2;
    cout << S.size() + 1 << endl;
    return 0;
}

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

int main()
{
    int H, W;
    cin >> H >> W;

    vector<vector<char>> a(H, vector<char>(W));
    for (int r = 0; r < H; r++)
    {
        for (int c = 0; c < W; c++)
        {
            cin >> a.at(r).at(c);
        }
    }

    vector<bool> can_remove_row(H, true);
    for (int r = 0; r < H; r++)
    {
        for (int c = 0; c < W; c++)
        {
            if (a.at(r).at(c) == '#')
            {
                can_remove_row.at(r) = false;
                break;
            }
        }
    }

    vector<bool> can_remove_col(W, true);
    for (int c = 0; c < W; c++)
    {
        for (int r = 0; r < H; r++)
        {
            if (a.at(r).at(c) == '#')
            {
                can_remove_col.at(c) = false;
                break;
            }
        }
    }

    for (int r = 0; r < H; r++)
    {
        if (can_remove_row.at(r))
        {
            continue;
        }
        for (int c = 0; c < W; c++)
        {
            if (can_remove_col.at(c))
            {
                continue;
            }
            cout << a.at(r).at(c);
        }
        cout << endl;
    }
}

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    if (a == b && b == c) cout << 1 << endl;
    else if (a != b && b != c && a != c) cout << 3 << endl;
    else cout << 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n, y, m, d;
	int year_sum[1024] = {0};
	int month_sum[16] = {0};
	int sum = 0;

	int i;

	for(i = 1; i < 1024; i++) {
		if(i % 3 == 0)
			year_sum[i] = 20 * 10 + year_sum[i - 1];
		else
			year_sum[i] = 20 * 5 + 19 * 5 + year_sum[i - 1];
	}

	for(i = 1; i < 16; i++) {
		if(i % 2 == 0)
			month_sum[i] = 19 + month_sum[i - 1];
		else
			month_sum[i] = 20 + month_sum[i - 1];
	}

	scanf("%d", &n);

	for(i = 0; i < n; i++) {
		int temp = 0;
		
		scanf("%d %d %d", &y, &m, &d);

		temp += year_sum[y - 1];

		if(y % 3 == 0)
			temp += 20 * (m - 1);
		else
			temp += month_sum[m - 1];

		temp += d;

		printf("%d\n", year_sum[999] + 1 - temp);
	}

	return 0;
}

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

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

	if (a > b){
		if (c > a){
			cout << b << " " << a << " " << c << endl;
		}
		else if (b > c){
			cout << c << " " << b << " " << a << endl;
		}
		else{
			cout << b << " " << c << " " << a << endl;
		}
	}
	else{
		if (c > b){
			cout << a << " " << b << " " << c << endl;
		}
		else if (a > c){
			cout << c << " " << a << " " << b << endl;
		}
		else{
			cout << a << " " << c << " " << b << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    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;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    string S; cin >> S;
    int a = (int)(S[0]-'0')*10 + (int)(S[1]-'0');
    int b = (int)(S[2]-'0')*10 + (int)(S[3]-'0');
    cerr << a << "\t" << b << endl;
    if(1<=a && a<=12){
        if(1<=b && b<=12){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "MMYY" << endl;
        }
    }else{
        if(1<=b && b<=12){
            cout << "YYMM" << endl;
        }else{
            cout << "NA" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3612
<?php
    fscanf(STDIN, "%d %d", $n, $m);

    for ($i = 0; $i < $m; $i++) {
        fscanf(STDIN, "%d %d %d", $a[$i], $b[$i], $c[$i]);
        $a[$i]--;
        $b[$i]--;
    }

    for ($i = 0; $i < $n; $i++) {
        for ($j = 0; $j < $n; $j++) {
            if ($i == $j) {
                $dist[$i][$j] = 0;
            } else {
                $dist[$i][$j] = PHP_INT_MAX;
            }
        }
    }

    for ($i = 0; $i < $m; $i++) {
        $dist[$a[$i]][$b[$i]] = min($dist[$a[$i]][$b[$i]], $c[$i]);
        $dist[$b[$i]][$a[$i]] = min($dist[$b[$i]][$a[$i]], $c[$i]);
    }

    for ($k = 0; $k < $n; $k++) {
        for ($i = 0; $i < $n; $i++) {
            for ($j = 0; $j < $n; $j++) {
                $dist[$i][$j] = min($dist[$i][$j], $dist[$i][$k] + $dist[$k][$j]);
            }
        }
    }

    $ans = $m;

    for ($i = 0; $i < $m; $i++) {
        $shortest = false;
        for ($j = 0; $j < $n; $j++) {
            if ($dist[$j][$a[$i]] + $c[$i] == $dist[$j][$b[$i]]) {
                $shortest = true;

            }
        }
        if ($shortest === true) {
            $ans--;
        }        
    }

    echo $ans . PHP_EOL;
    

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

typedef long long int ll;

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

    ll s = min(n, m / 2LL);
    ll l = m - 2LL * s;
    ll d = l / 4LL;

    cout << s + d << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX_N 100

int main(){
	int i,j,k,l;
	int n,tmp,min,cnt=0;
	int A[MAX_N];
	scanf("%d",&n);
	for(i=0; i<n; i++) scanf("%d",&A[i]);

	for(j=0; j<n; j++){
		min = j;
		for(k=j; k<n; k++){
			if(A[k] < A[min]) min = k;
		}
		tmp = A[j];
		A[j] = A[min];
		A[min] = tmp;
		if(j != min) cnt++;
	}

	for(l=0; l<n; l++){
		if(l != n-1) printf("%d ",A[l]);
		else printf("%d\n",A[l]);
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 600
package main

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

func main() {
	nextReader = newScanner()
	A, B := nextInt(), nextInt()
	ans := A - 2*B
	if ans <= 0 {
		ans = 0

	}
	fmt.Println(ans)
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}


Measured memory_bytes: 640
MOD = 1_000_000_007
n, m = map(int,input().split())
if abs(n-m)>1:
    print(0)
else:
    if abs(n-m)==1:
        ans = 1
    else:
        ans = 2
    for i in range(n):
        ans = (ans*(i+1))%MOD
    for i in range(m):
        ans = (ans*(i+1))%MOD
    print(ans)

Measured memory_bytes: 9172
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for(long long i = (n-1);i>=0;i--)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int n,Ma,Mb;
  cin >> n >> Ma >> Mb;
  
  int a[n],b[n],c[n];
  REP(i,n){
    cin >> a[i] >> b[i] >> c[i];
  }
  
  int dp[401][401];
  REP(i,401){
    REP(j,401){
        dp[i][j] = MOD;
    }
  }
  
  dp[0][0] = 0;
  REP(i,n){
    RREP(j,401){
      if(j-a[i] < 0) break;
      RREP(k,401){
        if(k-b[i] < 0) break;
        if(dp[j-a[i]][k-b[i]] != MOD) dp[j][k] = min(dp[j][k],dp[j-a[i]][k-b[i]] + c[i]);
      }
    }
  }
  
  int ans = MOD, i = 1;
  while(i*Ma <= 400 && i*Mb <= 400){
    ans = min(ans,dp[i*Ma][i*Mb]);
    i++;
  }
  
  if(ans == MOD) cout << -1 << endl;
  else			 cout << ans << endl;

  return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
using ll = long long;

int main(){
  ll n,m;
  cin >> n >> m;
  if(n < m){
    cout << 0;
  }else{
    cout << 10;
  }
}


Measured memory_bytes: 256
import bisect
import sys
import math
from collections import deque
from heapq import heappush, heappop

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29

DIV = (10**9) + 7
#DIV = 998244353

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    A,B,C = isRaw()
    K = iRaw()
    for k in range(K):
        if B<=A:
            B*=2
        else:
            C*=2
    if B>A and C>B:
        print("Yes")
    else:
        print("No")
main()


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

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007
void printbit(int u){if(u==0)cout<<0;else{int s=0,k=0;for(;0<u;u>>=1,k++)s=(s<<1)|(u&1);for(;0<k--;s>>=1)cout<<(s&1);}}

#define TIME chrono::system_clock::now()
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

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

ll m,n;

int main(){
    int i,j,k;
    
    cin >> n;
    
    ll result=0;
    
    ll l,h,c,d,nn;
    nn=n;
    while (result != n){
        l = 1;
        h = nn;
        while (l+1<h){
            c = (l + h) / 2;
            d = c*(c+1)/2+result;
            if (d<n){
                l = c;
            }else if (d > n){
                h = c;
            }else{
                l = h = c;
                break;
            }
        }
        if (l*(l+1)/2+result < n){
            printf("%lld\n",h);
            result+=h;
            nn=h;
        }else {
            printf("%lld\n",l);
            result+=l;
            nn=l;
        }
    }
    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
int main()
{
	int n;
	scanf("%d",&n);
	ll ans=0,pre=0,x;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&x);
		ans=(ans+x*pre)%mod;
		pre=(pre+x)%mod;
	}
	printf("%lld\n",ans);
}	

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

int main() {
  double N;
  cin>>N;
  vector<double> a(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
    }
  double m=0;
for(int i=0;i<N;i++){
  m+=a[i]/N;
}

double d=1234567890;
long ans=-1;
for(int i=0;i<N;i++){
  if(d>abs(a[i]-m)){
    d=abs(a[i]-m);
    ans=i;
  }
}
cout<<ans<<endl;
}


Measured memory_bytes: 3748
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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


int ans[1000000];


int main(){
  string s;
  cin >> s;
  int size = s.size();
  int tmp = 0;
  rep(i,size){
    if(s[i] == 'R'){
      tmp++;
    }
    else{
      ans[i] += tmp/2;
      ans[i-1] += tmp/2+(tmp%2);
      tmp = 0;
    }
  }
  for(int i = size - 1; i >= 0; i--){
    if(s[i] == 'L'){
      tmp++;
    }
    else{
      ans[i] += tmp/2;
      ans[i+1] += tmp/2+(tmp%2);
      tmp = 0;
    }
  }
  rep(i,size) cout << ans[i] << endl;
}




Measured memory_bytes: 1024