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

int main(){
  long long int n, a, b;
  cin >> n >> a >> b;
  if(a > b) cout << 0 << endl;
  else if(n == 1){
    if(a == b) cout << 1 << endl;
    else cout << 0 << endl;
  }
  else {
    long long int ans = (n - 2) * b - (n - 2) * a + 1;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int r;
	cin >> r; 
	cout << r * r << endl;
	return 0;
}



Measured memory_bytes: 3608
#include <cstddef>
#include <cstdint>
#include <vector>

namespace null_null {

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using usize = std::size_t;

template <typename T>
std::vector<T> make_v(usize a) { return std::vector<T>(a); }
template <typename T, typename... Ts>
auto make_v(usize a, Ts... ts) {
  return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename std::enable_if<std::is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V>
typename std ::enable_if<std::is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

template <typename T, typename V>
inline void chmin(T &a, V b) {
  if (a > b) a = b;
}
template <typename T, typename V>
inline void chmax(T &a, V b) {
  if (a < b) a = b;
}

} // namespace null_null

#include <algorithm>
#include <iostream>
#include <utility>

namespace null_null {

void main_() {
  usize n;
  std::cin >> n;
  std::vector<i32> p(n);
  for (usize i = 0; i < n; i++) std::cin >> p[i];

  i32 ans = 0;
  for (usize i = 1; i < n - 1; i++) {
    if (p[i - 1] < p[i] && p[i] < p[i + 1]) {
      ans++;
    }
    if (p[i - 1] > p[i] && p[i] > p[i + 1]) {
      ans++;
    }
  }

  std::cout << ans << std::endl;
}

} // namespace null_null

int main() {
  null_null::main_();
  return 0;
}


Measured memory_bytes: 256
import heapq
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]
ab.sort()
queue = []
flag = 0
heapq.heapify(queue)
ans = 0
for i in range(1,m+1):
  for j in range(flag,n):
    if ab[j][0] <= i:
      heapq.heappush(queue,-ab[j][1])
      flag += 1
    else:
      break
  if queue != []:
    k = heapq.heappop(queue)
    ans += k
print(-ans)

Measured memory_bytes: 78808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m, q;
    cin >> n >> m >> q;
    int cnt[n][n] = {};
    rep(i, 0, m) {
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        cnt[l][r]++;
    }

    int sum[n + 1][n + 1] = {};
    rep(l, 0, n) {
        rep(r, 0, n) {
            sum[l + 1][r + 1] = sum[l + 1][r] + cnt[l][r];
        }
    }
    rep(r, 0, n) {
        rep(l, 0, n) {
            sum[l + 1][r + 1] += sum[l][r + 1];
        }
    }

    int L[q], R[q];
    rep(i, 0, q) {
        cin >> L[i] >> R[i];
    }

    rep(i, 0, q) {
        int ans = sum[R[i]][R[i]] - sum[R[i]][L[i] - 1] - sum[L[i] - 1][R[i]] + sum[L[i] - 1][L[i] - 1];
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3712
//Daniel Grzegorzewski
#include <bits/stdc++.h>

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

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

string s;
int res;

signed main()
{
    init_ios();
    cin >> s;
    int n = s.size();
    for (int i = 0; i < (1<<(n-1)); ++i) {
    	int tmp = 0;
    	for (int j = 0; j < n; ++j) {
    		tmp = 10*tmp+(int)(s[j]-'0');
    		if (i&(1<<j)) {
    			res += tmp;
    			tmp = 0;
    		}
    	}
    	if (!(i&(1<<(n-1))))
    		res += tmp;
    }
    cout<<res<<"\n";
}

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

int main(){
    string s;
    long ssize;
    long long int K;
    string formap="bcdefghijklmnopqrstuvwxyza";
    unordered_map <char,int> amade;
    for(int i=0;i<=25;i++){
        amade[formap[i]]=25-i;
    }

    cin >> s;
    ssize =s.size();
    cin >> K;
    for(long i=0;i<ssize-1;i++){
        if(amade[s[i]]<=K){
            K-=amade[s[i]];
            s[i]='a';
            //cout << "K:" << K <<"\n";
        }
    }

    int temp=(amade[s[ssize-1]]-K%26+26)%26;
    //cout << temp << endl;
    s[ssize-1]=formap[25-temp];
    
    cout << s << "\n";
    return 0;
}

Measured memory_bytes: 512
def main():
    N = int(input())
    S = list(input())

    result = S[0]
    for i in range(len(S)-1):
        if(S[i] != S[i+1]):
            result += S[i+1]

    #print(result)
    print(len(result))



if __name__ == "__main__":
    main()

Measured memory_bytes: 4084
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String w = sc.next();
        String t;
        int cnt = 0;
        while(true){
            t = sc.next();
            if(t.equals("END_OF_TEXT")) break;
            if(t.equalsIgnoreCase(w)) cnt++;
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 25984
from operator import itemgetter

n=int(input())
arr=[]
for z in range(n):
  name,point=input().split(" ")
  point=int(point)
  arr.append((name,point,z+1))
  arr=sorted(arr,key=itemgetter(1),reverse=True)
  arr=sorted(arr,key=itemgetter(0))

for z in arr:
  print(z[2])

Measured memory_bytes: 3188
N, A, B = map(int, input().split())
sumS = 0
for x in range(1, N + 1, 1):
    count = 0
    S = str(x)
    for y in range(len(str(x))):
        count += int(S[y])
    if count >= A and count <= B:
        sumS += x
print(sumS)


Measured memory_bytes: 40684
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,op,b=split(readline())
    if op=="+"
        println(parseInt(a)+parseInt(b))
    else
        println(parseInt(a)-parseInt(b))
    end
end
main()

Measured memory_bytes: 113304
n,a,b=map(int,input().split())
s=input()
cnt=0
foreign=0
for i in range(n):
  if s[i]=="a":
    if cnt<a+b:
      print("Yes")
      cnt+=1
    else:
      print("No")
  elif s[i]=="b":
    foreign+=1
    if cnt<a+b and foreign<=b:
      print("Yes")
      cnt+=1
    else:
      print("No")
  elif s[i]=="c":
    print("No")

Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
int dp[200001][2];
string s;
int main(){
	ios::sync_with_stdio(false);
	cin >> s;
	int n=s.size();s='?'+s;
	for(int i=1; i<=n ;i++){
		dp[i][1]=dp[i][2]=-1e9;
	}
	dp[1][1]=1;
	for(int i=2; i<=n ;i++){
		dp[i][1]=max(dp[i][1],dp[i-1][2]+1);
		if(s[i]!=s[i-1]) dp[i][1]=max(dp[i][1],dp[i-1][1]+1);
		dp[i][2]=max(dp[i][2],dp[i-2][1]+1);
		if(i<=3 || s[i]!=s[i-2] || s[i-1]!=s[i-3]) dp[i][2]=max(dp[i][2],dp[i-2][2]+1);
	}
	cout << max(dp[n][1],dp[n][2]) << endl;
}

Measured memory_bytes: 2128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

// 2 4 8
// 2 4 6: 1 -> 2.5 > 4.25
// 6 4 2: 3 -> 

using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

bool dfs(int goal, int cur,int distance, const vector<vector<int> >& vs, vector<bool> &filled) {
	if (filled[cur]) {
		if (goal == cur) {
			//cout << "* cur:" << cur << " goal:" << goal << " dist:" << distance << endl;
			return distance >= 3;
		} else {
			return false;
		}
	} 

	filled[cur] = true;
	for (int v : vs[cur]) {
		//cout << "goal:" << goal << "cur:" << cur << " v:" << v << endl;
		if (dfs(goal, v, distance + 1, vs, filled)) {
			return true;
		}
	}

	return false;
}

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

	vector<vector<int> > vs(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		vs[a].push_back(b);
		vs[b].push_back(a);
	}
	vector<bool> on_loop(n,false);

	rep(i, n) {
		vector<bool> filled(n,false);

		if (dfs(i, i, 0, vs, filled)) {
			on_loop[i] = true;
		}
	}
	int count = 0;

	for(int x = 0; x < n; x++) { 
		for (int y : vs[x]) {
			if (x >= y) {
				continue;
			}
			if (on_loop[x] == false || on_loop[y] == false) {
				count++;
			}

		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const int INF = (1<<30)-1;
const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  ll n, h;
  cin >> n >> h;
  vl a(n), b(n);
  rep(i,n) cin >> a[i] >> b[i];
  sort(b.rbegin(), b.rend());
  ll ma = *max_element(rng(a));
  ll ans = 0;
  rep(i,n) {
    if (h <= 0) break;
    if (b[i] > ma) {
      h -= b[i];
      ans++;
    }
    else break;
  }
  if (h > 0) ans += dup(h, ma);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
using namespace std;

int main(){
  int a, b, d, r;
  double f;
  cin >> a >> b;

  d = a / b;
  r = a % b;
  f = ((double) a) / b;

  printf("%d %d %8f\n",d, r, f);




}



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

int main(){

    string a[3];

    rep(i,3) cin >> a[i];

    rep(i,3){
        cout << a[i][i];
    }
    cout << endl;

    return 0;
}

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

int main()
{
    int n;
    cin>>n;
    int num[n];
    for(int i=0; i<n;i++) {
        cin>>num[i];
    }
    for(int i=0; i<n;i++) {
        for(int s=0; s<i; s++){
        if(num[i]<num[s]){
            swap(num[i],num[s]);
        }
        }
        for(int t=0; t<n-1;t++){
            cout<<num[t]<<" ";
        }
        cout<<num[n-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3072
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

#define MAX_V 200000

typedef pair<long long int, long long int> P;
long long int INF = 1e18;

struct edge{
	int to;
	long long int cost;
};

vector<edge> G[MAX_V];
long long int d[MAX_V];

// 速さはO(|E|log|V|)

void shortest_path(int s, int V){ // Vは頂点数
	
	priority_queue<P, vector<P>, greater<P> > que;
	
	for(int i = 0; i < V; i++){
		d[i] = INF;
	}
	d[s] = 0;
	
	que.push(P(0, s));
	
	while(!que.empty()){
		
		P p = que.top();
		que.pop();
		
		int v = p.second;
		
		if(d[v] < p.first){
			continue;
		}
		
		for(int i = 0; i < G[v].size(); i++){
			edge e = G[v][i];
			if(d[e.to] > e.cost + d[v]){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		} // 頂点への最小コストを更新
	}
}

int main(){
	
	int V;
	cin >> V;
	
	for(int i = 0; i < V; i++){
		int u, num;
		cin >> u >> num;
		for(int j = 0; j < num; j++){
			edge e;
			cin >> e.to >> e.cost;
			G[u].push_back(e);
		}
	}
	
	shortest_path(0, V);
	
	for(int i = 0; i < V; i++){
		cout << i << " " << d[i] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 16636
#include <stdio.h>
#include <string.h>
 
int main(){
    char str[33];
    char ls[1000][33] = {0};
    int  len = 0, i, j;
    int  num[1000] = {0};
     
    while(scanf("%s", str) != EOF){
        if('A' <= str[0] && str[0] <= 'Z')
            str[0] -= 'A';
                
        strcpy(ls[len++], str);
    }
    
    strcpy(str, ls[0]);
    
    for(i = 1; i <= len; i++){
        if(strlen(str) < strlen(ls[i]))
            strcpy(str, ls[i]);
            
        for(j = i; j <= len; j++)
            if(!strcmp(ls[i], ls[j])) num[i]++;
    }
            
    for(i = 1, j = 0; i <= len; i++)
        if(num[j] < num[i]) j = i;
            
    printf("%s %s\n", ls[j], str);
    
    return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#define int long long
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
using namespace std;
static const int INF = 1ll<<60;
typedef pair<int,int> pii;

struct P{
    int x;
    int y;
    P(){}
    P(int p1,int p2){
        x=p1;
        y=p2;
    }
};


int W,H;
int N;
int dis[100010];
vector<int> posx;
vector<int> posy;
vector<P> pos;

int dist(int x,int y){
    int res=0;
    for(int i=0;i<N;++i){
        int disx=abs(x-pos[i].x);
        int disy=abs(y-pos[i].y);
        dis[i]=disx+disy;
    }
    sort(dis,dis+N);
    for(int i=0;i<N-1;++i)res+=dis[i]*2;
    res+=dis[N-1];
    return res;
}

signed main(){
    cin>>W>>H;
    cin>>N;
    for(int i=0;i<N;++i){
        int x,y;
        cin>>x>>y;
        posx.PB(x);
        posy.PB(y);
        pos.PB(P(x,y));
    }
    if(N%2!=0){
        sort(posx.begin(),posx.end());
        sort(posy.begin(),posy.end());
        int x=posx[N/2];
        int y=posy[N/2];
        int ans=dist(x,y);
        cout<<ans<<endl;
        cout<<x<<" "<<y<<endl;
    }
    else{
        sort(posx.begin(),posx.end());
        sort(posy.begin(),posy.end());
        int ans=INF;
        int x,y;
        int d1=dist(posx[N/2-1],posy[N/2-1]);
        int d2=dist(posx[N/2-1],posy[N/2]);
        int d3=dist(posx[N/2],posy[N/2-1]);
        int d4=dist(posx[N/2],posy[N/2]);
        if(ans>d1){
            ans=d1;
            x=posx[N/2-1];
            y=posy[N/2-1];
        }
        if(ans>d2){
            ans=d2;
            x=posx[N/2-1];
            y=posy[N/2];
        }
        if(ans>d3){
            ans=d3;
            x=posx[N/2];
            y=posy[N/2-1];
        }
        if(ans>d4){
            ans=d4;
            x=posx[N/2];
            y=posy[N/2];
        }
        cout<<ans<<endl;
        cout<<x<<" "<<y<<endl;
    }
}

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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

int main()
{
    solve();
}

void solve()
{
    ll a, b, c, k;
    in2(a, b);
    in2(c, k);
    if (a > k)
    {
        out(k);
    }
    else if (a + b > k)
    {
        out(a);
    }
    else
    {
        out(a - (k - a - b));
    }
}

Measured memory_bytes: 3528
#include <stdio.h>

int main()
{
	double v;
	double y;
	int n;
	while(scanf("%lf",&v) != EOF){
		y = v * v / 19.6;
		n = y / 5;
		if(n * 5 != y){
			n++;
		}
		printf("%d\n",n+1);
	}
	return 0;
}

Measured memory_bytes: 1056
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String s=sc.next();
		int x=0;
		int data=x;
		
		for(int i=0;i<n;i++){
			if(s.charAt(i)=='I')x++;
			else if(s.charAt(i)=='D')x--;
			if(data<x)data=x;
		}
		System.out.println(data);
	}

}


Measured memory_bytes: 9804
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  string S;
  cin>>S;
  int left = 0, right = 0;
  for(int i=0;i<N;++i) {
    if(S[i]=='(') {
      right++;
    }
    else {
      if(right>0) right--;
      else left++;
    }
  }
  for(int i=0;i<left;++i) cout<<'(';
  cout<<S;
  for(int i=0;i<right;++i) cout<<')';
  cout<<endl;
}



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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, M;
    cin >> N >> M;
    vec s(M), c(M);
    REP(i,0,M) {
        cin >> s[i] >> c[i];
        --s[i];
    }

    ll d = 1;
    bool f = true;
    REP(i,0,N) d *= 10;
    REP(i,N==1?0:d/10,d) {
        string S = to_string(i);
        f = true;
        REP(j,0,M) {
            if(!(s[j] < SZ(S) && S[s[j]]-'0' == c[j])) {
                f = false;
                break;
            }
        }
        if(f) {
            PR(i);
            break;
        }
    }
    if(!f) PR(-1);

    return 0;
}

/*



*/

Measured memory_bytes: 3648
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::max($x, max!($($y),+))
    };
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::min($x, max!($($y),+))
    };
}

const MOD: usize = 1_000_000_007;
const MAX: usize = 510_000;

struct BinCoeff {
    fac: Vec<usize>,
    finv: Vec<usize>,
    inv: Vec<usize>,
}

impl BinCoeff {
    fn new() -> BinCoeff {
        let fac = vec![0; MAX];
        let finv = vec![0; MAX];
        let inv = vec![0; MAX];
        let mut bincoeff = BinCoeff { fac: fac, finv: finv, inv: inv };
        bincoeff.com_init();
        bincoeff
    }

    fn com_init(&mut self) {
        let fac = &mut self.fac;
        let finv = &mut self.finv;
        let inv = &mut self.inv;
        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;
        for i in 2..MAX {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    fn bin_coeff(&mut self, n: usize, k: usize) -> usize {
        if k > n/2 {
            self.bin_coeff(n-k, k)
        } else {
            self.fac[n] * (self.finv[k] * self.finv[n - k] % MOD) % MOD
        }
    }
}

use std::cmp;
use std::collections::{HashSet, BinaryHeap, VecDeque, HashMap};
use std::iter::FromIterator;
fn main() {
    input!{
        N: usize
    }
    println!("{}", 180*(N-2));
}


Measured memory_bytes: 4352
import sys
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value

N, K = mi()
    
cnt_n = 0
ini_n = K
#while ini_n <= N:
    #cnt_n += 1
    #ini_n += K
cnt_n = N // K

ans = cnt_n ** 3

if K % 2 == 0:
    ini_k = K // 2
    '''
    cnt_k = 0
    while ini_k <= N:
        cnt_k += 1
        ini_k += K
    ans += cnt_k ** 3
    '''
    if N >= ini_k:
        ans += ((N - ini_k) // K + 1)**3

print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int ans = 0;
            for(int i = 1; i <= n; i++)
            {
                string a = i.ToString();
                if(a.Length % 2 == 1)
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
            Console.ReadLine();
        }
    }
}


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

void solve(long long N, std::vector<long long> v)
{
    long double max;

    sort(v.begin(), v.end());
    long double ave = (v[0] + v[1]) / 2.0;
    for (int i = 2; i < N; i++)
    {
        ave = (ave + v[i]) / 2;
    }
    cout << ave << endl;
}

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


Measured memory_bytes: 256
k=input().split()
a=int(k[0])
b=int(k[1])
c=int(k[2])
if(a>=c):
    a=a-c
else:
    b=(b+a)-c
    a=0
if(b<0):
    print(0,0)
else:        
 print(a,b)    


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    string s;
    cin>>s;
    if(s[0]!='9'&&s[1]!='9'){
        No;
    }
    else{
        Yes;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<60;
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; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;

const int maxv = 100005;

deque<int> d;

bool isOK(ll mid, ll key){
    if (key > d[mid]) return true;
    else return false; 
}

ll binary_search(ll key){
    ll ng = -1;
    ll ok = d.size();

    while(abs(ok-ng)>1){
        int mid = (ok+ng) / 2;

        if(isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(){
    int N; cin >> N;
    //cout << endl;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    rep(i,N){
        ll a = A[i];
        ll index = binary_search(a);
        //cout << index << endl;
        if (index != d.size()){
            d[index] = a;
        }else{
            d.push_back(a);
        }
    }
    /*
    cout << endl;
    rep(i,d.size()) cout << d[i] << endl;
    cout << endl;
    */
    cout << d.size() << endl;

}

Measured memory_bytes: 4488
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<vector>
#define LL long long
#define maxn 1000009

using namespace std;

const LL MOD = 1e9+7;
int aa[maxn];
int id[maxn];
LL fact[maxn+5];	//阶乘
LL a[maxn+10];	// 乘法逆元
//LL inv[maxn+10];	//快速幂

LL pow(LL x)
{
	LL n = MOD-2;
    LL res=1;
	while(n>0)
	{
	   if(n%2==1)
	   	 res=res*x%MOD;
	   x=x*x%MOD;
	   n>>=1;
	}
	return res;
}

void init(){
    a[0] = a[1] = 1;
    fact[0] = fact[1] = 1;
//  inv[1] = 1;
    for(int i = 2; i <= 1000005; i++)
    {
        fact[i] = fact[i-1] * i % MOD;
		a[i] = a[i-1] * pow(i) % MOD;	//m!的MOD次方 = (m-1)!的MOD次方 * m的MOD次方
//      inv[i] = (MOD - MOD/i)*inv[MOD%i]%MOD;
//      a[i] = a[i-1] * inv[i] % MOD;
    }
}

LL C(int n, int m){	//乘法逆元
	if(n<0||m<0||n<m)return 0;
    return fact[n]*a[n-m]%MOD*a[m]%MOD;
}

int main()
{
	int n,m;
	init();

    cin>>n;
    int x1,x2;
    n++;
    for(int i=1;i<=n;i++)
    {
        cin>>aa[i];
        if(id[aa[i]]==0)
        {
            id[aa[i]]=i;
        }
        else
        {
            x1=id[aa[i]];
            x2=i;
        }
    }
   m=n-x2+x1-1;
   for(int i=1;i<=n;i++)
    {
        LL sum=C(n,i)-C(m,i-1);
        sum%=MOD;
        sum=(sum+MOD)%MOD;
        cout<<sum<<endl;
    }
	return 0;
}


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

int main()
{
        string S;
        cin >> S;
        ll ans = 0;
        for (int i = 0; i < 3; ++i) {
                if (S[i] == '1') {
                        ans++;
                }
        }
        cout << ans << endl;


}


Measured memory_bytes: 3620
//ll _(){
//    ll n;
//    cin >> n;
//    vl arr(n);
//    cin >> arr;
//    vl psum(n+1);
//    rep(i,1,n)
//        psum[i] = psum[i-1]+arr[i-1];
//    ll ans = INF;
//    rep(i,1,n-1)
//        ans = min(ans,abs(psum[i]-(psum[n]-psum[i])));
//    return ans;
//}
//
//
//
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define REP_INT(i,l,r) for(int i = l; i <= r; ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
const ll INF = ll(2e18) + 666;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
T1 istream& operator>>(istream& stream, vector<T>& t){
    return read(all(t), stream);
}
T1 istream& read(T b, T e, istream& stream){
    for(T it = b; it != e; ++it)
        stream >> *it;
    return stream;
}
ll _(){
    ll n;
    cin >> n;
    vl arr(n);
    cin >> arr;
    vl psum(n+1);
    rep(i,1,n)
        psum[i] = psum[i-1]+arr[i-1];
    ll ans = INF;
    rep(i,1,n-1)
        ans = min(ans,abs(psum[i]-(psum[n]-psum[i])));
    return ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        cout << _() << '\n';
}


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

#define db(x) cerr << #x << " == " << x << endl
#define all(container) container.begin(), container.end()
#define mp(i,j) make_pair(i,j)
#define pb push_back

typedef pair<int,int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vii;

template<typename T>
void print_vector_debug(const T& t) {
	cout << "[DEBUG] VECTOR:";
	for (auto i = t.cbegin(); i != t.cend(); ++i) {
		if ((i + 1) != t.cend()) {
			cout << *i << " ";
		} else {
			cout << *i << endl;
		}
	}
}

const int MAXN = 1e5 + 5;

int N;
int K;
int vals[MAXN];
int dp[MAXN];
int vis[MAXN];

int solve(int idx)
{
	if (idx == N - 1)
	{
		return 0;
	}
	
	if (vis[idx])
	{
		return dp[idx];
	}
	vis[idx] = 1;
	
	int res = 2000000000;
	for (int k = 1; k <= K; k++)
	{
		if (idx + k < N)
		{
			res = min(res, solve(idx + k) + abs(vals[idx] - vals[idx + k]));
		}
	}
	dp[idx] = res;
	
	return res;
}

int main() 
{
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &vals[i]);
		
	}
	
	printf("%d\n", solve(0));
	return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
template <typename T>
std::ostream &operator<<(std::ostream &out, std::vector<T> const &cont) {
    for (auto &i : cont) {
        out << i << ' ';
    }
    return out;
}
template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &out, std::pair<T1, T2> const &p) {
    out << '{' << p.first << ", " << p.second << "}";
    return out;
}
#define imie(...) __debug_print(#__VA_ARGS__, __VA_ARGS__)
#ifdef __GLIBCXX_DEBUG
template <typename Arg1>
void __debug_print(const char *name, Arg1 &&arg1) {
    cerr << "[" << name << ": " << arg1 << "]" << endl;
}
template <typename Arg1, typename... Args>
void __debug_print(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr << "[";
    cerr.write(names, comma - names) << ": " << arg1 << "],  ";
    __debug_print(comma + 2, args...);
}
#else
#pragma GCC optimize("O2")
void __debug_print(const char *, ...) {}
#endif

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    double DP[N + 1];
    memset(DP, 0, sizeof DP);
    double probs[N];
    DP[0] = 1;
    for (double &i : probs)
        cin >> i;
    for (int i = 1; i <= N; ++i) {
        for (int j = i - 1; j >= 0; --j) {
            DP[j + 1] = DP[j] * probs[i - 1] + DP[j + 1] * (1 - probs[i - 1]);
        }
        DP[0] *= (1 - probs[i-1]);
    }
    double ans = 0;
    for (int i = 1; i <= N; ++i) {
        if (i > N - i)
            ans += DP[i];
    }
    cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 3776
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cctype>
#include<cstring>
#include<list>
#include<map>
#include<sstream>
#include<set>
#include<string>
#include<vector>
typedef long long ll;
using namespace std;
#define MN 300005
#define MM 600005
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define RF(i,a,b) for(int i=a;i>=(b);--i)
#define fast  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
int main()
{
   int x,y,z;
   cin>>x>>y>>z;
   swap(x,y);
   swap(x,z);
    cout<<x<<" "<<y<<" "<<z<<endl;
   return 0;
}


Measured memory_bytes: 256
import java.io.*;
class Main {
	static StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
	static int nextInt() throws IOException {
		st.nextToken();
		return (int)st.nval;
	}
	public static void main(String[] args) throws IOException {
		PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
		int k = nextInt(), s = nextInt(), ans = 0;
		for(int x=0;x<=k && x<=s;++x) {
			for(int y=0;y<=k && y+x<=s;++y) {
				if(s-x-y<=k) ++ans;
			}
		}
		pw.print(ans);
		pw.print('\n');
		pw.flush();
	}
}

Measured memory_bytes: 8404
n = int(input())
d = {}
for _ in range(n):
    s = sorted(input())
    if str(s) in d.keys():
        d[str(s)] += 1
    else:
        d[str(s)] = 1
ans = 0
for i in d.values():
    ans += i*(i-1) // 2
print(ans)

Measured memory_bytes: 21960
#include<iostream>
#include<cstdio>
using namespace std;
int a[100003],n,k;
int main()
{
	cin>>n>>k;
	k--;
	int q;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]==1) q=i;
	}
	int ans=1e9;
	for(int i=0;i<=k;i++)
	{
		int ans1=1,p;
		p=q-i;
		while(p>1)
		{
			ans1++; p-=k;
		}
		p=q+k-i;
		while(p<n)
		{
			ans1++;p+=k;
		}
		ans=min(ans,ans1);
	}
	cout<<ans;
	return 0;
}

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

const int N = 1e4L + 11;
bitset <N> bs;

int main() {
	ios :: sync_with_stdio(0);
	bs[0] = 1;
	int n; cin >> n;
	while(n --) {
		int x; cin >> x;
		bs = bs | (bs << x);
	}
	int ans = 0;
	for(int i = N - 1; i >= 0; i --) if(i % 10 && bs[i]) {
		ans = i; break;
	}
	cout << ans << '\n';
}

Measured memory_bytes: 256
from collections import deque

H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]


def move(h, w):
    if (0 <= h and h <= H - 1) and (0 <= w and w <= W - 1):
        if s[h][w] == '.':
            return True

    return False


start = (0, 0)
goal = (H - 1, W - 1)

dist = l = [[-1 for _ in range(W)] for _ in range(H)]
dist[0][0] = 0
q = deque()
q.append(start)

flag = False

while q:
    now = q.popleft()
    h, w = now

    next_h, next_w = h, w - 1
    if move(next_h, next_w) and dist[next_h][next_w] == -1:
        dist[next_h][next_w] = dist[h][w] + 1
        q.append((next_h, next_w))

    next_h, next_w = h, w + 1
    if move(next_h, next_w) and dist[next_h][next_w] == -1:
        dist[next_h][next_w] = dist[h][w] + 1
        q.append((next_h, next_w))

    next_h, next_w = h - 1, w
    if move(next_h, next_w) and dist[next_h][next_w] == -1:
        dist[next_h][next_w] = dist[h][w] + 1
        q.append((next_h, next_w))

    next_h, next_w = h + 1, w
    if move(next_h, next_w) and dist[next_h][next_w] == -1:
        dist[next_h][next_w] = dist[h][w] + 1
        q.append((next_h, next_w))

white = 0
for i in s:
    white += i.count('.')

ans = white - 2 - (dist[H - 1][W - 1] - 1)

if dist[H - 1][W - 1] == -1:
    print(-1)
else:
    print(ans)

# print(dist)


Measured memory_bytes: 40940
#include<iostream>
using namespace std;
int main()
{
	int a;
	cin>>a;
	if(a==1)  cout<<"1"<<endl;
	if(a>=2 && a<=3)   cout<<"2"<<endl;
	if(a>=4 && a<=7)   cout<<"4"<<endl;
	if(a>=8 && a<=15)   cout<<"8"<<endl;
	if(a>=16 && a<=31)   cout<<"16"<<endl;
	if(a>=32 && a<=63)   cout<<"32"<<endl;
	if(a>=64)   cout<<"64"<<endl;
	return 0;
}

Measured memory_bytes: 256
# -*- coding:utf-8 -*
s = int(input())
n_list = []
n_list.append(s)
end_flag = False
while not end_flag:
    if n_list[-1]%2 == 0:
        if (n_list[-1]/2) in n_list:
            print(len(n_list)+1)
            end_flag = True
        else:
            n_list.append(n_list[-1]/2)
    else:
        if (3*(n_list[-1])+1) in n_list:
            print(len(n_list)+1)
            end_flag = True
        else:
            n_list.append(3*(n_list[-1])+1) 


Measured memory_bytes: 3060
import sys  
sys.setrecursionlimit(200000)
n=int(raw_input())
tr=[[] for i in range(n)]
for i in range(n-1) :
  a,b,c=map(int,raw_input().split())
  a -= 1
  b -= 1
  tr[a].append((b,c))
  tr[b].append((a,c))
m,k=map(int,raw_input().split())
k -= 1
dis=[0 for i in range(n)]
def dfs(u,w=-1,l=0) :
  dis[u]=l
  for v,v1 in tr[u] :
    if v!=w :
      dfs(v,u,l+v1)
dfs(k)
for i in range(m) :
  x,y=map(int,raw_input().split())
  x-=1
  y-=1
  print dis[x]+dis[y]

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define pb push_back
#define f first
#define s second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const int MAXN = 100100;
const ll MOD = 1e9+7;

int l[MAXN], r[MAXN];
int cnt[MAXN];

int main()
{
    FAST_IO;

    string s; cin >> s;
    int n = s.size();

    FOR(i, 1, n-1) {
        if (s[i] == 'L') l[i] = l[i-1]+1;
    }
    for (int i = n-2; i >= 0; i--) {
        if (s[i] == 'R') r[i] = r[i+1]+1;
    }

    FOR(i, 0, n-1) {
        if (s[i] == 'L') {
            int m = l[i];
            if (m & 1) cnt[i-m+1]++;
            else cnt[i-m]++;
        } else {
            int m = r[i];
            if (m&1) cnt[i+m-1]++;
            else cnt[i+m]++;
        }
    }

    FOR(i, 0, n-1) cout << cnt[i] << " ";
    cout << endl;

    return 0;
}


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

const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int SUMN = 1e5 + 2;
const int N = 1e2 + 2;

int n, w, sum;
int weight[N], value[N];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
	
	cin >> n >> w;

	for (int i = 1; i <= n; ++i) {
		cin >> weight[i] >> value[i];
		sum += value[i];
	}

	vector<vector<ll>> dp(n + 1, vector<ll>(sum + 1, INFLL));
	dp[0][0] = 0;

	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j <= sum; ++j) {
			dp[i][j] = dp[i-1][j];
			if (value[i] <= j) 
				dp[i][j] = min(dp[i][j], dp[i-1][j-value[i]] + weight[i]);
		}
	}

	int ans = 0;
	for (int i = 0; i <= sum; ++i) {
		if (dp[n][i] <= w) {
			ans = max(ans, i);
		}
	}

	cout << ans << "\n";
	
	return 0;
}


Measured memory_bytes: 80256
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
    int k;
	double x[3],y[3],a,b,c,d,e,f,l,m,n;
    cin>>k;
	while(k-->0){
        cin>>x[0]>>y[0]>>x[1]>>y[1]>>x[2]>>y[2];
        a=2*(x[1]-x[0]);
        b=2*(y[1]-y[0]);
        c=(x[1]*x[1])+(y[1]*y[1])-(x[0]*x[0])-(y[0]* y[0]);
        d=2*(x[2]- x[0]);
        e=2*(y[2]- y[0]);
        f=(x[2]*x[2])+(y[2]*y[2])-(x[0]*x[0])-(y[0]*y[0]);
        l=(c*e-f*b)/(a*e-d*b);
        m=(c*d-f*a)/(b*d-e*a);
        n=sqrt((l-x[0])*(l-x[0])+(m-y[0])*(m-y[0]));
        printf("%.3f %.3f %.3f\n",l,m,n);
    }
    return 0;
}

Measured memory_bytes: 0
/*
  x + y^2 + z^3 = e テ」ツ?ォテ」ツ?甘」ツ??」ツ?ヲテ」ツ?』,y,zテ」ツ?ョテ」ツ??」ツ?。2テ」ツ?、テ」ツ?古・ツ按?」ツ?凝」ツつ古」ツ?ーテヲツョツ凝」ツつ甘」ツ?ョ1テ」ツ?、テ」ツつづヲツアツづ」ツ?セテ」ツつ凝」ツ??
  テ・ツ、ツ嘉ヲツ閉ーテ」ツ?ョテ・ツ?、テ」ツ?ョテ・ツ?凖ィツ」ツ愿」ツ?ョテヲツ閉ーテ」ツ?ッz,y,xテ」ツ?ョテゥツ??」ツ?ァテ・ツーツ妥」ツ?ェテ」ツ?敕」ツ??」ツ?ェテ」ツ?ョテ」ツ?ァz,yテ」ツ?ョテゥツ??」ツ?ァテ・ツ?ィテゥツ?堙」ツつ甘ィツゥツヲテ」ツ?凖」ツ??
 */

#include <stdio.h>
#define INF (1<<28)

int main() {
  int e, m, x, y, z, v;
  while(scanf("%d", &e) != EOF && e != 0) {
    m = INF;
    for(z = 0; z*z*z <= e; ++z) {
      for(y = 0; z*z*z + y*y <= e; ++y) {
        x = e - y*y - z*z*z;
        v = x + y + z;
        if(v < m) {
          m = v;
        }
      }
    }
    printf("%d\n", m);
  }
  return 0;
}

Measured memory_bytes: 1028
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  int key;
  struct node *prev;
  struct node *next;
};

typedef struct node * NodePointer;
NodePointer nil;

/*NodePointer listSearch(int key){
  NodePointer t;
  for(t = nil -> next; t != nil; t = t -> next){
    if(t -> key == key){
      return t;
    }
  }
}*/

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  if(t -> next == nil){
    nil -> prev = t -> prev;
    t -> prev -> next = nil;
    free(t);
  }else if(t -> prev == nil){
    nil -> next = t -> next;
    t -> next -> prev = nil;
    free(t);
  }else{
    t -> prev -> next = t -> next;
    t -> next -> prev = t -> prev;
    free(t);
  }
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t = nil -> prev;
  if(t == nil) return;
  deleteNode(t);
}

void delete(int key){
  struct node *n;
  if(nil -> key == key){
    deleteFirst();
    return;
  }
  for(n = nil -> next; n != nil; n = n -> next){
    if(n -> key == key){
      deleteNode(n);
      return;
    }
  }
}



void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  if(nil -> next == nil){
    nil -> prev = x;
  }

  x -> next = nil -> next;
  x -> prev = nil;
  nil -> next -> prev = x;
  nil -> next = x;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}

Measured memory_bytes: 31788
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2198

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

struct Crop {
	string name;
	double ef;
	bool operator<( const Crop& right ) const {
		if(ef == right.ef){
			return name < right.name;
		}else{
			return ef > right.ef;
		}
	}
};

int main()
{
	int N;

	while(cin >> N && N)
	{
		vector<Crop> crops;
		rep(nth,N)
		{
			string L;
			int P,A,B,C,D,E,F,S,M;
			cin >> L >> P >> A >> B >> C >> D >> E >> F >> S >> M;
			double income = ((S * F) * M) - P;
			double time = A + B + C + ((D + E)*M);
			crops.push_back({L,income/time});
		}

		sort(ALL(crops));

		rep(i,crops.size()){ 
			cout << crops[i].name << endl;
		}
		cout << "#" << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
const ll INF = 1<<30;
const ll MOD = 1e9+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll dp[3030][3030][2];

int main(){
    ll N, T; cin >> N >> T;
    vector<pair<ll,ll> > AB(N);
    rep(i,N){ ll a,b; cin >> a >> b; AB[i] = make_pair(a,b); }

    dp[0][0][0] = 0;
    ll res = 0;
    rep(i,N){
        rep(j,T){
            rep(k,2){
                chmax(dp[i+1][j][k], dp[i][j][k]);
                if(j-AB[i].first>=0){
                    chmax(dp[i+1][j][k], dp[i][j-AB[i].first][k] + AB[i].second);
                }
                if(k==0){
                    chmax(dp[i+1][j][1], dp[i][j][k] + AB[i].second);
                }
            }
        }
    }

    rep(j,T){
        rep(k,2){
            chmax(res, dp[N][j][k]);
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 143616
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <iterator>
using namespace std;
int main()
{
	int n,l,i;
	cin>>n>>l;
	vector <string> var;
	for(i=0 ; i<n ; i++){
		string inp;
		cin>>inp;
		var.push_back(inp);
	}
	sort(var.begin(),var.end());
	for(auto itr=var.begin() ; itr!=var.end() ; itr++){
		cout<<*itr;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256