akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using u64 = uint64_t;
using u32 = uint32_t;

template <typename T> T mod_pow(T n, T r, T m) {
	T ret = 1;
	T tmp = n;
	
	while(r != 0) {
		if(r % 2) {
			ret *= tmp;
		}
		tmp *= tmp;
		tmp %= m;
		ret %= m;
		r /= 2;
	}
	return ret;
}

template <typename T> T mod_inv (T a, T m) {
	return mod_pow(a, m - 2, m);
}

template <typename T> T mod_div (T a, T b, T m) {
	return a * mod_inv(b, m) % m;
}

template <typename T> T mod_sub (T a, T b, T m) {
	return (a < b) ? m + a - b : (a - b) % m;
}

int main() {
	u64 n, a, b;
	cin >> n >> a >> b;
	
	u64 mod = pow(10, 9) + 7;
	
	a = min(a, n - a);
	b = min(b, n - b);
	
	u64 ca = 1;
	u64 cb = 1;
	u64 cmb = 1;
	
	for(u64 i=1; i<=max(a, b); i++) {
		cmb = cmb * (n - i + 1) % mod;
		cmb = mod_div(cmb, i, mod); 
		
		if(i == a) ca = cmb;
		if(i == b) cb = cmb;
	}
	
	u64 ans = mod_pow((u64)2, n, mod) - 1;
	ans = mod_sub(ans, ca, mod);
	ans = mod_sub(ans, cb, mod);
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int n; cin >> n;
	VI a(n); REP(i, n)cin >> a[i];
	sort(ALL(a));
	REP(i, n - 1) {
		if (a[i] == a[i + 1]) {
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	return 0;
}

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

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> count(N,0);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    count.at(a-1)++;
    count.at(b-1)++;
  }
  
  for(int i=0;i<N;i++){
    cout<<count.at(i)<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<functional>
#include<algorithm>

using namespace std;

int power(int x,int n) {
	int ans = 1;
	for (int i = 0; i < n; i++) {
		ans = ans * x;
	}
	return ans;
}
int main(void)
{
	int X;
	scanf("%d", &X);
	int ans = 1;
	int n, x;
	
	for (int n = 2; n < 10; n++) {
		for (int x = 2; x <= 1000; x++) {
			int A = power(x, n);
			if(A > X) break;
			ans = max(ans,A);

		}
	}
	printf("%d", ans);

	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<string>
using namespace std;

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    s[k-1] = tolower(s[k-1]);
    cout << s << endl;
}

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

const ll MAXN = 200000;

ll N, M, ans=0, tmp=0;
priority_queue<ll> Q;

signed main(){
    cin >> N >> M;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        Q.push(a);
    }
    ll i=0;
    while(i<M) {
        ll u = Q.top();
        Q.pop();
        Q.push(u/2);
        i++;
    }
    while(!Q.empty()) {
        ans += Q.top();
        Q.pop();
    }
    cout << ans << endl;
    return 0;
}

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

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, const map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;

signed main() {
  int n, W; cin >> n >> W;
  VI w(n), v(n);
  REP (i, n) cin >> w[i] >> v[i];
  VI dp(W + 1);
  REP (i, n) {
    for (int j = W - 1; j >= 0; j--) {
      if (w[i] + j > W) continue;
      dp[w[i] + j] = max(dp[w[i] + j], dp[j] + v[i]);
    }
  }
  cout << *max_element(ALL(dp)) << endl;
}


Measured memory_bytes: 1024
#include <stdint.h>
#include <algorithm>
#include <bitset>
#include <functional>
#include <iostream>
#include <string>
#include <vector>

int dp[1024][1024];

int GetLengthOfLongestCommonSunseq(std::string &a, std::string &b) {
  int max = 0;
  for(int y = 0; y < a.size(); y++){
    for(int x = 0; x < b.size(); x++){
      const int vL = (y > 0) ? dp[y-1][x] : 0;
      const int vU = (x > 0) ? dp[y][x-1] : 0;
      const int vUL = (x > 0 && y > 0) ? dp[y-1][x-1] : 0;
      dp[y][x] = std::max(vL, std::max(vU, vUL + (a[y] == b[x] ? 1 : 0)));
      if(max < dp[y][x]) max = dp[y][x];
    }
  }
  return max;
}

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;
  for(int i = 0; i < n; i++){
    std::string a, b;
    std::cin >> a >> b;
    std::cout << GetLengthOfLongestCommonSunseq(a, b) << std::endl;
  }

  return 0;
}



Measured memory_bytes: 7124
n = gets.to_i
s = n.times.map {gets.chomp.chars}

memo = Array.new(n)
t = -501
n.times do |i|
    memo[i] and (s.map!(&:rotate!); next)
    
    catch do |tag|
        n.times do |x|
            x.upto(n-1) {|y| s[x][y] != s[y][x] and throw(tag, false)}
        end
        true
    end and (i.step(n-1, i-t) {|k| memo[k] = 1}; t = i)

    s.map!(&:rotate!)
end

p memo.count(1) * n

Measured memory_bytes: 8084
#include<iostream>
#include<algorithm>

int main() {
	int n, k;
	std::cin >> n >> k;
	int *h = new int[n];
	for (int i = 0; i < n; i++){
		std::cin >> h[i];
	}
	std::sort(h, h + n);
	
	int ans = 1 << 30, temp;
	for (int i = 0; i < n - k + 1; i++) {
		temp = h[i + k - 1] - h[i];
		if (ans > temp)ans = temp;
	}

	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
String s=sc.next();
if(s.length()<=t)
System.out.println(s);
else
{
s=s.substring(0,t)+"...";
System.out.println(s);
}
}
}
 

Measured memory_bytes: 27068
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main()
{
    ll a,b;
    cin>>a>>b;
    ll aa,bb;
    ll i;
    bb=0;
    aa=0;
    for(i=1;i<=a;i++)
    {
        bb=bb*10+b;
    }
    for(i=1;i<=b;i++)
    {
        aa=aa*10+a;
    }
    cout<<max(aa,bb);
    
}


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

using namespace std;

bool pm(long long a, long long b) {
    if ((a >= 0 && b <= 0) || (a <= 0 && b >= 0)) return true;
    return false;
}

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

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
    }

    long long sum = 0, ans1 = 0, ans2 = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        if ((i % 2 && sum >= 0) || (!(i % 2) && sum <= 0)) {
            ans1 += abs(sum) + 1;
            sum = (i % 2) ? -1 : 1;
        }
    }

    sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
        if ((i % 2 && sum <= 0) || (!(i % 2) && sum >= 0)) {
            ans2 += abs(sum) + 1;
            sum = (i % 2) ? 1 : -1;
        }
    }
    cout << min(ans1, ans2) << endl;

    return 0;
}

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

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

using namespace std;

typedef vector<int> Array;
const int INF = 1e+8;

int main() {
  while(1){
    int n,m,H,k;
    cin>>n>>m>>H>>k;
    if(!n)break;
    vector<tuple<int,int,int,int,int>> v;
    REP(i,m){
      int a,b,c,h,r;
      cin>>a>>b>>c>>h>>r;
      --a; --b; --r;
      v.emplace_back(a,b,c,h,r);
    }
    int s,t,p;
    cin>>s>>t>>p;
    --s;--t;
    Array cost1(1<<k);
    REP(i,1<<k){
      bitset<8> bs(i);
      Array ary(n*(H+1),INF);
      ary[s*(H+1)] = 0;
      REP(l,H+1) {
        REP(j,m) {
          int a,b,c,h,r;
          tie(a,b,c,h,r) = v[j];
          if (l+h>H) continue;
          int ai=a*(H+1), bi=b*(H+1);
          if (bs[r]) {
            ary[ai+l+h] = min(ary[ai+l+h], ary[bi+l]);
            ary[bi+l+h] = min(ary[bi+l+h], ary[ai+l]);
          } else {
            ary[ai+l+h] = min(ary[ai+l+h], ary[bi+l]+c);
            ary[bi+l+h] = min(ary[bi+l+h], ary[ai+l]+c);
          }
        }
      }
      int minc = INF;
      REP(j,H+1) minc = min(minc, ary[t*(H+1)+j]);
      cost1[i] = minc;
    }
    Array cost2(1<<k,INF);
    cost2[0] = 0;
    REP(i,p){
      Array tmp = cost2;
      int l,d;
      cin>>l>>d;
      int bits = 0;
      REP(j,l) {
        int kj;
        cin>>kj;
        --kj;
        bits |= 1 << kj;
      }
      REP(j,1<<k)
        tmp[j|bits] = min(tmp[j|bits],cost2[j]+d);
      swap(tmp,cost2);
    }
    int minc = INF;
    REP(i,1<<k) minc = min(minc, cost1[i]+cost2[i]);
    if(minc < INF)
      cout<<minc<<endl;
    else
      cout<<-1<<endl;
  }
  return 0;
}

Measured memory_bytes: 1248
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vvl G(n);
    vector<pair<ll, ll>> vp;
    rep(i, n-1) {
        ll a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].pb(b);
        G[b].pb(a);
        vp.eb(a, b);
    } 
    
    vl cs(n);  // cs[i] : 頂点iとiの親を結ぶ辺の色
    vl used(n);  // used[i] : 頂点iを訪れたら1
    map<pair<ll, ll>, ll> mp;
    queue<ll> Q;

    Q.push(0);
    used[0] = 1;
    ll K = 0;
    while(!Q.empty()) {
        ll v = Q.front();
        Q.pop();
        if(K < G[v].size()) {
            K = G[v].size();
        }
        ll color = 1;
        for(auto u : G[v]) {
            if(used[u]) {
                continue;
            }
            if(color == cs[v]) {
                color++;
            }
            cs[u] = mp[make_pair(u, v)] = mp[make_pair(v, u)] = color;
            color++;
            used[u] = 1;
            Q.push(u);
        }
    }

    out(K);

    for(auto p : vp) {
        out(mp[p]);
    }

    re0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

using Graph = vector<vector<int>>;

vector<int> color;
bool dfs(const Graph &G, int v, int cur = 0) {
    color[v] = cur;
    for (auto next_v : G[v]) {
        // 隣接頂点がすでに色確定していた場合
        if (color[next_v] != -1) {
            if (color[next_v] == cur) return false; // 同じ色が隣接したらダメ
            continue;
        }

        // 隣接頂点の色を変えて、再帰的に探索 (一回でも false が返ってきたら false)
        if (!dfs(G, next_v , 1 - cur)) return false;
    }
    return true;
}

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int d[210][210];

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

  int n;
  cin >> n;

  Graph G(n);

  rep(i, n){
    rep(j, n){
      if(i==j){
        d[i][j] = 0;
      }else{
        d[i][j] = (1<<29);
      }
    }
  }
    
  rep(i, n){
    string s;
    cin >> s;
    rep(j, n){
      if(s[j]=='1'){
        G[i].push_back(j);
        G[j].push_back(i);
        d[i][j] = 1;
        d[j][i] = 1;
      }
    }
  }

  color.assign(n, -1);

  bool is_bipartite = true;
  rep(v, n){
    if(color[v] != -1) continue;
    if(!dfs(G, v)) is_bipartite = false;
  }
  
  if(!is_bipartite){
    cout << -1 << endl;
    return 0;
  }

  rep(k, n){
    rep(i, n){
      rep(j, n){
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  int ans = 0;
  rep(i, n){
    rep(j, n){
      chmax(ans, d[i][j]);
    }
  }

  cout << ans + 1 << endl;



  
  return 0;
}


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

#define len(x)  (int((x).size()))
#define append push_back
#define pp make_pair
#define ff(a, b)    for (int a = 0; a < int(b); ++a)
#define kk(n)    ff(k, n)
#define xx(n)    ff(x, n)
#define yy(n)    ff(y, n)
#define ii(n)    ff(i, n)
#define fff(a, b, c) for (int a = int(b); a < int(c); ++a)
#define kkk(a, b) fff(k, a, b)
#define xxx(a, b) fff(x, a, b)
#define yyy(a, b) fff(y, a, b)
#define iii(a, b) fff(i, a, b)
#define bb begin()
#define ee end()
#define uu first
#define vv second
#define all(x)  (x).bb, (x).ee
#define ite(v)   decltype((v).bb)
#define fe(i, v) for(ite(v) i = (v).bb; i != (v).ee; ++i)
#define err(...)    { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#define zz(array, byte)   memset(array, byte, sizeof(array));

using LL = long long;
using DD = long double;
using pii = pair<int, int>;



const LL  INFLL  = 0x7f7f7f7f7f7f7f7fLL;
const int INFint = 0x7f7f7f7f;  //Works with memset(..).
 
     




int main() {
    //ios_base::sync_with_stdio(false);     cin.tie(NULL);
    //cout << '\n';
    cout.precision(16);
    
    int N, x;
    cin >> N >> x;
    vector<int> as(N);
    ii (N)
        cin >> as[i];

    LL rr = INFLL;
    vector<int> mins = as;
    ii (N) {
        LL here = LL(i) * LL(x);
        kk (N) {
            here += LL(mins[k]);
        }
        rr = min(rr, here);

        kk (N) {
            int earlier = (k - (i+1) + N) % N;
            mins[k] = min(mins[k], as[earlier]);
        }
    }

    cout << rr << '\n';

    return 0;
}



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

int main(){
  ll n;
  string s;
  cin >> n >> s;
  
  ll ans = 0;
  char exp = 'A';
  for(ll i=0; i<n; i++){
    if(exp == 'C' && s[i] == exp){
      ans++;
      exp = 'A';
    }
  	if(s[i] == exp){
      exp++;
    }else if(s[i] == 'A'){
      exp = 'B';
    }else{
      exp = 'A';
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;

class Program
{
	static int D;
	static int[] Ci;
	static int[][] Sdi;
	//last[d,i]
	static int[,] Ldi;

	static int tests = 26;

	//開催しなかった場合と開催した場合の満足度の差を求める
	static int CalcDiff(int d, int i){
		//開催た場合の増加
		int plus = Sdi[d][i];
		//開催しなかった場合の減少
		int minus = Ci[i] * (d - Ldi[d,i]);

		return (plus - minus);
	}

	//Solve
	static int Solve(int d){
		//満足度の変化が最大になるiを求める
		int max = -100000000;
		int maxIdx = 0;
		for(int i=0; i<tests; i++){
			int satis = CalcDiff(d, i);
			if(satis > max){
				max = satis;
				maxIdx = i;
			}
		}

		return maxIdx;
	}

	//Main
	static void Main(string[] args)
	{
		//読み込む
		D = int.Parse(Console.ReadLine());

		//初期化
		Ci = new int[tests];
		Sdi = new int[D][];
		Ldi = new int[D,tests];

		//Ldiは-1で初期化
		for(int i=0; i<D; i++){
			for(int j=0; j<tests; j++){
				Ldi[i,j] = -1;
			}
		}

		//読み込む
		Ci = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
		for(int i=0; i<D; i++){
			Sdi[i] = new int[tests];
			Sdi[i] = Console.ReadLine().Split(' ').Select(j => int.Parse(j)).ToArray();
		}

		/*debug
		Console.WriteLine(Ci[1]);
		Console.WriteLine(Sdi[0][0]);
		*/

		//出力準備（AutoFlushを切る）
		var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
		Console.SetOut(sw);

		for(int i=0; i<D; i++){
			int t = Solve(i);
			//出力
			Console.WriteLine(t+1);
			//データを更新
			Ldi[i,t] = i;
		}

		//出力終了
		Console.Out.Flush();
	}
}



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

int main(void)
{
    int a, b;
    cin >> a >> b;
    if((a<=9)&&(b<=9))
        cout << a*b << endl;
    else
        cout << -1;
    
    return 0;
}

Measured memory_bytes: 256
function Main(input) {
    input = input.split('\n');
    k = parseInt(input[0].split(' ')[1], 10);
    nidan = input[1].split(' ').map(n => parseInt(n, 10)).sort((a, b) => a < b ? -1 : 1).reverse();
    sum = 0;
    for(i = 0; i < k; i++) {
        sum += nidan[i];
    }
    console.log(sum);
    }
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9


int main(){ 
  int A, B, C;
  cin >> A >> B >> C;
  if(A==B && B == C){
    if(A % 2){
      cout << 0 << endl;
    }
    else{
      cout << -1 << endl;
    }
  }
  else{
    int cnt = 0;
    while(!(A %2 || B % 2 || C % 2)){
      cnt++;
      int na = (B+C) / 2, nb = (A+C)/2, nc = (A+B)/2;
      A = na, B = nb, C = nc;
    }
    cout << cnt << endl;
  }
  return 0;
}



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

int main() {
	// your code goes here
	int n, max;
	string vote;
	
    unordered_map<string, int> um; 
  
	max = 0;
	
	scanf("%d",&n);
	while(n--){
		cin>>vote;
		int num=1;
		if(um.count(vote)>0){
			num = um[vote] + 1;
		}
		
		um[vote] = num;
		if(max<num)
			max = num;
	}
	
	vector<string> maxVotes;
	
    unordered_map<string, int>:: iterator p; 
    for (p = um.begin(); p != um.end(); p++)
    	if(p->second == max)
    		maxVotes.push_back(p->first);
    		
    
    // Sorting the string vector
    sort(maxVotes.begin(), maxVotes.end());

    // Ranged Based loops. This requires a C++11 Compiler also
    // If you don't have a C++11 Compiler you can use a standard
    // for loop to print your vector.
    for (string &s : maxVotes)
        cout << s << "\n";		
	return 0;
}

Measured memory_bytes: 26692
#include <iostream>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define MOD 1000000007
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void WarshallFloyd(Graph& G, Matrix& d) {//O(V^3)
	d.resize(G.size());
	REP(i, d.size())d[i].resize(G.size());
	REP(i, d.size()) {
		REP(j, d[i].size()) {
			d[i][j] = INF;
		}
	}
	REP(i, G.size()) {
		REP(j, G[i].size()) {
			d[i][G[i][j].to] = G[i][j].cap;
		}
	}
	REP(i, G.size()) {
		REP(j, G.size()) {
			REP(k, G.size()) {
				chmin(d[j][k], d[j][i] + d[i][k]);
			}
		}
	}
}

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

	ll n, m, rr;
	cin >> n >> m >> rr;
	Array r(rr, 0);
	REP(i, rr) {
		cin >> r[i];
		r[i]--;
	}
	Graph g(n);
	REP(i, m) {
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		add_edge(g, a, b, c, true, c);
	}
	Matrix d;
	WarshallFloyd(g, d);

	queue<pair<ll, Array>> que;

	REP(i, rr) {
		Array temp;
		que.push(make_pair(r[i], temp));
	}

	ll ans = INF;

	while (!que.empty()) {
		ll v=que.front().first;
		Array order = que.front().second;
		order.push_back(v);
		que.pop();
		if (order.size() == rr) {
			ll sum = 0;
			REP(i,order.size()-1) {
				sum += d[order[i]][order[i + 1]];
			}
			chmin(ans, sum);
			continue;
		}

		for (auto i :r) {
			bool flag = true;
			for (auto j : order) {
				if (i == j)flag = false;
			}
			if (flag) {
				que.push(make_pair(i, order));
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5760
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<stack>
#include<stdlib.h>
#include<math.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
typedef pair<int, char> pic;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

int N, K;
char a[100];

signed main(){
    cin >> N >> K;
    cin >> a;
    a[K - 1] = tolower(a[K - 1]);
    cout << a << endl;

    return 0;
}
/*



*/

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if(to_string(i).size()%2) ans++;
    }
    cout << ans << "\n";
    return 0;
}

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

int main() {
  int h,w;
  cin>>h>>w;
  char s[55][55];
  for (int i=0; i<h; i++) 
    for (int j=0; j<w; j++) 
      cin>>s[i][j];
  int dx[4] = {1,0,-1,0};
  int dy[4] = {0,1,0,-1};

  for (int i=0; i<h; i++) { 
    for (int j=0; j<w; j++) {
      if (s[i][j]=='#') {
	bool flag=false;
	for (int k=0; k<4; k++) {
	  int nx=i+dx[k],ny=j+dy[k];
	  if (nx<0||nx>=h||ny<0||ny>=w) continue;
	  if (s[nx][ny]=='#') flag=true;
	}
	if (!flag) {
	  cout<<"No"<<endl;
	  return 0;
	}
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}
 


Measured memory_bytes: 256
import java.util.*;

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

        int N = sc.nextInt();
        int[] H = new int[N];
        H[0] = sc.nextInt();
        int max = H[0];
        int ans = 1;

        for(int i=1; i<N; i++){
            H[i] = sc.nextInt();
            max = Math.max(max, H[i]);
            if(H[i]==max){
                ans += 1;
            }
        }
        System.out.println(ans);
    }
}

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

int main() {
    int N, M;
    std::cin >> N >> M;

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

    int c[M], d[M];
    for (int i = 0; i < M; ++i) {
        std::cin >> c[i] >> d[i];
    }

    for (int i = 0; i < N; ++i) {
        int min = INT32_MAX;
        int index = 0;
        for (int j = 0; j < M; ++j) {
            const int dist = std::abs(a[i] - c[j]) + std::abs(b[i] - d[j]);
            if (dist < min) {
                min = dist;
                index = j + 1;
            }
        }

        std::cout << index << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		int x500 = x / 500;
		int x5 = (x % 500) / 5;

		System.out.print(x500 * 1000L + x5 * 5);
	}
}


Measured memory_bytes: 22996
/************************************************************
	> File Name: d.cpp
	> Author: TSwiftie
	> Mail: tswiftie@foxmail.com 
	> Created Time: Fri 19 Jun 2020 10:15:34 AM CST
************************************************************/
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#include <ext/rope>
#define lowbit(x) (x&-x)
#define SZ(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define lc (o<<1)
#define rc (o<<1|1)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<LL> vll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
const int INF = 0x3f3f3f3f;
const LL INF_ll = 0x3f3f3f3f3f3f3f3fLL;
const double PI = acos(-1.0);
const double EPS = 1e-8;
const int N = 2e5+10;
int a[N],n,ans,t[1000010];
bool ton[1000010];
signed main(void){
	cin >> n;
	for(int i = 1;i <= n;++i)
		cin >> a[i],++t[a[i]];
	sort(a+1,a+1+n);
	for(int i = 1;i <= n;++i){
		if(!ton[a[i]]){
			if(t[a[i]]==1) ++ans;
			for(int j = a[i];j <= 1000010;j+=a[i])
				ton[j] = 1;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 9200
month, day = map(int, input().split())
ans = 0
for m in range(1, month + 1):
    for d in range(1, day + 1):
        if d % 10 >= 2 and d // 10 >= 2 and (d % 10) * (d // 10) == m:
            ans += 1
print(ans)

Measured memory_bytes: 3316
n,k = map(int, input().split())
a = list(map(int, input().split()))
al = [0]*(n+1)
pl = [0]*(n+1)
ans = -10**10
for i in range(n):
  al[i+1] = al[i] + a[i]
  pl[i+1] = pl[i] + max(0,a[i])
for i in range(n-k+1):
  l,r = i,i+k-1
  cur = max(0,al[r+1]-al[l]) + pl[l] + pl[-1] - pl[r+1]
  if cur > ans:
    ans = cur
print(ans)

Measured memory_bytes: 16840
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>

using namespace std;

int n;
long long x, ans;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;
	cin >> x;

	if (x <= n) {
		cout << 0 << endl;
		return 0;
	}

	vector<long long> f(n+1), p(n+1);

	f[0] = p[0] = 1;
	for (int i = 1; i <= n; ++i) {
		f[i] = (f[i-1]<<1) + 3;
		p[i] = (p[i-1]<<1) + 1;
	}

	x = min(x, f[n]);

	while (x > 0) {
		if (x == f[n] || x == f[n]-1) {
			ans += p[n];
			break;
		}

		if (x <= f[n-1] + 1) {
			--n;
			--x;
		} else {
			ans += p[n-1] + 1;

			x -= f[n-1] + 2;
			--n;
		}
	}

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

Measured memory_bytes: 256
s = input()
t = input()
n = len(s)
m = len(t)
dp = [[0 for _ in range(n+1)] for _ in range(m+1)]
for i in range(m):
    for j in range(n):
        if t[i] == s[j]:
            dp[i+1][j+1] = dp[i][j] + 1
        else:
            dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])
ans = ''
while n != 0 and m != 0:
    if dp[m][n] == dp[m-1][n]:
        m -= 1
    elif dp[m][n] == dp[m][n-1]:
        n -= 1
    else:
        n -= 1
        m -= 1
        ans += s[n]
print(ans[::-1])

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

int main(){
  int n,a;
  cin >> n;
  int ball[n];
  int cnt[n+1] = {0};
  long long sum=0;
  rep(i,n){
    cin >> a;
    ball[i] = a;
    sum += cnt[a];
    cnt[a]++;
  }

  rep(i,n){
    cout << sum-cnt[ball[i]]+1 << endl;
  }
}


Measured memory_bytes: 4096
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main() {
	string N;

	cin >> N;

	string before = N;

	reverse(N.begin(), N.end());

	if (N == before) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int llint
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI (acos(-1))
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using Complex = std::complex<double>;
using namespace std;


int N;
int a[100010];
int cnt[100010];


int solve(){
	rep(i, 0, N) cnt[a[i]-1]++, cnt[a[i]]++, cnt[a[i]+1]++;
	return *max_element(RNG(cnt, 0, 100010));
}


signed main(){
	cin >> N;
	rep(i, 0, N) cin >> a[i], a[i]+1;

	cout << solve() << endl;

	return 0;
}

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

using namespace std;

int h, w, ans;
int dx[4]={1, 0, -1, 0};
int dy[4]={0, 1, 0, -1};
char maze[105][105];

void dfs(int x, int y)
{
    char temp =maze[x][y];
    maze[x][y]=0;
    for(int i=0; i<4; i++)
    {
        int nx=x+dx[i];
        int ny=y+dy[i];
        if(nx>=0&&ny>=0&&nx<h&&ny<w&&maze[nx][ny]==temp)
            dfs(nx, ny);
    }
    return;
}

int main(void)
{
    cin>>h>>w;
    while(h!=0||w!=0)
    {
        ans=0;
        memset(maze, 0, sizeof(maze));
        for(int i=0; i<h; i++)
            for(int j=0; j<w; j++)
                cin>>maze[i][j];
        for(int i=0; i<h; i++)
            for(int j=0; j<w; j++)
            {
                if(maze[i][j]=='@'||maze[i][j]=='#'||maze[i][j]=='*')
                {
                    ans++;
                    dfs(i, j);
                }
            }
        cout<<ans<<endl;
        cin>>h>>w;
    }
    return 0;
}


Measured memory_bytes: 3488
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

long long n;
long long x,y;
long long dp[100005][2];
vector<long long> adj[100005]; // đỉnh kề với đỉnh i
bool vis[100005]; // đỉnh đã duyệt

void init(){
  for(long long i=1;i<=n;i++)
	{
		vis[i] = false;
		dp[i][0] = dp[i][1] = 1;
	}
}

void dfs(long long s){
	vis[s] = true;

//		int ch = 0;
////		cout << "doan ch " << ch<<"\n";
//		for(auto x: adj[s])
//			{
////				cout << x <<" doan ch x\n";
//				if(vis[x]==false) { ch = 1; break; }
//				}
//
//		if(ch==0) {dp[s][0] = dp[s][1] = 1;}
//
//		else{
//			dp[s][0] = dp[s][1] = 1;
			for(auto x:adj[s]){
				if(vis[x]==false){
					dfs(x);
					dp[s][0]*=(dp[x][0]%mod+dp[x][1]%mod);
					dp[s][0]%=mod;

					dp[s][1]*=(dp[x][0]%mod);
					dp[s][1]%=mod;
				}
			}
		}

int main(){
   scanf("%lld",&n);
   for(long long i=1;i<n;i++){
	scanf("%lld %lld",&x,&y);
	adj[x].push_back(y);
	adj[y].push_back(x);
   }

//   for(int i=1;i<=n;i++)
//   {
//   	for(auto x: adj[i])
//		cout << x <<" ";
//	cout << "\n";
//   }
   init();

   dfs(1);

	printf("%lld",(dp[1][0]+dp[1][1])%mod);
}


Measured memory_bytes: 11520
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int n,m;
int array[305][305]={0};
int idx[305]={0};
bool judge(int border){
  for(int i=1;i<=n;i++) idx[i]=1;
  int cnt[305]={0};
  bool used[305];
  for(int i=1;i<=m;i++) used[i]=false;
  while(1){
    for(int i=0;i<=m;i++) cnt[i]=0;
    for(int i=1;i<=n;i++) cnt[array[i][idx[i]]]++;
    bool f=false;
    for(int i=1;i<=m;i++){
      if(cnt[i]>border) used[i]=true;
    }
    for(int i=1;i<=n;i++){
      while(used[array[i][idx[i]]]){
        idx[i]++;
        f=true;
        if(idx[i]>m) return false;
      }
    }
    if(!f) return true;
  }
}
int main(){
  cin>>n>>m;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      cin>>array[i][j];
    }
  }
  int lb=1,rb=n+1;
  for(int i=1;i<=n;i++){
    if(judge(i)) {
      cout<<i<<endl;
      return 0;
    }
  }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
lli count(int a[],int n)
{
	int i;
	lli diff,cost;
lli dp[n];
	for(i=1;i<n;i++)
	dp[i]=-1;
	dp[0]=0;
	for(i=0;i<n-1;i++)
	{
	 diff=abs(a[i+1]-a[i]);	
	 cost=dp[i]+diff;
	 if(dp[i+1]==-1 || cost<dp[i+1])
	 dp[i+1]=cost;
	 
	 if(i+2<n)
	 {
	 diff=abs(a[i+2]-a[i]);	
	 cost=dp[i]+diff;
	 if(dp[i+2]==-1 || cost<dp[i+2])
	 dp[i+2]=cost;
	 }
	}
//	for(i=0;i<n;i++)
//	cout<<dp[i]<<" ";
	return dp[n-1];	
}

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

Measured memory_bytes: 4752
#include<bits/stdc++.h>
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef double db;
const int inf = 0x3f3f3f3f;
const int mod = 1000000007;
const int N = 1e4 + 5;
int n,m,k,t;
struct node{
    int w,v;
    bool operator < (node & rhs)const {
        return w<rhs.w;
    }
}s[N];
int w[N], v[N];
int dp[N];

int main(){
    scanf("%d%d", &n,&t);
    rep(i,1,n) scanf("%d%d", &s[i].w, &s[i].v);
    sort(s+1,s+1+n);
    rep(i,1,n){
        per(j,6000,0){
            if(j - s[i].w < t && j>=s[i].w) dp[j] = max(dp[j],dp[j-s[i].w]+s[i].v);
        }
    }
    int ans = 0;
    //rep(i,0,10) printf("%d ",dp[i]); puts("");
    rep(i,t,6000) ans = max(ans, dp[i]);
    printf("%d\n", ans);
    return 0;
}


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 main() {
  vector<int> x(4), y(4);
  cin >> x[0] >> y[0] >> x[1] >> y[1];
  x[2] = x[1] - (y[1] - y[0]);
  y[2] = y[1] + (x[1] - x[0]);
  x[3] = x[0] - (y[1] - y[0]);
  y[3] = y[0] + (x[1] - x[0]);
  printf("%d %d %d %d\n", x[2], y[2], x[3], y[3]);
  return 0;
}

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

int main()
{
    ll a, b; cin >> a >> b;
    ll ans = 0;
    if (b > 12) b = 12;
    rep(i,a){
        rep(j,12) {
            if (i == a-1 && j > b-1) continue;
            if ((i+1) == (j+1)) ans++;
        }
    }
    cout << ans << endl;
 
    




}


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

int main()
{
  int n, x[2][4];
  char ans[2] = {'+', '-'};

  cin >> n;
  for(int i = 0; i < 4; i++){
    x[0][3-i] = n % 10;
    n /= 10;
    x[1][3-i] = -x[0][3-i];
  }

  for(int i = 0; i < 2; i++)
    for(int j = 0; j < 2; j++)
      for(int k = 0; k < 2; k++)
        if((x[0][0] + x[i][1] + x[j][2] + x[k][3]) == 7){
          cout << x[0][0];
          cout << ans[i] << x[0][1];
          cout << ans[j] << x[0][2];
          cout << ans[k] << x[0][3];
          cout << "=7" << endl;
          return 0;
        }
  return 0;
}

Measured memory_bytes: 256
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#include<unordered_map>
#define ll long long
#define vi vector<long long>
#define pb push_back
#define pop pop_back
#define pi pair<long long ,long long>
#define vp vector<pair<long long,long long> >
#define mkp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define map map<long long,long long>
#define inm1(b)  memset(b,-1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))
#define MOD         1000000007
#define I 1000000000000000001
#define t(a) cout<<a<<" "<<endl
#define tt(a,b) cout<<a<<" "<<b<<endl
#define th(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
using namespace std;
ll gcd(ll a, ll b) {  if (a == 0)  return b; return gcd(b % a, a); }


int main(){
    jaldi
    #ifndef ONLINE_JUDGE
    TakeInput
    #endif
    
    ll n,m,k,x;
    cin>>n>>x>>k;

    cout<<(int)(ceil((double)n/x) * k);
}


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

typedef pair<long long, long long> pll;
struct sort_second {
    bool operator()(const std::pair<long long, long long> &left, const std::pair<long long,long long> &right) {
        return left.second < right.second;
    }
};

void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b){
    vector<pll> conf(M);
    for (int i = 0; i < M; i++)
    {
        conf[i].first = a[i];
        conf[i].second = b[i];
    }
    sort(conf.begin(), conf.end(), sort_second());
    long long cnt=1, end_time;
    end_time = conf[0].second;
    for (long long i = 1; i < M; i++)
    {
        if(conf[i].first>= end_time){
            cnt++;
            end_time = conf[i].second;
        }
    }
    cout << cnt << endl;
}

// Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(M);
    std::vector<long long> b(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    solve(N, M, std::move(a), std::move(b));
    return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main()
{
    int n, ans = 1;
    cin >> n;
    vector<int> h(n);
    rep(i, n)cin >> h[i];
    for(int i = 1; i < n; i++){
        bool flag = true;
        for(int j = 0; j < i; j++){
            if(h[j] > h[i]) flag = false;
        }
        if(flag)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
program main
  implicit none
  integer(8) :: a, b, x
  read *, a, b, x
  print "(i0)", f(b) - f(a - 1)
  contains
  integer(8) function f(n)
    integer(8), intent(in) :: n
    if (n == -1) then
      f = 0
    else
      f = n / x + 1
    end if
  end function f
end program main


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


int main() {
  int K, S;
  cin >> K >> S;

  int count = 0;

  for(int i=0;i<S+1;i++){
    for(int j=i;j<S+1;j++){
      if(i<=K && j-i<=K && S-j<=K){
        count++;
      }
    }
  }

  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
 
const int mod=1e9+7;
const int Max=100005;
int n,m,s;
int sum[Max];
 
inline int ksm(int a,int b)
{
	int ans=1;
	while(b)
	{
	  if(b&1) ans=(ans*a)%mod;
	  b>>=1;
	  a=(a*a)%mod;
	}
	return ans;
}
 
signed main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&m),sum[m]++;
	for(int i=0;i<n;i++) if(sum[i]>=3) {cout<<"0";return 0;}
	if((n&1&&sum[0]!=1)||(!(n%2)&&sum[0])) {cout<<"0";return 0;}
	cout<<ksm(2,n/2);
	return 0;

}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
//C++11
#if __cplusplus == 201103L
#include <tuple>
#endif

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  for(string s; getline(cin, s);){
    string t;
    REP(i, s.size())if(isalpha(s[i])) t += toupper(s[i]);
    vector<string> candy;
    REP(i, t.size()){
      for(int l = 3; i + l - 1 < t.size(); l++){
        string sub = t.substr(i, l);
        string rev = sub;
        reverse(rev.begin(), rev.end());
        if(sub == rev) candy.push_back(sub);
      }
    }
    sort(candy.begin(), candy.end());
    candy.erase(unique(candy.begin(), candy.end()), candy.end());
    REP(i, candy.size()){
      bool ok = true;
      REP(j, candy.size()){
        if(candy[i] == candy[j].substr(1, candy[j].size() - 2)){
          ok = false;
        }
      }
      if(ok) cout<<candy[i]<<" ";
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 940
<?php
// C
fscanf(STDIN, '%d', $n);
fscanf(STDIN, '%s', $s);
$cusum['E'][0] = 0;
$cusum['W'][0] = 0;
for ($i = 1; $i <= $n; $i++) {
    $cusum['E'][$i] = $cusum['E'][$i - 1];
    $cusum['W'][$i] = $cusum['W'][$i - 1];
    $cusum[$s[$i - 1]][$i]++;
}
$ans = PHP_INT_MAX;
for ($i = 0; $i < $n; $i++)
    $ans = min($ans, $n - 1 - ($cusum['E'][$i] + ($cusum['W'][$n] - $cusum['W'][$i + 1])));
echo $ans;

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

const double PI = 3.1415926;

double a,b,x,c;
double deg;

int main()
{
	cin>>a>>b>>x;
	double ar=a*a*b/2;
	if(x<=ar)
	{
		a = x*2/a/b;
		deg = atan(b/a)*180.0/PI;
	}
	else if(x>ar)
	{
		c = b-(x*2/a/a-b);
		deg = (atan(a/b)-atan(a/c)+atan(b/a))*180.0/PI;
	}
	printf("%.8lf\n",deg);
	
	return 0;
}

Measured memory_bytes: 256
N, M = [int(s) for s in input().split(' ')]
stores = []
for i in range(N):
    stores.append(tuple([int(s) for s in input().split(' ')]))
stores = sorted(stores, key=lambda s: s[0])
N_buy = 0
money = 0
for store in stores:
    if N_buy + store[1] < M:
        N_buy += store[1]
        money += store[1] * store[0]
    else:
        money += (M - N_buy) * store[0]
        break
print(money)

Measured memory_bytes: 18888
#include<iostream>
#include<cmath>
using namespace std;
int a[1005]={0};
int	main()
{
	a[1]=1;
	for(int i=2;i<=sqrt(1000);i++)
	{
		for(int j=2;pow(i,j)<=1000;j++)
		{
			a[(int)pow((float)(i),(float)(j))]=1; 
		}
	}
	
	int x;
	cin>>x;
	while(!a[x])
	{
		x--;
	}
	
	cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

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

                String S = scan.next();
                String T = scan.next();
                int S_length = S.length();
                int T_length = T.length();
                int flag = 1;

                for (int i = 0; i < S_length; i++) {
                        char s = S.charAt(i);
                        char t = T.charAt(i);
                        if (!(s == t)) {
                                System.out.println("No");
                                flag = 0;
                                break;
                        }
                }

                if (flag == 1) {
                        System.out.println("Yes");
                }
        }
}

Measured memory_bytes: 35684
'''
Created on 2019年3月3日

@author: zcg01
'''
import math
import copy
 
 
 
 
def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:
 
            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
 
a=nCast(input().split());
b=nCast(input().split());
 

 
def func():

    return (a[0]-b[0])*(a[1]-b[1])
print(func()) 

Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <map>
#include <set>
#include <list>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

int i,j,k,l,m,n;
/////////////////////////////////////////////////////
#define MOD ((ll)1e9+7)

ll N;
ll A[101010];

ll P[202020];


ll moddiv(ll a,ll b){
    ll i=0;
    ll bb=b;
    //cout<<a<<"->";
    while(true){
        //cout<<bb<<":"<<i<<" ";
        if((MOD-2)&((ll)1<<i)){
            a=a*bb%MOD;
            
        }else if((MOD-2)<((ll)1<<i)){
            break;
        }
        bb=bb*bb%MOD;
        i++;
    }
    return a;
}

int main(){
    ll a,b;
    scanf("%lld",&N);
    for(i=0;i<N;i++){
        scanf("%lld",&A[i]);
    }
    //cout<<"a";
    ll fact=1;
    for(ll i=1;i<=N;i++){
        fact=(fact*i)%MOD;
    }

    //cout<<"a";
    for(ll i=N;i>0;i--){
        P[N-i]=P[N+i-2]=moddiv(fact,i);
    }
    //cout<<"a";

    ll Psum=0;

    for(ll i=0;i<N;i++){
        Psum=(Psum+P[i])%MOD;
    }
    //cout<<"a";
    /*
    for(ll i=0;i<N*2;i++){
        cout<<P[i]<<" ";
    }
    */
    ll ans=0;
    for(ll i=0;i<N;i++){
        //cout<<ans<<endl;
        ans=(ans+A[i]*Psum)%MOD;
        Psum=(Psum+MOD+P[i+N]-P[i])%MOD;
    }
    
    printf("%lld",ans);
    
    return 0;
}

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

using ll = long long ;

using namespace std;


int main() {
    int N, M, C, A[20][20], B[20];
    cin >> N >> M >> C;
    for(int i = 0; i < M; ++i) {
        cin >> B[i];
    }
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < M; ++j) {
            cin >> A[i][j];
        }
    }
    int num = 0;
    for(int i = 0; i < N; ++i) {
        int sum = 0;
        for(int j = 0; j < M; ++j) {
            sum += A[i][j] * B[j];
        }
        if(sum > -C) {
            num++;
        }
    }
    cout << num << endl;
    return 0;
}

Measured memory_bytes: 256