akhauriyash/Code-Regression huggingface dataset:
public class Main {


  private static void solve() {
    int n = ni();
    if (n == 7 || n == 5 || n == 3) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

using namespace std;

const int M = 2e9;
#define ll long long
void solve(){
	int n;

	scanf("%d",&n);
	map<ll,int> Hash;
	vector<int> in;
	for(int i=0;i<n;++i){
		int x;
		scanf("%d",&x);
		//++Hash[x];
		in.push_back(x);
	}
	sort(in.begin(),in.end());
	int ret = 0;
	for(int i=n-1;i>=0;--i){
		int x = in[i];
		ll t = 1;
		bool oc = false;
		while(t<=M){
			ll rem = t - x;
			if(x<=rem){
				if(Hash[rem]>0){
					oc = true;
					--Hash[rem];
					++ret;
					break;
				}
			}
			t*=2;
		}
		if(!oc){
			++Hash[x];
		}
	}
	printf("%d\n", ret);
}
int main(){
	//freopen("input.txt","r",stdin);
	solve();
}

Measured memory_bytes: 29300
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))

#到達したかの判定
#masu=[0]*(n+1)
#nは1~n
def junkan(N):
  #到達したかの判定
  masu=[0]*(n+1)
  ans=0
  ans22=-(10**9+1)
  junkan_flag=False
  now_mas=p[N-1]
  count=0
  masu[now_mas]=1
  #このwhileはせいぜい5000
  while True:
    if count>=k:
      break
    if (count!=0 and masu[now_mas]==1):
      junkan_flag=True
      break
    count+=1
    ans+=c[now_mas-1]
    
    if ans22<ans:
      ans22=ans
      
    masu[now_mas]=1
    now_mas=p[now_mas-1]
  if junkan_flag==True and ans>0:
    ans=(((k-1)//count)-1)*ans
    
    if ans22<ans:
      ans22=ans
    for i in range(k-((k-1)//count-1)*count):
      ans+=c[now_mas-1]
      if ans22<ans:
        ans22=ans
        
      now_mas=p[now_mas-1]
    return max(ans,ans22)
  
  else:
    return max(ans,ans22)
answ=-(10**9+1)

for i in range(1,n+1):
  hantei=junkan(i)
  if answ < hantei:
    answ=hantei
print(answ)



Measured memory_bytes: 76044
using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{
		string[] strInput = Console.ReadLine().Split(' '); ;
		int x = int.Parse(strInput[0]);
		int n = int.Parse(strInput[1]);
		strInput = Console.ReadLine().Split(' '); ;
		int[] p = new int[n];

		Dictionary<int, int> dict = new Dictionary<int, int>();

		for (int i = 0; i < n; i++)
		{
			p[i] = int.Parse(strInput[i]);
			dict.Add(p[i], 1);
		}
		if(dict.ContainsKey(x) == false)
		{
			Console.WriteLine(x);
			return;
		}
		
		for (int i = 1; i < 100; i++)
		{
			if (dict.ContainsKey(x - i) == false)
			{
				Console.WriteLine(x - i);
				return;
			}
			if (dict.ContainsKey(x + i) == false)
			{
				Console.WriteLine(x + i);
				return;
			}

		}

		return;
	}
}

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

int main() {
    int n, d;
    cin>>n>>d;
    int dist = d * 2 + 1;
    if(n % dist == 0){
        cout<<n/dist<<endl;
    } else {
        cout<<n/dist + 1<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define INFLL 0x3fffffffffffffffLL
#define INF 0x7fffffff
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define exist(s,e) (s.find(e)!=s.end())
#define ff first
#define ss second
#define EPS 1e-8
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
const ll MOD=1000000007;
/////////////////// DEBUG MODE ///////////////////////////////////
#define D(x) cerr<<"DEBUG: "<<#x<<" is: "<<x<<'\n'
#define error(args...) {string _s=#args; replace(all(_s),',',' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
void err(istream_iterator<string>) { cout<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
/////////////////// GLOBAL VARIABLES /////////////////////////////
vector<vector<int>> adj; vector<bool> vis;
/////////////////// FUNCTIONS ////////////////////////////////////
template<class T>
T maxx(T a, T b) {return a>b?a:b;}
template<typename T, typename... Args>
T maxx(T a, T b, Args... args){return maxx(a>b?a:b, args...);}
ll mexp(ll x, ll n, ll m){
  ll res=1;  while(n){if(n&1) res=(res*x)%m;n>>=1; x=((x%m)*(x%m))%m;}
  return res;
}
template<class T>
T minn(T a, T b) {return a<b?a:b;}
template<typename T, typename... Args>
T minn(T a, T b, Args... args){return minn(a>b?a:b, args...);}
bool ispow2(ll x){ return x && (!(x&(x-1))); }
ld pow(ld a, int n) {
  if(n == 0) return 1;if(n == 1) return a;
  double t = pow(a, n/2);return t * t * pow(a, n%2);
}
/////////////////// MAIN STARTS //////////////////////////////////
int main(){
  ios::sync_with_stdio(0);  cin.tie(0);   cout<<fixed; cerr<<fixed;
  cout<<setprecision(14); cerr<<setprecision(3);
  #ifdef DEBUG
  freopen("ip.txt","r",stdin); //freopen("op.txt","w",stdout);
  clock_t tStart = clock();
  #endif

	int ans=0,l,r; cin>>l>>r;
	for(int i=l;i<=r;++i){
		string s=to_string(i); bool ok=true;
		for(int j=0;j<s.size()/2;++j) if(s[j]!=s[s.size()-j-1]) ok=false;
		if(ok) ans++;
	}
	cout<<ans<<'\n';

	#ifdef DEBUG
	cerr<<"\nExecution time: "<<(((double)clock() - tStart)/CLOCKS_PER_SEC)*1e3<<"ms.\n";
	#endif
  return 0;
}


Measured memory_bytes: 256
import numpy as np
n,k = map(int,input().split())
h = np.array(list(map(int,input().split())))
dp = np.zeros(n)
for i in range(1,n):
    flag = max(0,i-k)
    dp[i] = np.min(dp[flag:i]+abs(h[flag:i]-h[i]))
print(int(dp[-1]))


Measured memory_bytes: 22832
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2020000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
//const int mod = 1e9 + 7;
const int mod = 998244353;

P d[42][101010];

int main(){
	ll n,x,m; cin >> n >> x >> m;
	rep(i,m){
		d[0][i] = P(i, (ll)i*i%m);
	}
	rep(i,40){
		rep(j,m){
			d[i+1][j] = P(d[i][j].first + d[i][d[i][j].second].first, d[i][d[i][j].second].second);
		}
	}
	ll ans = 0;
	ll now = x;
	rep(i,40){
		if(n>>i & 1){
			ans += d[i][x].first;
			x = d[i][x].second;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 67832
#include<bits/stdc++.h>
using namespace std;
vector<int> V[200050];
int path[200050];
int search(int a)
{
	int size = V[a].size();
	for(int i=0; i<size; i++)
	{
		if(path[V[a][i]])
			path[a] = max(path[a], path[V[a][i]] + 1);
		else
			path[a] = max(path[a], search(V[a][i]) + 1);
	}
	return path[a];
}
int main()
{
	int a, b;
	cin >> a >> b;
	for(int i=0; i<b; i++)
	{
		int c, d;
		cin >> c >> d;
		V[c].push_back(d); 
	}
	memset(path, 0, sizeof(path));
	int ans = 0;
	for(int i=1; i<=a; i++)
	{
		if(!path[i]) path[i] = search(i);
		ans = max(ans, path[i]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 10880
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }

ll inf=1001001001;
ll n,m,l,q;

class CompareDist
{
public:
    bool operator()(pair<pair<ll,ll>,ll> n1,pair<pair<ll,ll>,ll> n2) {
        if(n1.first.first==n2.first.first) return n1.first.second<n2.first.second;
        return n1.first.first>n2.first.first;
    }
};

int main(){
    cin>>n>>m>>l;
    vector<vector<pair<ll,ll>>> route(n+1);
    vector<vector<ll>> is(n+1,vector<ll>(n+1,0));
    rep(i,m){
        ll a,b,c;
        cin>>a>>b>>c;
        if(c>l) continue;
        route[a].push_back({b,c}); route[b].push_back({a,c});
        is[a][b]=c; is[b][a]=c;
    }
    cin>>q;
    vector<vector<ll>> memo(n+1,vector<ll>(n+1,-10));
    rep(i, q){
        ll s,t; cin>>s>>t;
        if(memo[s][t]!=-10) {cout<<memo[s][t]<<endl; continue;}
        if(is[s][t]!=0) {cout<<0<<endl; memo[s][t]=0; continue;}
        vector<pair<ll,ll>> cost(n+1,{inf,0});
        cost[s]={0,l};
        priority_queue<pair<pair<ll,ll>,ll>,vector<pair<pair<ll,ll>,ll>>,CompareDist> que;
        que.push({{0,l},s});
        while(!que.empty()){
            pair<pair<ll,ll>,ll> tmp=que.top();
            que.pop();
            int x=tmp.first.first,y=tmp.first.second,z=tmp.second;
            if(cost[z].first<x || (cost[z].first==x && cost[z].second>y)) continue;
            for(pair<ll,ll> j:route[z]){
                if(y>=j.second){
                    if(cost[j.first].first>x || (cost[j.first].first==x && cost[j.first].second<y-j.second)){
                        cost[j.first]={x,y-j.second};
                        que.push({{x,y-j.second},j.first});
                    }
                }else{
                    if(cost[j.first].first>x+1 || (cost[j.first].first==x+1 && cost[j.first].second<l-j.second)){
                        cost[j.first]={x+1,l-j.second};
                        que.push({{x+1,l-j.second},j.first});
                    }
                }
            }
        }
        rep(j,n+1){
            if(cost[j].first==inf) cost[j].first=-1;
            memo[s][j]=cost[j].first;
            memo[j][s]=cost[j].first;
        }
        cout<<cost[t].first<<endl;
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi = 3.1415926;
const int N = 200000 + 5;
int a[N];

int main()
{
	int n;
	cin >> n;
	for(int i = 2; i <= n; i++){
		int x;
		cin >> x;
		a[x]++;
	}
	for(int i = 1; i <= n; i++)
		cout << a[i] << endl;
    return 0;
}

Measured memory_bytes: 4404
#include<iostream>
#include<bits/stdc++.h>
#define LL long long int
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	LL n;
	cin>>n;
	vector<pair<LL,LL>>v;
	while(n--)
	{
		LL x,y;
		cin>>x>>y;
		v.push_back(make_pair(x,y));
		
	}
	for(LL i=0; i<v.size()-2; i++)
	{
		if(v[i].first==v[i].second && v[i+1].first==v[i+1].second && v[i+2].first==v[i+2].second)
		{
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";
}


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

int main(){
  int n;
  cin >> n;
  vector<long long> t(n);
  vector<long long> a(n);
  long long max_t = -1;
  int max_tid = -1;
  for(int i = 0; i < n; i++){
    cin >> t[i];
    if(max_t < t[i]){
      max_t = t[i];
      max_tid = i;
    }
  }
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  long long max_a = -1;
  int max_aid = n;
  for(int i = n-1; i >= 0; i--){
    if(max_a < a[i]){
      max_a = a[i];
      max_aid = i;
    }
  }

  if(max_t != max_a){
    cout << 0 << endl;
    return 0;
  }

  if(max_tid > max_aid){
    cout << 0 << endl;
    return 0;
  }

  long long ans = 1;
  if(max_tid != max_aid){
    if(max_aid - max_tid - 1 > 0){
      ans = (long long)max_t;
      for(int i = 1; i < max_aid - max_tid - 1; i++){
        ans *= (long long)max_t;
        ans %= 1000000007;
      }
    }
  }

  for(int i = 1; i < max_tid; i++){
    if(t[i-1] == t[i]){
      ans *= (long long)t[i];
      ans %= 1000000007;
    }
  }

  for(int i = n-2; i > max_aid; i--){
    if(a[i] == a[i+1]){
      ans *= (long long)a[i];
      ans %= 1000000007;
    }
  }

  cout << ans << endl;
  return 0;
}


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

int main(){
  long long A,B,K;
  cin>>A>>B>>K;
  if(K>=A+B){
    A=0;B=0;
  }else if(K>=A){
    B=B-K+A;
    A=0;
  }else if(K<A){
    A-=K;
  }
  cout<<A<<" "<<B<<endl;
  return 0;
}


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

using namespace std;

typedef long long int ll;
#define REP(i, I, N) for (int i = I; i < N; ++i)
#define rep(i, N) REP(i, 0, N)

int main() {
    int N, Q;
    cin >> N >> Q;
    string str;
    cin >> str;

    vector<int> vec(N + 1, 0);
    rep(i, N) {
        if (i + 1 < N && str[i] == 'A' && str[i + 1] == 'C') vec[i + 1] = vec[i] + 1;
        else vec[i + 1] = vec[i];
    }

    rep(i, Q) {
        int l, r;
        cin >> l >> r;
        --l, --r;
        cout << vec[r] - vec[l] << "\n";
    }
    return 0;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define N 3030
using namespace std;
const int Mod = 1e9 + 7;
const int i2 = (Mod + 1) >> 1;

int n, m, a[N], f[N][N], t[N][N];

int main() {
#ifdef isLOCAL
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    cin >> n >> m;
    
    for (int i = 1; i <= n; ++i)
        scanf("%d", a + i);

    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j)
            if (i != j) f[i][j] = a[i] > a[j];

    for (int k = 1, x, y; k <= m; ++k) {
        scanf("%d%d", &x, &y);
        for (int i = 1 ;i <= n; ++i) {
            t[i][x] = f[i][x], t[i][y] = f[i][y];
            t[x][i] = f[x][i], t[y][i] = f[y][i];
        }
        for (int i = 1; i <= n; ++i)
            if (i != x && i != y) {
                f[i][x] = f[i][y] = 1ll * (t[i][x] + t[i][y]) * i2 % Mod;
                f[x][i] = f[y][i] = 1ll * (t[x][i] + t[y][i]) * i2 % Mod;
            }
        f[x][y] = f[y][x] = 1ll * (f[x][y] + f[y][x]) * i2 % Mod;
    }

    int ans = 0;

    for (int i = 1; i <= n; ++i)
        for (int j = i + 1; j <= n; ++j)
            ans = (ans + f[i][j]) % Mod;

    while (m--) ans = 2ll * ans % Mod;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 71936
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
arrA = np.array(input().split(),dtype=np.int64)
bins = np.array([400,800,1200,1600,2000,2400,2800,3200,4801])
arr = np.digitize(arrA,bins)
ans = np.bincount(arr,minlength=9)
ans1 = len(ans[:-1][ans[:-1]>0])
ans2 = ans1 + ans[-1]
if ans1 == 0:
    ans1 = 1
print(ans1,ans2)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 12492
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
typedef long long int ll;

bool comp(string a,string b){
	if(a==b)return true;
	if(a.size()>b.size())return true;
	else if(b.size()>a.size())return false;
	else return a>b;
}

string add(string a,string b){
	int maxlen=max(a.size(),b.size())+1;
	vector<int> ret(maxlen,0);
	string ans="";
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for(int i=0;i<a.size();i++){
		ret[i]+=(a[i]-'0');
	}
	for(int i=0;i<b.size();i++){
		ret[i]+=(b[i]-'0');
	}
	for(int i=0;i<maxlen-1;i++){
		ans+=(ret[i]%10)+'0';
		ret[i+1]+=ret[i]/10;
	}
	if(ret[maxlen-1]){
		ans+=ret[maxlen-1]+'0';
	}
	reverse(ans.begin(),ans.end());
	return ans;
}

string sub(string a,string b){
	bool minus=0;
	if(!comp(a,b)){
		swap(a,b);
		minus=1;
	}
	int maxlen=max(a.size(),b.size());
	vector<int> ret(maxlen,0);
	string ans="";
	reverse(a.begin(),a.end());
	reverse(b.begin(),b.end());
	for(int i=0;i<a.size();i++){
		ret[i]=a[i]-'0';
	}
	for(int i=0;i<b.size();i++){
		ret[i]-=b[i]-'0';
	}
	for(int i=0;i<maxlen;i++){
		while(ret[i]<0){
			ret[i]+=10;
			ret[i+1]--;
		}
		ans+=(ret[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int cnt=0;
	while(ans[cnt]=='0'&&cnt!=ans.size()-1)cnt++;
	return (minus?"-":"")+ans.substr(cnt);
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	char s,t; string a,b;
	cin >> a >> b;
	s=a[0],t=b[0];
	a=a.substr(1); b=b.substr(1);
	if(s=='-'&&t=='-'){
		cout << "-" << add(a,b) << endl;
	}
	else if(s=='-'){
		b=t+b;
		if(comp(b,a)){
			cout << sub(b,a) << endl;
		}
		else{
			cout << "-" << sub(a,b) << endl;
		}
	}
	else if(t=='-'){
		a=s+a;
		if(comp(a,b)){
			cout << sub(a,b) << endl;
		}
		else{
			cout << "-" << sub(b,a) << endl;
		}
	}
	else{
		a=s+a;
		b=t+b;
		cout << add(a,b) << endl;
	}
	return 0;
}


Measured memory_bytes: 4064
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
ll kaijo(int x) {
  if (x == 1) return 1;
  return x * kaijo(x - 1); }
int main() { int N;
  cin >> N;
  vector<P> A(N);
  vector<int> junretu(N);
  REP(i, N) { int x, y;
    cin >> x >> y;
    A[i] = P(x, y);
    junretu[i] = i;
 }
 double ans = 0;
 do{
   for (int i = 0; i < N - 1;i++){
     int x1, y1, x2, y2;
     x1 = A[junretu[i]].first;
     y1 = A[junretu[i]].second;
     x2 = A[junretu[i + 1]].first;
     y2 = A[junretu[i + 1]].second;
     ans += sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
   }
 } while (next_permutation(junretu.begin(), junretu.end()));
 ans /= kaijo(N);
 cout <<fixed<<setprecision(10)<< ans << endl;
}

Measured memory_bytes: 256
use std::ops::{Index, IndexMut};
use std::cmp::{Ordering};
use std::collections::BinaryHeap;
use std::cmp::{min, max};
// use std::clone::Clone;

fn getline() -> String{
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

macro_rules! split {
    ($x: expr) => {
        ($x).trim().split(' ').collect()
    }
}

macro_rules! parse {
    ($x: expr) => {
        ($x).parse().unwrap()
    }
}

macro_rules! debug {
    ($x: expr) => {
        println!("{}: {}", stringify!($x), $x)
    }
}

fn printvec<T>(v: &Vec<T>) where T: std::fmt::Display {
    for (i,e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!();
}

fn main() {
    
    let s = getline();
    let iv: Vec<_> = split!(s);
    let n: i64 = parse!(iv[0]);
    let s = getline();
    let iv: Vec<_> = split!(s);
    let a: Vec<i64> = iv.into_iter().map(|x| parse!(x)).collect();
    
    let mut f = true;
    for e in &a {
        if *e >= n {
            f = false;
            break;
        }
    }
    if f {
        println!("{}",0);
        return;
    }
    let mut l: i64 = 0;
    let mut r: i64 = 1e16 as i64;
    
    let hoge = 2*n;
    let check = |x: i64| {
        let mut res = false;
        for i in 0..hoge {
            let m = x+i;
            let sum: i64 = a.clone().into_iter().map(|x| max((x-(n-1-m)+n)/(n+1),0)).sum();
            res = res || sum <= m; 
        }
        res
    };
    
    while r-l > 1 {
        let m = (l+r)/2;
        let sum: i64 = a.clone().into_iter().map(|x| max((x-(n-1-m)+n)/(n+1),0)).sum();
        // debug!(l); debug!(r); debug!(m); debug!(sum);
        if !check(m*hoge) {
            l = m;
        } else {
            r = m;
        }
    }
    // for i in 0..10 {
    //     println!("{}", check(i*hoge));
    // }
    // println!("{}",r);
    if check(0) {
        r = 0;
    }
    let mut ans = -100;
    for i in 0..hoge {
        let m = r*hoge+i;
        let sum: i64 = a.clone().into_iter().map(|x| max((x-(n-1-m)+n)/(n+1),0)).sum();
        if sum <= m {
            ans = m;
            break;
        }
    }
    println!("{}",ans);

}



Measured memory_bytes: 4352
#include <iostream>
#include <vector>

void linear(int n, std::vector<int> s, int q, std::vector<int> t) {
    int count = 0;
    for (int i = 0; i < q; i++) {
        for (int j = 0; j < n; j++) {
            if (t[i] == s[j]) {
                count++;
                break;
            }
        }
    }
    std::cout << count << std::endl;
    return;
}

int main(void) {
    int n;
    std::cin >> n;
    std::vector<int> s(n, 0);
    for (int i = 0; i < n; i++) {
        std::cin >> s[i];
    }

    int q;
    std::cin >> q;
    std::vector<int> t(q, 0);
    for (int i = 0; i < q; i++) {
        std::cin >> t[i];
    }

    linear(n, s, q, t);
    return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

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

    REP(x, N+1) REP(y, N+1-x){
        int z = N - x - y;
        if(10000 * x + 5000 * y + 1000 * z == Y) {
            cout << x << " " << y << " " << z << endl;
            return 0;
        }
    }

    cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
cin >> s;
reverse(s.begin(), s.end());
string vec[4] = {"dream", "dreamer", "erase", "eraser"};
for (int i=0; i<4; i++){
    reverse(vec[i].begin(), vec[i].end());
}

int i=0; bool can=true;
while(i<s.size()){
    can=false;
    for(int j=0; j<4; j++){
        string v=vec[j];
        if(s.substr(i, v.size())==vec[j]){
            i+=v.size();
            can=true;
        }
    }
    if(!can) break;
}

if(can) cout << "YES" << endl;
else cout << "NO" << endl;

}

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

int main()
{
	int H, W, i, j;
	
	while(1){
		cin >> H >> W;
		if(H == 0 && W == 0){
			break;
		}
		for(i = 0; i < H; i++){
			for ( j = 0; j < W; j++){
				if ((i + j)% 2 == 0 ){
					cout << '#';
				}else{
					cout << '.';
				}
			}
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}

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

int main() {
  int x, y;
  cin >> x >> y;
  for(int i = 0; i <= x; i++){
  	if(2*i + 4*(x-i) == y){
    	cout << "Yes" << endl;
      	return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
n = int(input())
a = (list(map(int, input().split())))
aa=[]
minus = 0
for i in range(n):
    if a[i] < 0:
        aa.append(-a[i])
        minus += 1
    else: aa.append(a[i])

sum_a = sum(aa)
if minus%2==0:
    print(sum_a)
else:
    print(sum_a-2*min(aa))


Measured memory_bytes: 14412
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


class UnionFind:
    def __init__(self, n_nodes):
        self.n_nodes = n_nodes

        # self.parents[x] < 0 の時，xが根である．
        # また，xが根の時，(-1) * (同一グループの要素数) が格納されるようになる.
        self.parents = [-1] * n_nodes

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

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        # 常にxの方が要素数が多くなるように，スワップする
        if self.parents[x] > self.parents[y]:
            x, y = y, x

        # 要素数の少ない方のグループを，要素数が多い方の木に貼る．
        self.parents[x] += self.parents[y]
        self.parents[y] = x

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

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

    def get_members(self, x):
        parent = self.find(x)
        return [i for i in range(self.n_nodes) if self.find(i) == parent]

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

    def get_n_groups(self):
        return len(self.get_parent_list())

    def get_members_dict(self):
        return {par: self.get_members(par) for par in self.get_parent_list()}


def main():
    N, M, K = map(int, input().split())
    tree = UnionFind(N)

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

    ng = [[] for _ in range(N)]
    for _ in range(K):
        c, d = map(int, input().split())
        c -= 1
        d -= 1
        ng[c].append(d)
        ng[d].append(c)

    ans = []
    for i in range(N):
        n_ng = 0
        for j in ng[i]:
            if tree.is_same(i, j):
                n_ng += 1

        n_member = tree.get_size(i)
        n_friends = len(friends[i])
        # 自分を引くのを忘れない
        ans.append(n_member - n_friends - n_ng - 1)

    print(*ans, sep=" ")


if __name__ == "__main__":
    main()


Measured memory_bytes: 46848
# solution

def solve(string):
    n, k, *v = map(int, string.split())
    ans = 0
    for i in range(k + 1):
        for j in range(k - i + 1):
            base = sorted(v[:i] + v[max(n - k + i + j, i):])
            ans = max(ans, sum([b for l, b in enumerate(base) if b >= 0 or j <= l]))
    return str(ans)


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 3060
package main

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

func main() {
	l := getInt()
	r := getInt()

	if r-l+1 >= 673 {
		fmt.Println(0)
		return
	}

	ans := 2019
	for i := l; i < r; i++ {
		for j := i + 1; j <= r; j++ {
			ans = min(ans, (i*j)%2019)
		}
	}

	fmt.Println(ans)
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

// 674 1345
// 1 673

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << "debug: " << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << "debug: " << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
//const int mod = 1e9 + 7;
const int mod = 998244353;

int op(int a, int b) {return max(a,b);};
int e() {return 0;};

int main(){
    int n,k; cin >> n >> k;
    segtree<int,op,e> seg(303030);
    rep(i,n){
        int a; cin >> a;
        seg.set(a,seg.prod(max(0,a-k), min(301010, a+k+1)) + 1);
    }
    cout << seg.all_prod() << "\n";
}

Measured memory_bytes: 8552
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Text;

namespace AtCoder.ABC
{
	class QuestionD
	{
		public static void Main(string[] args)
		{
			var n = long.Parse(Console.ReadLine());

			var power = 1L;

			for(int i = 1; i <= n; i++) {
				power *= i;
				power %= 1000000000 + 7;
			}

			Console.WriteLine(power);
		}
	}
}


Measured memory_bytes: 27288
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

// 標準入力
fn read_line<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

fn main() {
    let vec: Vec<usize> = read_line();
    let n = vec[0];
    let mut abcs: Vec<Vec<i32>> = Vec::new();
    let mut dp: Vec<Vec<i32>> = Vec::new();
    for _ in 0..n {
        let abc: Vec<i32> = read_line();
        abcs.push(abc);
        dp.push(Vec::new());
    }

    // calc
    dp[0] = abcs[0].clone();
    for i in 1..n {
        for j in 0..3 {
            let mut indices: Vec<usize> = vec![0, 1, 2];
            indices.remove(j);
            let score = cmp::max(
                dp[i - 1][indices[0]] + abcs[i][j],
                dp[i - 1][indices[1]] + abcs[i][j]
            );
            dp[i].push(score);
        }
    }

    let last = dp.last().unwrap();
    println!("{}", last.into_iter().max().unwrap());
}


Measured memory_bytes: 14260
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=105,INF=1<<28;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S;cin>>S;
    int K;cin>>K;
    
    if(K==1){
        cout<<(int(S.size())-1)*9+int(S[0]-'0')<<endl;
    }else if(K==2){
        ll ans=0;
        ans+=int(S[0]-'0'-1)*(int(S.size())-1)*9;
        string T;
        T+=S[0];
        while(T.size()<S.size()) T+='0';
        for(int j=1;j<S.size();j++){
            for(char c='1';c<='9';c++){
                T[j]=c;
                if(S>=T) ans++;
                T[j]='0';
            }
        }
        
        ans+=(int(S.size())-1)*(int(S.size())-2)/2*9*9;
        
        cout<<ans<<endl;
    }else{
        ll ans=0;
        ans+=(int(S.size())-1)*(int(S.size())-2)*(int(S.size())-3)/6*9*9*9;
        
        ans+=int(S[0]-'0'-1)*int(S.size()-1)*int(S.size()-2)/2*9*9;
        
        string T;
        T+=S[0];
        while(T.size()<S.size()) T+='0';
        for(int j=1;j<S.size();j++){
            for(int k=j+1;k<S.size();k++){
                for(char c='1';c<='9';c++){
                    for(char d='1';d<='9';d++){
                        T[j]=c;
                        T[k]=d;
                        if(S>=T) ans++;
                        T[j]='0';
                        T[k]='0';
                    }
                }
            }
        }
        
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
from sys import stdin, stdout
from itertools import repeat
def main():
    n, k = map(int, stdin.readline().split())
    a = map(int, stdin.readline().split(), repeat(10, n))
    for i in xrange(min(k, 42)):
        b = [0] * (n + 1)
        for j, x in enumerate(a):
            l = j - x
            if l < 0:
                l = 0
            r = j + x + 1
            if r > n:
                r = n
            b[l] += 1
            b[r] -= 1
        s = 0
        for j in xrange(n):
            s += b[j]
            a[j] = s
    stdout.write(' '.join(map(str, a)))
    stdout.write('\n')
main()


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

int a[5];

int main(){
    int n;
    cin>>n;
    vector<string>s(n);
    rep(i,n)cin>>s[i];
    string t="MARCH";
    rep(i,n){
        rep(j,5){
            if(t[j]==s[i][0])a[j]++;
        }
    }
    ll ans=0;
    for(int i=0; i<3; ++i){
        for(int j=i+1; j<4; ++j){
            for(int k=j+1; k<5; ++k){
                ans+=(ll)a[i]*a[j]*a[k];
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6316
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define mod (int)1000000007
#define DBLINF (DBL_MAX)/10
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline int gcd(int a, int b) {
	while (b) {
		int c = a;
		a = b; b = c % b;
	}
	return a;
}
inline int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
bool isprime(int n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
int mypow(int a, int b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	int memo = mypow(a, b >> 1);
	return memo * memo;
}
int modpow(int a, int b, int m = mod) {
	if (!b)return 1;
	if (b & 1)return modpow(a, b - 1, m) * a % m;
	int memo = modpow(a, b / 2, m);
	return memo * memo % m;
}
int n, k, a[100010];
vector<int> vec[100010];
int dist[100010];
void dfs(int node) {
	for (int i : vec[node]) {
		if (i != 1) {
			dist[i] = dist[node] + 1;
			dfs(i);
		}
	}
}
signed main() {
	cin >> n >> k;
	REP(i, n) {
		cin >> a[i];
		if (i != 1)vec[a[i]].push_back(i);
	}
	int ans = 0;
	if (a[1] != 1)ans++;
	a[1] = 1;
	dfs(1);
	priority_queue<P> que;
	REP(i, n) {
		if (vec[i].empty())que.push(make_pair(dist[i], i));
	}
	while (!que.empty()) {
		P p = que.top();
		que.pop();
		if (dist[p.second] <= k)continue;
		rep(i, k - 1) {
			if (dist[p.second] <= k - i)goto end;
			dist[p.second] = k - i;
			p.second = a[p.second];
			if (p.second == 1)goto end;
		}
		if (a[p.second] == 1)goto end;
		que.push(make_pair(dist[a[p.second]], a[p.second]));
		a[p.second] = 1;
		ans++;
	end:;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define loop(i, j, n) for(int i=j; i<n; i++)
using namespace std;
// }}} End Header

int main()
{
	lli x, a, b, ans;
	cin >> x;
	b = x/11;
	a = x%11;
	if(x < 11){
		if(x <= 6) ans = 1;
		if(x < 11 && x > 6) ans = 2;
	}
	else{
		if(a == 0) ans = b*2;
		else if(a >= 1 && a <= 6) ans = b*2+1;
		else if(a >= 7)ans = b*2+2;
	}
	cout << ans <<endl;
	return 0;
}


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

for i in range(n):
    a,b,c = list(map(int, input().split()))
    M = max([a,b,c])
    result = False
    if a == M:
        result = (a * a == b * b + c * c)
    elif b == M:
        result = (b * b == a * a + c * c)
    elif c == M:
        result = (c * c == a * a + b * b)
    if result:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 7548
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

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

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int N, M, X;
  int A[100];

  cin >> N >> M >> X;
  REP(i, M) cin >> A[i];

  int left = 0, right = 0;
  REP(i, M) {
    if (A[i] < X) left++;
    else if (A[i] > X) right++;
  }
  cout << min(left, right) << endl;
}


Measured memory_bytes: 256
from decimal import Decimal


def com_interest(n: int) -> int:
    saving = 100
    interest_per = 0.01
    years = 0

    while True:
        years += 1
        saving = int(saving * Decimal('1.01'))
        if saving >= n:
            break
    return years


print(com_interest(int(input())))

Measured memory_bytes: 10060
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll x;
  R x;
  ll ans=x/11*2;
  x%=11;
  if(!x);
  else if(x<=6) ans++;
  else ans+=2;
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 384
#include<stdio.h>
int main(void){
	int number[100];
	double weight[100],height[100];
	double bmi[100];
	int i;
	i = 0;
	while(scanf("%d,",&number[i]) != EOF){
		scanf("%lf,%lf",&weight[i],&height[i]);
		bmi[i] = weight[i] / height[i] / height[i];
		if(bmi[i] >= 25){
			printf("%d\n",number[i]);
		}
		i++;
	}
	return 0;
}

Measured memory_bytes: 636
#include<map>
#include<set>
#include<ctime>
#include<queue>
#include<cmath>
#include<bitset>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define mp(x,y) make_pair(x,y)
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline int read(){
	int ans=0,fh=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') fh=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
		ans=(ans<<1)+(ans<<3)+ch-'0',ch=getchar();
	return ans*fh;
}
const int maxn=5e3+100;
int n,A,B,p[maxn];
ll f[maxn][maxn],g[maxn];
int main(){
	//freopen("nh.in","r",stdin);
	//freopen("zhy.out","w",stdout);
	n=read(),A=read(),B=read();
	for(int i=1;i<=n;i++) p[i]=read();
	p[++n]=n+1;
	memset(f,0x3f,sizeof(f));
	memset(g,0x3f,sizeof(g));
	for(int i=0;i<=n;i++){
		f[i][i]=0;
		for(int j=i+1;j<=n;j++)
			f[i][j]=f[i][j-1]+(p[j]>p[i]?A:B);
	}
	g[0]=0;
	for(int i=1;i<=n;i++)
		for(int j=0;j<i;j++)
			if(p[j]<p[i]) qmin(g[i],g[j]+f[j][i-1]);
	printf("%lld\n",g[n]);
	return 0;
}










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

using namespace std;
string s[55];
int t[55];
int main()
{
    int n, i;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>s[i]>>t[i];
    }
    string x;
    cin>>x;
    for(i=0; i<n; i++)
    {
        if(x==s[i])break;
    }
    int ans=0;
    for(i++; i<n; i++)
    {
        ans+=t[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int N,M;
int p[333][333];
int pnt[333];
bool invalid[333];
int c[333];
bool ok(int x){
	memset(invalid,0,sizeof(invalid));
	for(int i=1; i<=N; i++)pnt[i] = 1;

	while(1){
		bool flag = false;
		memset(c,0,sizeof(c));
		for(int i=1; i<=N; i++){
			while(pnt[i] <= M && invalid[p[i][pnt[i]]])pnt[i] ++;
			if(pnt[i] > M)return false;
			c[p[i][pnt[i]]] ++;
		}
		for(int i=1; i<=M; i++)
			if(c[i] > x){
				invalid[i] = true;
				flag = true;
			}
		if(!flag)return true;
	}
}
int main(){
	scanf("%d%d",&N,&M);
	for(int i=1; i<=N; i++)
		for(int j=1; j<=M; j++)
			scanf("%d",&p[i][j]);
	int lo = 1, hi = N;
	while(lo != hi){
		int mi = (lo + hi)/2;
		if(ok(mi))
			hi = mi;
		else
			lo = mi+1;
	}
	printf("%d\n",lo);
	return 0;
}

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

using ll = long long;
const int MAXN = 110;
const ll MAXW = 1e9+10;
const int MAXV = 1e5+10;
struct item {
    ll w, v;
};
item a[MAXN];
int N, W;
ll dp[MAXV];
int main() {
    cin >> N >> W;
    ll s = 0;
    for(int i=1; i<=N; i++) {
        cin >> a[i].w >> a[i].v;
        s += a[i].v;
    }
    ll ans = 0;
    memset(dp, 0x3f, sizeof(dp));
    dp[0] = 0;
    for(int i=1; i<=N; i++) {
        for(ll j=s; j>=a[i].v; j--) {
            dp[j] = min(dp[j], dp[j-a[i].v] + a[i].w);
            if(dp[j]<=W) ans = max(ans, j);
        }
    }
    /*
    for(int j=s; j>=0; j--) {
        if(dp[j]<=W)
            ans = max(ans, j);
    }
    */
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    ll n;
    cin >> n;
    if(n%2){
        cout << 0;
        return 0;
    }
    ll sum=0;
    ll now=10;
    rep(i,37){
        sum+=n/now;
      	now*=5;
    }
  	cerr << now;
    cout << sum;
}

/*



 */



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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int solve(const vector<int> &idx1, const vector<int> &idx2, const vector<int> &X) {
  vector<int> Y1, Y2;
  for(int e: idx1) Y1.push_back(X[e]);
  for(int e: idx2) Y2.push_back(X[e]);

  int residue = 0;
  sort(ALL(Y2));
  vector<int> unY2 = Y2;
  unY2.erase(unique(ALL(unY2)), unY2.end());
  int m = unY2.size();
  REP(i,m) {
    auto itr = equal_range(ALL(Y2), unY2[i]);
    residue += ((itr.second - itr.first) / 2) * 2;
  }
  int res = Y1.size() + min(residue, (int)Y2.size() - (int)Y1.size()) / 2;
  return res;
}

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> X(N);
  REP(i,N) cin >> X[i];
  vector<vector<int>> mod(M);
  REP(i,N) mod[X[i] % M].push_back(i);

  int res = mod[0].size() / 2;
  for(int i = 1; i <= M / 2; ++i) {
    if(2 * i == M) res += mod[M / 2].size() / 2;
    else {
      if(mod[i].size() < mod[M - i].size()) {
        res += solve(mod[i], mod[M - i], X);
        //cout << i << " " << M - i << ": " << solve(mod[i], mod[M- i], X) << endl;
      }else{
        res += solve(mod[M - i], mod[i], X);
        //cout << i << " " << M - i << ": " << solve(mod[i], mod[M- i], X) << endl;
      }
    }
  }
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 6144