akhauriyash/Code-Regression huggingface dataset:
N = int(input())
d = list(map(int, input().split()))

same = N / 2

# d.sort()

# distribution = [0] * d[len(d) - 1]
# total = 0
# for di in d:
#     num = d.count(di)
#     distribution[di - 1] = num

table = {}
for di in d:
    table[di] = 1 if table.get(di) is None else table.get(di) + 1
table = sorted(table.items())

total = 0
start = 0
end = 0
for difficulty, num in table:
    total += num

    if start == 0 and total == same:
        start = difficulty
    elif start != 0:
        end = difficulty
        break

# print(table, start, end)

answer = end - start
print(answer)


Measured memory_bytes: 15712
#include <iostream>
#include <iostream>
#include <algorithm>
#include <string>
#include <utility>
#include <unordered_map>
#include <typeinfo>
using namespace std;

//stringを入れると、mapを返す関数
unordered_map<char, int> countChar(string str) {
    unordered_map<char, int> dic;
    int N = str.length();
    for(int i=0; i<N; ++i) {
        auto itr = dic.find(str[i]);
        if(itr != dic.end()) {
            dic.at(str[i]) += 1;
        } 
        else {
            dic.insert(make_pair(str[i], 1));
        }
    }
    return dic;
}

//2つのdictionaryを引数として、共通なkeyの数を返す
int countCommonKeys(unordered_map<char, int> dic1, unordered_map<char, int> dic2) {
    int cnt = 0;

    for(auto iter = dic1.begin(); iter != dic1.end(); ++iter) {
        if(dic2.find(iter->first) != dic2.end() ) {
            cnt++;
        } 
    }
    return cnt;
}


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

    string str;
    cin >> str;

    string X;
    string Y; 

    int max = 0;
    int tmp = 0;
    for(int d=1; d<N; ++d) {
        string X = "";
        string Y = ""; 
        for(int i=0; i<d; ++i){
            X.push_back(str[i]);
        }
        for(int j=d; j<N; ++j) {
            Y.push_back(str[j]);
        }
        // cout << "X : " << X << " Y : " << Y <<endl; 
        tmp = countCommonKeys(countChar(X), countChar(Y));
        // cout << tmp << endl;
        if(tmp >= max) {
            max = tmp;
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 256
N = int(input())

words = []
words.append(input())
for i in range(N-1):
    word = input()
    if word in words:
        print('No')
        break
    else:
        if word[0] != words[-1][-1]:
            print('No')
            break
        else:
            words.append(word)

if len(words) == N:
    print('Yes')

Measured memory_bytes: 3060
import sys
import math
#from queue import *
#import random
#sys.setrecursionlimit(int(1e6))
input = sys.stdin.readline
 
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
################################################################
############ ---- THE ACTUAL CODE STARTS BELOW ---- ############

n=inp()
ara=inara()

ans=0

for i in range(n):
	for j in range(i+1,n):
		for k in range(j+1,n):
			s=set()
			s.add(ara[i])
			s.add(ara[j])
			s.add(ara[k])
			
			if len(s)==3:
				a=ara[i]
				b=ara[j]
				c=ara[k]
				
				if a+b>c and b+c>a and a+c>b:
					ans+=1

print(ans)


Measured memory_bytes: 9228
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	sum := 0
	for i := 0; i < n; i++ {
		scanner.Scan()
		tmp, _ := strconv.Atoi(scanner.Text())
		sum += tmp
	}
	fmt.Println(sum/n)
}


Measured memory_bytes: 1136
N=int(input())
H=list(map(int,input().split()))
ans=0
while True:
    f=False
    g=False
    for i,h in enumerate(H):
        if h>0:
            if g==False:
                ans+=1
                g=True
            H[i]-=1
            f=True
        if h==0 and g==True:
            g=False
    if f==False:
        print(ans)
        break

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

int main()
{
	int N;
	scanf("%d", &N);
	
	int i, j, digit[10] = {}, tmp, max;
	while (1) {
		for (i = 0; i < N; i++) printf("%c", 'a' + digit[i]);
		printf("\n");
		
		for (i = N - 1; i > 0; i--) {
			if (digit[i] <= digit[i-1]) break;
			for (j = 1, max = 0; j < i; j++) if (digit[j] > max) max = digit[j];
			if (digit[i] <= max) break;
		}
		if (i == 0) break;
		for (tmp = ++digit[i++]; i < N; digit[i++] = 0);
	}
	
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

int freq[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    for(int i = 1; i < n; i++){
        int x;
        cin >> x;
        freq[x]++;
    }
    for(int i = 1; i <= n; i++){
        cout << freq[i] << '\n';
    }

    return 0;

}




Measured memory_bytes: 4444
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    string s;
    cin >> s;
    int flag = 0;
    int n = s.length();
    for (int i = 0; i < n; i++) {
        if (s[i] != s[n-i-1]) flag = 1;
    }
    for (int i = 0; i < n/2; i++) {
        if (s[i] != s[n/2-i-1]) flag = 1;
    }
    for (int i = n/2+1; i < n; i++) {
        if (s[i] != s[n-i-1]) flag = 1;
    }
    if (flag) cout << "No\n";
    else cout << "Yes\n";
    return 0;
}

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

int main() {
    int n; cin >> n;
    while (n--) {
        int max, b, c;
        cin >> max >> b >> c;
        if (max < b) swap(max, b);
        if (max < c) swap(max, c);
        cout << (max * max == b * b + c * c ? "YES" : "NO") << endl;
    }
    return 0;
}


Measured memory_bytes: 3044
// AUTHOR: ROSHAN SRIVASTAVA
// WEBSITE: https://www.youtube.com/channel/UC6uQdd7kLLOdlHSVklhV7Cw

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

ll x, k, d;

int main(){

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin >> x >> k >> d;

    x = abs(x);

    ll t = x / d;
    
   
    
    if(t >= k) {
         x -= (d*k);
        cout << x << endl; 
    } else {
        x -= (d*t);
        k -= t;
        if(k&1) cout << abs(x - d) << endl;
        else cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 3516
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	set<int> d;
	rep(i, k){
		int in;
		cin >> in;
		d.insert(in);
	}
	int ans = n;
	while(1){
		string sn = to_string(ans);
		// cerr << ans << endl;
		bool flag = true;
		rep(i, sn.size()){
			if(d.count(sn[i] - '0') == 1) flag = false;
		}
		if(flag == true){
			cout << ans << endl;
			return 0;
		}
		ans++;
	}
	return 1;
}

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

int main(){
  int n;
  cin >> n;
  
  vector <int> a(n);
  
  for(int i=0; i<n; i++)
    cin >> a.at(i);
  
  bool answer=true;
  
  for(int i=0; i<n; i++){
    if(a.at(i)%2==0&&a.at(i)%3!=0&&a.at(i)%5!=0){
      answer = false;
      break;
    }
  }
  
  if(answer)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" <<endl;
  return 0;
}

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

int facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

void solve(){
  int n,m,x,count=0,r[2];
  scanf("%d",&n);
  int a[2][n];
  for (int i = 0; i < n; i++)
  {
    scanf("%d",&a[0][i]);
  }
  
  for (int i = 0; i < n; i++)
  {
    scanf("%d",&a[1][i]);
  }

  vector<int> v;
  for(int i=0;i<2;i++){
    r[i]=1;
    for (int i = 1; i <= n; i++)
      {
        v.push_back(i);
    }
    for(int j=0;j<n;j++){
      auto x=find(v.begin(),v.end(),a[i][j]);
      int a=distance(v.begin(),x);
      r[i]+=facctorialMethod(v.size()-1)*a;
      v.erase(x);
    }
  //printf("%d\n",r);
  }
  printf("%d",abs(r[0]-r[1]));



 //printf("%d\n",count);
}
int main(){
  /*
  int q;
  scanf("%d",&q);
  while(--q)solve();
  */
  solve();

  return 0;
}

Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()



using namespace std;



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

  string s1 = s;
  reverse(all(s));
  string s2 = s;

  string t = "";

  for(int i=0;i<(s.size()-1)/2;i++){
    t += s1[i];
  }
  string t1 = t;
  reverse(all(t));
  string t2 = t;

  string u = "";

  for(int i=(s.size()+3)/2 -1;i<s.size();i++){
    u += s1[i];
  }

   string u1 = u;
  reverse(all(u));
  string u2 = u;

  if(u1 == u2 and t1 == t2 and s1 == s2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;





  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
    int a,b;

    scanf("%d%d",&a,&b);
    char st[a];
    scanf("%s",st);

   if(st[b-1]>=65&&st[b-1]<=90){
         st[b-1]=st[b-1]+32;
         }
    printf("%s",st);

return 0;
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);

const int N = 3e5;
int n, m;
vi adj[N];
bool vis[N];

int dfs(int node){
    vis[node] = true;
    int ret = 1;
    for(auto to : adj[node]){
        if(!vis[to]){
            ret += dfs(to);
        }
    }
    return ret;
}

int main()
{
    int i = 0, j = 0, cs = 0, in;
    cin>>n>>m;
    for(i = 0; i < m; i++){
        int a, b; cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    int ans = 0;
    for(i = 1; i <= n; i++){
        if(!vis[i]){
            ans = max(ans, dfs(i));
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define F first
#define S second
typedef double db;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main(){
  ll n,m,cnt=0;
  cin>>n>>m;
  vector<pll> a(n);
  rep(i,n){
  cin>>a[i].F>>a[i].S;
  }
  sort(a.begin(),a.end());
  rep(i,n){
  if(a[i].S<=m){
  m-=a[i].S;
    cnt+=a[i].F*a[i].S;
  }
  else {
    cnt+=a[i].F*m;
    break;
  }
  }
  cout<<cnt<<endl;
return 0;
}

Measured memory_bytes: 1920
import sys
from itertools import starmap
readline = sys.stdin.readline
EPS = 1e-9
ONLINE_FRONT = -2
CLOCKWISE = -1
ON_SEGMENT = 0
COUNTER_CLOCKWISE = 1
ONLINE_BACK = 2
class Segment(object):
    __slots__ = ('fi', 'se')
    def __init__(self, fi, se):
        self.fi = fi
        self.se = se
def cross(a, b):
    return a.real * b.imag - a.imag * b.real
def dot(a, b):
    return a.real * b.real + a.imag * b.imag
def norm(base):
    return abs(base) ** 2
def project(s, p2):
    base = s.fi - s.se
    r = dot(p2 - s.fi, base) / norm(base)
    return s.fi + base * r
def reflect(s, p):
    return p + (project(s, p) - p) * 2.0
def ccw(p1, p2, p3):
    a = p2 - p1
    b = p3 - p1
    if cross(a, b) > EPS: return 1
    if cross(a, b) < -EPS: return -1
    if dot(a, b) < -EPS: return 2
    if norm(a) < norm(b): return -2
    return 0
def intersect4(p1, p2, p3, p4):
    return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 and
			ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0)
def intersect2(s1, s2):
    return intersect4(s1.fi, s1.se, s2.fi, s2.se)
def getDistance(a, b):  return abs(a - b)
def getDistanceLP(l, p):
    return abs(cross(l.se - l.fi, p - l.fi) / abs(l.se - l.fi))
def getDistanceSP(s, p):
    if dot(s.se - s.fi, p - s.fi) < 0.0: return abs(p - s.fi)
    if dot(s.fi - s.se, p - s.se) < 0.0: return abs(p - s.se)
    return getDistanceLP(s, p)
def getDistances(s1, s2):
    if intersect2(s1, s2): return 0.0
    return min(getDistanceSP(s1, s2.fi), getDistanceSP(s1, s2.se),
               getDistanceSP(s2, s1.fi), getDistanceSP(s2, s1.se))
n = int(readline())
for _ in [0] * n:
    p0, p1, p2, p3 = starmap(complex, zip(*[map(int, input().split())] * 2))
    print(1 if intersect4(p0, p1, p2, p3) else 0)

Measured memory_bytes: 7876
def alter_altar(s):
    tmp = 'R' * s.count('R') + 'W' * s.count('W')
    ans = 0
    for i in range(len(s)):
        if s[i] == tmp[i]:
            pass
        else:
            ans += 1
    return ans//2
if __name__ == "__main__":
    _ = input()
    s = input()
    print(alter_altar(s))

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

int main(){
  long long N;
  cin>>N;
  vector <long long> a(N);
  long long mina=1000000000;
  long long  minuscount=0;
  long long  zerocount=0;
  long long sum=0;
  for (long long i=0;i<N;i++){
    cin>> a[i];
    if(abs(a[i])<mina){
      mina=abs(a[i]);
    }
    if(a[i]<0){
      minuscount++;
    }
    if(a[i]==0){
      zerocount++;
    }
    sum=sum+abs(a[i]);
  }
    
  if((minuscount%2==0)||(zerocount>0)){
    cout<<setprecision(18)<<sum<<endl;
    return 0;
  }
  cout<<setprecision(18)<<sum-2*mina<<endl;
  return 0;
}

       

Measured memory_bytes: 1024
if __name__ == '__main__':

	n = int(input())
	
	A = [[0 for _ in range(n)] for _ in range(n)]

	for i in range(n):
		cmd = input().split();
		m = int(cmd[1])
		for j in range(m):
			A[i][int(cmd[2+j])-1] = 1

	for i in A:
		print(*i)



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

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

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define pcnt __builtin_popcount
#define pcntll(x) __builtin_popcountll(x)
#define DMAX DBL_MAX;
#define IMIN INT_MIN;
#define IMAX INT_MAX;

//const ll MOD = 1e9+7;
//const ll MOD = 998244353;
//const ll MAX = 3e5+1;
//const ll INF = 1e18;
//const ld PI = acos(-1L);

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

    ll N;
    in(N);
    vector<ll> A(N), B(N);
    rep(i, N) in(A[i] >> B[i]);
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    ll ans;
    if (N % 2) {
        ll meda = A[(N-1)/2];
        ll medb = B[(N-1)/2];
        if (meda > medb) {
            out(0);
            exit(0);
        }
        ans = medb - meda + 1;
    }
    else {
        ll meda = (A[N/2-1] + A[N/2]);
        ll medb = (B[N/2-1] + B[N/2]);
        if (meda > medb) {
            out(0);
            exit(0);
        }
        ans = medb - meda + 1;
    }
    out(ans);

    return 0;
}


Measured memory_bytes: 6328
#include<iostream>
using namespace std;
int suretu[100000];
int cont = 0, max_sum = 0;

int ret_maxsum(int n, int k, int wa, bool isBegin)
{
	int temp = 0;
	int i;
	if(isBegin == 1){
		for(i = 0; i < k; i++){
			temp += suretu[cont+i];
		}
	}
	else{temp += wa + suretu[cont+k-1];}
	wa = temp - suretu[cont];
	cont++;
	if(max_sum < temp){max_sum = temp;}
	if(cont == n-k+1){return max_sum;}
	else{return ret_maxsum(n, k, wa, 0);}
}
main()
{
	for(;;){
		int n,k;
		cin >> n;
		cin >> k;
		if(n == 0 && k == 0){
			break;
		}
		for(int i = 0; i < n; i++){
			cin >> suretu[i];
		}
		printf("%d\n",ret_maxsum(n, k, 0, 1));
	}
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n,a[100001],ans,cnt=1;
int main()
{
	cin>>n;
	for (int i=1;i<=n;++i) cin>>a[i];
	for (int i=n-1;i>=1;--i)
	{
		if (a[i]>=a[i+1]) ++cnt;
		else
		{
			ans=max(ans,cnt);
			cnt=1;
		}
	}
	ans=max(ans,cnt);
	cout<<ans-1;
	return 0;
}

Measured memory_bytes: 1024
import collections as c

N = int(input())
A = list(map(int, input().split()))
B = c.deque([])
if N % 2 == 0:
	for i in range(N):
		if i % 2 == 0:
			B.append(A[i])
		else:
			B.appendleft(A[i])

else:
	for i in range(N):
		if i % 2 == 0:
			B.appendleft(A[i])
		else:
			B.append(A[i])

for b in B:
	print(b, end = " ")
print()
	

Measured memory_bytes: 25536
'use strict';

let count = 0;
// let answer;
function main(input) {
    //const num = parseInt(input)
	const str_list = input.replace("\n"," ").split(" ");
  	for (let i = 0; i < str_list[0].length; i++){
       if(str_list[0][i] !== str_list[1][i]){
         count = count + 1
       }
    }
	console.log(count)
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 33388
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int w, h;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

bool B[50][50], W[50][50];
char field[50][50];

void dfs(int y, int x, bool color){
	for(int k=0; k<4; k++){
		if(x+dx[k]<0 || x+dx[k]>=w || y+dy[k]<0 || y+dy[k]>=h) continue;
		if(field[y+dy[k]][x+dx[k]]=='.'){
			if(color){
				if(!W[y+dy[k]][x+dx[k]]){
					W[y+dy[k]][x+dx[k]] = true;
					dfs(y+dy[k],x+dx[k],1);
				}
			}else{
				if(!B[y+dy[k]][x+dx[k]]){
					B[y+dy[k]][x+dx[k]] = true;
					dfs(y+dy[k],x+dx[k],0);
				}
			}
		}
	}
}

int main(){
	int b_count, w_count;
	while(cin >> w >> h){
		if(!(w||h)) break;
		b_count = 0;
		w_count = 0;
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				cin >> field[i][j];
				B[i][j] = false;
				W[i][j] = false;
			}
		}
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				if(field[i][j] == 'B') dfs(i,j,0);
				if(field[i][j] == 'W') dfs(i,j,1);
			}
		}
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				if( B[i][j] && !W[i][j]) b_count++;
				if(!B[i][j] &&  W[i][j]) w_count++;
			}
		}
		cout << b_count << " " << w_count << endl;
	}
    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP2(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REP3(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define OVERLOAD2(_1, _2, _3, name, ...) name
#define REP(...) OVERLOAD2(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Feb  9 21:00:01 JST 2020
 **/

template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...));
}

signed main() {
    string s;
    cin >> s;
    Int n = s.size();
    Int K;
    cin >> K;
    auto dp = make_vec<Int>(n + 1, 2, K + 2, 0);
    dp[0][0][0] = 1;
    REP(i, n) {
        REP(j, 2) {
            REP(k, K + 1) {
                REP(d, j ? 10 : s[i] - '0' + 1) { dp[i + 1][j | (d < s[i] - '0')][k + bool(d)] += dp[i][j][k]; }
            }
        }
    }
    cout << dp[n][0][K] + dp[n][1][K] << endl;
}


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

int main() {
  i64 N;
  cin >> N;
  vector<i64> M(N);
  vector<vector<i64>> c(N);
  for(i64 i = 0;i < N;i++) {
    cin >> M[i];
    c[i].resize(M[i]);
    for(int j = 0;j < M[i];j++) {
      cin >> c[i][j];
    }
  }
  priority_queue<i64> que;

  i64 ans = 0;

  for(i64 i = N - 1;i >= 0;i--) {
    for(auto x: c[i]) {
      que.push(x);
    }
    if(!que.empty()) {
      ans += que.top();
      que.pop();
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 21452
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 510000;
const int MOD =  998244353;
const int INV2 = (MOD+1)/2;

     signed main(){
    int n,m,s;
    cin>>n>>m>>s;
   vector< pair<int,pair<int,int>> >hen[n];
    int u,v,a,b;
    for(int i=0;i<m;i++){
      cin>>u>>v>>a>>b;u--;v--;
      hen[u].push_back(make_pair(v,make_pair(a,b)));
      hen[v].push_back(make_pair(u,make_pair(a,b)));
    }
    int c[n],d[n];
    for(int i=0;i<n;i++)cin>>c[i]>>d[i];
    
    priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>> que;
    int ans[n][2501];
    for(int i=0;i<n;i++)fill(ans[i],ans[i]+2501,MOD*MOD);
    que.push(make_pair(0,make_pair(0,min(2500ll,s))));
    bool used[n]={};
    while(!que.empty()){
      pair<int,pair<int,int>>p=que.top();
      que.pop();
      if(p.first>ans[p.second.first][p.second.second])continue;
      if(p.first+d[p.second.first]<ans[p.second.first][min(2500ll,p.second.second+c[p.second.first])]){
          ans[p.second.first][min(2500ll,p.second.second+c[p.second.first])]=p.first+d[p.second.first];
          que.push(make_pair( ans[p.second.first][min(2500ll,p.second.second+c[p.second.first])]
          ,make_pair(p.second.first,min(2500ll,p.second.second+c[p.second.first]))));
        }
      //for(int i=0;p.second.second+i*c[p.second.first]<2500;i++){
   //      if(p.first+(i+1)*d[p.second.first]<ans[p.second.first][min(2500ll,p.second.second+(i+1)*c[p.second.first])]){
   //       ans[p.second.first][min(2500ll,p.second.second+(i+1)*c[p.second.first])]=p.first+(i+1)*d[p.second.first];
   ///       que.push(make_pair( ans[p.second.first][min(2500ll,p.second.second+(i+1)*c[p.second.first])]
  //        ,make_pair(p.second.first,min(2500ll,p.second.second+(i+1)*c[p.second.first]))));
  //      }
    //  }
      for(auto itr : hen[p.second.first]){
        if(p.second.second>=itr.second.first&&p.first+itr.second.second<ans[itr.first][p.second.second-itr.second.first]){
          ans[itr.first][p.second.second-itr.second.first]=p.first+itr.second.second;
          que.push(make_pair(ans[itr.first][p.second.second-itr.second.first],make_pair(itr.first,p.second.second-itr.second.first)));
        }
      }
    }
    int ans2;
    for(int i=1;i<n;i++){
      ans2=MOD*MOD;
      for(int j=0;j<2501;j++)ans2=min(ans2,ans[i][j]);
      cout<<ans2<<endl;
    }

    


}


        


Measured memory_bytes: 7204
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define y1 afasg
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);
const lli ln = (lli)(1e9);

lli s, x1, x2, x3, y1, y2, y3;

int main() {
	fast_io();
	//freopen("inp.in", "r", stdin);
	
	cin >> s;
	if(s == (lli)1e18) {
		cout << 0 << spc << 0 << spc << 0 << spc << ln << spc << ln << spc << 0 << endl;
		return 0;
	}
	if(s <= ln) {
		x1 = s;
		x2 = 0;
		y1 = 0;
		y2 = 1;
		x3 = 0;
		y3 = 0;
	}
	else {
		x1 = ln;
		y2 = s / ln + 1;
		x2 = 1;
		y1 = x1 * y2 - s;
		x3 = 0;
		y3 = 0;
	}
	cout << x1 << spc << y1 << spc << x2 << spc << y2 << spc << x3 << spc << y3;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

    	 Arrays.sort(n);
    	 Arrays.sort(s);

        String nn_last = new String(n);
        String ss_last = new String(s);
        ss_last = new StringBuilder(ss_last).reverse().toString();
        System.out.println(nn_last.compareTo(ss_last) < 0 ? "Yes" : "No");
    	}
    }

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

#define ll long long



void solve(){
    int n;
    int a,b;
    cin>>n;
    cin>>a>>b;
    if(a*n<b){
        cout<<a*n<<endl;
    }else{
        cout<<b<<endl;
    }
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 256
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
                         **/
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define fl '\n'
#define vi vector<int>
#define sz size
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 2*1e5+1;
const int mod = 1000000009;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 10000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b;
    int pwur = qpow(b,e>>1);
    return pwur * pwur;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);

    int n;
    vi v;
    cin>>n;
    for(int i=0;i<n;i++){
        int x;cin>>x;v.pb(x);
    }
    int res=inf;
    for(int i=-100;i<=100;i++){
        int s=0;
        for(int j=0;j<n;j++){
            int aux;
            aux=v[j]-i;
            s+=aux*aux;
        }
        res=min(res,s);
    }
    cout<<res<<endl;

    return 0;
}


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

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n;
    cin >> n;
    int ans=0;
    for(int i=1;i<=n;i++){
        ans+=i*(n-i+1);
    }
    for(int i=1;i<n;i++){
        int u,v;
        cin >> u >> v;
        if(v<u)swap(u,v);
        ans-=u*(n-v+1);
    }
    cout << ans;
}

Measured memory_bytes: 3684
#include<iostream>
#include<vector>
#include<numeric>

using namespace std;

typedef long long LL;

const LL MOD = 998244353;

int main(){
    LL N;
    cin >> N;
    vector<LL> a(N);
    for(LL i = 0; i < N; ++i){
        cin >> a[i];
    }
    vector<LL> prev(300*300+1);
    vector<LL> cur(300*300+1);
    prev[0] = 1;
    for(LL i = 0; i < N; ++i){
        for(LL j = 0; j < 300*299+1; ++j){
            cur[j + a[i]] = (cur[j + a[i]] + prev[j]) % MOD;
            cur[j] = (cur[j] + prev[j] * 2 % MOD) % MOD;
        }
        prev.swap(cur);
        cur = vector<LL>(300*300+1);
    }
    LL cnt = 0;
    LL total = accumulate(a.begin(), a.end(), 0);
    LL start = (total+1) / 2;
    for(LL i = start; i < prev.size(); ++i){
        cnt = (cnt + prev[i]) % MOD;
    }
    cnt = cnt * 3 % MOD;

    if(start * 2 == total){
        vector<LL> prev(300*300+1);
        vector<LL> cur(300*300+1);
        prev[0] = 1;
        for(LL i = 0; i < N; ++i){
            for(LL j = 0; j < 300*299+1; ++j){
                cur[j + a[i]] = (cur[j + a[i]] + prev[j]) % MOD;
                cur[j] = (cur[j] + prev[j] % MOD) % MOD;
            }
            prev.swap(cur);
            cur = vector<LL>(300*300+1);
        }
        LL two_col = prev[start] * 3 % MOD;
        cerr << "two_col=" << two_col << endl;
        cnt = (cnt + MOD - two_col) % MOD;
    }
    LL all = 1;
    for(LL i = 0; i < N; ++i){
        all = all * 3 % MOD;
    }
    cout << (all + MOD - cnt) % MOD << endl;
    cerr << "total=" << accumulate(a.begin(), a.end(), 0) << endl;
    cerr << "start=" << (accumulate(a.begin(), a.end(), 0)+1)/2 << endl;
    cerr << "cnt=" << cnt << endl;
    cerr << "all=" << all << endl;
    return 0;
}



Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define _ << ' ' <<
using namespace std;
using ll = long long;

ll a[200005];
const int N = 1 << 18;
ll tree[2 * N];
ll lazy[2 * N];

void upd(int node)
{
    tree[node] = tree[node * 2] + tree[node * 2 + 1];
}

void apply(ll val, int node, int p, int q)
{
    lazy[node] += val;
    tree[node] += 1ll * (q - p + 1) * val;
}

void prop(int node, int p, int q)
{
    if (node >= N)
        return;

    int mid = (p + q) / 2;
    apply(lazy[node], 2 * node, p, mid);
    apply(lazy[node], 2 * node + 1, mid + 1, q);
    lazy[node] = 0;
}

void update(int l, int r, ll val, int node = 1, int p = 1, int q = N)
{
    if (q < l || p > r)
        return;

    if (p >= l && q <= r)
    {
        apply(val, node, p, q);
        return;
    }

    int mid = (p + q) / 2;
    prop(node, p, q);
    update(l, r, val, 2 * node, p, mid);
    update(l, r, val, 2 * node + 1, mid + 1, q);
    upd(node);
}

ll query(int l, int r, int node = 1, int p = 1, int q = N)
{
    if (q < l || p > r)
        return 0;

    if (p >= l && q <= r)
        return tree[node];

    int mid = (p + q) / 2;
    prop(node, p, q);
    return query(l, r, 2 * node, p, mid) +
        query(l, r, 2 * node + 1, mid + 1, q);
}

int main()
{
    int n, q;
    cin >> n >> q;
    while (q--)
    {
        int e, a, b;
        cin >> e >> a >> b;
        if (e == 0)
        {
            ll x;
            cin >> x;
            update(a, b, x);
        }
        else
            cout << query(a, b) << '\n';
    }
}



Measured memory_bytes: 6264
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int N, X, m, min=1000, ans=0;
    cin >> N >> X;
    for(int i=0; i<N; i++){
        cin >> m;
        X-=m;
        ans++;
        if(min>=m){
            min=m;
        }
    }
    ans+=X/min;
    cout << ans << endl;
    
}

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

int t;
string s;

vector<vector<int> > ans;
int ma = 0;

void func2(int n, int now, int sum) {
  //cout << n << " " << now << " " << sum << endl;
  if ( n == (int)s.size() ) {
    if ( now+sum <= t ) {
      ma = max(ma, now+sum);
      return;
    } else {
      return;
    }
  }

  if ( ans.size() >= 2 ) return;

  func2(n+1, now*10+(s[n]-'0'), sum);
  func2(n+1, s[n]-'0', sum+now);
}

void func(int n, int now, int sum, vector<int> v) {
  if ( n == (int)s.size() ) {
    if ( now+sum == ma ) {
      //cout << n << " " << now << " " << sum << endl;
      vector<int> tmp;
      tmp = v;
      tmp.push_back(now);
      ans.push_back(tmp);
      return;
    } else {
      return;
    }
  }

  if ( ans.size() >= 2 ) return;

  func(n+1, now*10+(s[n]-'0'), sum, v);
  v.push_back(now);
  func(n+1, s[n]-'0', sum+now, v);
}

int main() {

  while ( cin >> t >> s, t && s != "0" ) {
    ma = 0;
    ans.clear();
    func2(1, s[0]-'0', 0);
    //cout << ma << endl;
    vector<int> v;
    func(1, s[0]-'0', 0, v);
    
    if ( ans.size() == 0 ) cout << "error" << endl;
    else if ( ans.size() == 1 ) {
      cout << ma << " ";
      for ( int i = 0; i < (int)ans[0].size()-1; i++ ) {
	cout << ans[0][i] << " ";
      }
      cout << ans[0][(int)ans[0].size()-1] << endl;
    }
    else cout << "rejected" << endl;
  }
}



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


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmpArray = br.readLine().split(" ");
		int a = Integer.parseInt(tmpArray[0]);
		int b = Integer.parseInt(tmpArray[1]);
		if(a > b){
			System.out.println("a > b");
		}
		else if(a == b){
			System.out.println("a == b");
		}
		else{
			System.out.println("a < b");
		}
	}

}

Measured memory_bytes: 24248
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
struct dice_{
  int x[6];
  dice_(){}
  void input(){
    rep(i, 6)cin >> x[i];
  }
  void north(){
    int y[6];
    y[0] = x[1];
    y[1] = x[5];
    y[2] = x[2];
    y[3] = x[3];
    y[4] = x[0];
    y[5] = x[4];
    swap(x, y);
  }
  void south(){
    int y[6];
    y[0] = x[4];
    y[1] = x[0];
    y[2] = x[2];
    y[3] = x[3];
    y[4] = x[5];
    y[5] = x[1];
    swap(x, y);
  }
  void east(){
    int y[6];
    y[0] = x[3];
    y[1] = x[1];
    y[2] = x[0];
    y[3] = x[5];
    y[4] = x[4];
    y[5] = x[2];
    swap(x, y);
  }
  void west(){
    int y[6];
    y[0] = x[2];
    y[1] = x[1];
    y[2] = x[5];
    y[3] = x[0];
    y[4] = x[4];
    y[5] = x[3];
    swap(x, y);
  }
  void right(){
    int y[6];
    y[0] = x[0];
    y[1] = x[2];
    y[2] = x[4];
    y[3] = x[1];
    y[4] = x[3];
    y[5] = x[5];
    swap(x, y);
  }
  void left(){
    int y[6];
    y[0] = x[0];
    y[1] = x[3];
    y[2] = x[1];
    y[3] = x[4];
    y[4] = x[2];
    y[5] = x[5];
    swap(x, y);
  }
};

using dice = struct dice_;

int main(int argc, char const* argv[])
{
  dice d;
  d.input();
  string s;
  cin >> s;
  rep(i, s.size()){
    if(s[i] == 'S')d.south();
    else if(s[i] == 'W')d.west();
    else if(s[i] == 'E')d.east();
    else if(s[i] == 'N')d.north();
  }
  cout << d.x[0] << endl;
	return 0;
}



Measured memory_bytes: 3208
import sys

K = int(sys.stdin.readline())
M = len(sys.stdin.readline())-1
N = K+M
mod = 10**9+7
ans = pow(26, N, mod)


class Data():
    def __init__(self):
        self.power = 1
        self.rev = 1


class Combi():
    def __init__(self, N, mod):
        self.lists = [Data() for _ in range(N+1)]
        self.mod = mod
        for i in range(2, N+1):
            self.lists[i].power = ((self.lists[i-1].power)*i) % self.mod
        self.lists[N].rev = pow(self.lists[N].power, self.mod-2, self.mod)
        for j in range(N, 0, -1):
            self.lists[j-1].rev = ((self.lists[j].rev)*j) % self.mod

    def combi(self, K, R):
        if K < R:
            return 0
        else:
            return ((self.lists[K].power)*(self.lists[K-R].rev)*(self.lists[R].rev)) % self.mod


X = Combi(N, mod)
for i in range(M):
    ans -= X.combi(N, i)*pow(25, N-i, mod)
    ans %= mod
print(ans)

Measured memory_bytes: 325684
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int x = scanner.nextInt();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        System.out.println(Math.abs(x - a) < Math.abs(x - b) ? "A" : "B");
    }
}

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

int r, g, b, num;

int main() {
	cin >> r >> g >> b;

	num = r * 100 + g * 10 + b;

	if (num % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int i,n,k,p,ans;

	scanf("%d",&n);

	for( i = 0; i < n; i++){
		scanf("%d %d",&k,&p);
		ans=k%p;
		if(ans==0)ans=p;
		printf("%d\n",ans);
	}
	return 0;
}


Measured memory_bytes: 2056
import sys
N = int(input())
W = list(map(int, input().split()))

sum0 = sum(W)
ans = 0
for i in range(N):
	if ans >= int(sum0 / 2):
		a0 = sum0 - ans * 2
		a1 = sum0 - (ans - W[i-1]) * 2
		print(min(abs(a0), abs(a1)))
		sys.exit()
	else:
		ans += W[i]

Measured memory_bytes: 3060
while 1:
    s=list(map(str,input().split()))
    if s[0]=="#":break
    if int(s[1])==31 and int(s[2])>=5 or int(s[1])>=32:
        s[0]="?"
        s[1]=str(int(s[1])-30)
    print(' '.join(map(str, s)))


Measured memory_bytes: 5604
import math

A, B, H, M = map(int, input().split())

angA = (H*60 + M) * (360/(12*60))
angB = M * (360/60)
angle = math.radians(max([angA, angB]) - min([angA, angB]))
C = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(angle))
print(C)

Measured memory_bytes: 9444
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << 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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
int a[N];
int pos[N];
int F[N], G[N];

int64 comb(int n, int m) {
  if (n < 0 || m < 0) return 0;
  if (m > n) return 0;
  return (int64)F[n] * G[m] % MOD * G[n - m] % MOD;
}

int64 power_mod(int64 a, int n) {
  int64 ret = 1;
  for (; n; n >>= 1) {
    if (n & 1) ret = ret * a % MOD;
    a = a * a % MOD;
  }
  return ret;
}

int64 inv_mod(int64 a) {
  return power_mod(a, MOD - 2);
}

int main() {
  F[0] = G[0] = 1;
  for (int i = 1; i < N; ++i) {
    F[i] = (int64)F[i - 1] * i % MOD;
    G[i] = inv_mod(F[i]);
  }
  int n;
  scanf("%d", &n);
  int k = -1, gap = 0;
  fill(pos, pos + N, -1);
  for (int i = 0; i < n + 1; ++i) {
    int x;
    scanf("%d", &x);
    if (pos[x] < 0) {
      pos[x] = i;
    } else {
      k = x;
      gap = abs(pos[x] - i) - 1;
    }
  }
  for (int i = 1; i <= n + 1; ++i) {
    int64 cur = comb(n - 1, i) + comb(n - 1, i - 2) + 2 * comb(n - 1, i - 1);
    cur = cur + MOD - comb(n + 1 - 2 - gap, i - 1);
    printf("%lld\n", cur % MOD);
  }
  return 0;
}


Measured memory_bytes: 2432
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 14;
char cn[cm], * ci = cn, ct;

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


	fread(ci, 1, cm, stdin);

	int N = 0;
	while ((ct = *ci++) >= '0') N = N * 10 + ct - '0';

	int M = N / 2;
	vector<ll> dp(M + 2);
	dp[0] = 1e15;

	rep(i, N) {
		ci += 2;
		int p = (*ci++ - '0') * 10;
		p += *ci++ - '0';
		ci++;

		for (int j = min(M, i); j >= max(0, i - M); j--) {
			dp[j + 1] += dp[j] * p / 100;
			dp[j] = dp[j] * (100 - p) / 100;
		}
	}

	printf("%.15f", 1e-15 * dp[M + 1]);

	Would you please return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
  
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " " << a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }
  
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}
 
typedef long long int64;
typedef pair< int64 , int64 > Pi;
typedef pair< int , Pi > Pii;
const int64 INF = 1LL << 53;

int64 N, M, L, K[2000], S[100000];
int64 dp[2000][2000];
int64 get_Sum(int a, int b){
  if(a > b) swap( a, b);
  if(a == 0) return S[b];
  else return S[b] - S[a - 1];
}

int64 rec(int idx, int right, int left){
  if(idx == N) return get_Sum( K[right], K[left]) / L;
  if(~dp[right][left]) return dp[right][left];
  int64 ret = INF;
  ret = min( ret, rec( idx + 1, idx, left) + get_Sum( K[right], K[idx]) / L);
  ret = min( ret, rec( idx + 1, right, idx) + get_Sum( K[left], K[idx]) / L);
  return dp[right][left] = ret;
}

int main(){
  fill_n( *dp, 2000 * 2000, -1);
  scanf("%lld %lld %lld", &N, &M, &L);
  for(int i = 0; i < N; i++){
    scanf("%lld", &K[i]); --K[i];
  }
  for(int i = 0; i < M; i++){
    scanf("%lld", &S[i]);
    if(i) S[i] += S[i - 1];
  }
  sort( K, K + N);
  printf("%lld\n", rec( 1, 0, 0));
}

Measured memory_bytes: 33404
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   string s, ans = "Yes";
   int ctr = 0;
   map<char, int> mp;
   cin >> s;
   for (int i = 0; i < s.length(); i++)
   {
      if (mp[s[i]] == 0)
         ctr++;
      mp[s[i]]++;
      if (ctr > 2 || mp[s[i]] > 2)
      {
         ans = "No";
         break;
      }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
answerAlpha = []
answerNum = []

# 全アルファベットに0を初期セット
for i in range(97, 97 + 26):
    answerAlpha.append(chr(i))
    answerNum.append(0)

#inp = input().lower()
inp = ""
while True:
    try:
        inp += input().lower()
    except:
        break

for i in range(len(inp)):
    if inp[i] in answerAlpha:
        answerNum[answerAlpha.index(inp[i])] += 1    

[print("{} : {}".format(*answerAlpha[i], answerNum[i])) for i in range(len(answerNum))]


Measured memory_bytes: 5568
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	
	int N;
	cin>>N;
	vector<int> A(N);
	FDS(i,N){
		cin>>A[i];
		A[i]-=(i+1);
	}
	VSORT(A);
	int naka,nakanaka;
	if(N%2==1){
		naka=A[N/2];
		ll sum=0;
		FDS(i,N){
			sum+=abs(naka-A[i]);
		}
		cout<<sum<<endl;
	}
	else{
		naka=A[N/2];
		nakanaka=A[N/2+1];
		ll sum=0,sumsum=0;
		FDS(i,N){
			sum+=abs(naka-A[i]);
		}
		FDS(i,N){
			sumsum+=abs(nakanaka-A[i]);
		}
		cout<<min(sum,sumsum)<<endl;
	}
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
   int H,W,i,j;
   for(;;){
      scanf("%d %d",&H,&W);
      if(H==0&&W==0) break;
      for(i=0;i<H;i++){
         for(j=0;j<W;j++)
            printf("#");
         printf("\n");
      }
   printf("\n");
   }
   return 0;
}



Measured memory_bytes: 2044
while True:
  a, op, b = input().split()
  a, b = int(a), int(b)
  if op == '?':
    quit()
  else:
    if op == '+':
      result = a+b
    elif op == '-':
      result = a-b
    elif op == '*':
      result = a*b
    elif op == '/':
      result = int(a/b)
    print(result)

Measured memory_bytes: 7664
#include<stdio.h>

int main() {
  long long sum = 0;
  int N, A[200000];
  scanf("%d", &N);
  for(int i=0; i<N; i++) {
    scanf("%d", &A[i]);
    sum += A[i];
    sum %= 1000000007;
  }
  
  long ans = 0;
  for(int i=0; i<N; i++) {
    sum -= A[i];
    if (sum < 0) sum += 1000000007;
    
    ans += sum * A[i];
    ans %= 1000000007;
  }
  
  printf("%ld", ans);
  return 0;
}

Measured memory_bytes: 2416
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	s := make([]string, h)
	for i := 0; i < h; i++ {
		fmt.Scan(&s[i])
	}
	result := ""
	for i := 0; i < h; i++ {
		for k := 0; k < w; k++ {
			str := []byte{}
			if s[i][k] == '.' {
				if 0 < i {
					str = append(str, eight(s[i-1], k, w)...)
				}
				if i < h-1 {
					str = append(str, eight(s[i+1], k, w)...)
				}
				str = append(str, eight(s[i], k, w)...)
				total := 0
				for _, s := range str {
					if s == '#' {
						total++
					}
				}
				result += strconv.Itoa(total)
			} else {
				result += "#"
			}
		}
		result += "\n"
	}
	fmt.Print(result)
}

func eight(s string, k int, w int) []byte {
	str := []byte{}
	str = append(str, s[k])
	if 0 < k {
		str = append(str, s[k-1])
	}
	if k < w-1 {
		str = append(str, s[k+1])
	}
	return str
}

Measured memory_bytes: 4352