akhauriyash/Code-Regression huggingface dataset:
a = [list(map(int, input().split())) for _ in range(3)]
bingo = [[False]*3 for _ in range(3)]
n = int(input())

for _ in range(n):
    b = int(input())
    for i, row in enumerate(a):
        for j, col in enumerate(row):
            if a[i][j]==b:
                bingo[i][j]=True

for i in range(3):
    if all([bingo[i][j] for j in range(3)]):
        print('Yes')
        exit()
    if all([bingo[j][i] for j in range(3)]):
        print('Yes')
        exit()

if all([bingo[i][i] for i in range(3)]):
    print('Yes')
    exit()
if all([bingo[i][2-i] for i in range(3)]):
    print('Yes')
    exit()

print('No')

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;



int main()
{
    int n;
    cin >> n;
    ll a[n];
    ll b[n];
    ll sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    b[0] = a[0];
    for(int i = 1; i < n; i++){
        b[i] = a[i] + b[i-1];
    }
    
    ll ans = sum;
    for(int i = 0; i < n; i++){
        if(ans > abs(sum-b[i]-b[i])){
            ans = abs(sum-b[i]-b[i]);
        }
    }
    cout << ans << endl;

}

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


int main()
{
	int N = 3;
	int a[3];
	int b[3];
	bool F_NO = false;
	string rslt;

	for (int i = 0; i < N; i++) {
		std::cin >> a[i] >> b[i];
	}

	int baget[] = { 0,0,0,0 };
	for (int i = 0; i < N; i++) {
		if (a[i] == b[i])F_NO = true;
		baget[a[i]-1] += 1;
		baget[b[i]-1] += 1;
	}

	for (auto&& s : baget) {
		if (s < 1 || s>2)F_NO = true;
	}
	rslt = (F_NO) ? "NO" : "YES";

	std::cout << rslt;

	return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    for (int i = 0; i < n; ++i) cin >> h[i];
    ll ans = 1001001001001001001;
    for (int j = 0; j < (1 << n); ++j) {
        ll cost = 0;
        bitset<15> bs(j);
        ll mx = 0;
        vector<ll> copy = h;
        for (int i = 0; i < n; ++i) {
            if (bs.test(i) && copy[i] <= mx) {
                cost += mx - copy[i] + 1;
                copy[i] = mx + 1;
            }
            mx = max(mx, copy[i]);
        }
        int cnt = 0;
        mx = 0;
        for (int l = 0; l < n; ++l) {
            if (mx < copy[l]) {
                cnt++;
                mx = copy[l];
            }
        }
        if (cnt < k) continue;
        ans = min(ans, cost);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define clr(x, y) memset(x,y,sizeof(x));
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i, m, n) for(int i=m ; i<n ; i++)
#define forr(i, m, n) for(ll i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N = 1e5 + 5;
const ll OO = 1e9+7;
using namespace std;
int main() {
    IO;
   int n; cin>>n;
   ll sum=0,g=0;
   forr(i,1,n){
       forr(j,1,n){
           forr(k,1,n){
               g=__gcd(__gcd(i,j),k);
               sum+=g;
           }
       }
   }

   cout<<sum;


    


}

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

using namespace std;
long long gcd(long long a,long long b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
int main(){
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	long long sum=b-a+1;
	long long ans=b/c-(a-1)/c;
//	cout<<ans<<endl;
	long long cnt=b/d-(a-1)/d;
//	cout<<cnt<<endl;
	long long k=c*d/gcd(c,d);
//	cout<<k<<endl;
	long long koko=b/k-(a-1)/k;
//	cout<<k<<endl;
	cout<<sum-ans-cnt+koko;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

//-------------------------------------

bool dist(vector<int> &y, vector<int> &z)
{
    double res = 0;
    int dd = y.size();
    for (int i = 0; i < dd; i++)
    {
        res += (double)(y[i] - z[i]) * (y[i] - z[i]);
    }
    res = sqrt(res);
    if (res - (int)res == 0)
    {
        return true;
    }
    return false;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d;
    cin >> n >> d;
    vector<vector<int>> x(n, vector<int>(d));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < d; j++)
        {
            cin >> x[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            if (dist(x[i], x[j]))
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
                
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pretime float(clock()-clk)/CLOCKS_PER_SEC
#define max2(a,b) ((a)>(b) ? (a) : (b))   
#define min2(a,b) ((a)<(b) ? (a) : (b)) 
#define rep(i,a,b) for(i=a;i<=b;++i)
#define rev(i,a,b) for(i=a;i>=b;--i) 
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define ll long long int 
#define ins insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
#define inf 1000000000000000
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'

using namespace std;
typedef vector<ll>   vll;
typedef vector<int>   vi;
typedef set<ll>      sll;
typedef set<int>      si;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
clock_t clk=clock();       

ll i,j;
void solve(void);

int main()
{
  speedio;
   int t=1;  
  // cin>>t;
   while(t--)
     solve();

  return 0;
}

// #define cerr if(0)cerr
void solve()
{
	string s; cin>>s;
	rep(i,1,3) if(s[i]==s[i-1]) {cout<<"Bad\n"; return;}
	cout<<"Good\n";
}

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

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  vector<vector<int>> c(3, vector<int>(3));

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

  vector<int> a(3);
  vector<int> b(3);
  bool judge = false;
  for(int i = 0; i <= 100; ++i) {
    a[0] = i;
    b[0] = c[0][0] - a[0];
    b[1] = c[0][1] - a[0];
    b[2] = c[0][2] - a[0];
    a[1] = c[1][1] + b[1];
    a[2] = c[2][1] + b[1];

    for(int j = 0; j < 3; ++j) {
      for(int k = 0; k < 3; ++k) {
        if(c[j][k] == (a[j] + b[k])) {
          judge = true;
        }
        else {
          judge = false;
          break;
        }
      }
      if(!judge) {
        break;
      }
    }
    if(judge) {
      break;
    }
  }

  cout << (judge ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3636
N=int(input())
A=list(map(int,input().split()))

X=[A[i] for i in range(0,N,2)]
Y=[A[i] for i in range(1,N,2)]

if N%2:
    A=X[::-1]
    B=Y
else:
    A=Y[::-1]
    B=X

print(" ".join(map(str,A+B)))


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

int main() {
    vector<int> vec(32);
    vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int K;
    cin >> K;

    cout <<  vec.at(K - 1) << endl;
    
}

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

int debug = 0;

int main()
{
    char ch;
    int n;
    cin >>ch;
    n = ch-'a';
    printf("%c\n",'a'+n+1);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int n, l;
  cin >> n >> l;
  
  int s = 0;
  int i = l;
  
  while(i < n + l){
    s += i;
    i++;
  }
      
  if(l > 0)
    s -= l;
  if(l + n - 1 < 0)
    s -= (l + n - 1);
  
  cout << s << endl;
}
    

Measured memory_bytes: 256
lisS = list(input())
lisT = list(input())
for i in range(len(lisS)-len(lisT)+1)[::-1]:
  for num,item in list(enumerate(lisT))[::-1]:
    if item != lisS[i+num] and lisS[i+num] != "?":
      break
  else:
    for j in range(len(lisT)):
      lisS[i+j] = lisT[j]
    while "?" in lisS:
      lisS[lisS.index("?")] = "a"
    print ("".join(lisS))
    break
else:
  print ("UNRESTORABLE")

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 100010
#define inf 1e9

int main()
{

    vector<string> v, ans;
    map<string,ll> m, tak;
    ll mx = 0;
    ll n;
    cin >> n;
    for(ll i = 0; i < n; i++)
    {

        string ss;
        cin >> ss;
        v.pb(ss);
        m[ss]++;
        mx = max(m[ss], mx);
    }
    for(ll i = 0; i < v.size(); i+=1)
    {

        string ss = v[i];
        if(m[ss] == mx && tak[ss] == 0) ans.pb(ss);
        tak[ss]=1;
    }
    sort(ans.begin(), ans.end());

    for(ll i = 0; i < ans.size(); i++) cout << ans[i] << endl;
}


Measured memory_bytes: 40816
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
        t: chars,
    }
    let mut hs = std::collections::HashMap::new();
    let mut ht = std::collections::HashMap::new();
    for i in 0..s.len() {
        *hs.entry(&s[i]).or_insert(0) += 1;
        *ht.entry(&t[i]).or_insert(0) += 1;
        if hs.get(&s[i]).unwrap() != ht.get(&t[i]).unwrap() {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 6396
def prime(k):
    j=2
    while j**2 <= k:
        if k%j == 0:
            break
        j += 1
    if j**2 <= k or k == 1:
        return False
    else:
        return True
n = int(input())
a=[]
for i in range(n):
    a.append(int(input()))
x=0
for k in a:
    if prime(k):
        x += 1
print(x)


Measured memory_bytes: 5976
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)
#define MP make_pair
typedef long long LL;
#define EPS (1e-6)
double zero(double d){
  return d < EPS ? 0.0 : d;
}

typedef pair<int,int> P;

int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(7);
  int INF = 1000000;

  string str;
  while(getline(cin,str)){

    REP(j,25){
      string nstr = "";
      REP(i, str.length()){
	if(str[i]==' ' || str[i]=='.'){
	  nstr += str[i];
	  continue;
	}
	int bd = str[i] - 'a';
	bd -= j;
	if(bd < 0)
	  bd += 26;
	nstr += 'a'+bd;
      }

      if( nstr.find("the") != string::npos ||
	  nstr.find("this") != string::npos ||
	  nstr.find("that") != string::npos ){       
	cout << nstr << endl;
	break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1192
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var S = cin.ReadStrArray(N);

            var ThreeElem = true;

            if (S.Any(elem => elem == "Y")) ThreeElem = false;

            if (ThreeElem) WriteLine("Three");
            else WriteLine("Four");
        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13396
#include <iostream>

using namespace std;
int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  int ret;
  if (n <= k){
    ret = n * x;
  } else {
    ret = k * x + (n - k) * y;
  }
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
	ll n;
	cin >> n;
	set <ll> s;
	s.insert(n);
	ll k = 1;
	while (true){
		k++;
		if (n & 1){
			n = 3*n+1;
		} else {
			n /= 2;
		}
		if (binary_search(s.begin(),s.end(),n)){
			cout << k << endl;
			break;
		}
		s.insert(n);
	}
	cin >> n;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FILE freopen("input.txt", "rt", stdin);freopen("output.txt", "wt", stdout);
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
const char nl = '\n';
int main(){
    FAST_IO;
    //FILE;
    int n=5;
    int a[n+1];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        if(a[i]==0){
            cout<<i+1<<nl;
            break;
        }
    }
    return 0;
}




Measured memory_bytes: 3592
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
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;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

ll n, k;
vector<long long> vec(n);
ll ans = 1e15;

void bit_search(ll n, ll k){

    for(ll bit = 0; bit < (1<<n); bit++){
        ll can_see = 0;
        vector<ll> build;
        vector<ll> test;
        for(ll i = 0; i < n; i++){
            if(bit & (1<<i)){
                can_see++;
                build.push_back(vec[i]);
                test.push_back(i);
            }
        }
        
        if(can_see >= k){
            ll tmp = 0;
            ll now = 0;
            ll count = 0;
            
            /*
            rep(j, test.size()){
                cout << test[j] << " ";
            }
            br;
            */

            for(ll j = 0; j < n; j++){
                /*
                if(j == 0){
                    now = build[j];
                    continue;
                }
                */
                if(j == test[count]){
                    if(now >= vec[j]){
                        tmp += now + 1 - vec[j];
                        now = now + 1;
                    }else{
                        now = vec[j];
                    }
                    count++;
                }else{
                    now = max(now, vec[j]);
                }

                //cout << tmp << " ";
                
            }
            //br;
            //cout << tmp << endl;
            ans = min(ans, tmp);
        }
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    cin >> n >> k;
    vec.resize(n);
    
    for(long long i = 0; i < n; i ++){
        cin >> vec[i];
    }

    bit_search(n, k);

    cout << ans << endl;


}

Measured memory_bytes: 3604
//#pragma warning(disable:4996)
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e15;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N;
	cin >> N;
	if (N % 2 == 1) {
		cout << 0 << "\n";
	}
	else {
		LL n = N / 2;
		LL ans = 0;
		while (n > 0) {
			ans += n / 5;
			n /= 5;
		}
		cout << ans << "\n";
	}
	return 0;
}

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

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

  vector<int> a(3 * N);
  for (int i = 0; i < 3 * N; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  
  int64_t ans = 0;
  for (int i = N; i < 3 * N; i += 2)
    ans += a[i];
  cout << ans << endl;
}


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

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

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  for(int i=0;i<h;++i){
    cin >> s[i];
  }
  for(int i=0;i<h;++i){
    for(int j=0;j<w;++j){
      if(s[i][j]=='#'){
        bool ha=false;
        for(int dir=0;dir<4;++dir){
          int di=i+dx[dir];
          int dj=j+dy[dir];
          if(di<0 || di>=h || dj<0 || dj>=w) continue;
          if(s[di][dj]=='#'){
            ha=true;
          }
        }
        if(ha==false){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

namespace _0347
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            double[] x = Console.ReadLine().Split().Select(double.Parse).ToArray();
            Array.Sort(x);
            double ret = 0;
            for (int i = 1; i < n - 2; i++)
            {
                ret = Math.Max(ret, (x[n - 1] + x[n - 2]) / (x[i] - x[i - 1]));
            }
            ret = Math.Max(ret, (x[n - 1] + x[n - 4]) / (x[n - 2] - x[n - 3]));
            ret = Math.Max(ret, (x[n - 3] + x[n - 4]) / (x[n - 1] - x[n - 2]));
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 9824
#include<bits/stdc++.h>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define pb(s) push_back(s)
#define ci(x) cin >>x
#define co(x) cout<<x<<endl
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
long long fac(ll a) {
 long long ans=1;
 while(a>1){
 ans*=a;
 ans%=1000000007;
     a--;
    }
    return ans;
     }

int main() {
  
  
  
  ll A;
   ll B;
   ll C;
  cin >>A>>B>>C;
  
  
  if(A+B>=C) {
    cout<<B+C<<endl;
  }
  else if(A+B<C) {
    cout<<(A+B)+B +1<<endl;
  }
}

Measured memory_bytes: 256
while 1:
    try:
        a = list(map(int, input().split()))
        b = list(map(int, input().split()))
    
        hit = 0
        blow = 0

        for i in range(4):
            if a[i] == b[i]:
                hit += 1
            for j in range(4):
                if a[i] == b[j]:
                    blow += 1
        blow -= hit
        print(hit, blow)
        
    except EOFError:
        break


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

int main() {
  int N;
  cin >> N;
  int a[100010];
  for (auto i = 0; i < N; i++) {
    cin >> a[i];
  }
  sort(a, a+N);
  reverse(a, a+N);
  int ind = 0;
  while (ind+1 < N && ind+1 < a[ind+1]) {
    ind++;
  }
  cerr << ind << endl;
  int x = a[ind] - ind;
  int t = ind;
  while (t < N && a[t] > ind) {
    t++;
  }
  int y = t - ind;
  cerr << x << " " << y << endl;
  if (x % 2 != 0 && y % 2 != 0) {
    cout << "Second" << endl;
  } else {
    cout << "First" << endl;
  }
}


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

long long n, a;
long long x[55] = {0};
long long dp[55][55][5550] = {0};

long long solve();

int main() {
  cin >> n >> a;
  for(int i = 0; i < n; ++i) cin >> x[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  for(int i = 0; i <= n; ++i) dp[i][0][0] = 1;
  for(int i = 0; i < n; ++i)
    for(int j = 1; j <= n; ++j)
      for(long long k = 1; k <= 3000; ++k) {
        dp[i + 1][j][k] += dp[i][j][k];
        if(k >= x[i])
          dp[i + 1][j][k] += dp[i][j - 1][k - x[i]];
      }
  for(long long i = 1; i <= n && i * a <= 3000; ++i)
    ans += dp[n][i][i * a];
  return ans;
}

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

typedef long long ll;
const ll mod=1e9+7;
const int N=200000;

void Run()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
ll a[N];
int main()
{
    Run();
    ll n;
    cin>>n;
    string s="";
    while(n--)
    {
        ll x=n%26;
        s.push_back('a'+x);
        n/=26;
    }
    reverse(s.begin(),s.end());
    cout<<s;
}


Measured memory_bytes: 3560
S = input()
T = input()

if all([c in S for c in T])!=True:
	print(-1)
	exit()

str_repeat_num = 0
now_idx = 0
for t in T:
    if t in S[now_idx:]:
        now_idx += S[now_idx:].index(t) + 1
    else:
        str_repeat_num += 1
        now_idx = S[:now_idx].index(t) + 1
print(len(S) * str_repeat_num + now_idx)


Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
int count(int H, int X, int a, int b, string s[]){
  int count = 0;
  for(int i = a; i < a+3; i++){
    if(i-1 >= 0 && i-1 <= H-1){
    	for(int j = b; j < b+3; j++){
      		if(j-1 >= 0 && j-1 <= X-1){
      			if(s[i-1].at(j-1) == '#')
        			count++;
            }
        }
    }
  }
  return count;
}
 
int main(){
  int H, X;
  cin >> H >> X;
  string S[H];
  for(int i = 0; i < H; i++)
    cin >> S[i];
  for(int i = 0; i < H; i++){
    for(int j=0; j < X; j++){
      if(S[i].at(j) == '#'){
        cout << "#";
      }else 
        cout << count(H, X, i, j, S);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
char s[N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  scanf("%s", s);
  vector<int> sum(n + 1);
  for (int i = 1; i < n; ++i) {
    sum[i + 1] = sum[i];
    if (s[i - 1] == 'A' && s[i] == 'C') {
      sum[i + 1] = sum[i - 1] + 1;
    }
  }
  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y);
    int ret = sum[y] - sum[x - 1];
    if (x - 2 >= 0 && s[x - 2] == 'A' && s[x - 1] == 'C') --ret;
    printf("%d\n", ret);
  }
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define set_zero(a) memset(a,0,sizeof(a));
#define ll long long
#define PI 2 * acos(0.0)
#define MAX 1000000000
#define INF 1000000 
#define M 1000000007
using namespace std;
int main(){
   string s;
   cin>>s;
   if(s == "SUN"){
      cout<<7<<endl;
   }
   else if(s == "MON"){
      cout<<6<<endl;
   }
   else if(s == "TUE"){
      cout<<5<<endl;
   }
   else if(s == "WED"){
      cout<<4<<endl;
   }
   else if(s == "THU"){
      cout<<3<<endl;
   }
   else if(s == "FRI"){
      cout<<2<<endl;
   }
   else if(s == "SAT"){
      cout<<1<<endl;
   }
   return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

void max_heapify(vector<ll> &A, ll i) {
	ll H = A.size() - 1; // size of 1-origin array A
	ll lc, rc;
	lc = 2*i;
	rc = 2*i + 1;
	ll largest = i;
	if (lc <= H && A[lc] > A[i]) {
		largest = lc;
	}
	if (rc <= H && A[rc] > A[largest]) {
		largest = rc;
	}

	if (largest != i) {
		ll temp = A[i];
		A[i] = A[largest];
		A[largest] = temp;
		max_heapify(A, largest); 
	}
}

void build_max_heap(vector<ll> &A) {
	ll H = A.size() - 1;
	for (ll i=H/2; i>0; --i) {
		max_heapify(A, i);
	}
}

int main() {
	ll H;
	cin >> H;
	vector<ll> A(H+1);
	for (ll i=1; i<A.size(); ++i) cin >> A[i];
	build_max_heap(A);
	for (ll i=1; i<A.size(); ++i) cout << " " << A[i];
	cout << endl;
	return 0;
}




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

int main() {
    int K, A, B;
    cin >> K >> A >>B;
    
    bool ans = 0;
    for (int i=A; i<B+1; i++) {
        if (i%K==0) {
            ans = 1;
        } 
    }
    if(ans) {
        cout << "OK" << endl;
    }else {
        cout << "NG" << endl;
    }
}

Measured memory_bytes: 3620
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	p := nextInt()
	q := nextInt()
	r := nextInt()
	fmt.Println(min(min(p+q, p+r), q+r))
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    int a, b, c, d;
    cin>>a>>b>>c>>d;

    if ((a + d - 1) / d < (b + c - 1) / b) {
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 3636
import * as fs from 'fs';

const input = fs.readFileSync('/dev/stdin', 'utf8');
const args: string[][] = input.split('\n').map(l => l.split(' '));

const n = parseInt(args[0][0]);
const s: string[] = [];
for (let i = 0; i < n; i++) {
    s.push(args[i + 1][0]);
}

const set = new Set(s);

const cnt = set.size;

console.log(cnt);

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

int main() {
  int N;
  cin>>N;
  int a,b,c,d;
  a=N/1000;
  b=(N-a*1000)/100;
  c=(N-a*1000-b*100)/10;
  d=N-a*1000-b*100-c*10;
    
   if((a==b&&b==c)||(b==c&&c==d))
    cout<<"Yes"<<endl;
   else
    cout <<"No" << endl;

}



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

const int mod = 1e9 + 7;

int exp(int x, int n) {
    int ret = 1;
    while(n) {
        if(n & 1) ret = 1LL * ret * x % mod;
        x = 1LL * x * x % mod;
        n >>= 1;
    }
    return ret;
}

int N, C;
int A[444], B[555];
int psum[444][444];

int calc(int x, int l, int r) {
    return (psum[x][r] + mod - (l? psum[x][l - 1] : 0)) % mod;
}

int cc[444][444];
int dp(int n, int c) {
    if(n == N) return !c;
    int &ret = cc[n][c];
    if(ret != -1) return ret;

    ret = 0;
    for(int i = 0; i <= c; i++) {
        ret += 1LL * calc(i, A[n], B[n]) * dp(n + 1, c - i) % mod;
        ret %= mod;
    }
    return ret;
}

int main() {
    scanf("%d %d", &N, &C);

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

    for(int i = 0; i <= C; i++) {
        for(int j = 0; j < 444; j++) {
            psum[i][j] = exp(j, i);
            if(j) {
                psum[i][j] += psum[i][j - 1];
                psum[i][j] %= mod;
            }
        }
    }

    memset(cc, -1, sizeof(cc));
    printf("%d", dp(0, C));
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  cout << a*b/2 << "\n";
}


Measured memory_bytes: 256
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws FileNotFoundException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new File("c:\\0520-input.txt"));

		while (scan.hasNext()) {
			String s = scan.next();
			System.out.println(countStr("JOI", s));
			System.out.println(countStr("IOI", s));
		}

		scan.close();
		System.exit(0);
	}

	private static int countStr(String w, String s) {
		int r = 0;
		for (int i = 0; i < s.length() - w.length() + 1; i++)
			if (s.substring(i, i + w.length()).equals(w))
				r++;
		return r;
	}

}

Measured memory_bytes: 29108
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String N = sc.next();
    long n = Long.parseLong(N);
    String A = sc.next();
    long a = Long.parseLong(A);
    String B = sc.next();
    long b = Long.parseLong(B);
    long buf;
    long rem;
    long ans;

    buf = n / (a + b);
    rem = n - buf * (a + b);
    if(rem > a){
      ans = (buf + 1) * a;
    } else {
      ans = buf * a + rem;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 22996
use std::io::Read;
use std::cmp;
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let N: usize = iter.next().unwrap().parse().unwrap();
    let mut M: usize = iter.next().unwrap().parse().unwrap();
    let mut AB: Vec<(usize, usize)> = (0..N).map(|_| {
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }).collect();
    AB.sort_by(|a, b|
        a.0.cmp(&b.0)
    );

    let mut result: i64 = 0;
    for (a, b) in AB {
        if M <= 0 {
            break;
        }
        let cost: i64 = a as i64 * cmp::min(M, b) as i64;
        result += cost;
        M -= cmp::min(M, b);
    }
    println!("{}", result);
}

Measured memory_bytes: 8444
#include <stdio.h>
#include <stdlib.h>

int compare_char(const void* left, const void* right) {
    char *left_char = (char *)left;
    char *right_char = (char *)right;
    
    return strcmp(left_char,right_char);
}

int main(void){
  int n, i, result=0, p;
  int x[101]={0};
  double total=0.0;
  
  scanf("%d", &n);
  for(i=0;i<n;i++) scanf("%d", &x[i]);
  
  //qsort(x, n, sizeof(x[0]), compare_char);
  
  for(i=0;i<n;i++){
    total += x[i];
  }
  total /= (double) n;
  
  total += 0.5;
  p = (int) total;
  
  for(i=0;i<n;i++) result += (x[i] - p) * (x[i] - p);
  printf("%d", result);
  
  return 0;
}

Measured memory_bytes: 128
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint mo=1000000007;
lint x[100100];
lint zyo[100100];
lint sum[100100];
lint extgcd(lint a, lint b, lint &x, lint &y) {
  lint g = a; x = 1; y = 0;
  if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
  return g;
}
lint invMod(lint a, lint m) {
  lint x, y;
  if (extgcd(a, m, x, y) == 1) return (x + m) % m;return 0;
}
int main()
{
	zyo[0]=1;rep(i,100050) zyo[i+1]=(zyo[i]*(i+1))%mo;
	int n;cin>>n;
	sum[0]=0;
	rep(i,100030){
		sum[i+1]=sum[i]+zyo[n-1]*invMod(i+1,mo);
		sum[i+1]%=mo;
	}
	rep(i,n) cin>>x[i];
	lint out=0;
	rep(i,n-1){
		out+=(x[i+1]-x[i])*sum[i+1];
		out%=mo;
	}
	cout<<out<<endl;
	/*rep(i,n-1){
		lint t=(x[i+1]-x[i]);
		//t*=i+1;t%=mo;
		t*=i+2;t%=mo;t*=invMod(2,mo);t%=mo;
		//cout<<t<<endl;
		//t*=invMod(i+1,mo);t%=mo;
		out+=t;out%=mo;
	}
	//cout<<out<<' '<<zyo[n-1]<<endl;
	out*=zyo[n-1];out%=mo;
	cout<<out<<endl;*/
}


Measured memory_bytes: 2560
a[6]={2,3,5,10,12,15},b[6]={380,550,850,1520,1870,2244},m[51],T;
int s(p,n){
	int d=5;
	if(!n)return 0;
	if(m[n]<99999)return m[n];
	for(;~d;d--){
		if(a[d]>n)continue;
		T=s(p,n-a[d])+b[d];
		if(m[n]>T)m[n]=T;
	}
	return m[n];
}

main(n){
	memset(m,99,sizeof(m));
	for(;scanf("%d",&n),n;)printf("%d\n",s(m,n/100));
	exit(0);
}

Measured memory_bytes: 600
while True:
	try:
		line = input()
		if  '?' in line:
			break	
		else:
			a,op,b = line.split(' ')
			if op == '+':
				print(int(a)+int(b))
			if op == '-':
				print(int(a)-int(b))
			if op == '*':
				print(int(a)*int(b))
			if op == '/':
				print(int(float(a)/float(b)))
	except EOFError:
		break



Measured memory_bytes: 5612
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define clr clear()
#define ins insert
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define rep(i,n) for(__typeof(n) i=0; i<(n); i++)
#define mem(x,val) memset((x),(val),sizeof(x));
#define cusmem(x,val) for(auto &i:x) i=val;
#define all(x) x.begin(),x.end()
#define fastio ios_base::sync_with_stdio(false);\
            cin.tie(NULL);\
            cout.tie(NULL);
using namespace std;
typedef pair<int,int> pii;
typedef pair<ll,ll>pll;
typedef pair<ll,int>pli;
typedef vector<ll> vl;
typedef vector<pll> vpll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pii> vpii;
string impossible;

mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
// const int N=6;
const int N=4e5+5;
const int L=41;
int MOD=1e9+7;
ll n,m,k,i,j;
bool f0,f1,f2;
const int MAXN=2e3;
int main(){
    #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin); 
            freopen("output.txt","w",stdout);
    #endif
    fastio
    cout<<fixed<<setprecision(11);
    int tests=1;    
    // cin>>tests;
    for(int te=1;te<=tests;te++){
        int n,x,t;
        cin>>n>>x>>t;
        int ans=ceil(n*1.0/x)*t;
        cout<<ans<<"\n";
    }
    return 0;
}





Measured memory_bytes: 3612
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n,ma,mb = inm()
a = []
b = []
c = []
for i in range(n):
    aa,bb,cc = inm()
    a.append(aa)
    b.append(bb)
    c.append(cc)
dp = [[BIG]*(10+1) for i in range(10+1)]
dp[0][0] = 0
for t in range(n):
    dp2 = [[BIG]*(10*(t+1)+1) for i in range(10*(t+1)+1)]
    for i in range(10*t+1):
        for j in range(10*t+1):
            if dp[i][j]<BIG:
                dp2[i][j] = min(dp2[i][j],dp[i][j])
                dp2[i+a[t]][j+b[t]] = min( \
                     dp2[i+a[t]][j+b[t]], dp[i][j]+c[t])
    dp = dp2
mn = BIG
for i in range(1,5000):
    if i*max(ma,mb)>n*10:
        break
    #ddprint(f"i {i} n {n} ma {ma} mb {mb} ima {i*ma}")
    mn = min(mn, dp[i*ma][i*mb])
print(-1 if mn==BIG else mn)


Measured memory_bytes: 47452
import bisect

#エラトステネスの篩
def sieve(n):
    import math
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        #ここで篩落としてる,wikiの2番目
        data = [e for e in data if e % p != 0]



N = int(input())
A = sieve(10**5+7)

if N in A:
    print(N)
else:
    index = bisect.bisect_right(A,N)
    print(A[index])


Measured memory_bytes: 7448
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7; //998244353

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	int n;
	cin>>n;
	vv<int> g(n);
	rep(i,n-1){
		int a,b;
		cin>>a>>b; --a; --b;
		g[a].pb(b);
		g[b].pb(a);
	}
	int rt=-1;
	rep(i,n)if(g[i].size()>2) rt=i;
	if(rt==-1){
		cout<<string(n,'1') NL;
		return 0;
	}
	vector<int> dst(n);
	{
		function<void(int,int)> dfs=
			[&](int v,int p){
				for(int w:g[v])if(w!=p){
						dfs(w,v);
						MX(dst[v],dst[w]+1);
					}
			};
		dfs(rt,-1);
	}
	out(rt,dst,1);
	int ng=0;
	{
		function<void(int,int,int)> dfs=
			[&](int v,int p,int pl){
				vector<pii> nth{{pl,p}};
				for(int w:g[v])if(w!=p) nth.eb(dst[w],w);
				sort(rall(nth));
				// partial_sort(nth.begin(), nth.begin()+min((int)nth.size(),3), nth.end(),
				// 						 [&](pii p,pii q){ return p>q;});
				int mx=nth[0].X;
				if(g[v].size()>=3){
					int len=nth[0].X+nth[2].X+2;
					if(nth[0].X==nth[2].X) --len;
					MX(ng,len);
				}
				for(int w:g[v])if(w!=p){
						if(nth[0].Y==w){
							dfs(w,v,nth[1].X+1);
						}else{
							dfs(w,v,nth[0].X+1);
						}
					}
			};
		dfs(rt,-1,0);
	}
	string re(n,'0');
	re[0]=re[1]='1';
	reps(i,ng,n) re[i]='1';
	cout<<re NL;
  return 0;
}



Measured memory_bytes: 27288
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x){
  return x * x;
}

signed main (){
ll X,A,B;
cin >> X >> A >> B;
if(A - B >= 0 ){
cout << "delicious" << endl;
}else if(A + X - B >= 0){
  cout << "safe" << endl;
}else{
cout << "dangerous" <<endl;
}
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
bool prime[55556];
int pr[55556];
int ask[100];
int main(void)
{
    for(int i = 2;i <= 55555;i++)
    {
        if(!prime[i])
        for(int j = i;(LL)i*(LL)j <= 55555;j++)
        {
            prime[i*j] = true;
        }
    }
    int cn = 0;
    for(int i = 2;i <= 55555;i++)
        if(!prime[i])pr[cn++] = i;
    int t = 0;
    int n;
    cin>>n;
    for(int i = 0;i < cn&&t < n;i++)
    {
        if(pr[i]%5 == 1)
        {
           ask[t++] = pr[i];
        }
    }
    printf("%d",ask[0]);
    for(int i = 1;i < n;i++)
        printf(" %d",ask[i]);
    printf("\n");
    return 0;
}


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

int main(){
  int a,b,c,d;
  cin >>a >>b >>c >>d;
  if(abs(b-a)<=d && abs(c-b)<=d) cout << "Yes" << endl;
  else if(abs(c-a)<=d) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256