akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
    int N;
    cin >> N;
    string s;
    cin >> s;
    rep(i, s.size()){
        int a = s[i];
        a += N;
        if(a > 90) a -= 26;
        s[i] = a;
    }
    cout << s << endl;
    return 0;
}

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

w, a, b = MAP()
left = min(a, b)
right = max(a, b)
if left+w < right:
    print(right - (left+w))
else:
    print(0)


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

int main() {
  string s;
  cin >> s;
  string t = "2019/04/30";
  if (s > t) {
    cout << "TBD" << endl;
  } else {
    cout << "Heisei" << endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >>n;

    bool judge=true;

    vector<string>w(n);
    for (int i=0; i<n; i++) {
        cin >>w[i];
    }

    for (int i=0; i<n-1; i++) {
        if(w[i].back() != w[i+1].front()){
            judge=false;
        }
    }

    for (int i=0;i<n; i++) {
        for(int j=i+1; j<n; j++){
            if(w[i]==w[j]){
                judge=false;
            }
        }
    }

    if(judge){
        cout <<"Yes" <<endl;
    }

    else {
        cout <<"No" <<endl;
    }
}


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

using namespace std;

int N, X, T;

int main(void)
{
    cin >> N >> X >> T;

    int time = 0;

    if (N % X == 0)
    {
        time = N / X * T;
    }
    else
    {
        time = ((N / X) + 1) * T;
    }

    cout << time << endl;
}

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

using namespace std;

#define optimize() 		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll				long long
#define pb				push_back
#define w(x)			int x; cin>>x; while(x--)
#define mp      		make_pair
#define F 				first
#define S 				second
#define mod     		1000000007
#define inf     		1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define endl	  		"\n"
#define sp 				" "
#define ca(x) 			"Case "<<x<<": "
#define all(x) 			x.begin(), x.end()
#define loop(i,a,n)		for (int i = a; i < (n); ++i)
#define rloop(i,a,n)	for (int i = n; i >= (a); --i)
#define in(n)			long long n ; cin >> n;
#define ins(s)			string s; cin >> s;
#define yes				cout << "YES"<<"\n"
#define no				cout << "NO"<<"\n"



int main()
{
	optimize();
	//............. S I D A T I V E  H I P N O T I X .............//

	float d, t, s;
	cin >> d >> t >> s;
	if (d / s <= t) cout << "Yes" << endl;
	else cout << "No" << endl;



	return 0;
}



Measured memory_bytes: 3736
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {
	int H, W;
	cin >> H >> W;
	vector<string> s(H);

	for (int i = 0; i < H; i++) {
		cin >> s[i];
	}
	vector<bool> a(H, false);
	vector<bool> b(W, false);

	for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
			if (s[i][j] == '#') {
				a[i] = true;
				b[j] = true;
			}
		}
	}

	for (int i = 0; i < H; i++) {
		if (a[i]) {
			for (int j = 0; j < W; j++) {
				if (b[j]) {
					cout << s[i][j];
				}
			}
			cout<<endl;
		}
		
	}

	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
v_list=list(map(int,input().split()))
ans=0
for i in range(min(k+1,n+1)):
    for j in range(min(k-i+1,n-i+1)):
        List=v_list[:i]+v_list[n-j:]
        Sum=sum(List)
        List.sort()
        count=k-i-j
        x=0
        if List==[]:
            Sum=0
        else:
            while not count==0 and List[x]<0:
                Sum=Sum-List[x]
                count=count-1
                x=x+1
                if x==len(List):
                    break
        ans=max(ans,Sum)
print(ans)
    


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

int N;
int L[50]{};
int a[51]{}; // 累積和
int ans = INT32_MAX;
int x, y; // x <= y

int dp[51]{};

void solve(int l) {
    fill(dp, dp + 51, 100000000);
    
    dp[0] = 0;
    for (int i = 0; i < N; i++) {
        int t = 0;
        for (int j = i; j >= 0; j--) {
            t += L[j];
            // 水ようかん全てを連結したものは除外する
            if(i == N - 1 && j == 0) continue;
            if (t >= l) {
                dp[i + 1] = min(dp[i + 1], max(dp[j], t));  
            }
        }
    }
    ans = min(ans, dp[N] - l);
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    for (int i = 0; i < N; i++) {
        a[i + 1] += a[i] + L[i];
    }
    set<int> s;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j <= N; j++) {
            s.insert(a[j] - a[i]);
        }
    }
    
    // 水ようかんの全体の長さは除外
    s.erase(*s.rbegin());
    for (int i : s) {
        solve(i);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3144
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val s = in.readLine()
    val t = in.readLine()

    out.println(
      if (t.startsWith(s)) {
        "Yes"
      } else {
        "No"
      }
    )

    out.flush()
  }
}


Measured memory_bytes: 54520
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int P = 2019;
        final char[] str = in.nextLine().toCharArray();
        final int N = str.length;
        final int[] digits = new int[N];
        for (int i = 0; i < N; i++) {
            digits[i] = Character.getNumericValue(str[i]);
        }
        final int[] remainders = new int[P];
        remainders[0] = 1;
        int sum = 0;
        int shift = 1;
        long ans = 0;
        for (int pos = N - 1; pos >= 0; pos--) {
            sum = (sum + shift * digits[pos]) % P;
            ans += remainders[sum];
            remainders[sum]++;
            shift = (shift * 10) % P;
        }
        System.out.println(ans);
    }
}


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

int main() {
  int n;
  cin>>n;
  int a[n+1], b[n];
  for (int i=0; i<=n; i++) cin>>a[i];
  for (int i=0; i<n; i++) cin>>b[i];
  long long ans = 0;
  for (int i=0; i<n; i++) {
    ans += min(a[i], b[i]);
    b[i] -= min(a[i], b[i]);
    if (b[i] > 0) {
      long long c = min(a[i+1], b[i]);
      ans += c;
      b[i] -= min(a[i+1], b[i]);
      a[i+1] -= c;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
N = int(input())
robots = []
for _ in range(N):
    X, L = map(int, input().split())
    robots.append([X + L, X - L])
robots.sort()
now = -float("inf")
ans = 0
for i in range(N):
    if robots[i][1] >= now:
        now = robots[i][0]
        ans += 1
print(ans)


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

int main(){
  int a,b;
  while(cin >> a >> b){
    int ans=a+b;
    if(ans>=1000000){
      cout << 7 << endl;
    }else if(ans>=100000){
      cout << 6 << endl;
    }else if(ans>=10000){
      cout << 5 << endl;
    }else if(ans>=1000){
      cout << 4 << endl;
    }else if(ans>=100){
      cout << 3 << endl;
    }else if(ans>=10){
      cout << 2 << endl;
    }else if(ans >=0){
      cout << 1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3008
a = int(input())
b = int(input())
c = int(input())
d = int(input())

if (a>=b):
  if (c>=d):
    print(b+d)
  else:
    print(b+c)
else:
  if (c>=d):
    print(a+d)
  else:
    print(a+c)
      


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    if (a + b >= 2 * c) {
        if (x > y) {
            cout << min(2 * c * y + (x - y) * a, 2 * c * x) << endl;
        } else {
            cout << min(2 * c * x + (y - x) * b, 2 * c * y) << endl;
        }
    } else {
        cout << a * x + b * y << endl;
    }
    return 0;
}

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

typedef long long ll;
char buff[12][1005];
ll n,m,k,ans=0x7fffffff;
ll sum[12][1005];
bool cho[12];
vector<int> V;
ll check(){
    int last=0,tot=0;
    for(int i=1;i<=m;i++){
        for(int j=1;j<V.size();j++){
            if(sum[V[j]][i]-sum[V[j]][last]-sum[V[j-1]][i]+sum[V[j-1]][last]>k){
                if(last==i-1) return 0x7fffffff;
                last=i-1;tot++;
            }
        }
    }return tot;
}
void dfs(int now,int cnt){
    if(now==n) {
        V.push_back(n);
        ans=min(ans,check()+cnt);
        V.pop_back();
        return;
    }
    for(int i=0;i<2;i++){
        cho[i];
        if(i) V.push_back(now);
        dfs(now+1,cnt+i);
        if(i) V.pop_back();
    }
}
int main() {
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++) cin>>(buff[i]+1);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            sum[i][j]=sum[i][j-1]+sum[i-1][j]-sum[i-1][j-1]+(buff[i][j]=='1');
    V.push_back(0);
    dfs(1,0);
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

int n, m;
int k[11];
int a[11][11];
int p[11];

int main()
{
    scanf("%d%d", &m, &n);
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &k[i]);
        for (int j = 0 ; j < k[i] ; ++j)
            scanf("%d", &a[i][j]), a[i][j]--;
    }
    for (int i = 0 ; i < n; ++i)
        scanf("%d", &p[i]);
    int tot = 0;
    for (int i = 0 ; i < (1<<m) ; ++i)
    {
        int ans = 1;
        for (int j = 0; j < n ; ++j)
        {
            int bb = 0;
            for (int z = 0 ; z < k[j] ; ++z)
            {
                bb += bool((1<<a[j][z]) & i);
            }
            ans &= (bb&1) == p[j];
        }
        tot += ans;
    }
    printf("%d\n", tot);
    return 0;
}


Measured memory_bytes: 256
/*
    Author: Wasi Ur Rahman
    From RMSTU
*/
#include <iostream>
#include <cmath>
#include <chrono>
#include <algorithm>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <list>
#include <cstring>
#include <cstdio>
#define  gcd(a,b) __gcd(a,b)
#define  lcm(a,b) (a*b)/gcd(a,b)
#define  PI acos(-1.0)
#define  sqr(x) ((x)*(x))
#define  min3(a,b,c) min(a,min(b,c))
#define  min4(a,b,c,d) min(d,min(a,min(b,c)))
#define  max4(a,b,c,d) max(d,max(a,max(b,c)))
#define  pb             push_back
#define  ln             printf("\n");
#define  fast           ios::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;

int main()
{
    fast;
    ll n;
    cin >> n;
    ll i,j;
    ll sum = 0;
    for( i = 1;i<=n;i++){
        if(i % 3 != 0 && i % 5 != 0)
            sum += i;
    }
    cout << sum << endl;
}
/// Gadha


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005

#define eps 0.0000000000001

struct line{
    ll a,b;
    ld x;
};

ld Cross(line a, line b){
    return (ld)(a.b-b.b)/(b.a-a.a);
}

struct CHT{

    vector <line> s;

    void Insert(ll a, ll b){
        if(s.sz==0){
            s.pb({a,b,-1.0});
        }
        else if(s.sz==1){
            s.pb({a,b,-1.0});
            s[1].x=Cross(s[0],s[1]);
        }
        else{
            line nw={a,b,-1.0};
            while(s.sz>=2){
                if(Cross(s[s.sz-2],s[s.sz-1])-Cross(s[s.sz-1],nw)>-eps) s.pop_back();
                else break;
            }
            nw.x=Cross(s[s.sz-1],nw);
            s.pb(nw);
        }
    }

    ll Qry(ll x){
        ll l=0,r=s.sz-1;
        while(l!=r){
            int mid=(l+r+1)/2;
            if(s[mid].x-x>-eps) r=mid-1;
            else l=mid;
        }
        return s[l].a*x+s[l].b;
    }

};


CHT h;

int n;

ll a[200005],C,dp[200005];

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n >> C;
    for(int i=1;i<=n;i++) cin >> a[i];
    dp[0]=0; h.Insert(-2*a[1],a[1]*a[1]);
    for(int i=2;i<=n;i++){
        dp[i]=h.Qry(a[i])+a[i]*a[i]+C;
        h.Insert(-2*a[i],a[i]*a[i]+dp[i]);
    }
    cout << dp[n];
}


Measured memory_bytes: 13676
N = int(input())
A = [int(a) for a in input().split()]

counter = 0
for a in A:
    tmp = a
    while True:
        if tmp == 0:
            break
        elif tmp % 2 == 0:
            counter += 1
            tmp = tmp // 2
        else:
            break


print(counter)

Measured memory_bytes: 4148
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.run();
    }
    
    // 変数一覧
    String s;
    String t;

    public void run() {
        // 入力情報取得
        Scanner sc = new Scanner(System.in);
        s = sc.next();
        t = sc.next();
        sc.close();

        // 解答処理
        solve();
    }
    
    private void solve() {
        if (t.substring(0, t.length() - 1).equals(s)) {
            System.out.println("Yes");            
        } else {
            System.out.println("No");
        }
    }
}

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

n = int(input())

connect_list = [ [] for i in range(n) ]
distance_list = [ -1 for i in range(n) ]
color_list = [ "Gray" for i in range(n) ]
distance_list[0] = 0

for i in range(n-1):
	u, v, w = [ int(v) for v in input().split() ]
	w %= 2
	connect_list[u-1].append((v-1,w))
	connect_list[v-1].append((u-1,w))
	

search_list = [0]


while search_list != []:
	s = search_list[0]
	for i in connect_list[s]:
		if distance_list[i[0]] == -1:
			distance_list[i[0]] = (distance_list[s] + i[1]) % 2
			search_list.append(i[0])
	del search_list[0]

for i in distance_list:
	print(i)

Measured memory_bytes: 36376
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define rev(i,s,e) for(i64 (i) = (s);(i) --> (e);)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  string s;
  cin >> s;
  for(auto& c: s) {
    c = 'x';
  }
  cout << s << endl;
}


Measured memory_bytes: 256
N=int(input())
S=[input() for _ in range(N)]
cnt=[0]*N
cnt2=[]
flag=0

if len(S)>1:
    for i in range(N):
        if S[i][0]=='M':
            cnt[0]+=1
        elif S[i][0]=='A':
            cnt[1]+=1
        elif S[i][0]=='R':
            cnt[2]+=1
        elif S[i][0]=='C':
            cnt[3]+=1
        elif S[i][0]=='H':
            cnt[4]+=1

for i in range(N):
    if cnt[i]!=0:
        cnt2.append(cnt[i])
        
import math
import itertools
ans=0

for v in itertools.combinations(cnt2, 3):
    ans+=v[0]*v[1]*v[2]

print(ans)

Measured memory_bytes: 16968
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var x = cin.nextInt();
            var a = cin.nextInt();
            var b = cin.nextInt();
            Console.WriteLine(Math.Abs(x-a)< Math.Abs(x - b) ? "A":"B");
        }
    }

    class Scanner
    {
        string[] s;
        int i;

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

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

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

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

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

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

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

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

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


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

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


Measured memory_bytes: 11092
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
#define ar array
#define ld long double
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
char c[4]={'D' , 'R' , 'U' , 'L'};
const ll maxN=1e5+5 , N=1e2+5;
ll w[N] , v[N] , dp[N][maxN] , n , W;
void solve(){
	cin>> n >> W ;
	for(ll i=0;i<n ;i++)cin>>w[i]>>v[i];
	for(ll i=1;i<maxN ; i++)dp[0][i]=inf;
	for(ll i=1;i<=n ;i++){
		for(ll j=0;j<maxN ; j++)dp[i][j]=inf;
		for(ll j=0;j<maxN ; j++){
			dp[i][j]=min(dp[i][j] , dp[i-1][j]);
			if(j-v[i-1]>=0)dp[i][j]=min(dp[i][j] , dp[i-1][j-v[i-1]]+w[i-1]);
		}
	}
	ll ans=0;
	for(ll i=0;i<maxN ; i++){
		if(dp[n][i]<=W)ans=i;
	}
	cout<<ans<<endl;
}

int main(){
	// mahakal();
	fast;
	ll t =1 ;
	// cin>> t ; 
	while(t--)solve();
	// cerr << "\ntime taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; 
	return 0;
}

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


int main()
{
    int M, N;
    cin >> N >> M;
    int tot = 0, cnt = 0;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        tot += A[i];
    }
    for (int i = 0; i < N; i++) {
        if (A[i]*4*M >= tot) cnt++;
    }
    if (cnt >= M) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
m=998244353
def c(n,r):return (g[n]*h[r]*h[n-r])%m
g=[1,1]
h=g[:]
v=[0,1]
for i in range(2,999999):
  g.append(g[-1]*i%m)
  v.append(m//i*-v[m%i]%m)
  h.append(h[-1]*v[i]%m)
N,K=map(int,input().split())
P=0
for k in range(N-1,K):P+=c(K-1,k)
print(P%m)

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll N;
  scanf("%lld",&N);
  ll ans=111;
  while(ans<N) ans+=111;
  cout << ans << endl;
}

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


Measured memory_bytes: 256
function main(input) {
  const n = Number(input.trim());
  let result = 0;
  const rf = (str) => {
    if(n < Number(str)) return;
    if(str.indexOf("7") !== -1 && str.indexOf("5") !== -1 && str.indexOf("3") !== -1) {
      result++;
    }
    ["7", "5", "3"].forEach(a => {
      rf(str + a);
    });
  };
  rf("");
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 12224
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  string s;
  cin >> s;
  bool ok = false;
  if (s[0] == '7') ok = true;
  if (s[1] == '7') ok = true;
  if (s[2] == '7') ok = true;
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <algorithm>
using namespace std;
int arr[101];
int main(){
	int SW = 2;
	if(SW==0){
		int X,Y,Z;
		scanf("%d %d %d",&X,&Y,&Z);
		printf("%d %d %d",Z,X,Y);
	}
	else if(SW==1){
		int N,M;
		scanf("%d %d",&N,&M);
		int sum=0,cnt=0;
		for(int i=0;i<N;i++){
			scanf("%d",arr+i);
			sum+=arr[i];
		}
		for(int i=0;i<N;i++)cnt+=4*M*arr[i]>=sum;
		printf("%s",cnt>=M?"Yes":"No");
	}
	else{
		long long N,K;
		scanf("%lld %lld",&N,&K);
		printf("%lld",min(N%K,K-(N%K)));
	}
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  cin>>h>>w;
  string s[111];
  for(int i=0;i<h;i++)cin>>s[i];
  for(int i=0;i<h;i++){
    cout<<s[i]<<endl;
    cout<<s[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
P x[300][300];
vector<P> v[300];
priority_queue<pair<P,int>,vector<pair<P,int>>,greater<pair<P,int>>> q[300];
int vy[100000],vz[100000];
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	f(i,b){
		int d,y,z;
		cin>>y>>z>>d;
		if(d>c)continue;
		y--,z--;
		v[y].push_back({z,d});
		v[z].push_back({y,d});
	}
	f(i,a){
		f(j,a){
			if(i!=j)x[i][j]={INF,INF};
		}
	}
	f(i,a){
		q[i].push({{0,0},i});
		while(q[i].size()){
			pair<P,int> p=q[i].top();
			q[i].pop();
			if(x[i][p.S].F<p.F.F||(x[i][p.S].F<=p.F.F&&x[i][p.S].S<p.F.S))continue;
			f(j,v[p.S].size()){
				P pa={p.F.F,p.F.S+v[p.S][j].S};
				if(p.F.S+v[p.S][j].S>c){
					pa.F++;
					pa.S=v[p.S][j].S;
				}
				if(x[i][v[p.S][j].F].F>pa.F||(x[i][v[p.S][j].F].F>=pa.F&&x[i][v[p.S][j].F].S>pa.S)){
					x[i][v[p.S][j].F]=pa;
					q[i].push({pa,v[p.S][j].F});
				}
			}
		}
	}
	int q;
	cin>>q;
	f(i,q){
		cin>>vy[i]>>vz[i];
	}
	f(i,q){
		if(x[vy[i]-1][vz[i]-1].F==INF)puts("-1");
		else cout<<x[vy[i]-1][vz[i]-1].F<<endl;
	}
}


Measured memory_bytes: 142380
using System.Linq;

namespace MinPro_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var cnt = new int[4];
            for (int i = 0; i < 3; i++)
            {
                var ab = System.Console.ReadLine().Split().Select(int.Parse).ToArray();
                switch (ab[0])
                {
                    case 1: cnt[0]++; break;
                    case 2: cnt[1]++; break;
                    case 3: cnt[2]++; break;
                    case 4: cnt[3]++; break;
                    default: break;
                }
                switch (ab[1])
                {
                    case 1: cnt[0]++; break;
                    case 2: cnt[1]++; break;
                    case 3: cnt[2]++; break;
                    case 4: cnt[3]++; break;
                    default: break;
                }
            }

            var none = cnt.Where(x => x == 0).Count();
            var overthree = cnt.Where(x => x >= 3).Count();
            System.Console.WriteLine(none == 0 && overthree == 0 ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <set>

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

constexpr int inf = (int)1e9;
constexpr double INF = 1e12, EPS = 1e-9;
constexpr int MX = 2010;
constexpr int mod = inf + 7;

int n, m, q, a[MX];
int L[MX][MX], R[MX][MX];
int memo[MX][MX];

int main() {
  int N;
  int dup{0};
  set<ll> s;
  cin >> N;
  rep(i,N) {
    ll in;
    cin >> in;
    auto result{s.insert(in)};
    if (!result.second) {
      ++dup;
    }
  }

  cout << N - dup << endl;
}

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

int main(void) {
	int N;
	cin >> N;
	vector<int> p;
	vector<int> p2;

	p.resize(N);
	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < N; i++) {
		p2.push_back(p[i]);
	}

	sort(p.begin(), p.end());

	int count = 0;
	for (int i = 0; i < N; i++) {
		if (p[i] != p2[i]) {
			count++;
		}
	}

	if (count == 0 || count == 2) {
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;

	//for (int i = 0; i < N; i++) {
	//	cout << p2[i] << " ";
	//}
	//cout << endl;

	//for (int i = 0; i < N; i++) {
	//	cout << p[i] << " ";
	//}
	//cout << endl;

}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

vector<pair<int, int> > p;
int r[250010];

int main(){
  int N; scanf("%d", &N);
  for(int i = 1; i <= N; i++){
    int x; scanf("%d", &x); r[x] = i;
    p.push_back(make_pair(x, i));
  }

  sort(p.begin(), p.end());

  bool v = true;

  int i_ = 1;
  for(int i = 0; i < N; i++){
    int x = p[i].first, y = p[i].second;

    for(int c = 0; c < y - 1; c++){
      while(r[i_] != 0) i_++;
      r[i_++] = y;
    }

    if(i_ > x) v = false;
  }

  i_ = N * N;
  for(int i = N - 1; i >= 0; i--){
    int x = p[i].first, y = p[i].second;

    for(int c = 0; c < N - y; c++){
      while(r[i_] != 0) i_--;
      r[i_--] = y;
    }

    if(i_ < x) v = false;
  }

  puts(v ? "Yes" : "No");
  if(v){
    for(int i = 1; i <= N * N; i++) printf("%d ", r[i]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 2176
//再帰しない
using System;
using System.Collections.Generic;

namespace tst
{
    class Program
    {
        public static int n = 0;
        public static int cnt = 0;
        public static void Permu_start(string text, string x, string y, int[] num)
        {
            int index = 0;
            //ここに取得した順列でどうするかの処理を書く
            foreach(var s in Permutation(text))
            {
                index++;
                if (x == s) num[0] = index;
                if (y == s) num[1] = index;
                //Console.WriteLine(s);
            }
        }
        public static List<string> Permutation(string s)
        {
            if (s.Length == 1) return new List<string>() { s };
            var ret = new List<string>();
            for(int i =0; i<s.Length; i++)
            {
                foreach (string t in Permutation(s.Remove(i, 1)))
                {
                    ret.Add(s[i] + t);
                }
            }
            return ret;
        }

        public static void Main()
        {
            n = int.Parse(Console.ReadLine());
            string[] In1 = Console.ReadLine().Split(' ');
            string[] In2 = Console.ReadLine().Split(' ');
            int x = 0;
            int y = 0;
            var list = new List<int>();
            for (int i = 0; i < n; i++)
            {
                x += int.Parse(In1[i]) * (int)Math.Pow(10, n - i - 1);
                y += int.Parse(In2[i]) * (int)Math.Pow(10, n - i - 1);
                list.Add(i + 1);//listは使える数
            }
            list.Reverse();
            //重複なし順列にするためstringに
            int sum =0;
            for(int i=0; i<n; i++)
            {
                sum += list[i] * (int)Math.Pow(10, i);
            }
            string str = sum.ToString();
            int[] num = new int[2];
            string x_str = x.ToString();
            string y_str = y.ToString();
            //順列関数へ
            Permu_start(str, x_str, y_str, num);
            //出力
            Console.WriteLine(Math.Abs(num[0] - num[1]));
        }

    }
}

Measured memory_bytes: 26432
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

struct SegTree {
    int n;
    vll dat;

    SegTree(int _n) {
        int m = 1;
        while(m < _n) m *= 2;
        n = m;
        dat = vll(2 * n - 1, 0);
    }

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

    ll _query(int a, int b, int k, int l, int r) {
        if(r <= a || b <= l) return 0;
        if(a <= l && r <= b) return dat[k];
        else {
            ll vl = _query(a, b, k * 2 + 1, l, (l + r) / 2);
            ll vr = _query(a, b, k * 2 + 2, (l + r) / 2, r);
            return max(vl, vr);
        }
    }

    ll query(int a, int b) {
        return _query(a, b, 0, 0, n);   // query for [a, b)
    }
};

int main() {
//	cout << fixed << setprecision(15);
    int n;
    cin >> n;
    vll h(n), a(n);
    rep(i, n) cin >> h[i];
    rep(i, n) cin >> a[i];

    SegTree st(n + 1);
    rep(i, n) {
        ll amax = st.query(0, h[i]);
        st.update(h[i], a[i] + amax);
    }
    cout << st.query(0, n + 1) << endl;
}


Measured memory_bytes: 7424
#! /usr/bin/perl

use strict;
use warnings;

chomp(my $n = <>);
chomp(my $buf = <>);
my @numbers = sort {$b <=> $a} split(/\s+/, $buf);

my $alice = 0;
my $bob = 0;
for(my $i = 0;$i < @numbers;$i ++){
    if($i % 2 == 0) {
        $alice += $numbers[$i];
    }else{
        $bob += $numbers[$i];
    }
}

print $alice - $bob, "\n";


Measured memory_bytes: 768
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Candles solver = new Candles();
        solver.solve(1, in, out);
        out.close();
    }

    static class Candles {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();

            long result = 0;
            int[] x = new int[n];
            for (int i = 0; i < n; i++) {
                x[i] = in.nextInt();
            }

            // start
            long distance = Math.min(Math.abs(x[0]), Math.abs(x[k - 1]));
            for (int i = 0; i < k - 1; i++) {
                distance += Math.abs(x[i] - x[i + 1]);
            }

            result = distance;
            int pos = 0;
            while (pos + k < x.length) {
                distance -= Math.abs(x[pos] - x[pos + 1]);
                distance -= Math.min(Math.abs(x[pos]), Math.abs(x[pos + k - 1]));

                distance += Math.abs(x[pos - 1 + k] - x[pos + k]);
                distance += Math.min(Math.abs(x[pos + 1]), Math.abs(x[pos + k]));

                result = Math.min(result, distance);
                pos++;
            }
            out.print(result);


        }

    }
}



Measured memory_bytes: 64344
X = gets.chomp.to_i

list = []

if X == 1 then
  puts "1"
  exit
end

(2..(Math.sqrt(X).to_i)).each do |n|
  (2..Float::INFINITY).each do |e|
    break if n ** e > X
    list << n ** e
  end
end

puts list.max

Measured memory_bytes: 1788
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines
MOD = 10**9+7
INF = 1<<60
# A：想定する最短距離と計算(WF)で算出した最短距離が合っているか判定
# A[i][j] > A[i][k] + A[k][j] : -1
# AとWFが合っていたら最短距離の和を出力
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

def resolve():
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(N)]

    csr = csr_matrix(np.array(A))
    wf =  floyd_warshall(csr, directed=False)
    for i in range(N):
        wf[i][i] = INF
        A[i][i] = INF
    ans = 0
    for i in range(N):
        for j in range(N):
            if A[i][j] != wf[i][j]:
                print(-1)
                return
            if wf[i][j] < np.min(wf[i] + wf[j]):
                ans += wf[i][j]
    print(int(ans//2))

if __name__ == "__main__":
    resolve()

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;



int main() {
	int a, b, h;
	cin >> a >> b >> h;
	cout << ((a + b) * h) / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
/**
 *    author:  math2do
 *    created: 23.12.2019 12:25:13
**/

#include <bits/stdc++.h>

using namespace std;

inline int gcd(int a, int b) {
  while (b > 0) {
    a = a % b;
    swap(a, b);
  }
  return a;
}

inline long long lcm(int a, int b) {
  return (long long) a / gcd(a, b) * b;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  long long ans = lcm(a, b); 
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int x,a,b;
    cin>>x;
    cin>>a;
    cin>>b;

    if((x>=1 && x<=1000)&&(a>=1 && a<=1000)&&(b>=1 && b<=1000)){
            int dis1, dis2;
            dis1=x-a;
            dis2=x-b;

            if(dis1<1){
                dis1=dis1*(-1);
            }
            if(dis2<1){
                dis2=dis2*(-1);
            }

            if(dis1!=dis2){
                if(dis1>dis2){
                    cout<<"B";
                }else{
                    cout<<"A";
                }
            }

    }else{
        cout<<"invalido";
    }
    return 0;
}


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

int main() {
    ll n;
    cin>>n;
    vector<ll> w(n);
    rep(i,n)cin>>w[i];
    ll sum=0;
    rep(i,n){
        sum+=w[i];
    }
    ll min=1e9;
    ll ab=0;
    rep(i,n){
        ab+=w[i];
        sum-=w[i];
        if(abs(ab-sum)<min)min=abs(ab-sum);
    }
    cout<<min<<endl;
}


Measured memory_bytes: 256
A, B, Q = list(map(int, input().split()))
S = [-int(1e11)] + [int(input()) for _ in range(A)] + [int(1e11)]
T = [-int(1e11)] + [int(input()) for _ in range(B)] + [int(1e11)]
X = [int(input()) for _ in range(Q)]

import bisect
for x in X:
  SL = S[bisect.bisect_left(S, x) -1]
  SR = S[bisect.bisect_right(S, x)]
  TL = T[bisect.bisect_left(T, x) -1]
  TR = T[bisect.bisect_right(T, x)]
  
  print(min(x-min(SL,TL), max(SR,TR)-x, TR+x-2*SL, SR+x-2*TL, 2*SR-x-TL, 2*TR-x-SL))


Measured memory_bytes: 17796
//#include<bits_stdc++.h>
#include <iostream>
#include <math.h>
#include <vector>
#include <stdlib.h>
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define ll long long
using namespace std;
int main() {
    int x;
    vector<int> s;
    string str;
    while(cin >> str) {
        if(str == "+" || str == "-") {
            if(str == "+") {
                x = s.back();
            } else {
                x = -1 * s.back();
            }
            s.pop_back();
            x += s.back();
            s.pop_back();
        } else if(str == "*") {
            x = s.back();
            s.pop_back();
            x *= s.back();
            s.pop_back();
        } else {
            x = atoi(str.c_str());
        }
        s.push_back(x);
    }
    cout << s.back() << endl;
}



Measured memory_bytes: 3168
"use strict";
function main(input) {
    const line = input.split("\n");
    let arr = line[0].split(" ");
    const A = parseInt(arr[0]);
    const B = parseInt(arr[1]);
    console.log((A + B) % 2 === 0 ? (A + B) / 2 : "IMPOSSIBLE");
    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 30336
using System;
using System.Linq;

class ALDS1
{
    static void Main()
    {
        string[] x = new string[200];
         x = Console.ReadLine().Split(' ');
        int[] y = new int[100];
        for (int i = 0,j =0; i < x.Length;i++ )
        {
            if (x[i] == "+")
            {
                y[j - 2] = y[j - 2] + y[j - 1]; j--;
            }
            else if (x[i] == "-")
            {
                y[j - 2] = y[j - 2] - y[j - 1]; j--;
            }
            else if (x[i] == "*")
            {
                y[j - 2] = y[j - 2] * y[j - 1]; j--;
            }
            else
            {
                y[j] = int.Parse(x[i]); j++;
            }
        }
        Console.WriteLine(y[0]);
    }
}

Measured memory_bytes: 5624
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
 
using namespace std;
 
const int N=100005;
const int P=998244353;
const long long INFll=0x3f3f3f3f3f3f3f3fll;
 
int n,m;
int a[N],b[N],c[N],id[N];
int top=-1;
int p[N],fa[N];
long long f[N],size[N];
 
vector<int> son[N];
 
struct edge{
	int u,v;
	inline edge(){}
	inline edge(int _u,int _v){
		u=_u;
		v=_v;
		if(c[u]<c[v]) swap(u,v);
	}
	inline bool operator<(const edge &w)const{
		if(c[u]==c[w.u]) return c[v]>c[w.v];
		return c[u]<c[w.u];
	}
}d[N];
 
int find(int x){
	if(p[x]==0) return x;
	return p[x]=find(p[x]);
}
 
inline void onion(int x,int y){
	x=find(x),y=find(y);
	if(x==y) return ;
	p[y]=x;
	fa[y]=x;
}
 
inline bool cmp(int x,int y){
	return c[x]<c[y];
}
 
#define min(x,y) ((x<y)?x:y)
#define max(x,y) ((x>y)?x:y)
 
void init(){
	int x1,x2;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]),c[i]=max(a[i]-b[i],0),id[i]=i;
	sort(id+1,id+n+1,cmp);
	for(int i=1;i<=n;i++) c[id[i]]=i;
	for(int i=1;i<=m;i++){
		scanf("%d%d",&x1,&x2);
		d[i]=edge(x1,x2);
	}
	//printf("id : ");	for(int i=1;i<=n;i++) printf("%d ",id[i]); printf("\n");
	sort(d+1,d+m+1);
	for(int i=1,j=0;i<=n;i++){
		//int u=id[i];
		while(c[d[j+1].u]==i && j<=m){
			j++;
			onion(d[j].u,d[j].v);
			//printf("edge: %d %d\n",d[j].u,d[j].v);
		}
	}
	for(int i=1;i<=n;i++) c[i]=max(a[i]-b[i],0);
	for(int i=1;i<=n;i++) son[fa[i]].push_back(i);
	for(int i=1;i<=n;i++){
		int u=id[i],len=son[u].size();
		if(len==0) f[u]=c[u]+b[u],size[u]=b[u];
		else{
			f[u]=INFll;
			size[u]=b[u];
			for(int j=0;j<len;j++) size[u]+=size[son[u][j]];
			for(int j=0;j<len;j++){
				int v=son[u][j];
				f[u]=min(f[u],size[u]-size[v]+max(c[u],f[v]));
			}
		}
	}
	/*
	printf("a : ");		for(int i=1;i<=n;i++) printf("%d ",a[i]); printf("\n");
	printf("b : ");		for(int i=1;i<=n;i++) printf("%d ",b[i]); printf("\n");
	printf("id : ");	for(int i=1;i<=n;i++) printf("%d ",id[i]); printf("\n");
	printf("fa : ");	for(int i=1;i<=n;i++) printf("%d ",fa[i]); printf("\n");
	printf("size : ");	for(int i=1;i<=n;i++) printf("%lld ",size[i]); printf("\n");
	printf("f : ");		for(int i=1;i<=n;i++) printf("%lld ",f[i]); printf("\n");
	*/
	printf("%lld\n",f[id[n]]);
}
 
int main(){
	init();
	return 0;
}

Measured memory_bytes: 9728
n=int(input())
P=list(map(int,input().split()))
p=[0 for i in range(n)]
p[0]=P[0]
cnt=0
for i in range(1,n):
    p[i]=min([P[i],p[i-1]])
for i in range(n):
    if P[i]==p[i]:
        cnt+=1
print(cnt)
    
    

Measured memory_bytes: 85712
n = int(input())
P = list(map(float, input().split()))

#dp[i][j] i枚投げた時にj枚表の確率
dp = [[0] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 1.0

for i in range(n):
  for j in range(i + 1):
    dp[i+1][j+1] += dp[i][j] * P[i]
    dp[i+1][j] += dp[i][j] * (1 - P[i])
    
ans = sum([dp[n][j] for j in range(n + 1) if j * 2 > n])
      
print(ans)


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

ll gcd(ll x, ll y) {return y ? gcd(y, x % y) : x;}

int a[1000005];

int main()
{
    ll x, y; scanf("%lld%lld", &x, &y);
    x = gcd(x, y);
    int ans = 0;
    for(int i = 2; i <= 1000; i++)
    if(!a[i])
    {
        for(int j = i * i; j <= 1000000; j += i) a[j] = 1;
        if(x == 1LL) break; if(x % i) continue;
        ans++; while(x % i == 0) x /= i;
    }
    for(int i = 1001; i <= 1000000; i++)
    if(!a[i] && x % i == 0)
    {
        ans++; while(x % i == 0) x /= i;
    }
    if(x > 1) ans++; ans++;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define int long long
#define pb push_back
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define diff(a,b) (a>b?a-b:b-a)
const int N=1e5+5;
void pairsort(int a[], int b[], int n){
    pair<int, int> pairt[n];
    for (int i = 0; i < n; i++) 
    {
        pairt[i].first = a[i];
        pairt[i].second = b[i];
    }
    sort(pairt, pairt + n);
    for (int i = 0; i < n; i++) 
    {
        a[i] = pairt[i].first;
        b[i] = pairt[i].second;
    }
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b); 
}
int isPrime(int n){
    if(n < 2)
        return 0;
    if(n < 4)
        return 1;
    if(n % 2 == 0 or n % 3 == 0)
        return 0;
    for(int i = 5; i*i <= n; i += 6)
        if(n % i == 0 or n % (i+2) == 0)
            return 0;
    return 1;
}
long long C(int n, int r) {
    if(r>n-r) 
        r=n-r;
    long long ans=1;
    for(int i=1;i<=r;i++){
        ans*=n-r+i;
        ans/=i;
    }
    return ans;
}
int mod = 1e9+7;
int modexpo(int x,int p){
    int res = 1;
    x = x%mod;
    while(p){
        if(p%2)
            res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}
int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    b[0]=0,b[1]=diff(a[0],a[1]);
    for(int i=2;i<n;i++)
        b[i]=min(b[i-2]+diff(a[i],a[i-2]),b[i-1]+diff(a[i],a[i-1]));
    cout<<b[n-1];
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<bool> vb;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sq(x) ((x)*(x))
#define fo(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<n;i++)
#define Fo(i,n) for(int i=1;i<=n;i++)
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<"="<<x<<"\n"
#define deb2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<"\n"
#define fi first
#define se second
const double pi = 3.14159265358979323846;
#define uni(c) (c).resize(unique(all(c))-(c).begin())
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
//pair <int, int> w[4] = {mp(-1, 0), mp(0, -1), mp(1, 0), mp(0, 1)};   // for matrix movement:
void cp()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
void solve()
{
	ll n; cin >> n;
	if (n % 1000 == 0)
		cout << "0";
	else
		cout << 1000 - (n % 1000);

}
int main()
{
	fast;
	//cp();
	ll t = 1;
	//cin >> t;
	while (t--)
		solve();


	return 0;
}

Measured memory_bytes: 3688
#include <algorithm>
#include <array>
#include <bitset>
#include <chrono>
#include <complex>
#include <fstream>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;

#define INT_MAX std::numeric_limits<int>().max()
#define INT_MIN std::numeric_limits<int>().min()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

//#define _DEBUG_ 3
void run() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> city(N+1, vector<int>(N+1, 0));
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		city[a][b]++;
		city[b][a]++;
	}

	FOR(i, 1, N+1) {
		auto& p = city[i];
		cout << accumulate(p.begin(), p.end(), 0) << endl;
	}
}

int main() {
#ifdef _DEBUG_
	using std::chrono::system_clock;
	using std::chrono::duration_cast;
	system_clock::time_point  start, end;
	std::ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
	for (int i = 0; i < _DEBUG_; i++) {
		cout << "-------------------------- (cnt:" << i << ")" << endl;
		start = system_clock::now();
		run();
		end = system_clock::now();
		int elapsed = duration_cast<std::chrono::milliseconds>(end - start).count();
		cout << "-------------------------- (time:" << elapsed << "ms)" << endl << endl;
	}
#else
	run();
#endif
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>
#include <numeric>
#include <cassert>

using lli = long long int;
lli inf = 1000000007;
using namespace std;

void solve()
{
	int N, A;
	cin >> N >> A;
	vector<int> x(N);
	for (int i = 0; i < N; i++)cin >> x[i];
	lli dp[52][52][2540];
	dp[0][0][0] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k <= 2500; k++) {
				dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
				dp[i + 1][j][k] += dp[i][j][k];
			}
		}
	}
	lli ans = 0;
	for (int j = 1; j <= N; j++) {
		ans += dp[N][j][j * A];
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 52352