akhauriyash/Code-Regression huggingface dataset:
from itertools import combinations

N, M, Q = (int(_) for _ in input().split())

abcd = []
for q in range(Q):
    abcd.append([int(_) for _ in input().split()])
    
ret = 0
for i in combinations(list(range(N + M - 1)), N):
    # A = [i[0] + 1]
    # for ii in range(len(i) - 1):
    #     A.append(i[ii + 1] - i[ii] + A[ii] - 1)
    # print(A)
    subret = 0
    for a, b, c, d in abcd:
        if i[b - 1] - i[a - 1] - (b - a) == c:
            subret += d
    ret = max(ret, subret)
print(ret)


Measured memory_bytes: 9076
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin>>a[i];
  }
  ll sum = 0;
  ll sum2 = 0;
  sort(a.begin(),a.end());
 
  for(int i = 0; i < n/2-1; i++){
    sum+=a[n-1-i]*2;
    sum2-=a[i]*2;
  }
  
  for(int i = 0; i < (n-1)/2; i++){
    sum-=a[i]*2;
    sum2+=a[n-1-i]*2;
  }
  
  
  if(n%2==0){
    sum-=a[n/2-1];
    sum+=a[n/2];
    sum2-=a[n/2-1];
    sum2+=a[n/2];
  }
  else{
    sum+=a[n/2];
    sum+=a[n/2+1];
    sum2-=a[n/2];
    sum2-=a[n/2-1];
  }
  
  cout<<lmax(sum,sum2)<<endl;
  
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int A,B,M;
    cin>>A>>B>>M;
    vi a(A),b(B);
    rep(i,A) cin>>a[i];
    rep(i,B) cin>>b[i];
    int plan_A=1000000,plan_B;
    rep(i,M) {
        int x,y,c;
        cin>>x>>y>>c;
        x--; y--;
        plan_A=min(plan_A,a[x]+b[y]-c);
    }
    sort(all(a)); sort(all(b));
    plan_B=a[0]+b[0];
    cout<<min(plan_A,plan_B)<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
using namespace std;

int main() {
	int n, ans=0,sum,i,a,b;
	vector <int> ah(100), bh(100);
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a;
		ah[i] = a;
	}
	for (i = 0; i < n; i++) {
		cin >> b;
		bh[i] = b;
	}
	for (i = 0; i < n; i++) {
		sum = ah[i] - bh[i];
		if (sum > 0) {
			ans += sum;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
from sys import stdin, stdout

n = int(stdin.readline().rstrip())
w = [int(x) for x in stdin.readline().rstrip().split()]

ans = 1000000

for T in range(n - 1):
	ans = min(ans, abs(sum(w[0:T + 1]) - sum(w[T + 1:n])))

stdout.write(str(ans) + "\n")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long; 
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
template<class T> using pq = priority_queue<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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 gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
const ll BetsuMOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -MOD * MOD;
const long double pi = 3.141592653589793;
int main() { // 問題文はしっかり読め!!!
	int n;
	cin >> n;
	VL a(n);
	rep(i, n) {
		cin >> a[i];
		a[i] -= (i + 1);
	}
	sort(all(a));
	int mid = a[n / 2];
	ll ans = 0;
	rep(i, n) {
		ans += abs(a[i] - mid);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
    ll n;
    cin >> n;
    ll y = 1;
    while (y * (y + 1) / 2 <= n) y++;
    ll avoid = y * (y + 1) / 2 - n;
    for (int i = 1; i <= y; ++i) if (i != avoid) cout << i << endl;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}

use std::cmp::{max, min};

fn main() {
    let n: i64 = read();
    let a: String = read();
    let a_char: Vec<char> = a.chars().collect();
    if a_char.len() % 2 != 0 {
        println!("{}", "No");
        return;
    }
    if a_char[0..a_char.len() / 2] == a_char[a_char.len() / 2..] {
        println!("{}", "Yes");
    } else {
        println!("{}", "No");
    }
}


Measured memory_bytes: 4352
class Union_Find():
    def __init__(self,N):
        """0,1,...,n-1を要素として初期化する.

        n:要素数
        """
        self.n=N
        self.parents=[-1]*N
        self.rank=[0]*N

    def find(self, x):
        """要素xの属している族を調べる.

        x:要素
        """
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        """要素x,yを同一視する.

        x,y:要素
        """
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x]>self.rank[y]:
            self.parents[x] += self.parents[y]
            self.parents[y] = x
        else:
            self.parents[y] += self.parents[x]
            self.parents[x] = y

            if self.rank[x]==self.rank[y]:
                self.rank[y]+=1

    def size(self, x):
        """要素xの属している要素の数.

        x:要素
        """
        return -self.parents[self.find(x)]

    def same(self, x, y):
        """要素x,yは同一視されているか?

        x,y:要素
        """
        return self.find(x) == self.find(y)

    def members(self, x):
        """要素xが属している族の要素.
        ※族の要素の個数が欲しいときはsizeを使うこと!!

        x:要素
        """
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        """族の名前のリスト
        """
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        """族の個数
        """
        return len(self.roots())

    def all_group_members(self):
        """全ての族の出力
        """
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
#================================================
N,M=map(int,input().split())
P=list(map(lambda x:int(x)-1,input().split()))

U=Union_Find(N)
for _ in range(M):
    a,b=map(int,input().split())
    U.union(a-1,b-1)

K=0
for x in range(N):
    K+=U.same(x,P[x])
print(K)

Measured memory_bytes: 86224
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

int main(void){
  ll N, M, A, B, C, D, K, W, H, Q, X, Y;
  ll ans;
  string S, T;
  cin >> S;
  cin >> K;
  vector<string> s_vec;
  rep_s(i, 1, K+1){
    //cout <<"i: " << i << endl;
    //cout <<"S.length()" << (int)S.length()-i << endl;
    if ((int)S.length()-i>=0){
       //cout << i << endl;
       rep(j, S.length()-i+1){
        //cout << " j: " << j;
        s_vec.push_back(S.substr(j,i));
      }
      
    }
  }
  sort(ALL(s_vec));
  
  //cout <<"hey" << endl;
  s_vec.erase(unique(ALL(s_vec)), s_vec.end());
  //cout << s_vec.size() << endl;
  cout << s_vec[K-1] << endl;
  //rep(i, s_vec.size()) cout << s_vec[i] << endl;

}


Measured memory_bytes: 1660
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
void f(int a[],int b[],int d[],int p,int m,int n){
  int i,j,k;
  int t;
  if(p==m){
    t=a[b[0]];
    for(i=1;i<m;i++){
      k=0;
      for(j=0;j<i;j++){
	if(a[b[j]]>9)
	  k+=2;
	else
	  k++;
      }
      t+=a[b[i]]*pow(10,k);
    }
    for(i=0;d[i]!=0&&d[i]!=t;i++);
    if(d[i]==0)
      d[i]=t;
  }else{
    for(i=0;i<n;i++){
      for(j=0;j<p&&i!=b[j];j++);
      if(j==p){
	b[p]=i;
	f(a,b,d,p+1,m,n);
      }
    }
  }
  return;
}
int main(){
  int i;
  int a[10],b[4],d[10000],m,n;
  while(cin>>n>>m&&n+m){
    for(i=0;i<n;i++)
      cin>>a[i];
    memset(b,0,sizeof(b));
    memset(d,0,sizeof(d));
    f(a,b,d,0,m,n);
    for(i=0;d[i]!=0;i++);
    cout<<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i)
    cin >> vec[i];
}

int main() {
  int A, B;
  get(A, B);
  if (A == 1)
    A = 99;
  if (B == 1)
    B = 99;
  print(A > B ? "Alice" : A == B ? "Draw" : "Bob");
  return 0;
}

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

int main(){
    int a,b,c,t;
    cin >> a >> b >> c;
    if (b<a) {
        t=a;
        a=b;
        b=t;
    }
    if (c<b) {
        t=b;
        b=c;
        c=t;
    }
    if (b<a) {
        t=a;
        a=b;
        b=t;
    }
    
    cout << a << " " << b << " " << c << endl;
}


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

int main() {
	int n, p;
	cin >> n >> p;
	bool elf = false;
	rep(i, n) {
		int a; cin >> a;
		if (a % 2 != 0) elf = true;
	}
	if (!elf) {
		if (p) cout << 0 << endl;
		else cout << ll(pow(2, n)) << endl;
		return 0;
	}
	ll ans = pow(2, n - 1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const ll mod=1000000007;
int main(void){
    int n,k,a[200]={};
    cin>>n>>k;
    for(int i=0;i<k;i++){
        int d;
        cin>>d;
        for(int i=0;i<d;i++){
            int x;
            cin>>x;
            a[x]++;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++){
        if(a[i]==0) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        s: chars,
    }
    let mut cnt = 0;
    for i in 0..s.len() / 2 {
        if s[i as usize] != s[(s.len() - 1 - i) as usize] {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
#include<stdio.h>

using namespace std;

int main() {

 int a,b;
     
    scanf("%d %d", &a,&b);
 if(a > b){
     printf("a > b\n");
 }
 else if(a < b){
     printf("a < b\n");
 }
else{
     printf("a == b\n");
 }
}




Measured memory_bytes: 2624
#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>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
#include <atcoder/all>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#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 MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#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()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

vector<ll> yakusu(ll n){
  vector<ll> ret;
  for(ll p = 1; p*p <= n; p++){
    if(n%p == 0){
      ret.push_back(p);
      if(p*p != n){
        ret.push_back(n/p);
      }
    }
  }
  sort(all(ret));
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll n,m;cin>>n>>m;
  vector<ll> A(n), B(m);
  rep(i,n){
    cin>>A[i];
  }
  rep(i,m){
    cin>>B[i];
  }
  //reverse(all(A));
  //reverse(all(B));

  auto result = atcoder::convolution(A,B);
  rep(i,result.size()){
    cout<<result[i]<<" ";
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 27212
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
ll MOD = 1000000007;
ll INF = 2147483647;
double EPS = 1e-12;
double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

int main(){
   ll N,K;cin >> N >> K;
   vector<ll> cnt(50);
   rep(i,N){
       ll a;cin >> a;
       rep(j,50) if(a >> j & 1) cnt[j]++;
   }
   ll dp[50][2];
   rep(i,50) rep(j,2) dp[i][j] = -1;
   dp[45][0] = 0;
   rrep(i,45){
       if(dp[i+1][1] >= 0) dp[i][1] = max((ll)dp[i][1],dp[i+1][1] + (ll)max(cnt[i],N-cnt[i]) * (ll)pow(2,i));
       if(dp[i+1][0] >= 0){
           if(K >> i & 1){
               dp[i][1] = max(dp[i][1],dp[i+1][0] + cnt[i] * (ll)pow(2,i));
               dp[i][0] = max(dp[i][0],dp[i+1][0] + (N-cnt[i]) * (ll)pow(2,i));
           }else{
               dp[i][0] = max(dp[i][0],dp[i+1][0] + cnt[i] * (ll)pow(2,i));
           }
       }
   }
   cout << max(dp[0][0],dp[0][1]) << endl;
}

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

using namespace std;
typedef long long ll;

int main(){
    int N; cin >> N;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        bool not_prime = 0;
        int p;
        cin >> p;
        if (p == 2) ans += 1;
        if (p%2 == 0) continue;
        for (int j = 3; j <= int(sqrt(p)); j+=2)
        {
            if (p%j == 0)
            {
                not_prime = 1;
                break;
            }
        }
        if (!not_prime) ans += 1;
        
    }
    cout << ans << endl;
}


Measured memory_bytes: 3084
import java.util.*;

class Main{
	public static void main(String[] $){
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    int ans[] = new int [n+1];
    
    
    for(int i  = 1 ; i <= n ; i++){
        ans[in.nextInt()] = i;
    }
    for(int i = 1;i <= n;i++){
        System.out.print(ans[i] + " ");
    }
		
	}
}


Measured memory_bytes: 64468
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,k=map(int,input().split())
a=lmp()

def ok(s):
    c=0
    for i in a:
        c+=-(-i//s)-1
    return c<=k


l=0
r=max(a)
while r>l+1:
    md=(r+l)//2
    if ok(md):
        r=md
    else:
        l=md
print(r)

Measured memory_bytes: 32172
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
    vector<int> x(5);
    for (int i = 0; i < 5; i++)
        cin >> x[i];

    for (int i = 0; i < 5; i++)
        if (x[i] == 0)
            cout << i + 1 << endl;

    return 0;
}


Measured memory_bytes: 3576
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int mod = 998244353;

inline int add(int a, int b) {
  return a+b >= mod ? a+b-mod : a+b;
}

inline int sub(int a, int b) {
  return a >= b ? a-b : a-b+mod;
}

inline int mul(int a, int b) {
  return llint(a)*b % mod;
}

int powmod(int a, int b) {
  if (b == 0) return 1;
  if (b&1) return mul(a, powmod(a, b-1));
  return powmod(mul(a, a), b/2);
}

int main(void) {
  int N, A, B;
  llint K;
  scanf("%d %d %d", &N, &A, &B);
  scanf("%lld", &K);

  vector<int> ch(N+1);
  ch[0] = 1;
  for (int i = 1; i <= N; ++i) {
    ch[i] = mul(ch[i - 1], mul(N-i+1, powmod(i, mod-2)));
  }


  int ret = 0;
  for (int i = 0; i <= N; ++i) {
    llint rem = K - i*1LL*A;
    if (rem >= 0 && rem % B == 0) {
      llint j = rem / B;
      if (j <= N) ret = add(ret, mul(ch[i], ch[j]));
    }
  }

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


Measured memory_bytes: 1408
#include<set>
#include<iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    set<int> s;
    for (int i = 0; i < n; i++) {int t; cin >> t;s.insert(t);}
    cin >> n;
    for (int i = 0; i < n ;i++) {int t; cin >> t; s.insert(t);}
    auto it = s.begin();
    while (it!=s.end()) {
        cout << *it << endl;
        it++;
    }
    return 0;
}


Measured memory_bytes: 21844
def resolve():
    n = int(input())
    a = []

    for _ in range(n):
        x, l = map(int, input().split())
        a.append((x - l, x + l))

    t = -float('inf')
    a.sort(key=lambda x: x[1])
    ans = 0

    for start_t, end_t in a:
        if t <= start_t:
            ans += 1
            t = end_t

    print(ans)

resolve()

Measured memory_bytes: 18248
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using static System.Console;

namespace ABC122A
{
    static class Program
    {
        static void Main(string[] args)
        {
            var b = Console.ReadLine();

            var d = new Dictionary<string, string>()
            {
                {"A", "T"},
                {"C", "G"},
                {"G", "C"},
                {"T", "A"}
            };
            WriteLine(d[b]);


        }

        public static T TryParse<T>(this String input)
        {
            try
            {
                var converter = TypeDescriptor.GetConverter(typeof(T));
                if (converter != null)
                {
                    return (T)converter.ConvertFromString(input);
                }
                else
                {
                    throw new InvalidCastException("");
                }
            }
            catch
            {
                throw new InvalidCastException(typeof(T) + " is not supported.");
            }
        }

        public static List<T> SplitTryParseToList<T>(this String input)
        {
            return input.Split().Select(n => n.TryParse<T>()).ToList();
        }

        public static List<T> ListSwap<T>(this List<T> list, Int32 index1, Int32 index2)
        {
            var t = list[index1];
            list[index1] = list[index2];
            list[index2] = t;
            return list;
        }

        public static List<Tuple<T, int>> DuplicateCount<T>(this IEnumerable<T> list)
        {
            return list
                .GroupBy(i => i)
                .Where(g => g.Any())
                .Select(g => Tuple.Create(g.Key, g.Count()))
                .ToList();
        }
        public static List<Tuple<T, int>> DuplicateSort<T>(this IEnumerable<Tuple<T, int>> list)
        {
            return list.OrderByDescending((x) => x.Item2).ToList();
        }
        public static List<T> ReadLineOne<T>(int n)
        {
            var list = new List<T>();
            foreach (var i in Enumerable.Range(1, n))
            {
                list.Add(Console.ReadLine().TryParse<T>());
            }
            return list;
        }
        public static void PrintAll<T>(this IEnumerable<T> list)
        {
            foreach (var i in list)
            {
                Console.Write($"{i} ");
            }

            Console.WriteLine();
        }
    }
}


Measured memory_bytes: 13152
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
typedef pair<int,int> p;

int kai[9];
int kaij(int n){
  if(n==1) return kai[1]=1;
  return kai[n] = kaij(n-1)*n;
}

int main(){
  int n;
  cin >> n;
  vector<p> vec(n,p());
  for(int i=0; i<n; ++i){
    cin >> vec.at(i).first >> vec.at(i).second;
  }
  double ans=0;
  for(int i=0; i<n; ++i){
    for(int j=0; j<n; ++j){
      if(i==j)continue;
      int dx=abs((vec.at(i).first-vec.at(j).first)*(vec.at(i).first-vec.at(j).first));
      int dy=abs((vec.at(i).second-vec.at(j).second)*(vec.at(i).second-vec.at(j).second));
      ans+= kaij(n-1)*pow(dx+dy,0.5);
    }
  }
  ans /= kaij(n);
  printf("%.10f",ans);
}

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

int main() {
    int a,b;
    while(1){
        cin>>a>>b;
        if (a==0 && b==0) break;
        
        if (a<b){
        cout<<a<<" "<<b<<endl;
        }else{
            cout<<b<<" "<<a<<endl;
        }
    }
                

        
    return 0;        
         
}

Measured memory_bytes: 1160
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.1415926535897932384626;
long long int mod = 1000000007;
 
vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//abcのbed乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 





ll i,j,k,ii,jj;
ll n,m,num,sumxor,sum,ans;
ll a,b,c,d,e,f,g,h,w,v;
ll x[800005],y[800005],z[900005];

int main(){	
	cin>>n;
	p(((n+110)/111)* 111);


	return 0;
}

Measured memory_bytes: 24832
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;
#define N 1000010
#define LL long long
int a[N],vis[N];
LL s[N],b[N],c[N],p[N];
int main()
{
    int i,j,k,n,m;
    int x,y,z;
    LL d,t,ans;
    scanf("%d%d",&n,&m);
    p[0]=1;
    for(i=1;i<=50;i++)
        p[i]=p[i-1]*2;
    for(i=1;i<=n;i++)
        scanf("%d",&a[i]);
    s[0]=0;
    for(i=1;i<=n;i++)
        s[i]=s[i-1]+a[i];
    k=0;
    for(i=1;i<=n;i++)
    for(j=i;j<=n;j++)
    {
        d=s[j]-s[i-1];
        b[k++]=d;
    }
    ans=0;
    y=40;
    while(1)
    {
        for(i=y;i>=0;i--)
        {
            z=0;
            d=ans+p[i];
            for(j=0;j<k;j++)
            if((b[j]&d)==d)
                z++;
            if(z>=m)
                break;
        }
        if(i<0)
            break;
        ans=ans+p[i];
        y=i-1;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

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

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define REREP(i,n) for(int i = int(n - 1); i >= 0; i--)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define fi first 
#define se second

#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VD vector<double>
#define VVD vector<vector<double>>
#define VVVD vector<vector<vector<double>>>
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define VVVB vector<vector<vector<bool>>>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVVS vector<vector<vector<string>>>

#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<ll,ll>
#define VPII vector<pair<int,int>>
#define VVPII vector<vector<pair<int,int>>>
#define VVVPII vector<vector<vector<pair<int,int>>>>
#define VPLL vector<pair<ll,ll>>
#define VVPLL vector<vector<pair<ll,ll>>>
#define VVVPLL vector<vector<vector<pair<ll,ll>>>>

const ll HMOD = (ll)1e9 + 7;
const ll LMOD = 998244353;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;
const long double EPS = 1e-10;


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

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

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

int main() {
	ll N; cin >> N;
	VL a(3 * N); REP(i, 3 * N) cin >> a[i];
	priority_queue<ll, vector<ll>, greater<ll>> pql;
	priority_queue<ll> pqr;
	REP(i, N) pql.push(a[i]);
	FOR(i, 2 * N, 3 * N) pqr.push(a[i]);
	VL sum(N + 1);
	ll l = 0, r = 0;
	REP(i, N) l += a[i];
	FOR(i, 2 * N, 3 * N) r += a[i];
	
	sum[0] += l;
	FOR(i, 1, N + 1) {
		pql.push(a[i + N - 1]);
		l += a[i + N - 1] - pql.top();
		pql.pop();
		sum[i] += l;
	}

	sum[N] -= r;
	REFOR(i, 1, N + 1) {
		pqr.push(a[i + N - 1]);
		r += a[i + N - 1] - pqr.top();
		pqr.pop();
		sum[i - 1] -= r;
	}

	cout << *max_element(ALL(sum)) << endl;

	
	return 0;
}



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

namespace question3
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = new Program();
            p.Run();
        }

        void Run()
        {
            var line = Console.ReadLine();
            var n = int.Parse(line.Split(' ')[0]);
            var k = int.Parse(line.Split(' ')[1]);

            var h = new List<int>();
            var ans = int.MaxValue;

            for (int i = 0; i < n; i++)
            {
                h.Add(int.Parse(Console.ReadLine()));
            }
            h.Sort();

            for (int i = 0; i <= n - k; i++)
            {
                ans = Math.Min(ans, h[i + k - 1] - h[i]);
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 16092
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1e9+7;

int main() {
    int x;
    scanf("%d",&x);
    if(x>=1200) puts("ARC");
    else puts("ABC");
    return 0;
}

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

int comparator(const void *p, const void *q) 
{ 
    int l = *(const int *)p; 
    int r = *(const int *)q;
    return (l-r);
}

int main()
{
    int n;
    scanf("%d", &n);
    int d[100000];
    for(int i=0; i<n; i++)
    {
        scanf("%d", &d[i]);
    }
    qsort(d, n, sizeof(int), comparator);
    int a=d[(n/2)-1];
    int b=d[n/2];
    printf("%d", b-a);
    return 0;
}

Measured memory_bytes: 892
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int x, y;
    int tmp;

    x = sc.nextInt();
    y = sc.nextInt();

    for(;;){
      if(x < y){
        tmp = x;
        x = y;
        y = tmp;
      }
      tmp = y;
      y = x % y;
      x = tmp;
      if(x == 0 || y == 0){
        System.out.println(x + y);
        break;
      }
    }
/*fin*/
    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 17164
def can_communication(x,y,k)
    (y-x).abs <= k
end
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i
k = gets.to_i
res = can_communication(b,a,k)
res = res && can_communication(c,a,k)
res = res && can_communication(d,a,k)
res = res && can_communication(e,a,k)
res = res && can_communication(c,b,k)
res = res && can_communication(d,b,k)
res = res && can_communication(e,b,k)
res = res && can_communication(d,c,k)
res = res && can_communication(e,c,k)
res = res && can_communication(e,d,k)
puts res ? "Yay!" : ":("

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


void solve(long long X){
    ll cnt = 100;
    ll ans = 0;
    while(cnt < X){
        cnt *= 1.01;
        ans++;
    }
    cout<<ans<<endl;
}

int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3688
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <functional>
#include <time.h>
#include <math.h>

using namespace std;


int main() {

	int a, b;

	cin >> a >> b;

	double x, y, z,ans;
	x = a + b;
	y = a - b;
	z = a * b;

	ans = max(x, max(y,z));

	cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

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


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
for i in range(n):
    if(a[i]>b[i]):
        ans+=b[i]
    else:
        if(a[i+1]<b[i]-a[i]):
            ans+=a[i]+a[i+1]
            a[i+1]=0
        else:
            ans+=b[i]
            a[i+1]-=b[i]-a[i]


print(ans)

Measured memory_bytes: 18624
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	int l,r;
	cin >> l >> r;
	r = min(l+5000,r);
	ll ans = 1e9;
	for(ll i = l; i <= r; i++){
		for(ll j = i+1; j <= r; j++){
			ans = min(ans,i*j%2019);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long
#define vi vector<int>
#define mod 10000000
using namespace std;
ll dp[100001];
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
  int n,m;
  cin>>n>>m;
  vector<double>a(100,0);
  double sum=0;
  for(int i=0;i<n;i++)
  {
  cin>>a[i];
sum+=a[i];
}
double temp=(sum)/((double)4*m);
int count=0;
  for(int i=0;i<n;i++)
  {
  if(a[i]<temp)
  continue;
count++;
}
if(count>=m)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
		return 0;
}



Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF =1e9;
const ll LINF=1e18;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
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; }
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a / gcd(a, b)*b;}
int n, m;
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    n=s.size();
    vector<vector<int> >v(n,vector<int>(m));
    bool check=true;
    int now=0;
    int j=1;
    if(s[n-1]=='1')return cout<<-1<<"\n",0;
    if(s[0]=='0')return cout<<-1<<"\n",0;
    for(int i=0;i<(n-1)/2;i++){
        if(s[i]!=s[n-2-i])return cout<<-1<<"\n",0;
    }
    for(int i=0;i<n;i++){
        if(j>=n)break;
        if(check){
            if(s[i]=='1'){
                v[now].push_back(j);
                now=j;
                j++;
            }
            else{
                v[now].push_back(j);
                check=false;
                j+=1;
            }
        }
        else{
            if(s[i]=='1'){
                v[now].push_back(j);
                now=j;
                j++;
                check=true;
            }
            else{
                v[now].push_back(j);
                check=false;
                j++;
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<v[i].size();j++){
            cout<<i+1<<" "<<v[i][j]+1<<"\n";
        }
    }
}



Measured memory_bytes: 6992
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()

    found = [0] * 26
    for c in S:
        found[ord(c) - ord('a')] = True

    ans = 'None'
    for i, f in enumerate(found):
        if not f:
            ans = chr(i + ord('a'))
            break

    print(ans)
    return


if __name__ == '__main__':
    main()


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

int main()
{
	int N, X, T;
    int time=0;
    scanf("%d%d%d", &N, &X, &T);

    for (int i = 0; N > 0; i++){
        N -= X;
        time += T;
    }  

    printf("%d", time);
}

Measured memory_bytes: 1708
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	string n;
	int ans=0;
	cin>>n;
	for(int i=0;i<4;i++){
		if(n[i]=='2'){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)



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

    vector<ll> a(n);
    vector<ll> ida(n);
    vector<vector<ll>> b(m,vector<ll>(2));

    rep(i,n){
        cin>>a.at(i);
    }
    rep(i,m){
        cin>>b.at(i).at(1)>>b.at(i).at(0);
    }

    sort(a.begin(),a.end());
    sort(b.rbegin(),b.rend());

    ll ind=0;
    ll sum=0;
    for(int i=0;i<n;i++){
        if(ind<m&&a.at(i)<=b.at(ind).at(0)){
            a.at(i) = b.at(ind).at(0);
            b.at(ind).at(1)--;
            if(b.at(ind).at(1)==0)ind++;
        }
        sum += a.at(i);
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 7296
#include <iostream>
#include <cmath>

using namespace std;
int main()
{
    bool a[1000000];
    for (int i = 0; i < 1000000; i++) {
        a[i] = true;
    }
    for (int i = 2; i <= sqrt(1000000); i++) {
        if (a[i]){
            for (int j = i; i*j < 1000000; j++) {
                a[i*j] = false;
            }
        }
    }
    
    
    int n;
    while (cin >> n) {
        int cnt = 0;
        for (int i = 2; i <= n; i++) {
            if (a[i]){
                cnt++;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 2136
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
char list[110][100];

void work() {
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		scanf("%s", list[i]);
		sort(list[i], list[i] + strlen(list[i]));
	}
	
	for(int i = 1; i < n; i++) {
		int i1 = 0, i2 = 0;
		int index = 0;
		memset(list[100], 0, sizeof(list[100]));
		while(i1 < strlen(list[0]) && i2 < strlen(list[i])) {
			if(list[0][i1] == list[i][i2]) {
				list[100][index++] = list[0][i1];
				i1++;
				i2++;	
			}
			else if(list[0][i1] > list[i][i2]) {
				i2++;	
			}
			else {
				i1++;	
			}
		}
		memcpy(list[0], list[100], sizeof(list[0]));
	}
	printf("%s\n", list[0]);
}
	
int main() {
	work();
	return 0;
}
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
set<int> G[26];
typedef set<int>::iterator it;
int n;
string s[505];
bool flag;
bool vis[26];
int in[26];
int main()
{
	while(~scanf("%d",&n)&&n)
	{
		for(int i=0;i<n;i++)
			cin>>s[i];
		for(int i=0;i<26;i++)
			G[i].clear(),vis[i] = 0,in[i] = 0;
		flag = true;
		for(int x=1;x<n;x++)
			for(int y=0;y<x;y++)
		    {
			    int len1 = s[y].size();
			    int len2 = s[x].size();
			    bool flag1 = true;
			    for(int i=0;i<min(len1,len2);i++)
				    if(s[y][i]!=s[x][i])
			        {
			    	    flag1 = false;
			    	    G[s[y][i]-'a'].insert(s[x][i]-'a');
			    	    break;
			        }
			    if(flag1&&len1>len2)
				    flag = false;
		    }
		int cnt = 0;
		for(int i=0;i<26;i++)
			for(it p = G[i].begin();p!=G[i].end();p++)
			    in[*p]++,cnt++;
		while(1)
		{
			bool flag1 = true;
			for(int i=0;i<26;i++)
				if(in[i]==0&&!vis[i])
				{
					flag1 = false;
					vis[i] = 1;
				    for(it p = G[i].begin();p != G[i].end();p++)
			        {
			        	int v = *p;
			        	cnt--;
			        	in[v]--;
			        }
				}
			if(flag1) break;
		}
		if(cnt!=0) flag = false;
		puts(flag?"yes":"no");
	}
	return 0;
}

Measured memory_bytes: 1264
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int A[1000001], N[1000001];

int main(){
  int a;
  while(scanf("%d", &a) && a){
    rep(i, a) scanf("%d", A+i);
    memset(N, 0, sizeof(N));

    rep(i, a) N[A[i]]++;

    rep(i, 1000001) if(N[i] > a/2){ printf("%d\n", i); goto e;}
    puts("NO COLOR");
  e:;
  }
  return 0;
}

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

ll a[300005];

int main(){
  ios::sync_with_stdio(0); cin.tie(0), cout.tie(0);
  int n; cin >> n;
  for(int i = 0 ; i < 3* n ; i++){
    cin >> a[i];
  }
  sort(a,a+3*n, greater<int>() );
  ll tot = 0;
  for(int i = 1 ; i < 2*n ; i+=2){
      tot += a[i];
  }
  cout << tot;
}


Measured memory_bytes: 2560
N_A_B = list(map(int,input().split()))
N=N_A_B[0]
A=N_A_B[1]
B=N_A_B[2]
summary=0

for i in range(1,N+1):
    tmp=list(map(int,list(str(i))))
    if A<=sum(tmp)<=B:
        summary=summary+i

print(summary)


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

#define int long long

using namespace std;

int a[100001];
int sm[100001];
int nxt[100001];
int ans;
map <int ,int> ok, first, second, del;
vector <int> pr, primes;

bool check (int x) {
	for (int i = 2;i * i <= x;i ++) {
		if (x % i == 0) return 0;
	}
	return 1;
}

 main () {
	int n;
	cin >> n;
	for (int i = 1;i <= n;i ++) {
		cin >> a[i];
		nxt[i] = 1;
	}
	for (int i = 2;i * i * i <= 10000000000;i ++) {
		int x = i;     
		if (check (x)) pr.push_back (x * x * x);
		if (check (x)) primes.push_back (x);
	}
	for (int i = 2;i * i <= 10000000000;i ++) {
		int x = i;
		if (check (x)) ok[x * x] = 1;
	}
	for (int i = 1;i <= n;i ++) {
		int x = a[i];
		for (int j = 0;j < pr.size ();j ++) {
			while (x % pr[j] == 0) {
				x /= pr[j];
			}
		}
		sm[i] = x;
	}
	for (int i = 1;i <= n;i ++) {
		int x = a[i];
		for (int j = 0;j < primes.size ();j ++) {
			int cnt = 0;
			while (x % primes[j] == 0) {
				cnt ++;
				x /= primes[j];
			}
			cnt %= 3;
			if (cnt > 0) cnt = 3 - cnt;
			while (cnt) {
				cnt --;
				nxt[i] *= primes[j];
			}
		}
//		cout << x << ' ';               
		if (ok[x]) {
			nxt[i] *= sqrt (x);
		}
		else nxt[i] *= x * x;
	}
//	cout << endl;
	for (int i = 1;i <= n;i ++) {    
	//	cout << sm[i] << ' ' << nxt[i] << endl;
		if (sm[i] == 1 && ans == 0) ans ++;
		first[sm[i]] ++;                             
		second[nxt[i]] ++;
	}
	for (int i = 1;i <= n;i ++) {
		if (del[sm[i]] || sm[i] == 1) continue;
		del[sm[i]] = 1;
		del[nxt[i]] = 1;
		ans += max (first[sm[i]], first[nxt[i]]);
	}
	cout << ans;
	return 0;                   
}

Measured memory_bytes: 39424
import java.util.Scanner;

public class Main {

  /*
    input: 3 5
    output: 15 16
  */

  public static void main(String[] args) {
    // https://stackoverflow.com/questions/27880245/reading-input-delimited-by-spaces-in-java
    Scanner scan = new Scanner(System.in);
    int w = scan.nextInt();
    int h = scan.nextInt();
    System.out.printf("%d %d\n", w*h, 2*(w+h));
  }
}


Measured memory_bytes: 26184