akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int cnt = 0;

		for (int i = a ; i <= b ; i++) {
			if (i / 10000 == i % 10 && i / 1000 % 10 == i / 10 % 10) cnt++;
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define rt return
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b){ll ans=1;while(b){if(b%2)ans=ans*a;a=a*a;b/=2;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
// HFUU-QerM  
// 22:15:03

ll n;
ll a[maxn];

int main()
{
    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);
	//freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);
	gbtb;
	cin>>n;
	repd(i,1,n)
	{
		cin>>a[i];
	}
	ll ans=1e18;
	ll temp;
	for(ll i=-100;i<=100;i++)
	{
		temp=0ll;
		repd(j,1,n)
		{
			temp+=powmod(abs(a[j]-i),2);
		}
		// db(temp);
		ans=min(ans,temp);
	}
	cout<<ans<<endl;
	
		
	
    return 0;
}

inline void getInt(int* p) {
    char ch;
    do {
        ch = getchar();
    } while (ch == ' ' || ch == '\n');
    if (ch == '-') {
        *p = -(getchar() - '0');
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 - ch + '0';
        }
    }
    else {
        *p = ch - '0';
        while ((ch = getchar()) >= '0' && ch <= '9') {
            *p = *p * 10 + ch - '0';
        }
    }
}



Measured memory_bytes: 384
from collections import defaultdict
dicS = defaultdict(lambda: 0)
dicT = defaultdict(lambda: 0)
N = int(input())
S=[input() for i in range(N)]
M = int(input())
T=[input() for i in range(M)]
for s in S:
    dicS[s]+=1
for t in T:
    dicT[t]+=1
ans=0
for word, cnt in dicS.items():
    ans = max(ans, cnt-dicT[word])
print(ans)


Measured memory_bytes: 3316
import math
n, d = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in range(n - 1):
    tmp = 0
    for j in range(i + 1, n):
        tmp = 0
        for k in range(d):
            tmp += (l[i][k] - l[j][k]) ** 2
        if math.sqrt(tmp).is_integer():
            ans += 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll ar1[5000000]= {0};
int main()
{
    ll a,b,c=0,i,j;
    cin>>a;
    for(i=1; i<=a; i++)
        cin>>ar1[i];
    ll min=99999999999;
    for(i=1; i<=a; i++)
    {
        if(ar1[i]<min){min=ar1[i];c++;}
    }
    cout<<c<<endl;
    return 0;
}


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

int main()
{
    int r, D, x2000;
    cin >> r >> D >> x2000;
    int x = x2000;
    for(int i=1;i<=10;i++){
        x = r*x - D;
        cout << x << endl;
    }
    return 0;
}

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

using namespace std;

using ll = long long;

const int mod = 1e9 + 7;

void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}

int main() {
    int n;
    scanf("%d", &n);
    vector<vector<int>> can(n, vector<int>(n));
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            scanf("%d", &can[i][j]);
        }
    }
    vector<int> dp(1 << n); // 2^n
    dp[0] = 1;
    //~ for(int a = 0; a < n; ++a) {
    for(int mask = 0; mask < (1 << n) - 1; ++mask) {
        int a = __builtin_popcount(mask); // the number of bits set to 1
        for(int b = 0; b < n; ++b) {
            if(can[a][b] && !(mask & (1 << b))) {
                int m2 = mask | (1 << b);
                //~ debug() << imie(mask) imie(m2) imie(dp[mask]);
                add_self(dp[m2], dp[mask]);
            }
        }
    }
    //~ }
    printf("%d\n", dp[(1<<n)-1]);
}

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

using namespace std;

typedef long long ll;

ll N,M,K;

const ll MAX = 4000010;
const ll MOD = 1e9 + 7;
long long fac[MAX], finv[MAX], inv[MAX];
 
 
void COMinit() {
 fac[0] = fac[1] = 1;
 finv[0] = finv[1] = 1;
 inv[1] = 1;
  for (ll 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(ll n, ll k){
  if (n < k){ return 0;}
  if (n < 0 || k < 0) {return 0;}
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
     }
 







ll number(ll a, ll b){
  if( a == 0|| b == 0){ return (( N - a ) * ( M - b)) % MOD;}
  else{
    return (  2 * ( N - a) * ( M - b)) % MOD;}}


int main(){
  cin >> N >> M >> K;
  
  COMinit();
  
  ll ans = 0;
  
  for(ll X = 0; X < N; X++){
    for(ll Y = 0; Y < M; Y++){
      
      ans += ( X + Y) * number(X ,Y) * COM( N * M  -2 , K - 2);
      ans %= MOD;}}
    
    cout << ans << endl; return 0;}

Measured memory_bytes: 93952
#include<bits/stdc++.h>
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
using namespace std;
const int MOD = 1000000007; 
typedef long long ll;
typedef string str;

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

  deque<int> ans;
  str line;
  getline(cin,line);

  bool LorR;
  if(N % 2 == 0) LorR = false;
  else LorR = true;

  split_str(line,' '){
    if(LorR) ans.push_front(i_str(res));
    else ans.push_back(i_str(res));
    LorR = !LorR;
  }

  for(auto i:ans) printf("%d ",i);
  return 0;
}

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

int main(){
  ll x, y;
  cin >> x >> y;
  cout << (abs(x-y) <= 1 ? "Brown" : "Alice") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;

char in[2000];
char dig[1001],pref[9],unit[51];

int main()
{
	map<string,int> prefix;
	prefix["yocto"]=-24; prefix["zepto"]=-21; prefix["ato"]=-18; prefix["femto"]=-15;
	prefix["pico"]=-12; prefix["nano"]=-9; prefix["micro"]=-6; prefix["milli"]=-3;
	prefix["centi"]=-2; prefix["deci"]=-1; prefix["deca"]=1; prefix["hecto"]=2;
	prefix["kilo"]=3; prefix["mega"]=6; prefix["giga"]=9; prefix["tera"]=12;
	prefix["peta"]=15; prefix["exa"]=18; prefix["zetta"]=21; prefix["yotta"]=24;
	
	int cs; cin>>cs; cin.ignore();
	while(cs--)
	{
		string line; getline(cin,line);
		strcpy(in,line.c_str());
		int sp=count(in,in+strlen(in),' ');
		if(sp==2)sscanf(in,"%s%s%s",dig,pref,unit);
		else sscanf(in,"%s%s",dig,unit),pref[0]=0;
		
		int p,q=strlen(dig),r,e=prefix[pref];
		for(p=0;p<q&&(dig[p]=='.'||dig[p]=='0');p++);
		for(r=0;r<q&&dig[r]!='.';r++);
		
		e-=p-r+(p==0);
		char ans[1010]; int l=0;
		ans[l++]=dig[p];
		if(++p==q)goto END;
		ans[l++]='.';
		for(;p<q;p++)if(dig[p]!='.')ans[l++]=dig[p];
		
		END:
		ans[l]=0; 
		printf("%s * 10^%d %s\n",ans,e,unit);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
int MOD = 1000000007; //10^9 + 7

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(int argc, char *argv[]){
  int n,k;
  cin >> n >> k;
  vi h(n);
  rep(i, n) cin >> h[i];

  // 無限大の値
  const long long INF = 1LL << 60;

  // DP テーブル
  long long dp[100010];

  // DP テーブル全体を初期化 (最小化問題:INF else:0)
  for (int i = 0; i < 100010; ++i) dp[i] = INF;

  // 初期条件
  dp[0] = 0;

  // ループ
  for (int i = 0; i < n; ++i) {
    for(int j = 1; j < k+1; ++j){
      if(i+j<n)chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
    }
  }
  // 解を得て出力
   cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 4572
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;

int n, m;
stringstream ss;

void solve(int l, bool top = false) {
  if (l == 1) {
    if (top) {
      n = 2;
      m = 1;
      ss << "1 2 0" << endl;
    } else {
      n = 1;
    }
  } else if ((l % 2) == 0) {
    solve(l/2);
    ss << n << ' ' << n+1 << ' ' << 0 << endl;
    ss << n << ' ' << n+1 << ' ' << l/2 << endl;
    ++n;
    m += 2;
  } else {
    solve(l-1);
    ss << "1 " << n << ' ' << l-1 << endl;
    ++m;
  }
}

int main() {
  int l;
  cin>>l;
  solve(l, true);
  cout << n << ' ' << m << endl;
  cout << ss.str();
  return 0;
}


Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

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

typedef long long int ll;

char S[100001] = {0};
char R[100001] = {0};
int main()
{
	int N = 0, ans = 0;
	int len = 0, i = 0, j = 0;
	scanf("%d", &N);
	scanf("%s", S);

	len = strlen(S);
	for (i = 0; i < len; i++) {
		if (S[i] == S[i+1]) {

		} else {
			R[j++] = S[i];
		}
	}
	ans = strlen(R);
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 384
import sys
input = sys.stdin.readline
n,m = map(int, input().split())
es = [[] for _ in range(n)]
for i in range(m):
    a,b=map(int, input().split())
    es[a].append(b)

# strongly connected component
def scc(n_node,es): # DFSを2回行う
    esinv = [[] for _ in range(n_node)]
    for i in range(n_node):
        for e in es[i]:
            esinv[e].append(i)
    used = [False]*n_node
    dim = [len(es[i]) for i in range(n_node)]
    order = []
    for st in range(n_node): # DFS 1回目, postorderを求める
        if not used[st]:
            stack = [(st, 0)] # [(index, 既に辿ったエッジの数)]
            while stack:
                now, i = stack.pop() 
                if not i and used[now]:
                    continue
                else:
                    used[now] = True
                    if i < dim[now]: # nowから延びるエッジを辿りきってない
                        stack.append((now,i+1))
                        stack.append((es[now][i],0))
                    else: # nowから延びる全てのエッジを辿った
                        order.append(now)
    res = [-1]*n_node # 各ノードが所属するグループのidを保存
    used = [False]*n_node 
    cnt = -1 # idカウンター
    for st in order[::-1]:  # DFS 2回目, postorderの逆順から
        if not used[st]:    # 逆向き矢印を辿って通れるノードを記録していく
            cnt += 1
            stack = [st]
            res[st] = cnt
            used[st] = True
            while stack:
                now = stack.pop()
                for e in esinv[now]:
                    if not used[e]:
                        used[e] = True
                        res[e] = cnt
                        stack.append(e)
    n_group = cnt+1
    components = [[] for _ in range(n_group)]
    for i in range(n_node):
        components[res[i]].append(i)
    return res, components

res,compo=scc(n,es)
# print(res,compo)

row=max(res)+1

print(row)
for i in range(row):
    length = len(compo[i])
    print(length, *compo[i])


Measured memory_bytes: 249912
#include<bits/stdc++.h>
    using namespace std;
    int main(){
    char a;
    int b=0,c=0,d=0,e=0;
    for(int i=0;i<3;i++){
    cin>>a;
    if(a=='a'&&c==0||a=='b'&&d==0||a=='c'&&e==0){
    b++;
    if(a=='a'){
    c=1;
    }
    if(a=='b'){
    d=1;
    }
    if(a=='c'){
    e=1;
    }
    }
    }
    if(b==3){
    cout<<"Yes\n";
    }
    else{
    cout<<"No\n";
    }
    }

Measured memory_bytes: 256
#include <stdio.h>
#define INF 2000000001
int heap[1000000];
int size;

void insert(int);
void heapIncreaseKey(int);
int extractMax();
void maxHeapify(int);
int main (){
    int i,tmp;
    char com[10];
    size=0;
    while(1){
        scanf("%s",com);
        if(com[0]=='i'){
            scanf("%d",&tmp);
            insert(tmp);
        }
        else if(com[1]=='x'){
            printf("%d\n",extractMax());
        }
        else break;
    }
    return 0;
}
void insert(int key){
    size++;
    heap[size]=-INF;
    heapIncreaseKey(key);
}
void heapIncreaseKey(int key){
    int i,tmp;
    i=size;
    heap[i]=key;
    while(i>1 && heap[i/2]<heap[i]){
        tmp=heap[i];
        heap[i]=heap[i/2];
        heap[i/2]=tmp;
        i=i/2;
    }
}
int extractMax(){
    int max;
    max=heap[1];
    heap[1]=heap[size];
    size--;
    maxHeapify(1);
    return max;
}
void maxHeapify(int i){
    int l,r,largest,tmp;
    l=i*2;
    r=i*2+1;
    if(l<=size && heap[l]>heap[i]){
        largest=l;
    }
    else{
        largest=i;
    }
    if(r<=size && heap[r]>heap[largest]){
        largest=r;
    }
    if(largest!=i){
        tmp=heap[i];
        heap[i]=heap[largest];
        heap[largest]=tmp;
        maxHeapify(largest);
    }
}


Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//深さ優先探索
//全て添字で扱うこと
void dfs(ll n, vector<vll> &next, ll start, vll &cnt) {
  stack<ll> task;
  task.push(start);

  vll seen(n, 0);
  seen[start] = 1;

  while (task.size() > 0) {
    vll subtask(0);
    for (ll i = 0; i < next[task.top()].size(); i++) {
      if (seen[next[task.top()][i]] == 0) {
        cnt[next[task.top()][i]] += cnt[task.top()];
        subtask.push_back(next[task.top()][i]);
        seen[next[task.top()][i]] = 1;
      }
    }
    task.pop();
    for (ll i = 0; i < subtask.size(); i++) task.push(subtask[i]);
  }
}

int main() {
  ll n, q;
  cin >> n >> q;
  vector<ll> a(n - 1), b(n - 1), p(q), x(q), cnt(n, 0);
  for (ll i = 0; i < n - 1; i++) cin >> a.at(i) >> b.at(i);
  for (ll i = 0; i < q; i++) cin >> p.at(i) >> x.at(i);
  for (ll i = 0; i < q; i++) cnt.at(p.at(i) - 1) += x.at(i);
  vector<vector<ll>> children(n);
  for (int i = 0; i < n - 1; i++) {
    children.at(a.at(i) - 1).push_back(b.at(i) - 1);
    children.at(b.at(i) - 1).push_back(a.at(i) - 1);
  }
  dfs(n, children, 0, cnt);
  for (ll i = 0; i < n - 1; i++) cout << cnt.at(i) << " ";
  cout << cnt.at(n - 1) << endl;
}

Measured memory_bytes: 25328
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
#include <utility>
 
using namespace std;
 
int dp[3003][3003];
int main(){
    memset(dp, 0, sizeof dp);
    string s;
    string t;
 
    cin >> s >> t;
 
    int n = s.size();
    int m = t.size();
 
    for(int i  = 1; i <= n; ++i){
        for(int j = 1; j <= m; ++j){
            if(s[i - 1] == t[j - 1]){
                dp[i][j] = 1 + dp[i - 1][j - 1];
            } else {
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
    }
    string ans="";
 
    int j = m;
    int i = n;
 
    while(i > 0 and j > 0){
        if(dp[i][j] == dp[i - 1][j]){
            --i;
        } else if(dp[i][j] == dp[i][j - 1]){
            --j;
        } else {
            --i;
            --j;
            ans+=s[i];
        }
    }
 
    reverse(ans.begin(), ans.end());
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 35584
n, m = map(int, input().split())

s = [0] * (n + 1)
s[-1] = 1
for _ in range(m):
    a = int(input())
    s[a] = None

if s[0] is None and s[1] is None:
    print(0)
    exit()

for i in range(n - 1, -1, -1):
    if s[i] is None:
        continue
    if i + 1 < len(s) and s[i + 1] is not None:
        s[i] += s[i + 1]
    if i + 2 < len(s) and s[i + 2] is not None:
        s[i] += s[i + 2]

print(s[0] % 1000000007)


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

using namespace std;
typedef long long ll;
const int inf = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;
const ll mod = 998244353;

const int N = (int)1e6 + 100;
ll inv[N], invfact[N], fact[N];

ll C(int n, int k) {
    return fact[n] * invfact[n - k] % mod * invfact[k] % mod;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, a, b;
    ll k;
    cin >> n >> a >> b >> k;

    ll res = 0;
    fact[0] = fact[1] = 1;
    inv[0] = inv[1] = 1;
    invfact[0] = invfact[1] = 1;
    for (int i = 2; i < N; ++i) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = (mod - (mod / i) * inv[mod % i] % mod) % mod;
        invfact[i] = invfact[i - 1] * inv[i] % mod;
    }

    for (int i = 0; i <= n; ++i) {
        if ((k - 1ll * i * a) % b == 0) {
            ll x = i, y = (k - 1ll * i * a) / b;
            if (x <= n && y <= n && y >= 0) {
                res = (res + C(n, x) * C(n, y) % mod) % mod;
            }
        }
    }

    cout << res;
    return 0;
}


Measured memory_bytes: 23680
using System;

class Program
{
    static void Main(string[] args)
    {
        //文字列受け取り
        string str = Console.ReadLine();

        //文字列→char配列
        char[] array = str.ToCharArray();

        //文字数取得
        int len = str.Length;

        for (int i = 0; i < len; i++)
        {

            if (char.IsLower(array[i]))
            {
                //小文字→大文字
                array[i] = char.ToUpper(array[i]);
                Console.Write(array[i]);
            }
            else if (char.IsUpper(array[i]))
            {
                //大文字→小文字
                array[i] = char.ToLower(array[i]);
                Console.Write(array[i]);
            }
            else
            {
                Console.Write(array[i]);
            }
        }
        Console.WriteLine("");
    }
}



Measured memory_bytes: 9000
#include<iostream>

	using namespace std;

	int main() {
		int a{}, b{}, c{}, d{};
		cin >> a>>b>>c>>d;

		while (true) {
			
			c -= b;
			if (c <= 0) {
				cout << "Yes";
				break;
			}
			a -= d;
			if (a <= 0) {
				cout << "No";
				break;
			}
		}

		return 0;
	}

Measured memory_bytes: 3588
h, w = map(int, input().split())
mat_a = [ list(input()) for _ in range(h) ]

count = 0

ans = True
for i in range(h):
    for j in range(w):
        if mat_a[i][j] == '#':
            count+= 1

if count == h+w-1:
    print('Possible')
else:
    print('Impossible')

Measured memory_bytes: 9188
#!/usr/bin/env python3

N = int(input())

Ret = [0 for _ in range(10**5)]

for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            r = i**2 + j**2 + k**2 + i*j + j*k + i*k
            if r > len(Ret): print(r)
            Ret[r] += 1

for r in Ret[1:N+1]:
    print(r)




Measured memory_bytes: 73456
n=int(input())
a=list(map(int,input().split()))
arr=[0]*(10**5+1)
for i in a:
    arr[i]+=1


s=sum(a)

for i in range(int(input())):
    b,c=map(int,input().split())
    arr[c]+=arr[b]
    s=s+arr[b]*c-arr[b]*b
    arr[b]=0
    print(s)


Measured memory_bytes: 20872
//
//  main.cpp
//  The Balance of the World
//
//  Created by x15071xx on 2017/06/16.
//  Copyright ?? 2017??´ AIT. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <string>
using namespace std;
int main(int argc, const char * argv[]) {
    
    
    while(1){
        string yn = "yes";
        string str;
        vector<char> st;
        getline(cin, str);
        
        
        if (str == ".") {
            break;
        }
        
        for (int i = 0;  i < str.size(); i++) {
            
            if (str[i] == '(' || str[i] == '[') {
                st.push_back(str[i]);
            }
            
            
            if (str[i] == ')') {
                
                if (st.empty()) {
                    yn = "no";
                    break;
                }
                if ('(' != st.back()) {
                    yn = "no";
                    break;
                }
                
                st.pop_back();
                
            }
            
            if (str[i] == ']') {
                
                if (st.empty()) {
                    yn = "no";
                    break;
                }
                
                if ('[' != st.back()) {
                    yn = "no";
                    break;
                }
                
                st.pop_back();
                
            }
    
        

        }
        
        if (!st.empty()) {
            yn = "no";
        }
        
        cout << yn << endl;
    }
    return 0;
}

Measured memory_bytes: 3156
package main

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

func main() {
	N := getStdinInt()
	c := getStdin()

	ridx := N - 1
	widx := 0
	cnt := 0
	for widx < N && ridx >= 0 {
		if widx > ridx {
			break
		}

		w := -1
		if c[widx] == 'W' {
			w = widx
		} else {
			widx++
		}

		r := -1
		if c[ridx] == 'R' {
			r = ridx
		} else {
			ridx--
		}

		if r != -1 && w != -1 {
			widx++
			ridx--
			cnt++
		}
	}

	fmt.Printf("%d\n", cnt)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntU64() uint64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return uint64(rtn)
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func getStdinIntArrU64() []uint64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]uint64, len(list))
	for idx, val := range list {
		r, _ := strconv.ParseInt(val, 10, 64)
		rtn[idx] = uint64(r)
	}
	return rtn
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}
func abs64(n int64) int64 {
	if n < 0 {
		return -n
	}
	return n
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2800
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,c,s;
    cin>>n>>x>>c;
    if(n<=x)
    {
        s=1;
    }
    else if(n%x==0)
    {
        s=n/x;
    }
    else{
        s=(n/x)+1;
    }
    cout<<s*c<<endl;
    return 0;
}


Measured memory_bytes: 3624
/* 
chirag11032000
Chirag Thakur
*/

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

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void testCase();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	testCase();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void testCase() {
	vector < int > v(5);
	for (auto &el: v) {
		cin >> el;
	}
	sort(all(v));
	int k;
	cin >> k;
	for (int i = 0; i < 5; ++i) {
		for (int j = 0; j < 5; ++j) {
			if (abs(v[j] - v[i]) > k) {
				cout << ":(\n";
				return;
			}
		}
	}
	cout << "Yay!\n";
}

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

// varibable settings
#define int long long
const int INF=1e18;
const int MOD=1e9+7;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

signed main() {
  int n;cin>>n;
  vector<int> a(n);
  rep(i, n) {
    cin>>a[i];
  }
  dump(a);

  int cur = 1;
  int cnt = 0;
  rep(i, n){
    if (a[i]!=cur){
      cnt++;
    }
    else{
      cur++;
    }
  }
  if (cur==1){
    cout << -1 << endl;
  }
  else{
    cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <limits>

#define seq(i, n) for (int i = 0; i < (n); i++)
#define seq2(i, f, t) for (int i = (f); i < (n); i++)
#define rev(i, n) for (int i = (n); i >= 0; i--)
#define rev2(i, f, t) for (int i = (f); i >= t; i--)
#define all(x) (x).begin(),(x).end()
#define max(x, y) x > y ? x : y
#define min(x, y) x < y ? x : y

using namespace std;

using ll = long long;

void solve() {
  int n,m;
  cin >> n >> m;

  int l2=0,r2=1000000;
  seq(i, m) {
    int l,r;
    cin >> l >> r;
    if (l > l2) {
      l2=l;
    }
    if(r<r2){
      r2=r;
    }
  }
  const int res=r2-l2+1;
  cout << (res > 0 ? res : 0) << endl;
}

int main() {
  solve(); 

  return 0;
}


Measured memory_bytes: 256
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

ll a[10];
int main()
{
  ll n, bottle_neck = LLINF, ans = 0;
  scanf("%lld", &n);
  for (int i = 0; i < 5; i++)
  {
    scanf("%lld", &a[i]);
  }
  for (int i = 0; i < 5; i++)
  {
    bottle_neck = MIN(bottle_neck, a[i]);
  }
  printf("%lld\n", (n + bottle_neck - 1) / bottle_neck + 4);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 3e15
    
const int N=1e5+5;
const int M=1e9+7;
void solve()
{
	int n;
	cin>>n;
	queue<int> q;
	f(i,1,9) q.push(i);
	while(1)
	{
		int k=q.front();
		q.pop();
		n--;
		if(n==0)
		{
			cout<<k;
			return;
		}
		int pp=k%10;
		string s=to_string(k);
		if(pp-1>=0)
		{
			string tt=s+(char)('0'+pp-1);
			int x=stoll(tt);
			q.push(x);
		}
		string ttt=s+(char)('0'+pp);
		int xx=stoll(ttt);
		q.push(xx);
		if(pp+1<=9)
		{
			string tt=s+(char)('0'+pp+1);
			int x=stoll(tt);
			q.push(x);
		}
		
	}
}
signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}




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

int main() {

	string s; cin >> s;
	string ans = "Heisei";
	if (5 <= (s[6] - '0') || (s[5] - '0') == 1) {
		ans = "TBD";
	}
	cout << ans << endl;
	return 0;
}

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

#define vi vector<int>
#define all(v) v.begin(),v.end()
#define ll long long int
#define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
#define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

const ll MOD=1e9+7;

void solve(){
   int n;
   cin >> n;
   vector<bool> primes(n+1,1);
   primes[1]=false;
   for(int i=2;i*i<=n;i++){
     if(primes[i]==true){
       for(int j =i*i;j<=n;j+=i)
        primes[j]=false;
     }
   }
   vector<int> final(0);
   for(int i=2;i<=n;i++){
      if(primes[i]){
        int k = 0;
        for (int j = i; n / j >= 1; j *= i)
          k += n / j;
         final.push_back(k);
      }
   }
   ll ans = 1;
   // D2(final);
   // D2(primes);
   for(int c:final){
      ans = ans%MOD*(c+1)%MOD;
   }
   cout << ans;

}


int main(){
  IOS
     solve();
}
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <math.h>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
static const ll maxLL = (ll)1 << 62;

ll x[100001] = {};
ll t[100001] = {};
int main() {
	ll N, A, B; cin >> N >> A >> B;
	repe(i, 1, N) cin >> x[i];

	t[1] = 0;
	repe(i, 2, N) {
		t[i] = t[i - 1] + min(A*(x[i] - x[i - 1]), B);
	}

	cout << t[N] << endl;
	return 0;
}

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

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

    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= N; j++){
           int k = N-(i+j);
           if(k >= 0){
               if(10000*i+5000*j+1000*k == Y){
                   printf("%d %d %d\n",i,j,k);
                   return 0;
               }
           }
        }
    }
    printf("-1 -1 -1 \n");
    return 0;
}

Measured memory_bytes: 256
n,m = (int(i) for i in input().split())
c = [[int(i) for i in input().split()] for i in range(n)]
ans = 0
for i in range(8,16):
	d = []
	for j in range(n):
		num = 0
		for k in range(3):
			if bin(i)[3+k]=="0": num+=c[j][k]
			else: num-=c[j][k]
		d.append(num)
	d = sorted(d)[::-1]
	ans = max(ans,sum(d[:m]))
print(ans)

Measured memory_bytes: 3300
N = int(input())
a = list(map(int, input().split()))
a.sort()
x = a[0]
y = a[N // 3]
z = a[- N // 3]
if a[-1] == 0:
	print('Yes')
else:
	if N % 3 == 0:
		if a[N // 3 - 1] == 0 and y == a[-1]:
			print('Yes')
		else:
			if a.count(x) == N // 3 and a.count(y) == N // 3 and a.count(z) == N // 3: 
				if x ^ y == z and y ^ z == x and z ^ x == y:
					print('Yes')
				else:
					print('No')
			else:
				print('No')
	else:
		print('No')

Measured memory_bytes: 14704
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int d=a-b;
  if(c<=d){
    cout<<0<<endl;
  }
  else{
    cout<<(c-d)<<endl;
  }
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

int main()
{
	FAST;
	ll n,i;
	cin >> n;
	ll a[n],b[n],c[n];
	fr(i,0,n)
		cin >> a[i] >> b[i] >> c[i];
	ll dp[n][3];
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	fr(i,1,n)
	{
		dp[i][0] = max(dp[i-1][1] + a[i],dp[i-1][2] + a[i]);
		dp[i][1] = max(dp[i-1][0] + b[i],dp[i-1][2] + b[i]);
		dp[i][2] = max(dp[i-1][1] + c[i],dp[i-1][0] + c[i]);
	}
	cout << max(dp[n-1][0],max(dp[n-1][1], dp[n-1][2]));
}


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

int Comb(int m, int n)
{
    if (m == n || n == 0)
        return 1;

    int ans = 1;
    for (int i = 1; i <= n; i++)
    {
        ans = ans * (m - i + 1) / i;
    }
    return ans;
}

int main()
{
    int n, m, ans = 0;
    cin >> n >> m;

    if (n > 1)
        ans += Comb(n, 2);
    if (m > 1)
        ans += Comb(m, 2);

    cout << ans << endl;
}

Measured memory_bytes: 3608
#include<cstdio>
long long a[200001],b[200001];
int n;
long long sum=0;
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%lld",&a[i]),sum+=a[i];
	long long p=(1ll*n*(n+1)/2);
	if(sum%p)return !puts("NO");
	long long k=sum/p;
	for(int i=0;i<n;i++)b[i]=a[(i+1)%n]-a[i]-k;
	for(int i=0;i<n;i++)if(b[i]>0||(-b[i])%n) return !puts("NO");
	return !puts("YES");
}

Measured memory_bytes: 1664
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (k : n : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    rotate :: [Int] -> [Int]
    rotate (x : xs) = xs ++ [x + k]
  as <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    ds = zipWith subtract <$> id <*> rotate $ as :: [Int]
    m = maximum ds :: Int
  print $ k - m

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


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

using namespace std;

typedef long long ll;
typedef long double ld;

const int M = 107;

ll a, b, c;
void read() {
  cin >> a >> b >> c;
}


void kill() {
  if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
    cout << "0\n";
    return;
  }

  if (a > b)
    swap(a, b);
  if (b > c)
    swap(b, c);
  if (a > b)
    swap(a, b);

  ll ans = a * b;
  cout << ans << endl;
}

int main() {
  cout.precision(20);
  cout << fixed;
  ios_base::sync_with_stdio(false);
  read();
  kill();
}


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

int vector_out(vector <int> &A){
    int n=A.size();
    for (int i=0; i<n; i++){
        cout << A[i];
        if (i!= n-1) cout<<" ";
        else cout<<endl;
    }
    return 0;
}

int countingsort(vector <int> &A, vector <int> &B, int k){
	vector <int> C(k+1,0);
	for (int i=0; i<(int)A.size(); i++)
		C[A[i]]++;
	for (int i=1; i<=k; i++)
		C[i] += C[i-1];
	for (int i=A.size(); 0<i; i--){
		int i2=i-1;
		B[C[A[i2]]-1] = A[i2];
		C[A[i2]] --;
	}
	return 0;
}

int main(void){
	int n, max=0;
	cin >> n;
	vector <int> A(n,0), B(n,0);
	for (int i=0; i<n; i++){
		cin >> A[i];
		if (max<A[i]) max=A[i];
	}
	countingsort(A, B, max);
	vector_out(B);
	return 0;
}

Measured memory_bytes: 16800
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

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

	vector<pair<Int, Int>> v;
	Int a, b;

	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		v.push_back(make_pair(a,b));
	}
	sort(v.begin(), v.end());

	Int cnt = 0, cost = 0;
	//cout << v[0].first << " " << v[0].second << endl;

	for (int i = 0; i < n; i++) {
		if (v[i].second + cnt <= m) {
			cnt += v[i].second;
			cost += v[i].first * v[i].second;
		}
		else {
			cost += v[i].first * (m-cnt);
			break;
		}
	}
	cout << cost;

	cout << endl;
	return 0;
}

Measured memory_bytes: 2420
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String str;
		int a,b;
		while((str=in.readLine())!=null){
			a=getA(str);
			b=getB(str);
			System.out.println(countDigit(a+b));
		}
		
	}
	
	public static int getA(String str){
		int index,num;
		index = str.indexOf(" ");
		num=Integer.parseInt(str.substring(0,index));
		return num;
	}
	
	public static int getB(String str){
		int index,num;
		index = str.indexOf(" ");
		num=Integer.parseInt(str.substring(index+1));
		return num;
	}
	
	public static int countDigit(int num){
		int dig=1;
		while(num>=10){
			num=num/10;
			dig++;
		}		
		return dig;
	}

}

Measured memory_bytes: 24368
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

day = ["SUN","MON","TUE","WED","THU","FRI","SAT"]

# if S == "SAT":
#     print(1)
# else:
for i, d in enumerate(day):
    if d == S:
        print(7 - i)
        exit()

        

Measured memory_bytes: 5144
//https://atcoder.jp/contests/abc152/tasks/abc152_b
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a , b ;
    cin >> a >> b ;
    if(a < b) {
        while(b--)
        {
            cout << a ;
        }
    }
    else
    {
        while(a--)
        {
            cout << b ;
        }
    
    }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    int a, b, c; cin >> a >> b >> c;
    if(a + b + c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  long long W;
  scanf("%lld", &W);
  std::vector<long long> w(N);
  std::vector<long long> v(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &w[i]);
    scanf("%lld", &v[i]);
  }
  vector<vector<ll>> dp(N + 1, vector<ll>(101001, 1e15));
  for (int i = 0; i <= N; ++i)
    dp[i][0] = 0;
  for (int i = 0; i < N; ++i)
  {
    for (int j = 0; j < 101001 - v[i]; ++j)
    {
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
      dp[i + 1][j + v[i]] = min({dp[i + 1][j + v[i]], dp[i][j] + w[i], dp[i][j + v[i]]});
    }
  }
  ll ans = 0;
  for (ll i = 0; i < 101001; ++i)
  {
    if (dp[N][i] <= W)
      ans = max(i, ans);
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
	int n, q, l, r;
	string s;

	cin >> n >> q >> s;

	vector<int> found(n);
	for (int i = 1; i <= n-1; i++)
	{
		if (s[i-1] == 'A' && s[i] == 'C')
		{
			found[i] = 1;
		}
	}

	// 累積和
	vector<int> ruiseki(n+1, 0);
	for (int i = 1; i <= n; i++)
	{
		ruiseki[i] = ruiseki[i - 1] + found[i - 1];
	}

	for (int i = 0; i < q; i++)
	{
		cin >> l >> r;
		cout << ruiseki[r] - ruiseki[l] << endl;
	}
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){
	int i,n;
	scanf("%d",&n);
	int r[n],min[n],max[n],Max=-1000000000;
	for(i=0;i<n;i++){
		scanf("%d",&r[i]);
    }

	min[0]=r[0];
	max[0]=r[n-1];
	for(i=1;i<n-1;i++){
		if(r[i] < min[i-1]){min[i]=r[i];}else{min[i]=min[i-1];}
		if(r[n-1-i] > max[i-1]){max[i]=r[n-1-i];}else{max[i]=max[i-1];}
	}
	for(i=0;i<n-1;i++){
		if(max[n-2-i]-min[i] > Max){Max=max[n-2-i]-min[i];}
	}
	printf("%d\n", Max);

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<double> a(n);
        double sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
        sum += 1/a.at(i);
    }
    
    cout << 1 / sum << endl;
    
}

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

int main() {
  string s; cin >> s;
  int a = s[0]-'0', b = s[1]-'0', c = s[2]-'0', d = s[3]-'0';
  if (a+b+c+d == 7) cout << a << '+' << b << '+' << c << '+' << d << "=7" << endl;
  else if (a+b+c-d == 7) cout << a << '+' << b << '+' << c << '-' << d << "=7" << endl;
  else if (a+b-c+d == 7) cout << a << '+' << b << '-' << c << '+' << d << "=7" << endl;
  else if (a+b-c-d == 7) cout << a << '+' << b << '-' << c << '-' << d << "=7" << endl;
  else if (a-b+c+d == 7) cout << a << '-' << b << '+' << c << '+' << d << "=7" << endl;
  else if (a-b+c-d == 7) cout << a << '-' << b << '+' << c << '-' << d << "=7" << endl;
  else if (a-b-c+d == 7) cout << a << '-' << b << '-' << c << '+' << d << "=7" << endl;
  else if (a-b-c-d == 7) cout << a << '-' << b << '-' << c << '-' << d << "=7" << endl;
  return 0;
}

Measured memory_bytes: 256
n, m, t = map(int, input().split())
a = list(map(int, input().split()))
s = t
for i in range(n):
    if i == 0:
        s -= m
    elif a[i] - a[i - 1] >= 2 * m:
        s -= 2 * m
    else:
        s -= a[i] - a[i - 1]
    if i == n - 1:
        s -= min(t - a[-1], m)
print(s)


Measured memory_bytes: 5596