akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
  
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed(x) fixed<<setprecision(x)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline A abs(A &a) { return (a < 0 ? -a : a); }
bool inLine(int x,int y,int mx,int my){return (x>=0&&y>=0&&x<mx&&y<my);}
const lol inf=(1LL<<62);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >>a[i];
  int g=a[0];
  for(int i=1;i<n;i++){
    g=gcd(g,a[i]);
  }
  if(g!=1){
    cout <<"not coprime\n";
    return (0);
  }
  set<int> s;
  for(int i=0;i<n;i++){
    int tmp=a[i];
    for(int j=2;j*j<=tmp;j++){
      if(a[i]%j==0){
        if(s.find(j)!=s.end()){
          cout <<"setwise coprime\n";
          return (0);
        }
        s.insert(j);
      }
      while(a[i]%j==0){
        a[i]/=j;
      }
    }
    if(a[i]!=1){
      if(s.find(a[i])!=s.end()){
        cout <<"setwise coprime\n";
        return (0);
      }
      s.insert(a[i]);
    }
  }
  cout <<"pairwise coprime\n";
  return(0);
}

Measured memory_bytes: 7336
#include<stdio.h>
int main()
{
	int N, k;
	scanf("%d", &N);
	
	int H[N];
	
	for(k=0; k<N; k++){
		scanf("%d", &H[k]);
	}
	
	int max = 0;
	int c = 0;
	
	for(k=0; k<N; k++){
		if(H[k] >= max){
			max = H[k];
			c++;
		}
	}
		
	printf("%d", c);
	
	return 0;
	
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<double> v(n);
	rep(i,n) cin >> v[i];
	sort(v.begin(), v.end());
	rep(i,n-1){
		v[i+1] = (v[i+1] + v[i]) / 2;
	}
	cout << fixed << setprecision(12) << v[n-1] << endl;
	return 0;
}

Measured memory_bytes: 3768
# Maximum Profit

n = int(input())

maximumProfit = - 10 ** 9
minimum = int(input())

i = 1
while i < n:
    a = int(input())
    maximumProfit = max(a - minimum, maximumProfit)
    minimum = min(a, minimum)
    i += 1

print(maximumProfit)



Measured memory_bytes: 5612
# -*- coding: utf-8 -*-
import sys
import itertools#これは色々使える組み込み関数みたいなやつ
import math#数学的計算はこれでいける。普通に0.5乗しても計算可能
#w=input()
i=0
j=0
N=int(input())
T, A=input().split()
#S=input()
#T=input()
#S_list=list(S)
h_list=  list(map(int, input().split(" ")))
#M=int(input())
#drink_list = [list(map(int, input().split(" ")))for i in range(M)]
#print(T_list[1])
T=int(T)
A=int(A)
#不本意だが内包表記で二次元の空のリストを作成する
     
#dp=[['' for i in range(2)] for j in range(N)]
absTH=[''for i in range(N)]
#K=int(K)
#S_list=[]
sentence_list=[]
#total=0
#mojiretu=""
#センテンスを暗記するのではなく、まずinput()を書いて、膨らます感じで記述する。すると#思考の流れ通りに書ける。素晴らしい！
#for i in range(K):
# ID_list.append(i+1)
#print(ID_list)
#for i in range(H)
#この下の行が二次元リストの読み込
#intを消して記号を読み込めるようにしたしかしこれでは文字列から読み込んでいるのと同じ
#weight_value_list =  [list(input())for i in range(N)]#一文字づつばらして入れてしまう
#s = [input() for i in range(N)]
#複数行に複数の入力値を取得し、出力する
#sentence_list =  (list(input())for i in range(N))
#for i in range(H):
#  ppixel_list=list(input())
    
#print(pixel_list)
#high_pixel_list =[['' for i in range(W)]for j in range(2*H)]
#print(high_pixel_list)
#print(pixel_list[0][1])#行　列の順番にかっこが並んでいる
#print(a_list)
first_term=0
second_term=0
#整数二次元配列を読み込む時のやり方
#a_b_c_list =  [list(map(int, input().split(" ")))for i in range(N)]
     
#センテンスを暗記するのではなく、まずinput()を書いて、膨らます感じで記述する。すると#思考の流れ通りに書ける。素晴らしい！
  
     
#x, y = [0]*N, [0]*N#N個の空のリストを作成
#l = list(range(N))#範囲がNのリストを作成する
     
#for i in range(N):
#  x[i], y[i] = map(int, input().split())
#分けて入力する形式を設定することで可読性が高く仕上がっている
#素晴らしいことだ
     
     
distance = 0
#comb = list(itertools.permutations(l))
#prmutation:英語の意味としては順列である
'''p[, r]で
長さrのタプル列、重複なしのあらゆる並びを表す
今回はリストlの重複なしの並び替え順序を新たなリストに収納している
並び方を計算しリストに収納しているイメージ
l[0,1,2]
l[0,2,1]これにもリスト番号が0,1,2と割り振られている
これが全通り入っている
これ作った人はすごい
自分も早く理解したい
'''
#for i in range(0, len(comb)):#i番目のパターンの時を考える。
#  for j in range(0, N-1):#lのリスト番号を読み込み
#    distance += math.sqrt((x[comb[i][j]]-x[comb[i][j+1]])**2 + (y[comb[i][j]]-y[comb[i][j+1]])**2)
'''
各経路の距離を足していき全距離分を経路数
で割れば平均距離が出るので各経路ごとの距離は
不必要と判断されている。
'''
#print(distance/len(comb))
i=0
j=0

#1を選んだとき0,2を選ぶってのがどう実装すべきかわからんかった
#だからここで学ぶ
#2019/1/4参考サイトに見当たらず 　仕方がないのでその場しのぎ
#for i in range(N):
for j in range(N):
    absTH[j]=abs(A-T+0.006*h_list[j])
#print(absTH)
print(absTH.index(min(absTH))+1)
# dp[i+1][j]=max(dp[i][j]+a_b_c_list[i],dp[i][j],dp[i][j])
#リストを一周するようにすればいいのか


Measured memory_bytes: 3572
// Let's bring the sky down :)
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e5 + 5;
int main()
{
    ios_base ::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n;
    cin >> n;
    ll ans = 0;
    map<pair<int, int>, int> mp;
    for(int i = 1; i <= n; i++){
        vector<int> v;
        int x = i;
        while(x > 0){
            int d = x % 10;
            x /= 10;
            v.push_back(d);
        }
        mp[{v[0], v[v.size() - 1]}]++;
    }
    for(int i = 1; i <= n; i++){
        vector<int> v;
        int x = i;
        while(x > 0){
            int d = x % 10;
            x /= 10;
            v.push_back(d);
        }
        ans += mp[{v[v.size() - 1], v[0]}];
    }
    cout << ans;
return 0;
}


Measured memory_bytes: 256
# AOJ 0521
# JOI 2007/2008 yo-t1

while d = gets.chomp.to_i
  break if d==0
  c = [500, 100, 50, 10, 5, 1]
  p = 1000 - d
  n = 0
  6.times do |i|
    n += p/c[i]
    p %= c[i]
  end
  puts n
end

Measured memory_bytes: 6096
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]


N, M, K = map(int, input().split())
uf = UnionFind(N)
friends = [[] for _ in range(N)]
blocks = [[] for _ in range(N)]
root = {}

for i in range(M):
    a, b = map(int, input().split())
    friends[a - 1].append(b - 1)
    friends[b - 1].append(a - 1)
    uf.unite(a - 1, b - 1)

roots = uf.roots()
for r in roots:
    size = uf.size(r)
    root[r] = size - 1

for i in range(K):
    c, d = map(int, input().split())
    if uf.same(c - 1, d - 1):
        blocks[c - 1].append(d - 1)
        blocks[d - 1].append(c - 1)

ans = []
for i in range(N):
    ans.append(root[uf.find(i)] - len(blocks[i]) - len(friends[i]))
print(*ans)


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

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9 + 7;
const int inf = 1e8;

int main() {
	int ans=0;
	int N,H,W;
	cin >> N>>H>>W;
	vector<int> A(N);
	vector<int> B(N);
	rep(i,N)cin>>A[i]>>B[i];
	rep(i,N){
		if(A[i]>=H and B[i]>=W)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int p[55];
int root(int n)
{
	if (p[n] == n)
		return n;
	p[n] = root(p[n]);
	return p[n];
}
void uni(int x, int y)
{
	x = root(x);
	y = root(y);
	if (x == y)
		return;
	p[y] = x;
	return;
}
int main()
{
	int n, m;
	scanf("%d %d", &n, &m);
	int i, j;
	int a[55], b[55];
	for (i = 0; i < m; i++)
	{
		scanf("%d %d", &a[i], &b[i]);
		a[i]--;
		b[i]--;
	}
	int ans = 0, cnt;
	for (i = 0; i < m; i++)
	{
		for (j = 0; j < n; j++)
			p[j] = j;
		for (j = 0; j < m; j++)
			if (j != i)
				uni(a[j], b[j]);
		cnt = 0;
		for (j = 0; j < n; j++)
			if (p[j] == j)
				cnt++;
		if (cnt > 1)
			ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
// #include<bits\stdc++.h>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<string>
#include<unordered_map>

using namespace std;

#define ll long long
#define MOD 1000000007


void solve(){
    int n, d;
    cin >> n >> d;
    long long x, y;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        cin >> x >> y;
        if(pow(x * x + y * y, 0.5) <= d){
            cnt++;
        }
    }
    cout << cnt;
}

int main()
{   
    ios::sync_with_stdio(0);
    cin.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    {
        solve();
        }
    return 0;
}

Measured memory_bytes: 4136
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

static const int INF = 1001001001;

struct Node {
    int c; // 0: White, 1: Gray, 2: Black
    int d;
    int p;
};

int main()
{
    int h, w;
    int n_blocks = 0;
    cin >> h >> w;
    vector<vector<char> > maze(h, vector<char>(w));

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> maze[i][j];
            if (maze[i][j] == '#') ++n_blocks;
        }
    }

    // Adjacency list
    vector<vector<int> > adj_list(h*w, vector<int>(0));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (maze[i][j] == '#') continue;
            if (j + 1 < w) {
                if (maze[i][j + 1] == '.') adj_list[i * w + j].push_back(i * w + j + 1);
            }
            if (j - 1 >= 0) {
                if (maze[i][j - 1] == '.') adj_list[i * w + j].push_back(i * w + j - 1);
            }
            if (i + 1 < h) {
                if (maze[i + 1][j] == '.') adj_list[i * w + j].push_back((i + 1) * w + j);
            }
            if (i - 1 >= 0) {
                if (maze[i - 1][j] == '.') adj_list[i * w + j].push_back((i - 1) * w + j);
            }
        }
    }

    // Nodes on a graph
    vector<Node> nodes(h * w);
    nodes[0].c = 1;
    nodes[0].d = 0;
    nodes[0].p = -1;
    for (int i = 1; i < nodes.size(); ++i) {
        nodes[i].c = 0;
        nodes[i].d = INF;
    }

    // Breadth-first search
    queue<int> q;
    q.push(0); // push the origin node
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (int v : adj_list[u]) {
            if (nodes[v].c == 0) {
                nodes[v].c = 1; // visited as a frontier
                nodes[v].d = nodes[u].d + 1;
                nodes[v].p = u;
                q.push(v);
            }
            nodes[u].c = 2; // visited as a parent
        }
    }

    // // Compute the answer
    if (nodes[h * w - 1].c == 0) cout << -1 << endl;
    else {
        int n_paths = nodes[h * w - 1].d + 1;
        int maze_size = h * w;
        cout << maze_size - n_blocks - n_paths << endl;
    }

    return 0;
}


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

#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define endl "\n" 
#define all(c) c.begin(),c.end()
#define present(c,element) (c.find(element)!=c.end())
#define cpresent(c,element) (find(c,element)!=c.end())
#define foo(i,a,b) for(int i=a;i<int(b);i++)
#define tr(i,a) for(auto i:a)
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
const double PI=acos(-1);
const ll mod=1e9+7;



int32_t main()
{
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

int test=1;
//cin>>test;
while(test--)
{
	int n;
	cin>>n;
	vi a(n);
	foo(i,0,n)cin>>a[i];
	ll dp[n][n]={0};	
	for(int l=n-1;l>=0;l--)
	{
		for(int r=l;r<n;r++)
		{
			if(l==r)dp[l][r]=a[l];
			else dp[l][r]=max(a[l]-dp[l+1][r], a[r]-dp[l][r-1]);
		}
	}
	//foo(i,0,n){foo(j,0,n)cout<<dp[i][j]<<" ";cout<<endl;}
	cout<<dp[0][n-1]<<endl;
}
return 0;
}










Measured memory_bytes: 70528
#include<stdio.h>

int main()
{
   int i;
   int n;
   scanf("%d", &n);
   int R[n];

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

   int min = R[0];
   int max = R[1]-R[0];

   for(i=1; i<n; ++i){
      max = (max<(R[i]-min)) ? (R[i]-min) : max;
      min = (min>R[i]) ? R[i] : min;
   }

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

   return 0;
}

Measured memory_bytes: 2632
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#include <time.h>
#include <functional>
#include <atcoder/all>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<ll, ll, ll, ll> tlglglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
typedef vector<ll> vll;
typedef vector< vector<ll> > matrix;
typedef unsigned int uint;
typedef unsigned long long ull;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <class T> using VVV = V<VV<T>>;
#define REP(i, x, y) for(ll i = (ll)x; i < (ll)y; i++)
#define DREP(i, x, y, d) for(ll i = (ll)x; i < (ll)y; i += (ll)d)
#define PER(i, x, y) for(ll i = (ll)x; i > (ll)y; i--)
#define DPER(i, x, y, d) for(ll i = (ll)x; i > (ll)y; i -= (ll)d)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-12;
void yesno(bool ok, string yes = "Yes", string no = "No") {
    if (ok) {
        cout << yes << endl;
    } else {
        cout << no << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, Q;
    cin >> N >> Q;
    ll a[N];
    fenwick_tree<ll> fw(N);
    REP(i, 0, N) {
        cin >> a[i];
        fw.add(i, a[i]);
    }
    REP(i, 0, Q) {
        ll x, y, z;
        cin >> x >> y >> z;
        if (x == 0) {
            fw.add(y, z);
        } else {
            cout << fw.sum(y, z) << endl;
        }
    }
}


Measured memory_bytes: 12152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

const ll MAX_ANS = ll(1e18);



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

    ll ans = 1;
    vector<ll> a;
    for(int i=0; i<n; i++){
        ll tmp_a; cin >> tmp_a;
        a.push_back(tmp_a);
    }
    sort(a.begin(), a.end());
    for(int i=0; i<n; i++){
        // かけた時点でoverflowするやつない??
        if(ans != 0 && a[i] <= MAX_ANS/ans){
            ans *= a[i];
        }
        else if(ans == 0){
            ans = 0;
            break;
        }
        else{
            ans = -1;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4252
import itertools


def LI():
    return tuple(map(int, input().split()))


N = int(input())
P = LI()
Q = LI()
Nlist = list(range(1, N+1))
count = 1
for v in itertools.permutations(Nlist, N):
    if P == v:
        p = count
    if Q == v:
        q = count
    count += 1
print(abs(p-q))


Measured memory_bytes: 9112
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define MAX_N 10
using namespace std;

typedef long long ll;
typedef pair<int,int> P1;
typedef pair<P1,P1> P2;
const ll INF=100000000000000001;
int dp[MAX_N][MAX_N]={};
bool d[MAX_N]={};
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
queue<P1> que;
vector<string> v;
int main() {
	int h,w;
	cin>>h>>w;
	rep(i,h){
		rep(j,w){
			char chr;
			cin>>chr;
			if(chr=='#')dp[i][j]=1;
		}
	}
	que.push(P1(0,0));
	while(!que.empty()){
		P1 pp1=que.front();que.pop();
		int x=pp1.first;
		int y= pp1.second;
		dp[x][y]=2;
		if(dp[x+1][y]==1&&dp[x][y+1]==1){
			cout<<"Impossible"<<endl;
			return 0;
		}
		if(dp[x+1][y]==1)que.push(P1(x+1,y));
		if(dp[x][y+1]==1)que.push(P1(x,y+1));
	}
	bool flg=true;
	rep(i,h){
		rep(j,w){
			if(dp[i][j]==1)flg=false;
		}
	}
	if(flg){
		cout<<"Possible"<<endl;
	}else{
		cout<<"Impossible"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  string s;
  cin>>s;

  int ans = 0;
  for(auto c : s) if(c=='2') ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#define N 100100
using namespace std;
long long f[N],k[N],ans[N],sum;
char   m[N];
int get(int x)
{
    if(k[x]==x) return x;
    return k[x]=get(k[x]);
}
void ju(int x,int y)
{
    int tx=get(x);
    int ty=get(y);
    k[tx]=ty;
    f[ty]+=f[tx];
}
int main()
{
    int i,nu=0,sum=0;
    scanf("%s",m+1);
    for(i=1;m[i];i++)
    {
        if(m[i]=='0') sum++;
        else nu++;
    }
    printf("%d\n",2*min(sum,nu));
}


Measured memory_bytes: 888
#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;
    }
    return 0;
}

Measured memory_bytes: 256
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	map<string,int> ma;
	while(n--)
	{
		string s; cin>>s; ma[s]++;
	}
	cout<<"AC x "<<ma["AC"]<<'\n';
	cout<<"WA x "<<ma["WA"]<<'\n';
	cout<<"TLE x "<<ma["TLE"]<<'\n';
	cout<<"RE x "<<ma["RE"]<<'\n';
}


Measured memory_bytes: 3664
def main():
    N, M = list(map(int, input().split()))
    A = list(map(int, input().split()))

    total = sum(A)

    count = 0
    for a in A:
        if a >= total / (4.0 * M):
            count += 1

    if count >= M:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<int,int> pi;
typedef pair<int,pi> pii;
typedef vector<pi> vpi;
typedef set<int> si;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define f first
#define s second
ll INF = 1e15;
ll MOD = 1e9;
#define lb lower_bound
#define ub upper_bound
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(),x.end()

ll N, a, ans;

multiset<ll> S;
vi V;

int main(){
  // freopen("input.txt","r",stdin);
  cin>>N;
  for (int i=0;i<N;++i){
    cin>>a;
    S.insert(a);
  }
  for (int i=0;i<32;++i)V.pb(1LL<<i);
  while(SZ(S)){
    ll T = *(--S.end());
    S.erase(S.find(T));
    ll it = *ub(ALL(V),T);
    ll opp = it - T;
    if (S.lb(opp) != S.ub(opp)){
      S.erase(S.find(opp));
      ++ans;
    }
  }
  cout<<ans;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <sstream>
#include <string>
using namespace std;
int main(){
	int a,b;
	vector <string> box;
	vector <int> ans;
	string s;
	stringstream ss;
	getline(cin,s);
	ss << s;
	while(ss>>s){
		box.push_back(s);
	}
	/*for(int i=0;i<box.size();i++){
		cout<<box[i]<<endl;
	}*/
	for(int i=0;i<box.size();i++){
		switch(box[i][0]){
			case '+':
				a=ans.back();
				ans.pop_back();
				b=ans.back();
				ans.pop_back();
				ans.push_back(a+b);
				break;
			case '-':
				a=ans.back();
				ans.pop_back();
				b=ans.back();
				ans.pop_back();
				ans.push_back(b-a);
				break;
			case '*':
				a=ans.back();
				ans.pop_back();
				b=ans.back();
				ans.pop_back();
				ans.push_back(a*b);
				break;
			default:
				ss.clear();
				int n;
				ss<<box[i];
				ss>>n;
				ans.push_back(n);
				break;
		}
	}
	for(int i=0;i<ans.size();i++){
		cout<<ans[i]<<endl;
	}
	
}


Measured memory_bytes: 3212
p = [('ru','lu'), ('lu','ru'),('rd','ld'), ('ld','rd')]
while True:
	n = int(input())
	if n == 0:
		break
	l = False
	r = False
	f = input().split()
	print(len([t for t in zip(f[1:], f[:-1]) if t in p]))

Measured memory_bytes: 7620
H,W,D=list(map(int,input().split()))
X=[(0,0) for i in range(H*W+1)]

for i in range(1,H+1):
	A=list(map(int,input().split()))
	for idx,a in enumerate(A):
		X[a]=(i,idx+1)

Q=int(input())
L=[]
R=[]
S=[0]*(H*W+1)

for i in range(Q):
	l,r=list(map(int,input().split()))
	L.append(l)
	R.append(r)

for i in range(D+1,H*W+1):
	S[i]=S[i-D]+abs(X[i][0]-X[i-D][0])+abs(X[i][1]-X[i-D][1])

for i in range(Q):
	print(S[R[i]]-S[L[i]])
	

Measured memory_bytes: 22248
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	ll h, w; cin >> h >> w;
	if (h == 1 || w == 1)cout << 1 << endl;
	else
	{
		ll res = ((w + 1) / 2)*((h + 1) / 2) + (w / 2)*(h / 2);
		cout << res << endl;
	}
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main() {
	int n; cin >> n;
	unordered_map<string, int> freq;
	while (n--) {
		string s; cin >> s;
		freq[s]++;
	}
	cout << "AC x " << freq["AC"] << endl;
	cout << "WA x " << freq["WA"] << endl;
	cout << "TLE x " << freq["TLE"] << endl;
	cout << "RE x " << freq["RE"] << endl;


	return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k, p, m, y;
string s, t;
ld w;
ll a, b;

ll c[11][11];

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> k;
	ll val = 1;
	while(n--) {
		val = min(val+k,val*2);
	}
	cout<<val;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3608
a = list(map(int, input().split()))
b, c = a[0], a[1]
ans = min(b, c // 2)
if b > c // 2:
    c = c % 2
else:
    c -= b * 2
b -= min(b, c // 2)
if c > 3:
    ans += c // 4
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;
long long modpow(long long x,long long n,long long mod)
{
  if(n==0)return 1;
  long long res=modpow(x*x%mod,n/2,mod);
  if(n&1)res=res*x%mod;
  return res;
}
long long modinv(long long a,long long mod)
{
  return modpow(a,mod-2,mod);
}
ll fact[200007],inv[200007];
ll mod=1e9+7;
void init(int n){
  fact[0]=1LL;
  rep(i,n-1){
    fact[i+1]=(ll)fact[i]*(i+1)%mod;
  }
  inv[n-1]=modinv(fact[n-1],mod);
  rrep(i,n-1){
    inv[i]=(ll)inv[i+1]*(i+1)%mod;
  }
}
ll c(ll a,ll b){
  return (ll)fact[a]*inv[b]%mod*inv[a-b]%mod;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  init(2e5+7);
  ll h,w,a,b;cin>>h>>w>>a>>b;
  ll res=0;
  //rep(i,10)////cout<<fact[i]*inv[i]%mod<<endl;
  //cout<<c(5,2)<<endl;
  if(h-a<w-b){
    //cout<<"asdjfl"<<endl;
    ll x=h-a-1,y=b;
    rep(i,h-a){
      //cout<<x<<y<<endl;
      res+=(ll)c(x+y,x)*c(h-1-x+w-1-y,h-1-x)%mod;
      x--;y++;
    }
    res%=mod;
  }
  else{
    ll x=h-a-1,y=b;
    rep(i,w-b){
      //cout<<x<<y<<endl;

      res+=(ll)c(x+y,x)*c(h-1-x+w-1-y,h-1-x)%mod;
      //cout<<res<<endl;
      x--;y++;
    }
    res%=mod;
  }
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 3328
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;

            int N = int.Parse(Console.ReadLine());

            string[] s = Console.ReadLine().Split(' ');
            int[] X = new int[N];

            for (int i = 0; i < N; i++)
            {
                X[i] = int.Parse(s[i]);
            }

            Array.Sort(X);

            ans = X[X.Length - 1] - X[0];

            Console.WriteLine(ans.ToString());
        }
    }
}


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

typedef long long ll;

using tpl = tuple<int, int, int>;
typedef pair<ll,ll> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

int N;
int A[100010];
int B[100010];
pii C[100010];

int main(){
    fastStream();
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i] >> B[i];
    
    for(int i = 0; i < N; i++){
        C[i] = pii(A[i] + B[i], i);
    }
    sort(C, C + N, greater<pii>());

    ll sum = 0;
    for(int i = 0; i < N; i++){
        if(i % 2 == 0)
            sum += A[C[i].second];
        else
            sum -= B[C[i].second];
    }

    cout << sum << endl;


    return 0;
}


Measured memory_bytes: 2560
### subroutines

def max_w(mbls)
  len = mbls.length
  
  if len == 1
    mbl = mbls.first
    return mbl[1] + mbl[2]
  end

  mw = -1.0

  for i in (0...(len - 1))
    wi0, l0, r0 = mbls[i]
    wi1, l1, r1 = mbls[i + 1]

    nwi = wi0 + wi1
    li = wi1 / nwi
    ri = wi0 / nwi
    nl0 = l0 + li
    nr0 = r0 - li
    nl1 = l1 - ri
    nr1 = r1 + ri
    nmbl = [nwi, (nl0 > nl1) ? nl0 : nl1, (nr0 > nr1) ? nr0 : nr1]

    nmbls = mbls[0...i] + [nmbl] + mbls[(i + 2)...len]
    w = max_w(nmbls)
    mw = w if mw < w && w < $rw
  end

  mw
end

### main

n = gets.to_i

n.times do
  $rw = gets.to_f
  sn = gets.to_i

  wis = sn.times.map{gets.to_f}
  #p [rw, wis]

  mbls = wis.map{|wi| [wi, 0.0, 0.0]}
  #p mbls
  
  mw = -1.0
  
  mbls.permutation.each do |mbls0|
    w = max_w(mbls0)
    if mw < w && w < $rw
      mw = w
    end
  end

  puts (mw < 0.0 ? -1 : mw)
end

Measured memory_bytes: 6144
#include<iostream>
#include<map>
using namespace std;
typedef long long ll;

const int MAX_N = 1e5 + 5;
const ll MOD = 1e9 + 7;

int a[MAX_N];
ll factorial[MAX_N];

ll calc_pow(ll x, ll y) {
    ll z = 1;
    while (y > 0) {
        if (y & 1) {
            z = (z * x) % MOD;
        }
        x = (x * x) % MOD;
        y /= 2;
    }
    return z;
}

ll calc_comb(ll x, ll y) {
    if (x < y) return 0;
    ll div_num = (factorial[x - y] * factorial[y]) % MOD;
    return (factorial[x] * calc_pow(div_num, MOD - 2)) % MOD;
}

int main() {
    int N;
    cin >> N;
    for (int i = 0; i < N + 1; i++) cin >> a[i];
    factorial[0] = 1;
    for (int i = 1; i <= N + 1; i++) {
        factorial[i] = (i * factorial[i - 1]) % MOD;
    }
    map<int, bool> MP;
    ll idx1, idx2;
    for (int i = 0; i < N + 1; i++) {
        if (MP[a[i]]) {
            idx2 = i;
            break;
        }
        MP[a[i]] = true;
    }
    for (int i = 0; i < idx2; i++) {
        if (a[i] == a[idx2]) {
            idx1 = i;
            break;
        }
    }
    for (int i = 1; i <= N + 1; i++) {
        ll num = idx1 + N - idx2;
        cout << (calc_comb(N + 1, i) - calc_comb(num, i - 1) + MOD) % MOD << endl;
    }
    return 0;
}

Measured memory_bytes: 7040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if(Math.max(a, b) - (Math.min(a, b)+w) > 0) {
			System.out.println(Math.max(a, b) - (Math.min(a, b)+w));
		}else {
			System.out.println(0);
		}
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
/*メモ 
*/
int main(){
    vvector(a,int,3,3,0);
    reprep(i,j,3,3){
        std::cin >> a[i][j];
    }
    vvector(aa,bool,3,3,0);
    int n;
    std::cin >> n;
    rep(i,n){
        int b;
        std::cin >> b;
        reprep(i,j,3,3){
            if(a[i][j]==b)aa[i][j]=1;
        }
    }
    bool han=0;
    rep(i,3){
        bool dum=1;
        rep(j,3){
            if(!aa[i][j])dum=0;
        }
        if(dum)han=1;
    }
    rep(j,3){
        bool dum=1;
        rep(i,3){
            if(!aa[i][j])dum=0;
        }
        if(dum)han=1;
    }
    if(aa[0][0]&&aa[1][1]&&aa[2][2])han=1;
    if(aa[2][0]&&aa[1][1]&&aa[0][2])han=1;
    if(han)std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        double a = scanner.nextDouble();
        double b = scanner.nextDouble();
        double n = scanner.nextDouble();
        double x = 0.0;
        if(b <= n){
            x = b - 1.0;
        }else{
            x = n;
        }
        System.out.println((int)(Math.floor(a * x / b) - a * Math.floor(x / b)));
    }
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

const int MAXN = 200010;

int n, K;
ll a[MAXN];

int v[MAXN];

void add(int x, int p)
{
	for (; x <= n+1; x += x&-x)
		v[x] += p;
}

int get(int x)
{
	int p = 0;
	for (; x; x -= x&-x)
		p += v[x];
	return p;
}

int main()
{
	
	scanf("%d%d", &n, &K);
	vector<ll> p;
	p.push_back(0);
	for (int i = 1; i <= n; ++ i)
	{
		int x;
		scanf("%d", &x);
		a[i] = x;
		a[i] -= K;
		a[i] += a[i-1];
		p.push_back(a[i]);
	}
	sort(p.begin(), p.end());
	for (int i = 0; i <= n; ++ i)
		a[i] = lower_bound(p.begin(), p.end(), a[i]) - p.begin() + 1;
	ll ans = 0;
	add(a[0], 1);
	for (int i = 1; i <= n; ++ i)
	{
		ans += get(a[i]);
		add(a[i], 1);
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 4336
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.lang.*;
 
public class Main {
	
	static int MOD = 1000000007;
	
	public static void main(String[] args) throws InterruptedException {
		FastScanner fs=new FastScanner();
		int h=fs.nextInt(), w=fs.nextInt();
		char [][] grid = new char[h][w];
		for(int i=0 ; i<h ; ++i) {
			char [] line = fs.next().toCharArray();
			for(int j=0 ; j<w ; ++j)
				grid[i][j] = line[j];
		}
		
		long [][] dp = new long[1000][1000];
		dp[0][0] = 1;
		for(int i=0 ; i<h ; ++i) {
			for(int j=0 ; j<w ; ++j) {
				if(grid[i][j] == '#') {
					dp[i][j] = 0;
					continue;
				}
				if(i > 0 && grid[i-1][j] == '.')dp[i][j] = dp[i-1][j];
				if(j > 0 && grid[i][j-1] == '.')dp[i][j] += dp[i][j-1];
				
				dp[i][j] %= MOD;
			}
		}
		
		System.out.println(dp[h-1][w-1]);
	}
	
	static void sort(int[] a) {
		ArrayList<Integer> list=new ArrayList<>();
		for (int i:a) list.add(i);
		Collections.sort(list);
		for (int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	static String reverse(String str) {
	    StringBuilder sb=new StringBuilder(str);
	    sb.reverse();
	    return sb.toString();
	}
	
	static long maxElement(int [] arr) {
		return Arrays.stream(arr).max().getAsInt();
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
		
		public long[] readLongArray(int n) {
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
	}
 
}

Measured memory_bytes: 49684
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 1000000000

//aのb乗
int beki(int a,int b,int M = modulo){
	int x = 1;
	while(b!=0){
		if(b&1){
			x=((long long)x*a)%M;
		}
		a=((long long)a*a)%M;
		b>>=1;
	}
	return x;
}


//aの逆元
int gyakugen(int a){
	return beki(a,modulo-2);
}

struct combi{
	deque<int> kaijou;
	deque<int> kaijou_;
	
	combi(int n){
		kaijou.push_back(1);
		for(int i=1;i<=n;i++){
			kaijou.push_back(mod(kaijou[i-1]*i));
		}
		
		int b=gyakugen(kaijou[n]);
		
		kaijou_.push_front(b);
		for(int i=1;i<=n;i++){
			int k=n+1-i;
			kaijou_.push_front(mod(kaijou_[0]*k));
		}
	}
	
	int combination(int n,int r){
		if(r>n)return 0;
		int a = mod(kaijou[n]*kaijou_[r]);
		a=mod(a*kaijou_[n-r]);
		return a;
	}
	
	int junretsu(int a,int b){
		int x = mod(kaijou_[a]*kaijou_[b]);
		x=mod(x*kaijou[a+b]);
		return x;
	}
	
	int catalan(int n){
		return mod(combination(2*n,n)*gyakugen(n+1));
	}
	
};

vector<int> calc(auto X,auto Y){
	vector<int> ret(X.size(),0);
	
	for(int i=0;i<X.size();i++){
		for(int j=0;j<Y.size();j++){
			int k = i-j;
			if(k<0)break;
			ret[i] = mod(ret[i] + mod(X[k] * Y[j]));
		}
	}
	
	return ret;
}
	
int main(){
	
	int N;
	cin>>N;
	
	string S;
	cin>>S;
	
	int K = N-S.size();
	
	combi C(100000);
	
	vector<vector<int>> X(13,vector<int>(K/2+1,0));
	
	for(int i=0;i<13;i++){
		if(i==0){
			for(int j=0;j<X[i].size();j++){
				if(j==0)X[i][j] = 1;
				else{
					X[i][j] = mod(C.catalan(j)*beki(2,j));
				}
			}
		}
		else{
			X[i] = calc(X[i-1],X[i-1]);
		}
	}
	
	int A = S.size();
	vector<int> ans(K/2+1,0);
	ans[0] = 1;
	
	for(int i=0;i<13;i++){
		if((1<<i)&A){
			ans = calc(ans,X[i]);
		}
	}
	
	vector<vector<int>> dp(5001,vector<int>(5001,0));
	dp[0][0] = 1;
	
	
	for(int i=0;i<5000;i++){
		for(int j=0;j<=5000;j++){
			if(j!=5000){
				dp[i+1][j+1] = mod(dp[i+1][j+1] + mod(2*dp[i][j]));
			}
			int k = max(j-1,0);
			dp[i+1][k] = mod(dp[i+1][k] + dp[i][j]);
		}
	}
	
	int ANS = 0;
	
	for(int i=0;i<ans.size();i++){
		int temp = K - i*2;
		ANS = mod(ANS + mod(ans[i] * dp[temp][0]));
	}
	
	cout<<ANS<<endl;
	
    return 0;
}


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

int main(){
	int a,b,c;
	int temp=-1;
	cin >> a >> b >> c;

	while(((a<=b&&a<=c)&&b<=c)==0){

	if (a>b){
		temp = a;
		a=b;
		b=temp;
	}
	if (b>c){
		temp = b;
		b=c;
		c=temp;
	}
	}

	cout << a << " " << b << " " << c << endl;
	
	return 0;
}



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

#ifdef BTK
#include<dvector.h>
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define DEBUG if(0)
#endif

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

typedef __int128 INT;
int main(){
    int N;LL T;
    cin>>N>>T;
    LL a = 0;
    LL b = 0;
    REP(i,N){
        LL h;
        cin>>h;
        auto check = [&](INT t){
            return T<a*t+b+h;
        };
        chmax(a,h);
        LL lb = -1e15;
        LL ub = 1e15;
        while(ub-lb>1){
            const LL mid= (lb+ub)/2;
            if(check(mid))ub=mid;
            else lb=mid;
        }
        cout<<max(1ll,ub+1)<<endl;
        b+=h;
    }
    return 0;
}

Measured memory_bytes: 3216
import java.util.Scanner;

/**
 * @Author: zhengtiantian
 * @Date: 19-3-28 下午3:58
 * @Description:
 */
public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        while (cin.hasNext()) {
            int n = cin.nextInt();
            int[] money = new int[n];
            for (int i = 0; i < n; i++) {
                money[i] = cin.nextInt();
            }
            int minv = money[0];
            int maxv = -2000000000;
            for (int i = 1; i < n; i++) {
                maxv = Math.max(maxv, money[i] - minv);
                minv = Math.min(minv, money[i]);
            }
            System.out.println(maxv);
        }
    }
}



Measured memory_bytes: 100828
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>
#include <fstream>
using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
const double pi = 3.14159265359;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define Rep(i, n) for (int i = (int)(n-1); i >= 0; i--)
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N;++i) {
        string str = to_string(i);
        if (str.size() % 2 == 1)ans++;
    }
    cout << ans << endl;
    return 0;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    int A;
    string B;
    cin >> A >> B;
    int b = (B[0] - '0') * 100 + (B[2] - '0') * 10 + (B[3] - '0');
    cout << A * b / 100 << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod = 1000000007;

int N, K;
const int MAX=300005;
struct SegmentTree {
private:
    int n;
    vector<int> node;

public:
    SegmentTree(vector<int> v) {
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1,0);
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = max(node[2*i+1], node[2*i+2]);
    }

    void update(int x, int val) {
        x += (n - 1);
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = max(node[2*x+1], node[2*x+2]);
        }
    }

    int getmax(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return node[k];

        int vl = getmax(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmax(a, b, 2*k+2, (l+r)/2, r);
        return max(vl, vr);
    }
};
int main() {
  int N,K;
  cin>>N>>K;
  SegmentTree seg(vector<int>(MAX,0));//AのMAX個の種類がある
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    int l=max(0,a-K);
    int r=min(MAX,a+K+1);
    int v=seg.getmax(l,r);
    seg.update(a,v+1);
  }
  cout<<seg.getmax(0,MAX)<<endl;
  return 0;
}


Measured memory_bytes: 8540
#include <bits/stdc++.h>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
int w[100005];
int tot=0;
int dp[200105];
int main()
{
	memset(dp,23,sizeof(dp));
	dp[0]=0;
	int n;
	int gg=9;
	for(;gg<=100000;gg*=9)
		w[tot++]=gg;
	gg=6;
	for(;gg<=100000;gg*=6)
		w[tot++]=gg;
	read(n);
	for(int i=0;i<n;i++)
	{
		dp[i+1]=min(dp[i+1],dp[i]+1);
		for(int j=0;j<tot;j++)
			dp[i+w[j]]=min(dp[i+w[j]],dp[i]+1);
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int i,l,m[13],n[13],x,y;
	1<=l && l<=1000000;
	scanf("%d",&l);
	while(l!=0) {
		for(i=1;i<=12;i++)	{
			scanf("%d %d",&m[i],&n[i]);
		}
		i=1;
		y=0;
		while(i<=12) {
			x=m[i]-n[i];
			y+=x;
			if(y>=l) {
				printf("%d\n",i);
				break;
			}
			if(12<=i && y<l) {
				printf("NA\n");
			}
			i+=1;
		}
	scanf("%d",&l);
	}
	return 0;
}

Measured memory_bytes: 612
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    x = 1
    count = 0
    while (x < B):
        x += A - 1
        count += 1
    print(count)
    return


# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import { count } from 'console';

process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
let gInput = '';
process.stdin.on('data', (chunk) => (gInput += chunk));
process.stdin.on('end', () => main(gInput.split(/\r?\n/)));

// 解答
function main(inputs: string[]): void {
  const vacation = Number(inputs[0].split(' ')[0]);
  const homeworkNum = Number(inputs[0].split(' ')[1]);
  const homework = inputs[1].split(' ').map(Number);

  const sum = homework.reduce((prev, current) => prev + current);

  if (vacation < sum) {
    console.log('-1');
  } else {
    console.log(vacation - sum);
  }
}


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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector <int> a(n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &a[i]);
  vector <int> dp(n);
  for (int i = 1; i < n; ++i) {
    dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]);
    if (i > 1)
      dp[i] = min(dp[i], dp[i - 2] + abs(a[i] - a[i - 2]));
  }
  printf("%d", dp[n - 1]);
  return 0;
}


Measured memory_bytes: 1024