akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int MAX = 210000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    ll H, W, A, B;
    cin >> H >> W >> A >> B;

    COMinit();

    ll ans = 0;
    int i = H - A, j = B + 1;
    for(;;) {
        if ( i < 1 || j > W ) break;
        ans += COM(i-1+j-1,i-1) * COM(H-i+W-j,H-i) % MOD;
        ans %= MOD;
        i--;
        j++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>

using namespace std;

int main() {
  string s,t;
  cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

int main() {
    int N;
    cin >> N;
    vector<int> first(100005), second(100005);
    for (int i = 0; i < 100005; ++i) {
        first[i] = 0; second[i] = 0;
    }
    int input;
    for (int i = 1; i <= N; ++i) {
        cin >> input;
        if (i % 2 == 1) {
            first[input]++;
        } else {
            second[input]++;
        }
    }
    int firstMax1 = 0, firstMax2 = 0, secondMax1 = 0, secondMax2 = 0;
    int firstMaxValue = 0, secondMaxValue = 0;
    for (int i = 0; i < 100005; ++i) {
        if (firstMax1 == first[i]) {
            firstMax2 = firstMax1;
        } else {
            int temp = firstMax1;
            firstMax1 = max(firstMax1, first[i]);
            if (firstMax1 == first[i]) {
                firstMaxValue = i;
                firstMax2 = temp;
            } else {
                firstMax2 = max(firstMax2, first[i]);
            }
        }
        if (secondMax1 == second[i]) {
            secondMax2 = secondMax1;
        } else {
            int temp = secondMax1;
            secondMax1 = max(secondMax1, second[i]);
            if (secondMax1 == second[i]) {
                secondMaxValue = i;
                secondMax2 = temp;
            } else {
                secondMax2 = max(secondMax2, second[i]);
            }
        }
    }
    if (firstMaxValue == secondMaxValue) {
        cout << min((N / 2 - firstMax1) + (N / 2 - secondMax2), (N / 2 - secondMax1) + (N / 2 - firstMax2)) << endl;
    } else {
        cout << (N / 2 - firstMax1) + (N / 2 - secondMax1) << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int a,b;
  cin>>a>>b;
  cout<<max(max(a+b,a-b),a*b)<<endl;
  return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

class Dijkstra {
  private:
    struct Graph {
        int to, cost;
    };
    const long long INF = 4'000'000'000'000'000'000;
    using P             = pair<long long, int>;
    int V;
    vector<vector<Graph>> G;
    vector<long long> dist;

  public:
    Dijkstra(int vertex) {
        V = vertex;
        G.resize(vertex);
        dist.resize(vertex, INF);
    }
    // 無向グラフの構築
    void undirected_update(int x, int y, int cost) {
        G[x].push_back({y, cost});
        G[y].push_back({x, cost});
    }
    // 有向グラフの構築
    void directed_update(int from, int to, int cost) {
        G[from].push_back({to, cost});
    }

    // start からの最短経路計算
    void calc(int start) {
        priority_queue<P, vector<P>, greater<P>> que;
        dist[start] = 0;
        que.push({0, start});

        while (!que.empty()) {
            auto p = que.top();
            que.pop();
            int v = p.second;
            if (dist[v] < p.first)
                continue;
            for (int i = 0; i < G[v].size(); i++) {
                auto e = G[v][i];
                if (dist[v] + e.cost < dist[e.to]) {
                    dist[e.to] = dist[v] + e.cost;
                    que.push({dist[e.to], e.to});
                }
            }
        }
    }

    // calc で渡した start からの最短経路を返す
    // 最短経路が存在しないとき -1 を返す
    long long min_dist(int to) { return dist[to] != INF ? dist[to] : -1; }
};

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

    int N;
    cin >> N;
    auto dj = Dijkstra(N);
    REP(i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        dj.undirected_update(u, v, w);
    }
    dj.calc(0);
    REP(i, N) {
        if (dj.min_dist(i) % 2 == 0) {
            std::cout << 0 << '\n';
        } else {
            std::cout << 1 << '\n';
        }
    }

    return 0;
}

Measured memory_bytes: 7296
import itertools

n, m, q = map(int, input().split(' '))
a = [list(map(int, input().split(' '))) for i in range(q)]
b = list(itertools.combinations_with_replacement(range(1, m+1), n))
c = 0
d = 0
for i in range(len(b)):
	for j in range(len(a)):
		if b[i][(a[j][1]-1)] - b[i][(a[j][0]-1)] == a[j][2]:
			c += a[j][3]
	if d <= c:
		d = c
	c = 0
print(d)

Measured memory_bytes: 21396
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  
  if (N%2==1)
    cout << "No" << endl;
  else{
    bool flag=1;
    for (int i=0;i< N/2 ;i++){
      if (S.at(i)==S.at(i+N/2))
        continue;
      else
        flag=0;
    }
    if (flag)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
# AOJ 0073: Surface Area of Quadrangular Pyramid
# Python3 2018.6.15 bal4u

import math
while True:
	x = int(input())
	if x < 1: break
	h = int(input())
	s = math.sqrt(4*h*h + x*x) + x;
	print(s*x);


Measured memory_bytes: 5664
#include<stdio.h>
int main(){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    
    while(1){
        c-=b;
        if(c<=0){
            printf("Yes\n");
            return 0;
        }
        a-=d;
        if(a<=0){
            printf("No\n");
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1660
//Rooted tree
//2018-01-09
//Ebitani Akira

#include <stdio.h>
#include <stdlib.h>

void again (int, int);
void Print_tree (int);

#define N 1000000

typedef struct node { int p, l, r; } Node;
Node A[N];
int D[N];

int main(){
  int n, l, root;
  int v, d;
  int i, j;
  int c;

  scanf("%d", &n);
  if(n < 1 || 1000000 < n){
    printf("節点が適当ではありません。\n");
    exit(1);
  }
  for(i = 0 ; i < n ; i++){
    A[i].p = A[i]. l = A[i]. r = -1;
  }
  for(i = 0 ; i < n ; i++){
    scanf("%d%d", &v, &d);

    for(j = 0 ; j < d ; j++){
      scanf("%d", &c);
      if(j == 0){
	A[v].l = c;
      }
      else{
	A[l].r = c;
      }
      l = c;
      A[c].p = v;
    }
  }
  for(i = 0 ; i < n ; i++ ){
    if(A[i].p == -1) root = i;
  }
  again(root, 0);
  for(i = 0 ; i < n ; i++) Print_tree(i);

  return 0;
}

void again(int a, int b){
  D[a] = b;
  if(A[a].l != -1) again(A[a].l, b+1);
  if(A[a].r != -1) again(A[a].r, b);
}

void Print_tree(int x){
  int i, a;
  printf("node %d: parent = %d, depth = %d, ", x, A[x].p, D[x]);
  if(A[x].p == -1)
    printf("root, ");
  else if(A[x].l == -1)
    printf("leaf, ");
  else
    printf("internal node, ");
  printf("[");
  
  for(i = 0, a = A[x].l ; a != -1 ; a = A[a].r, i++){
    if(i != 0)
      printf(", ");
    printf("%d", a);
    
  }
  printf("]\n");
}
  



Measured memory_bytes: 3364
#include <bits/stdc++.h>
#include <iostream>	
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;

const int inf = int(2e9);
const int mod = inf + 7;
using namespace std;

const int N = 100000;

void solve(){
	int n;
	cin >> n;
	int l[n];
	ll sum = 0;
	rep(i, n) {
		cin >> l[i];
		sum += l[i];
	}
	bool ok = 0;
	rep(i, n){
		if(l[i] >= sum - l[i]) ok = 1;
	}
	cout << (ok ? "No" : "Yes");
}

int main() {
	Red;
	solve();
	return 0;
}

Measured memory_bytes: 256
k,a,b=list(map(int,input().split()))

if a>=b:
  print(k+1)
  exit()

elif b-a<=2:
  print(k+1)
  
elif k<=a:
  print(k+1)
  exit()

else:
  n=(k-(a-1))#交換できる回数。
#  print('n:',n)
  if n%2==1:
    print((n-1)//2*(b-a)+(k-n)+1+1)
  else:
    print(n//2*(b-a)+(k-n)+1)

  

Measured memory_bytes: 2940
length = raw_input()
arr = map(int, raw_input().split())

from collections import defaultdict
d = defaultdict(int)
count = 0
for a in arr:
	if d[a] == a:
		count += 1
		continue
	d[a] += 1
for k,x in d.items():
	if k != x:
		count += x

print count

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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main(){
    int n,m,p;
    while(cin>>n>>m>>p){
        if(n==0 and m==0 and p==0) break;
        m--;
        int sum=0;
        vector<int> x(n);
        rep(i,n){
            cin>>x[i];
            sum += x[i];
        }

        int t = sum * (100-p);

        if(x[m]==0){
            cout << 0 << endl;
            continue;
        }
        cout << t / x[m]<< endl;
    }
}

Measured memory_bytes: 2988
def main():
  s=input()
  n=len(s)
  a,b,M=0,1,10**9+7
  p=[1]
  for i in range(n-1):
    p.append(p[i]*3%M)
  for i,t in enumerate(map(int,s)):
    if t:
      a=(a+b*p[~i])%M
      b=b*2%M
  print((a+b)%M)
main()

Measured memory_bytes: 7156
const input = require("fs").readFileSync("/dev/stdin", "utf8").slice(0, -1).split('\n')[0]; // sliceは最終行の改行削除に利用
let total = 0;
for (let i = 0;i < input.length;i++) {
  total += Number(input[i]);
}

console.log(total % 9 == 0 ? "Yes" : "No");

Measured memory_bytes: 32536
# https://atcoder.jp/contests/diverta2019/tasks/diverta2019_d

n = int(input())

i = 1
ans = 0
while i <= n ** 0.5 + 1:
    if (n - i) % i == 0 and (n - i) // i > i:
        ans += (n - i) // i
    i += 1
print(ans)


Measured memory_bytes: 40556
#include <stdio.h>
#include <cstdio>
#include <string>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>

const int Type_Max = 12345;


int Data[Type_Max];

int Map[123][123];

int main()
{
	int ans = 0;
	int N;

	int buf, buf2;
	
	scanf("%d", &N);

	for (int i = 0; i < N; i++)
	{
		scanf("%d%d", &buf, &buf2);

		ans += buf2 - buf + 1;
	}

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

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int Maxn=200020;
int n;
char s[Maxn];
int f[Maxn][2];
void up(int &a, int b){
	if(a<0||a>b)a=b;
}
int main(){
	scanf("%d",&n);
	scanf("%s",s);
	memset(f,-1,sizeof(f));
	f[0][0]=0;
	for(int i=0;s[i];i++){
		for(int j=0;j<2;j++){
			if(f[i][j]<0)continue;
			for(int k=0;k<2;k++){
				int next=(s[i]=='.'?0:1)^k;
				if(j&&!next)continue;
				up(f[i+1][next], f[i][j]+k);
			}
		}
	}
	int ans=f[n][0];
	up(ans, f[n][1]);
	printf("%d\n",ans);
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll N;
    cin >> N;
    cout << N * (N - 1) / 2 << endl;
    return 0;
}

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

using namespace std;
int main()
{
   int L;
   cin >> L ;

   double tmp = L/3.0 ;
   
    cout <<   setprecision(10) << tmp*tmp*tmp << endl ;
    return 0;
}


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

int main() {
    int n,k; cin >> n >> k;
    int h[n];
    rep(i, n) cin >> h[i];
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i = 2; i < n; i++){
        int minn = 1001001001;
        for(int j = 1; j <= k; j++){
            if((i-j) >= 0){
                minn = min(minn, dp[i-j] + abs(h[i-j] - h[i]));
            }
        }

        dp[i] = minn;
    }
    // rep(i, n) cout << dp[i] << " ";
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1152
/* be name khoda */

#define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <vector>
#include <fstream>
#include <set>
#include <map>
using namespace std;

#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

#define forifrom(i, s, n) for (ll i = s; i < n; ++i)
#define forirto(i, n, e) for (ll i = (n) - 1; i >= e; --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl

const ll MOD = 1000000007;
const ll INF = 2000000000;
const long long BIG = 1446803456761533460LL;

#define XL (x << 1)
#define XR (XL | 1)
#define MD ((l + r) >> 1)
#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

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

const ll maxn = 200010;

ll n;
pip vals[maxn];
ll cnt[maxn];

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    cin >> n;
    fori (i, n) {
        ll a, b; cin >> a >> b;
        vals[i * 2] = {a, {i, -1}};
        vals[i * 2 + 1] = {b, {i, 1}};
    }
    sort(vals, vals + n * 2);
    bool flag = true;
    ll s = 0;
    ll d = 0;
    fori (i, n) {
        s += vals[i].F;
        d += vals[i].S.S;
        if (++cnt[vals[i].S.F] == 2) flag = false;
    }
    if (flag && abs(d) != n) {
        if (vals[n - 1].S.F != vals[n].S.F) {
            s = s - vals[n - 1].F + vals[n].F;
        } else { 
            s = min(s - vals[n - 1].F + vals[n + 1].F,
                    s - vals[n - 2].F + vals[n].F);
        } 
    }
    cout << s << '\n';

}


Measured memory_bytes: 9132
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    string s, t;
    cin >> s;
    for (int i = 0; i < s.size(); i += 2) {
        t.push_back(s.at(i));
    }
    cout << t << endl;
}

Measured memory_bytes: 512
#![allow(non_snake_case)]

fn main() {
    // snip
    let _N: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    // snip

    let ans = _N.pow(3);

    println!("{}", ans);
}



Measured memory_bytes: 5036
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#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 FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;

int main() {
    ll a, b, c, x, y;
    cin >> a >> b >> c;
    if(a+b+1 >= c) {
        cout << b + c << endl;
    } else {
        cout << a + b*2 + 1 << endl;
    }
}


Measured memory_bytes: 256
#include <set>
#include <iostream>
using namespace std;
int main(){
  string s;
  int K;
  cin >> s >> K;
  set<string> S;
  for(int i = 0; i < s.length(); ++i){
    for(int j = 0; j <= min((int)s.length() - i, K); ++j)
      S.insert(s.substr(i, j));
  }
  auto itr = S.begin();
  for(int i = 0; i < K; ++i){
    //cout << *itr << endl;
    ++itr;
  }
  cout << *itr << endl;
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> bool chmax(T &a, U b) { if (a < b) a = b; return true; }
template<class T, class U> bool chmin(T &a, U b) { if (a > b) a = b; return true; }

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

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;
  map<int,int> mp;

  rep(i, n) {
    int a; cin >> a;
    ++mp[a], ++mp[a-1], ++mp[a+1];
  }

  int ans = 0;
  for (auto e : mp) chmax(ans, e.se);

  cout << ans << endl;

  return (0);
}


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

constexpr int mod = 998244353;
struct Mint {
  int v;
  Mint(long long a = 0) : v((a %= mod) < 0 ? a + mod : a) {}
  Mint& operator*=(Mint r) { v = (long long)v * r.v % mod; return *this; }
  Mint& operator/=(Mint r) { return *this *= r.inv(); }
  Mint& operator+=(Mint r) { if ((v += r.v) >= mod) v -= mod; return *this; }
  Mint& operator-=(Mint r) { if ((v -= r.v) < 0) v += mod; return *this; }
  friend Mint operator*(Mint l, Mint r) { return l *= r; }
  friend Mint operator/(Mint l, Mint r) { return l /= r; }
  friend Mint operator+(Mint l, Mint r) { return l += r; }
  friend Mint operator-(Mint l, Mint r) { return l -= r; }
  Mint pow(long long n) const {
    assert(n >= 0);
    Mint res = 1;
    for (Mint t = *this; n; t *= t, n >>= 1) if (n & 1) res *= t;
    return res;
  }
  Mint inv() const { assert(v); return pow(mod - 2); }
  friend string to_string(Mint a) { return to_string(a.v); }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  map<string, Mint> mp;
  auto fn = [&](auto&& F, string s) -> Mint {
    int n = s.size();
    if (n == 0) {
      return 1;
    }
    if (mp.count(s)) {
      return mp[s];
    }
    Mint res = F(F, s.substr(1));
    if (s[0] == '1') {
      res *= 2;
    }
    for (int d = 1; 2 * d <= n; ++d) {
      string t = s.substr(0, d);
      for (int k = 2; d * k <= n; ++k) {
        for (int i = 0; i < d; ++i) {
          if (s[d * (k - 1) + i] == '0') {
            t[i] = '0';
          }
        }
        res += F(F, t) * F(F, s.substr(d * k));
      }
    }
    return mp[s] = res;
  };
  string s;
  cin >> s;
  cout << fn(fn, s).v << '\n';
}


Measured memory_bytes: 6144
N, K = map(int, input().split())

def createFacArr(n, mod):
    '''
    二項係数計算用の配列の作成

    Parameters
    n : int
        配列のサイズ
    mod : int
        あまり

    Returns
    fac : list
        階乗のリスト
    finv : list
        modの逆元のリスト
    ivn : list
    '''
    fac = [0] * n
    finv = [0] * n
    inv = [0] * n
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1
    for i in range(2, n):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod
    return fac, finv

def comb(n ,k, mod, fac, finv):
    '''
    二項係数の計算

    Parameters
    n : int
        元集合
    k : int
        元集合から選択する数
    mod : int
        あまり
    fac : list
        階乗のリスト
    finv : list
        逆元のリスト
    
    Returns
    c : int
        nCkの組み合わせの数
    '''
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod

K = min(N-1, K)
ans = 0
MOD = 10 ** 9 + 7
fac, finv = createFacArr(N+100, MOD)

for i in range(K+1):
    # iは0の個数
    ans += comb(N, i, MOD, fac, finv) * comb(N-1, N-i-1, MOD, fac, finv) % MOD
    ans %= MOD
print(ans)


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

int main() {
  int n;
  cin >> n;
  vector<int> x(n + 1, 0), y(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> x[i];
    y[i] = x[i];
  }
  sort(x.begin() + 1, x.end());
  int a = x[n/2], b = x[n/2 + 1];
  for (int i = 1; i <= n; i++) {
    if (y[i] <= a) {
      cout << b << endl;
    }
    else {
      cout << a << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3712
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

const string YES = "Yes";
const string NO = "No";

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(){
    int n;
    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; ++i)
        cin >> s[i];
    vector<i64> su(n, 0);
    vector<i64> mi(n, 0);
    vector<i64> ma(n, 0);
    for(i64 i = 0; i < n; ++i){
        for(auto c : s[i]){
            su[i] += (c == '(' ? 1 : -1);
            chmax(mi[i], -su[i]);
        }
        reverse(s[i].begin(), s[i].end());
        su[i] = 0;
        for(auto c : s[i]){
            su[i] += (c == '(' ? 1 : -1);
            chmax(ma[i], su[i]);
        }
    }
    priority_queue<pair<i64,i64>, vector<pair<i64,i64>>, greater<pair<i64,i64>>> que, que2;
    for(i64 i = 0; i < n; ++i){
        if(su[i] > 0){
            que2.emplace(mi[i], su[i]);
        }
        else if(su[i] < 0){
            que.emplace(ma[i], -su[i]);
        }
        else{
            if(mi[i] < ma[i])
                que2.emplace(mi[i], 0);
            else
                que.emplace(ma[i], 0);
        }
    }
    i64 now = 0;
    while(!que2.empty()){
        auto t = que2.top();
        que2.pop();
        if(now < t.first){
            cout << "No" << endl;
            return;
        }
        now += t.second;
        if(now < 0){
            cout << "No" << endl;
            return;
        }
    }
    i64 now2 = now;
    now = 0;
    while(!que.empty()){
        auto t = que.top();
        que.pop();
        if(now < t.first){
            cout << "No" << endl;
            return;
        }
        now += t.second;
        if(now < 0){
            cout << "No" << endl;
            return;
        }
    }
    if(now != now2){
        cout << "No" << endl;
        return;
    }
    cout << "Yes" << endl;
}


signed main(){
    solve();
    return 0;
}


Measured memory_bytes: 73796
/*** ??±????????£????????? ***/

#include <bits/stdc++.h>
using namespace std;

int main(){
	int n, r;
	int p, c;
	vector<int> huda, temp;
	vector<int>::iterator itr;
	
	cin >> n >> r;
	for(int i=0; i<n; i++) huda.push_back(i+1);
	
	while(n!=0 && r!=0){
		for(int i=0; i<r; ++i){
			cin >> p >> c;
			
			for(int j=0; j<c; ++j){
				itr = huda.begin()+(n-p-j);
				temp.push_back(*itr);
				huda.erase(itr);
			}
			for(int j=c-1; j>=0; --j){
				itr = temp.begin()+j;
				huda.push_back(*itr);
			}
			
			temp.clear();
		}
		cout << *(huda.begin()+n-1) << endl;
		
		cin >> n;
		cin >> r;
		huda.clear();
		for(int i=0; i<n; i++) huda.push_back(i+1);
	}
	return 0;
}

Measured memory_bytes: 3152
package main

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

func printTable(t [][]int) {
	for _, r := range t {
		for j, d := range r {
			if j > 0 {
				fmt.Print(" ")
			}
			fmt.Print(d)
		}
		fmt.Println()
	}
}

func sum(arr []int) (s int) {
	for _, v := range arr {
		s += v
	}
	return
}

func main() {
	var r, c int
	fmt.Scan(&r, &c)

	rd := bufio.NewReader(os.Stdin)
	table := make([][]int, r)
	for i := 0; i < r; i++ {
		row := make([]int, 0, c+1)
		s, _, _ := rd.ReadLine()
		for _, v := range strings.Split(string(s), " ") {
			a, _ := strconv.Atoi(v)
			row = append(row, a)
		}
		row = append(row, sum(row))
		table[i] = row
	}
	table = append(table, make([]int, c+1))
	for i := 0; i < c+1; i++ {
		col := make([]int, 0, c)
		for j := 0; j < r; j++ {
			col = append(col, table[j][i])
		}
		table[r][i] = sum(col)
	}

	printTable(table)
}



Measured memory_bytes: 1652
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <fstream>
#include <vector>
using namespace std;
#define INF 0x3f3f3f3f
vector<int> vec1[100005], vec2[100005], vec3[100005];
int fa[100005];
int getf(const int& x) {
	if (fa[x] == x) return x;
	return fa[x] = getf(fa[x]);
}
void union_(const int& x, const int& y) {
	int fx = getf(x), fy = getf(y);
	if (fx != fy) fa[fx] = fy;
}
int main() {
	int n, m, k, x, y;
	cin >> n >> m >> k;
	for (int i = 1; i <= n; ++i) fa[i] = i;
	for (int i = 1; i <= m; ++i) {
		scanf("%d%d", &x, &y);
		vec1[x].push_back(y);
		vec1[y].push_back(x);
		union_(x, y);
	}
	for (int i = 1; i <= k; ++i) {
		scanf("%d%d", &x, &y);
		vec2[x].push_back(y);
		vec2[y].push_back(x);
	}
	for (int i = 1; i <= n; ++i) {
		vec3[getf(i)].push_back(i);
	}
	for (int i = 1; i <= n; ++i) {
		int k = getf(i);
		int c = vec3[k].size() - 1;
		set<int> se;
		for (int j = 0; j < vec1[i].size(); ++j) {
			vector<int>::iterator it = lower_bound(vec3[k].begin(), vec3[k].end(), vec1[i][j]);
			if (it != vec3[k].end() && *it == vec1[i][j]) se.insert(vec1[i][j]);
		}
		for (int j = 0; j < vec2[i].size(); ++j) {
			vector<int>::iterator it = lower_bound(vec3[k].begin(), vec3[k].end(), vec2[i][j]);
			if (it != vec3[k].end() && *it == vec2[i][j]) se.insert(vec2[i][j]);
		}
		c -= (int)se.size();
		if (i != n) printf("%d ", c);
		else printf("%d\n", c);
	}

	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
    int N;
    cin >> N;
    vector<ll> S(N);
    REP(i, N) cin >> S[i];
    sort(S.begin(), S.end());
    vector<ll> T(N);
    T[0] = S[0];
    for(int i=1;i<N;i++){
        T[i] = T[i-1]+S[i];
    }
    int i = N-1;
    while(i>0){
        if(S[i]<=2*T[i-1]){
            i--;
        }else{
            break;
        }
    }
    cout << N-i << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <queue>
#include <map>
#include <algorithm>
#include <vector>
#include <functional>

using namespace std;

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

typedef pair<int, int> pii;

int n, l;
int h[100002];
bool done[100002];

int main() {
	cin >> n >> l;
	h[0] = 0;
	REP(i, n) scanf("%d", &h[i + 1]);
	h[n + 1] = 0;
	n += 2;

	priority_queue<pii, vector<pii>, greater<pii> > q;	//hout, i
	FOR(i, 1, n - 1) if (h[i - 1] < h[i] && h[i] > h[i + 1])
		q.push(make_pair(l - h[i], i));

	int ans = 0;
	while (!q.empty()) {
		pii p = q.top(); q.pop();
		int pos = p.second;
		int t = p.first;

		if (done[pos]) continue;
		
		h[pos] = 0;
		done[pos] = true;
		ans = max(ans, t);
		
		if (pos - 2 >= 0 && h[pos - 2] < h[pos - 1] && h[pos - 1] > h[pos])
			q.push(make_pair(t + l - h[pos - 1], pos - 1));
		if (pos + 2 < n && h[pos] < h[pos + 1] && h[pos + 1] > h[pos + 2])
			q.push(make_pair(t + l - h[pos + 1], pos + 1));
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2140
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		List<int>[] E = new List<int>[N];
		for(int i=0;i<N;i++){
			E[i] = new List<int>();
		}
		
		int[] ind = new int[N];
		for(int i=0;i<M;i++){
			E[X[i]].Add(Y[i]);
			ind[Y[i]]++;
		}
		
		int[] max = new int[N];
		var q = new Queue<int>();
		for(int i=0;i<N;i++){
			if(ind[i] == 0){
				max[i] = 1;
				q.Enqueue(i);
			}
		}
		
		while(q.Count > 0){
			var now = q.Dequeue();
			foreach(var nxt in E[now]){
				max[nxt] = Math.Max(max[nxt], max[now] + 1);
				ind[nxt]--;
				if(ind[nxt] == 0){
					q.Enqueue(nxt);
				}
			}
		}
		
		Console.WriteLine(max.Max() - 1);
		
		
	}
	int N,M;
	int[] X,Y;
	public Sol(){
		var d = ria();
		N = d[0]; M = d[1];
		X = new int[M];
		Y = new int[M];
		for(int i=0;i<M;i++){
			d = ria();
			X[i] = d[0] - 1; Y[i] = d[1] - 1;
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 26580
import sys
input=sys.stdin.readline

def main():
    N,T = map(int, input().split())
    CT = []
    for _ in range(N):
        c,t = map(int, input().split())
        if t <= T:
            CT.append(c)
    if len(CT) == 0:
        print("TLE")
    else:
        print(min(CT))

if __name__ == '__main__':
    main()


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

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

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

int main()
{
    ll n;
    cin >> n;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==n){
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
    return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    if ((a + b)%2 == 0){
        cout << (a + b)/2 << endl;
    }
    else{
        cout << (a + b)/2 + 1 << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static int[][] setColor (int[][] board, int c, int d, int x, int y) {
		int w = d == 0 ? 4 : 2;
		int h = d == 1 ? 4 : 2;
		for (int i = y; i <= y + h - 1; i++) {
			for (int j = x; j <= x + w - 1; j++)
				board[i][j] = c;
		}
		return board;
	}

	public static boolean bfs (int[][] board, int xs, int ys, int xg, int yg, boolean[][] check) {

		int[] dx = {0,0,-1,1}, dy = {-1,1,0,0};
		int startColor = board[ys][xs];

		Queue<Integer> queueX = new LinkedList<Integer>();
		Queue<Integer> queueY = new LinkedList<Integer>();

		queueX.add(xs);
		queueY.add(ys);
		check[ys][xs] = true;

		while (!queueX.isEmpty()) {

			int x = queueX.poll();
			int y = queueY.poll();

			for (int i = 0; i < dx.length; i++) {

				int nextX = x + dx[i];
				int nextY = y + dy[i];

				if (0 <= nextY && nextY < board.length &&
					0 <= nextX && nextX < board[0].length &&
					board[nextY][nextX] == startColor &&
					!check[nextY][nextX]) {

					check[nextY][nextX] = true;
					queueX.add(nextX);
					queueY.add(nextY);

				}

			}

		}

		return check[yg][xg];

	}

	public static void main (String[] args) {

		Scanner sc = new Scanner(System.in);

		while (true) {

			int w = sc.nextInt();
			int h = sc.nextInt();
			if (w == 0 && h == 0) break;

			int[][] board = new int[h][w];
			boolean[][] check = new boolean[h][w];

			int xs = sc.nextInt() - 1;
			int ys = sc.nextInt() - 1;
			int xg = sc.nextInt() - 1;
			int yg = sc.nextInt() - 1;
			int n = sc.nextInt();

			for (int i = 0; i < n; i++) {
				int c = sc.nextInt();
				int d = sc.nextInt();
				int x = sc.nextInt() - 1;
				int y = sc.nextInt() - 1;
				board = setColor(board,c,d,x,y);
			}

			System.out.println(bfs(board,xs,ys,xg,yg,check) ? "OK" : "NG");

		}

	}

}

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

int main(){

    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    int ans = 1;
    int bre = 0;
    rep(j, N){
        if(ans == a[j]) ans++;
        else bre++;
    }
    
    if(ans != 1) cout << bre << endl;
    else cout << "-1" << endl;

    return 0;
}

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

int main()
{
  int A, B;
  cin >> A >> B;
  int cnt = 0;
  int concent_number = 0;
  int ans;
  while (true) {
    if (B == 1) {
      ans = 0;
      break;
    }
    concent_number += A;
    if (cnt != 0) {
      concent_number -= 1;
    }
    cnt++;
    if (concent_number >= B) {
      ans = cnt;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<map>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<typeinfo>
#include<queue>
#include<iomanip>
using namespace std;
using Graph = vector<vector<int>>;
int main() {
	int N, M;
	cin >> N >> M;
	int a,b;
	Graph G(N);
	for (int i = 0; i < M; i++) {
		cin >> a >> b;
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	bool flag = true;
	vector<int> guide(N);
		vector<int> dist(N, -1);
		queue<int> que;
		dist[0] = 0;
		que.push(0);
		while (!que.empty()) {
			int v = que.front();
			que.pop();
			for (int nv : G[v]) {
				if (dist[nv] != -1)continue;
				dist[nv] = dist[v] + 1;
				que.push(nv);
			}
		}
		for (int i = 1; i < N; i++) {
			if (dist[i] == -1) {
				flag = false;
				break;
			}
		}
	if (flag) {
		cout << "Yes" << endl;
		for (int i = 1; i < N; i++) {
			for (int nv : G[i]) {
				if (dist[nv] == dist[i] - 1)guide[i]=nv;
			}
			bool flag2 = true;
			if (flag2) {
				cout << guide[i]+1<<endl;
				flag2 = false;
			}
		}
	}
	else {
		cout << "No" << endl;
	}

}

Measured memory_bytes: 10636
n = int(input())

count = 0
judge = False
for i in range(n):
  d1, d2 = input().split()
  if d1 == d2:
    count += 1
  else:
    count = 0
  if count >=3:
    judge = True

if judge:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9168
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var N = sc.nextInt();
        var K = sc.nextInt();
        for (int i = 1; i <= K; i++) {
            if (N - K + 1 < i) {
                WriteLine(0);
                continue;
            }
            WriteLine(Combination.Calc(N - K + 1, i) * Combination.Calc(K - 1, i - 1) % 1000000007);
        }

    }
}

class Combination {
    static int mod = 1000000007;

    public static long Calc(int a, int b) {
        if (b > a - b) return Calc(a, a - b);

        long ansMul = 1;
        long ansDiv = 1;
        for (int i = 0; i < b; i++) {
            ansMul *= (a - i);
            ansDiv *= (i + 1);
            ansMul %= mod;
            ansDiv %= mod;
        }
        return ansMul * ModPow(ansDiv, mod - 2) % mod;
    }

    private static long ModPow(long a, int p) {
        if (p == 0) return 1;
        if (p % 2 == 0) {
            long half = ModPow(a, p / 2);
            return half * half % mod;
        } else {
            return a * ModPow(a, p - 1) % mod;
        }
    }
}

class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}


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

int main(){
  int a,b,c,d;
  cin >>a >>b >>c >>d;
  bool can = false;
  while(a>0){
    c -= b;
    if(c<=0){
      can = true;
      break;
    }
    a -= d;
  }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3644
using System;
class pg
{
  static void Main(string[] args)
  {
    string a = Console.ReadLine();
    int count = 0;
    string ppreStr = string.Empty;
    string preStr = string.Empty;
    string nowStr = string.Empty;
    foreach(char i in a)
    {
      nowStr = nowStr + i;
      if(preStr == nowStr)
      {
      }
      else
      {
        ppreStr = preStr;
        preStr = nowStr;
        nowStr = string.Empty;
        count++;
      }
    }
    Console.WriteLine(count);
  }
}


Measured memory_bytes: 15712
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    long long A=1,B=1,C=1;
    for(int i=0;i<N;i++){  
        A*=10;
        B*=8;
        C*=9;
        A=A%(1000000000+7);
        B=B%(1000000000+7);
        C=C%(1000000000+7);
    }
    //printf("A=%llu B=%llu C=%llu\n",A,B,C);
    long long ans = A - 2*C + B + 2*(1000000000+7);
    ans = ans%(1000000000+7);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3664
#coding:utf-8                                                              

N, A, B = raw_input().split()
N = int(N)
A = int(A)
B = int(B)

count = 0
for i in range(1, N+1):
    all = 0
    for j in range(len(str(i))):
        all += int(str(i)[j])
    if all >= A and all <= B:
        count += i

print count



Measured memory_bytes: 2948
#include <bits/stdc++.h>
using namespace std;
int n, a[200010], x;

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

Measured memory_bytes: 4348
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
	queue<pair<string, int>> Q;
    int n,q;
    cin >> n >> q;
    rep(i,0,n){
        pair<string, int> p;
        cin >> p.first >> p.second;
        Q.push(p);
    }

    ll all_time = 0;

    while(!Q.empty()){
        pair<string, int> p = Q.front();
        Q.pop();
        if(p.second - q <= 0){
            all_time += p.second;
            cout << p.first << ' ' << all_time << endl;
        }else{
            pair<string, int> pp = make_pair(p.first, p.second - q);
            Q.push(pp);
            all_time += q;
        }
    }
}


Measured memory_bytes: 6184
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef vector<int>		vi;
typedef vector<pii>		vpii;
typedef vector<vi>		vvi;
//=======================
const int MOD = 1000000007;
const int N = 2e6+13, M = N;
//=======================
vi g[N];
int a[N];
int n, m, k;
//=======================

void solve() {
    int n, x, t;
  cin >> n >> x >> t;
  if (n%x != 0)
  {
      cout << (n/x + 1)*t;
  }
  else
  {
      cout << (n/x)*t;
  }
  
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    int t = 1;
    while(t--) {
      solve();
    }

    return 0;
}

Measured memory_bytes: 50488
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	int n, m; cin >> n >> m; vector<int>v(2 * n);
	rep(i, 0, v.size())v[i] = i + 1;
	int k;
	while (m--) {
		cin >> k;
		if (k == 0) {
			vector<int>w(v);
			int a(0);
			rep(i, 0, n) {
				w[a++] = v[i];
				w[a++] = v[i + n];
			}
			v = w;
		}
		else {
			vector<int>w(v);
			int a(0);
			rep(i, k, v.size())w[a++] = v[i];
			rep(i, 0, k)w[a++] = v[i];
			v = w;
		}
	}
	rep(i, 0, v.size())cout << v[i] << endl;
	return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

//const ll INF = 1e18L + 5;
const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int n, m, x;
	cin >> n >> m >> x;
	vector<vector<int>> v(n, vector<int>(m));
	vi c(n);
	rep(i, n) {
		cin >> c[i];
		rep(j, m) cin >> v[i][j];
	}
	int ans = INF;
	for (int b = 0; b < (1 << n); b++) {
		int sc = 0;
		vi tmp(m);
		for (int i = 0; i < n; i++) {
			if (b >> i & 1) {
				sc += c[i];
				rep(j, m) {
					tmp[j] += v[i][j];
				}
			}
		}
		bool ok = true;
		for (int mi : tmp) {
			if (mi < x) {
				ok = false;
				break;
			}
		}
		if (ok) chmin(ans, sc);
	}
	if (ans == INF)
		cout << -1 << endl;
	else
		cout << ans << endl;
}

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

	solve();
}


Measured memory_bytes: 3660