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

int main(){
  int N,K;
  cin >> N >> K;
  map<int,int> m;
  for (int i=0;i<N;i++){
    int x;
    cin >> x;
    m[x]++;
  }
  vector<int> count; 
  for (auto x : m){
    int y=x.second;
    count.push_back(y);
  }
  sort(count.begin(),count.end());
  reverse(count.begin(),count.end());
  int ans=0;
  int s=count.size();
  if (s>K){
    for (int i=K;i<s;i++){
      ans+=count[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 10748
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    ll a, od = 0;
    REP(i, n){
        cin >> a;
        if(a % 2) od++;
    }
    if(od % 2) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	int sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	int cnt = 0;
	rep(i, n) {
		if (a[i] * 4 * m >= sum) cnt++;
	}
	if (cnt >= m) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3604
// author: lkx
// Problem:
// ID:
#include<bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define fi first
#define se second
#define PB push_back
#define MP make_pair
#define PH push
#define ll long long

const int MOD=1e9+7;

int n,m;
int p[100010];
vector<int> vec[100010];
int col=0;
int d[100010],visit[100010];
int ans=0;

void dfs(int a,int c)
{
//	cout<<"a="<<a<<endl;
	d[++d[0]]=a;
	visit[a]=c;
	for(int i=0;i<vec[a].size();i++)
		if(!visit[vec[a][i]])
			dfs(vec[a][i],c);
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++) scanf("%d",&p[i]),p[i]--;
	for(int i=0;i<m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		vec[x].PB(y);
		vec[y].PB(x);
	}
	for(int i=0;i<n;i++)
		if(!visit[i])
		{
			memset(d,0,sizeof(d));
			dfs(i,++col);
//			for(int j=1;j<=d[0];j++) cout<<d[j]<<' ';
			for(int j=1;j<=d[0];j++)
				if(visit[p[d[j]]]==col)
					ans++;	
//			puts("");
		}
	printf("%d",ans);
	return 0;
}
/*
5 2
5 3 1 4 2
1 3
5 4
*/

Measured memory_bytes: 9984
N = int(input())
p = list(map(int, input().split()))
answer = 0
for i in range(1,N-1):
  if p[i-1] < p[i] and p[i] < p[i+1]:
    answer += 1
  elif p[i-1] > p[i] and p[i] > p[i+1]:
    answer += 1
print(answer)

Measured memory_bytes: 3064
import java.util.*;

class Main{
	static public void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();//料理の種類
		int[] an=new int[n+1];//料理を食べる順番
		int[] bn=new int[n+1];//1-nまでの満足度
		int[] cn=new int[n-1];//満足度
		
		int sum=0;
		for(int i=0;i<n;i++){
			an[i]=sc.nextInt();
		}
		for(int i=0;i<n;i++){
			bn[i]=sc.nextInt();
		}
		for(int i=0;i<n-1;i++){
			cn[i]=sc.nextInt();
		}
		
		for(int i=0;i<n;i++){
			int a=an[i]-1;
			sum+=bn[a];
			if(an[i+1]-an[i]==1){
				int ss=an[i+1]-2;
				sum+=cn[ss];
			}
		}
		
		System.out.println(sum);
		
	}
}

Measured memory_bytes: 22740
using System;

public class AtCoder{
	public static void Main(){
		string[] s;
		s = NextS();
		
		int n; long k;
		n = int.Parse(s[0]);
		k = long.Parse(s[1]);
		
		s = NextS();
		long[] a = new long[n];
		long m = 0;
		for (int i = 0; i < n; i++){
			a[i] = long.Parse(s[i]);
			m += a[i];
		}
		
		int[] x = new int[40];
		for (int i = 0; i < n; i++){
			for(int j = 0; j < 40; j++){
				if(a[i]%2==0) x[j]++;
				else x[j]--;
				a[i] /= 2;
			}
		}
		
		long[] y = new long[40];
		long t = 1;
		for(int j = 0; j < 40; j++){
			if(x[j]<0) x[j] = 0;
			y[j] = x[j] * t;
			t *= 2;
		}
		
		long[] sum = new long[40];
		sum[0] = y[0];
		for(int j = 1; j < 40; j++){
			sum[j] = sum[j-1] + y[j];
		}
		
		t = 0;
		long ans = 0;
		for(int i = 39; i > -1; i--){
			if((k>>i)%2==1){
				if(i>0) if(t+sum[i-1]>ans) ans = t+sum[i-1];
				t += y[i];
				//Console.WriteLine(ans+".");
			}
		}
		if(t>ans) ans = t;
		if(k!=0) if(y[0]>ans) ans = y[0];
		
		Console.WriteLine(m + ans);
		//s = NextS();
	}

	public static void DebugWL(object x){ System.Diagnostics.Debug.WriteLine(x); }
	public static string[] NextS(){ return Console.ReadLine().Trim().Split(' '); }
}


Measured memory_bytes: 28124
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#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()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  ll n;
  cin >> n;
  ll ans = 1e10;
  for(ll i = sqrt(n); i > 0; i--){
    if(n % i == 0){
      ans = min(ans,max(n / i,i));
    }
  }
  cout << to_string(ans).size() << endl;
  return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#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++)
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};


int main(int argc, char const *argv[]) {
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		string s1;
		string s2;
		cin >> s1 >> s2;
		int dp[1000][1000] = {{0}};
		if (s1[0] == s2[0]) {
			dp[0][0] = 1;
		}
		for (int i = 1; i < s1.size(); ++i) {
			if (s1[i] == s2[0]) {
				dp[i][0] = 1;
			} else {
				dp[i][0] = dp[i - 1][0];
			}
		}
		for (int i = 1; i < s2.size(); ++i) {
			if (s1[0] == s2[i]) {
				dp[0][i] = 1;
			} else {
				dp[0][i] = dp[0][i - 1];
			}
		}
		for (int i = 1; i < s1.size(); ++i) {
			for (int j = 1; j < s2.size(); ++j) {
				if (s1[i] == s2[j]) {
					dp[i][j] = dp[i - 1][j - 1] + 1;
				} else {
					dp[i][j] = std::max(dp[i - 1][j], dp[i][j - 1]);
				}
			}
		}
		cout << dp[s1.size() - 1][s2.size() - 1] << endl;
	}	

	return 0;
}

Measured memory_bytes: 5120
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
#include <cmath>
#include <cstdio>
#include <complex>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main() {
  ll a,b,c;
  cin>>a>>b>>c;
  cout<<a+b+c+max({a,b,c})*9<<endl;
	return 0;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

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

const int MAX_N = 55;
const int MAX_S = 900;

int N;
int T[MAX_N];
bool dp[MAX_N][MAX_S][MAX_S];

signed main() {
	cin >> N;
	int sm = 0;
	rep(i, N) {
		cin >> T[i];
		sm += T[i];
	}

	rep(i, MAX_N) rep(j, MAX_S) rep(k, MAX_S) dp[i][j][k] = false;
	dp[0][0][0] = true;

	rep(i, N) {
		rep(j, MAX_S) {
			rep(k, MAX_S) {
				if (!dp[i][j][k]) continue;

				if (j + T[i] < MAX_S) {
					dp[i + 1][j + T[i]][k] = true;	// ?±±1?????????
				}
				if (k + T[i] < MAX_S) {
					dp[i + 1][j][k + T[i]] = true;	// ?±±2?????????
				}
				dp[i + 1][j][k] = true;				// ?±±3?????????
			}
		}
	}

	int mi = 99999999;
	rep(j, MAX_S) {
		rep(k, MAX_S) {
			if (dp[N][j][k]) {
				int ma = max(j, k);
				ma = max(ma, sm - j - k);
				mi = min(mi, ma);
			}
		}
	}

	cout << mi << endl;
}

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

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    if(a[a.size()-1] == b[0]&&b[b.size()-1] == c[0]){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

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

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

int numR = 1, numL = 0, tmp;
string S;
char pre = 'R';
vi vec;
bool ans[MAXN] = {};


void solve(){
    for(int i = 1; i < S.size(); ++i){
        // cout << pre << " " << S[i] << endl;
        if(S[i] == 'R') {
            if(pre != S[i]){
                vec.push_back(numL);
                numR = 1;
            } else {
                numR++;
            }
        } else {
            if(pre != S[i]){
                vec.push_back(numR);
                numL = 1;
                ans[i-1] = true;
                ans[i] = true;
            } else {
                    numL++;
                }
            }
        pre = S[i];
        }

        vec.push_back(numL);

    rep(i, vec.size()/2){
        tmp = vec[i*2] + vec[i*2+1];
        
        if(tmp % 2 == 0){
            vec[i*2] = tmp/2;
            vec[i*2+1] = tmp/2;
        } else {
            if(max(vec[i*2]-1, vec[i*2+1]-1) % 2 != 0){
                swap(vec[i*2], vec[i*2+1]);
            }

            if(vec[i*2] > vec[i*2+1]){
                vec[i*2] = (tmp+1)/2;
                vec[i*2+1] = (tmp-1)/2;
            } else {
                vec[i*2+1] = (tmp+1)/2;
                vec[i*2] = (tmp-1)/2; 
            }

        }
    }

    int cur = 0;

    rep(i, S.size()){
        if(ans[i]){
            cout << vec[cur];
            cur++;
        } else 
            cout << 0;

        if(i == S.size()-1) cout << endl;
        else cout << " ";
    }
}

int main(){
    cin >> S;

    solve();
}


Measured memory_bytes: 1272
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef tuple<ll,ll,ll,ll> tp;
typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m;
	cin>>n>>m;
	vi co(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		co[a]++;
		co[b]++;
	}
	rep(i,n)cout<<co[i]<<endl;
}











Measured memory_bytes: 256
MOD = 10**9 + 7
def solve(n, k):
    v = list(range(n+1))
    l = [0] * (n+1)
    u = [0] * (n+1)
    u[0] = n
    for i in range(1, n+1):
        l[i] = l[i-1] + v[i]
    for i in range(1, n+1):
        u[i] = u[i-1] + v[n-i]
    return sum((u[i] - l[i] + 1)for i in range(k-1, n+1)) % MOD

n, k = map(int, input().split())
print(solve(n, k))

Measured memory_bytes: 37976
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int n,a[110000];
int main(){
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1,greater<int>());
    a[0]=a[1];
    for (int i=0;i<=n;i++)
        if (a[i+1]<=i){
            int j=i+1;
            while (j<=n&&a[j]==i) j++;
            if ((j-i+1)&1||(a[i]-i)&1) puts("First");
            else puts("Second");
            break;
        } 
    return 0;
}
//atcoder 1999

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    long long a = 2;
    long long b = 1;
    while(--n >= 0){
        a += b;
        swap(a, b);
    }
    cout << a << endl;

    return 0;
}


Measured memory_bytes: 256
def hitachi(input_s: str):
    length = len(input_s)
    if length % 2 != 0:
        return 'No'
    else:
        for i in range(1,length // 2 + 1):
            if input_s[2*i-2:2*i] != 'hi':
                return 'No'
        return 'Yes'

if __name__ == "__main__":
    S = input()
    print(hitachi(S))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const ll MOD = 1000000007;

ll dp[100005][13];

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

  dp[0][0] = 1;
  rep(i,S.size()){
    rep(j,13){
      if(S[i] == '?'){
        rep(k,10){
          dp[i+1][(j*10+k)%13] += dp[i][j];
          dp[i+1][(j*10+k)%13] %= MOD;
        }
      }else{
        int k = S[i] - '0';
        dp[i+1][(j*10+k)%13] += dp[i][j];
        dp[i+1][(j*10+k)%13] %= MOD;
      }
    }
  }

  cout << dp[S.size()][5] << endl;
  
  return 0;
}



Measured memory_bytes: 10624
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c;
	while(cin>>a>>b>>c)
	{
		int x=a/2;
		int y=b/2;
		int z=c/2;
		int sum=0;
		int flag=1;
		while(a%2==0&&b%2==0&&c%2==0)
		{
			a=y+z;
			b=x+z;
			c=x+y;
			x=a/2;
			y=b/2;
		 	z=c/2;
		 	sum++;
			if(a==b&&a==c)
			{
				flag=0;
				break;
			}
		}
		if(flag==1)
			cout<<sum<<"\n";
		else
			cout<<"-1\n";
	}
}

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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		List<String> w = Arrays.asList("", "SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN");

		System.out.println(w.indexOf(sc.next()));
	}
}

Measured memory_bytes: 35488
#include <algorithm>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <stack>
#include <string>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
//const int INF = INT_MAX/3;

/*------------------------------------------------------------------------------*/

void dfs(char c, pair<int, int> cur, vector<vector<char>> &p, int H, int W){
  int x[4] = {-1, 0, 1, 0};
  int y[4] = {0, -1, 0, 1};
  p[cur.first][cur.second] = '.';

  REP(i, 0, 4){
    int nx = cur.second + x[i];
    int ny = cur.first + y[i];
    if(nx >= 0 && nx < W && ny >= 0 && ny < H && c == p[ny][nx]){
      dfs(c, {ny, nx}, p, H, W);
    }
  }
  return;
}

int solve(int H, int W, vector<vector<char>> p){
  int ans = 0;
  char c = '.';

  REP(i, 0, H){
    REP(j, 0, W){
      if('.' != p[i][j]){
        ans++;
        c = p[i][j];
        dfs(c, {i, j}, p, H, W);
      }
    }
  }
  return ans;
}

int main(){
  int H, W;
  while(1){
    cin >> H >> W;
    if(H == 0 && W == 0){
      break;
    }
    vector<vector<char>> p(H, vector<char>(W));
    REP(i, 0, H){
      REP(j, 0, W){
        cin >> p[i][j];
      }
    }
    int ans = solve(H, W, p);
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 4368
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

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

__attribute__((constructor)) void initial() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main() {
    string S;
    cin >> S;
    int cnt[128] = {0};

    rep(i, 4) {
        int c = (int)S[i];
        cnt[c]++;
    }
    bool result = true;
    rep(i, 128) {
        if (!(cnt[i] == 0 || cnt[i] == 2)) result = false;
    }
    cout << (result ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    ll n, m, v, p;
    cin >> n >> m >> v >> p;
    VL a(n);
    REP(i,n) a[i] = in();
    sort(ALL(a));
    reverse(ALL(a));
    if (v <= p){
        int ans = 1;
        REP(i,n){
            if (a[i] + m >= a[p - 1]) chmax(ans, i + 1);
        }
        cout << ans << endl;
        return 0;
    }
    int ok = p - 1, ng = n;
    while (ng - ok > 1){
        int x = (ok + ng) / 2;
        // cout << "check " << x << endl;
        if (a[x] + m < a[p - 1]){
            ng = x;
            continue;
        }
        ll s = 0;
        FOR(i,p-1,n-1){
            if (i == x) continue;
            s += min(m, a[x] + m - a[i]);
        }
        // cout << s << endl;
        if (s >= (v - p) * m) ok = x;
        else ng = x;
    }
    cout << (ok + 1) << endl;
    return 0;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n, m = [int(x) for x in input().split()]
    a = [int(x) for x in input().split()]
    a.sort()
    ans = a[-1] - a[0]
    b = []
    for i in range(m-1):
        b.append(a[i+1] - a[i])
    b.sort(reverse=True)
    for i in range(min(len(b), n-1)):
        ans -= b[i]
    print(ans)
        

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""


"""


Measured memory_bytes: 20176
// ALDS1_13_B.cpp
// Heuristic Search - 8 Puzzle
// ????????¨?????????24????????±??????????????????
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

const int N = 3;
const int N2 = 9;
const int INF = 40;
struct Puzzle {
    int f[N2];
    //int space;
    string path;

    bool operator < (const Puzzle &p) const {
        for (int i = 0; i < N2; i++) {
            if (f[i] == p.f[i]) continue;
            return f[i] > p.f[i];
        }
        return false;
    }
};

static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char dir[4] = {'u', 'l', 'd', 'r'};
map<Puzzle, bool> ms;
Puzzle in;
int ministep = INF;
int sx = 0;
int sy = 0;

void swap(int& a, int& b)
{
    int t = a;
    a = b;
    b = t;
}

bool isTarget(Puzzle p)
{
    for (int i = 0; i < N2; i++) {
        if (p.f[i] != i + 1)
            return false;
    }
    return true;
}

int getAllMD(Puzzle p)
{
    int dist = 0;
    int x, y;
    int ux, uy;
    for (int i = 0; i < N2; i++) {
        if (p.f[i] == N2) continue; // ??????0??????
        x = (p.f[i] - 1) / N;
        y = (p.f[i] - 1) % N;
        ux = i / N;
        uy = i % N;
        dist += abs(x - ux) + abs(y - uy);
    }
    return dist;
}

void bfs(int i)
{
    if (isTarget(in)) {
        ministep = min(ministep, i);
//        cout << "ministep = " << ministep << endl;
        return;
    }
    if (ms[in] || ministep < i + getAllMD(in)) {
        return;
    }
    
    ms[in] = true;
    for (int u = 0; u < 4; u++) {
        int tx = sx + dx[u];
        int ty = sy + dy[u];
        if (tx < 0 || tx >= N || ty < 0 || ty >= N)
            continue;
        swap(in.f[sx * N + sy], in.f[tx * N + ty]);
        sx = tx;
        sy = ty;
        in.path += dir[u];
        /* test */
//    cout << "(i = " << i << ") " << in.path << endl;
//    for (int j = 0; j < N2; j++)
//        cout << " " << in.f[j];
//    cout << endl;
//    cout << "MD: " << getAllMD(in) << endl;
        bfs(i+1);
        sx = sx - dx[u];
        sy = sy - dy[u];
        swap(in.f[sx * N + sy], in.f[tx * N + ty]);
        in.path.pop_back();
    }
    ms[in] = false;
}

int main()
{
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);

    for (int i = 0; i < N2; i++) {
        cin >> in.f[i];
        if (in.f[i] == 0) {
            sx = i / N;
            sy = i % N;
            in.f[i] = 9; // ??????isTarget?????????
        }
    }
    bfs(0);
    cout << ministep << endl;
    return 0;
}

Measured memory_bytes: 10364
#include<iostream>
#define MAX_PR 10
using namespace std;
typedef long long ll;
ll d,g,ans=10000000000;
ll p[MAX_PR],c[MAX_PR];
bool all[MAX_PR];
void solve(ll pr,ll sol,ll score){
  if(pr==d){
    ll tmp,least=g-score;
    for(int i=d-1;i>=0;i--){
      if(least<=0){
        break;
      }
      if(all[i]) continue;
      if(100*(i+1)*p[i]<=least){
        least -= 100*(i+1)*p[i];
        sol += p[i];
      }else{
        tmp=100*(i+1);
        sol+=(least+tmp-1)/tmp;
        break;
      }
    }
    ans = min(sol,ans);
    return;
  }
  all[pr]=0;
  solve(pr+1,sol,score);
  all[pr]=1;
  solve(pr+1,sol+p[pr],score+100*(pr+1)*p[pr]+c[pr]);
  all[pr]=0;
}
signed main(){
  cin >> d>>g;
  for(int i=0;i<d;i++){
    cin >> p[i]>>c[i];
  }
  solve(0,0,0);
  cout << ans << endl;
}


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

#define pb push_back
#define mp make_pair
#define F(i, a, n, b) for(int i=a;i<n;i+=b)
#define REVF(i, a, b, c) for(int i=a;i>=b;i-=c)
#define REP(i, n) F(i, 0, n, 1)
#define REP1(i, n) F(i, 1, n+1, 1)
#define REV(i, n) REVF(i, n, 0, 1)
#define PTR(it, x) for(auto it=x.begin();it!=x.end();++it)
#define REVPTR(it, x) for(auto it=x.rbegin();it!=x.rend();++it)
#define MOD 1000000007

typedef unsigned long long ll;

const int MAX = 2e6 + 5;

int a,b,c,d,x,y;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin>>a>>b>>c>>d;
	x = c / b;
	y = a / d;
	if(c % b > 0)
		x++;
	if(a % d > 0)
		y++;
	if(x <= y)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <sstream>
#include <complex>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
#define ll long long
#define ull unsigned long long

const int MAXN = 100005;
const int INF = 0x3f3f3f3f;
const ll INFLL = 9223372036854775807;
const int MOD = 1e9 + 7;
const double PI=2.0*asin(1.0);

int N, K, arr[100], ans;

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	
	while(cin>>N>>K){
		ans=0;
		for(int i=0; i<N; i++){
			cin>>arr[i];
		}
		sort(arr, arr+N);
		for(int i=1; i<=K; i++)
			ans+=arr[N-i];
		cout<<ans<<endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 256
n = int(input())
As = list(map(int,input().split()))
min_d = float('inf')
sum_1 = 0
sum_2 = sum(As)
for i in range(n):
  sum_1 += As[i]
  sum_2 -= As[i]
  min_d = min(min_d,abs(sum_1-sum_2))
print(min_d)
  
  
  

Measured memory_bytes: 3060
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> Point;

int main()
{
	int n;
	while(scanf("%d", &n), n!=-1){

		Point p(1.0, 0.0), v(0.0, 1.0);
		rep(i, n-1){
			p += v;
			v = p/abs(p)*Point(0.0, 1.0);
		}
		printf("%lf\n%lf\n", p.real(), p.imag());
	}

	return 0;
}

Measured memory_bytes: 0
#define _USE_MATH_DEFINES
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<string>
#include<cctype>
#include<iomanip>
#include<cassert>
//using namespace std;
//#define rep(i, n) for(int i = 0; i < (int)(n); i++)

bool judge(int number){
	int waru = 3;

	if (number == 2){//2のとき
		return true;
	}
	if (number > 2 && number % 2 != 0){//3以上の奇数のとき
		while (waru <= std::sqrt(number)){
			if (number % waru == 0){
				return false;
			}

			waru += 2;
		}

		return true;
	}
	else{
		return false;
	}
}

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

	int all;//入力列の数
	int current_number;
	int counter = 0;

	std::cin >> all;

	for (int i = 0; i < all; i++){
		std::cin >> current_number;

		if (judge(current_number) == true){
			counter++;
		}
	}

	std::cout << counter << '\n';

	return 0;
}


Measured memory_bytes: 3140
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int A,B,K; cin >> A >> B >> K;
    for (int i=0;i<K;i++){
        if (i%2==0){
            if (A%2==1) A--;
            B += (A/2);
            A /= 2;
        }
        else {
            if (B%2==1) B--;
            A += (B/2);
            B /= 2;
        }
    }
    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y;
    cin >> x  >> y;
    cout << x + y/2 << endl;

    return 0;
}

Measured memory_bytes: 256
#=
C:
- Julia version: 
- Author: abap
- Date: 2020-01-18
=#
N,K,S = parse.(split(readline()))
A = fill(1, N)
if N - K < S
for i in 1:K
	A[i] = S
end
for k in A
	print("$k ")
end
else
    A = fill(S + 1, N)
    for i in 1:K
        A[i] = S
	end
	for k in A
		print("$k ")
	end
end

println("")

Measured memory_bytes: 197508
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

#define str to_string
#define rep(i, n) for (int i=0; i<int(n); i++)
#define all(c) (c).begin(), (c).end()

#define MAX_M 1000001

int n, m;
char s[MAX_M];


// O(m)
int solve() {
  if (2*n+1 >= m) return 0;
  // p: (IO*n + I)
  // count p in s
  int count = 0;
  int cont_a = 0;
  int cont_b = 0;
  for (int i=0; i<m; i++) {
    char c = s[i];
    // a
    if      (i % 2 == 0 && c == 'I') cont_a++;
    else if (i % 2 != 0 && c == 'O') ; // ok
    else {
      if (cont_a >= n+1) {
        count += cont_a - n;
      }
      cont_a = 0;
    }
  }

  for(int i=1; i<m; i++) {
    char c = s[i];
    // b
    if      (i % 2 == 0 && c == 'O') ;
    else if (i % 2 != 0 && c == 'I') cont_b++;
    else {
      if (cont_b >= n+1) {
        count += cont_b - n;
      }
      cont_b = 0;
    }
  }
  return count;
}

int main() {
  while (true) {
    cin >> n;
    if (n == 0) break;
    cin >> m;
    cin >> s;
    cout << solve() << "\n";
  }
  return 0;
}

Measured memory_bytes: 2136
#include <stdio.h>

int main(){
  int a1,a2,a3;
  int r;
  scanf("%d %d %d",&a1,&a2,&a3);
  r = a1 + a2 + a3;
  if(r <= 21){
    printf("win");
  }else{
    printf("bust");
  }
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
using namespace std;

string a,b,c;

int main(void)
{
	cin>>a>>b>>c;
	if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0])
	cout<<"YES"<<endl;
	else
	cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
n, y = map(int, input().split())

res10000 = -1
res5000 = -1
res1000 = -1

for i in range(n+1):
	for j in range(n+1-i):
		k = n - i - j
		total = 10000 * i + 5000 * j + 1000 * k
		if total == y:
			res10000 = i
			res5000 = j
			res1000 = k
print(res10000, res5000, res1000)


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

using namespace std;

void solve2() {
	long long a, b, c;
	cin >> a >> b >> c;
	long long ans = b / c - a / c;
	if (a %c==0)
		ans++;
	cout << ans << endl;

}

void solve1() {
	string a, b, c;
	cin >> a >> b >> c;
	cout << "A" << b[0] << "C" << endl;
}

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

Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int a,b,h,m;
  cin>>a>>b>>h>>m;

  double a_rad=2*M_PI/720*(60*h+m);
  double b_rad=2*M_PI/60*m;
  double theta=abs(a_rad-b_rad);

  cout<<sqrt(a*a+b*b-2*a*b*cos(theta))<<endl;

  return 0;
}




Measured memory_bytes: 4244
#include <stdio.h>

int main(void) {

  int n;
  scanf("%d", &n);
  char s[n+1];
  scanf("%s", s);
  int left = 0;
  int right = 0;
  int dif = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '(') {
      dif++;
    } else {
      dif--;
    }
    if (dif < 0) {
      left++;
      dif++;
    }
  }
  if (dif > 0) {
    right = dif;
  }
  for (int i = 0; i < left; i++) {
    printf("(");
  }
  printf("%s", s);
  for (int i = 0; i < right; i++) {
    printf(")");
  }
  printf("\n");

  return 0;
}

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

int64_t MOD = 1000000007;
double PI = 3.141592653589793;

int main()
{
    int N;
    cin >> N;
    vector<char> list(N);
    vector<bool> tmp(N);
    bool x = true;
    int red = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> list[i];
        if (list[i] == 'W')
            x = false;
        if (x && list[i] == 'R')
            tmp[i] = true;
        else
            tmp[i] = false;
        if (list[i] == 'R')
            red++;
    }
    int ans = 0;
    for (int i = red; i < N; i++)
    {
        if (list[i] == 'R' && !tmp[i])
            ans++;
    }
    cout << ans;
}

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

int main(){
    string s;
    cin >> s;
    vector<ll> vec(s.size(),0);
    
    for(ll i=0;i<s.size();i++){
        if(s[i]=='R'){
            ll cnt=0;
            while(s[i]=='R'){
                cnt++;
                i++;
            }
            vec[i]+=cnt/2;
            vec[i-1]+=(cnt+1)/2;
        }else{
            continue;
        }
    }
    
    for(ll i=s.size()-1;i>=0;i--){
        if(s[i]=='L'){
            ll cnt=0;
            while(s[i]=='L'){
                cnt++;
                i--;
            }
            vec[i]+=cnt/2;
            vec[i+1]+=(cnt+1)/2;
        }else{
            continue;
        }
    }
    
    rep(i,s.size()){
        if(i) cout << " ";
        cout << vec[i];
    }
    cout << endl;
    

    return 0;
}





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

void fnInput(vector<int>& rvnMaxHeap)
{
  int nMaxSiz;
  cin >> nMaxSiz;
  rvnMaxHeap.resize(nMaxSiz + 1);

  for (int i = 1; i < nMaxSiz + 1; ++i)
    cin >> rvnMaxHeap[i];
}

void fnMaxHeapify(vector<int>& rvnMaxHeap, int nx)
{
  int nLeft = nx * 2;
  int nRigt = nLeft + 1;
  int nLrge = nx;

  if (nLeft < rvnMaxHeap.size()  &&
      rvnMaxHeap[nLrge] < rvnMaxHeap[nLeft])  
    nLrge = nLeft;
  if (nRigt < rvnMaxHeap.size()  &&
      rvnMaxHeap[nLrge] < rvnMaxHeap[nRigt])
    nLrge = nRigt;

  swap(rvnMaxHeap[nx], rvnMaxHeap[nLrge]);
  if (nx != nLrge)
    fnMaxHeapify(rvnMaxHeap, nLrge);
}

void fnMaximumHeap(vector<int>& rvnMaxHeap)
{
  for (int i = (rvnMaxHeap.size() - 1) / 2; i > 0; --i)
    fnMaxHeapify(rvnMaxHeap, i);
}

void fnResult(const vector<int>& cnrvnMaxHeap)
{
  for (int i = 1; i < cnrvnMaxHeap.size(); ++i)
    cout << " " << cnrvnMaxHeap[i];

  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnMaxHeap; 

  fnInput(vnMaxHeap);
  fnMaximumHeap(vnMaxHeap);
  fnResult(vnMaxHeap);
  return 0;
}

Measured memory_bytes: 4972
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }

const int MAXN=200000;
const int MAXQ=200000;

int n,nq;
char s[MAXN+1];
int qc[MAXQ],qdir[MAXQ];

int sim(int at) {
	REP(i,nq) {
		if(s[at]==qc[i]) { if(qdir[i]=='L') --at; if(qdir[i]=='R') ++at; }
		if(at<0||at>=n) return at;
	}
	return at;
}

int calcleft() {
	int lo=0,hi=n+1;
	while(lo+1<hi) {
		int mi=lo+(hi-lo)/2;
		int pos=sim(mi-1);
		if(pos==-1) lo=mi; else hi=mi;
	}
	return lo;
}

int calcright() {
	int lo=0,hi=n+1;
	while(lo+1<hi) {
		int mi=lo+(hi-lo)/2;
		int pos=sim(n-mi);
		if(pos==n) lo=mi; else hi=mi;
	}
	return lo;
}

int solve() {
	return n-calcleft()-calcright();
}

void run() {
	scanf("%d%d",&n,&nq);
	scanf("%s",s);
	REP(i,nq) scanf(" %c %c",&qc[i],&qdir[i]);
	printf("%d\n",solve());
}

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

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
using namespace std;


ll gcd(ll a, ll b)   //Function to find gcd of two numbers
{
    if (a == 0)
    return b;
    return gcd(b % a, a);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
  
    ll x1 = a*c , x2 = a*d , x3 = b*c , x4 = b*d;

    cout<<max({x1,x2,x3,x4})<<endl;


    return 0;
}

Measured memory_bytes: 3544
fun main(args: Array<String>) {
    val iv = readLine()!!.toCharArray().distinct().sorted().map { it - 'a' }
            .withIndex().reduce { acc, iv -> if (acc.index == acc.value) iv else acc }

    val ch = 'a' + iv.index + if (iv.index == iv.value) 1 else 0
    println(if (ch.isLowerCase()) ch else "None")
}


Measured memory_bytes: 40332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

string S, T, U;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
	
	int N, R; cin >> N >> R;

	if(N >= 10) cout << R << endl;
	else{
		cout << R + 100*(10 - N) << endl;
	}

}

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

class Program {

    static void Main (string[] args) {
        string[] strtemp = Console.ReadLine ().Split (' ');
        for (int i = 0; i < 5; i++) {
            int temp = int.Parse (strtemp[i]);
            if (temp == 0) {
                Console.WriteLine (i + 1);
            }
        }
    }

}

//dotnet run --project test

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

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N, M, R;
		N = sc.nextInt();
		M = sc.nextInt();
		R = sc.nextInt();
		int[] r = new int[R];
		int[][] mat = new int[N][N];
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				if (i != j)
					mat[i][j] = Integer.MAX_VALUE / 3;
			}
		}
		for (int i = 0; i < R; ++i) {
			r[i] = sc.nextInt();
			--r[i];
		}
		for (int i = 0; i < M; ++i) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			--a;
			--b;
			mat[a][b] = c;
			mat[b][a] = c;
		}
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				for (int k = 0; k < N; ++k) {
					mat[j][k] = Math.min(mat[j][k], mat[j][i] + mat[i][k]);
				}
			}
		}
		int[] ord = new int[R];
		for (int i = 0; i < R; ++i) {
			ord[i] = i;
		}

		int ans = Integer.MAX_VALUE / 3;
		do {
			int tmp = 0;
			for (int i = 0; i + 1 < R; ++i) {
				tmp += mat[r[ord[i]]][r[ord[i + 1]]];
			}
			ans = Math.min(ans, tmp);
		} while (nextPermutation(ord));
		System.out.println(ans);
	}

	boolean nextPermutation(int[] a) {
		int i = a.length - 1;
		while (i > 0 && a[i - 1] > a[i])
			--i;
		if (i == 0)
			return false;
		int j = a.length - 1;
		while (a[i - 1] >= a[j])
			--j;
		a[i - 1] ^= a[j];
		a[j] ^= a[i - 1];
		a[i - 1] ^= a[j];
		int t = a.length - 1;
		int s = i;
		while (t - s > 0) {
			a[s] ^= a[t];
			a[t] ^= a[s];
			a[s] ^= a[t];
			++s;
			--t;
		}
		return true;
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


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


#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))
#define  nl "\n";

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



template <class T> inline T biton(T n, T pos)
{
    return n | ((T)1 << pos);
}
template <class T> inline T bitoff(T n, T pos)
{
    return n & ~((T)1 << pos);
}
template <class T> inline T ison(T n, T pos)
{
    return (bool)(n & ((T)1 << pos));
}
template <class T> inline T gcd(T a, T b)
{
    while (b)
    {
        a = a % b;
        swap(a, b);
    }
    return a;
}
template <class T> inline T bigmod(T p, T e, T m)
{
    T ret = 1;
    for (; e > 0; e >>= 1)
    {
        if (e & 1)
            ret = (ret * p) % m;
        p = (p * p) % m;
    }
    return (T)ret;
};



#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " is " << arg1 << std::endl;
}
template < typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " is " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define debug(...)
#endif


bool pal(string str)
{

    string rev=str;

    reverse(rev.begin(),rev.end());

    return rev==str;

}

void solve()
{
    string str;
    cin>>str;


    int f=((int)str.size()-1)/2;

    string str2=str.substr(0,f);

    f=((int)str.size()+3)/2;

    string str3=str.substr(f-1);

    if(pal(str)&& pal(str2)&& pal(str3)){

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

}

int main()
{
    ios_base::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    cout.tie(nullptr);
    cin.tie(nullptr);

    int t = 1;

    while (t--)
    {
        solve();
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <bitset>
#include <unordered_map>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <cstring>
#include <cmath>

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


void dfs(int parent, int current, const vector<vector<int> >& nodes, int distances[], int distance = 0){
    distances[current] = distance;
    for(int to : nodes[current]){
        if( to == parent ){
            continue;
        }
        dfs(current, to, nodes, distances, distance+1);
    }
}

int main(){
    int N, u, v;
    vector<vector<int>> nodes;
    cin >> N >> u >> v;
    u--;
    v--;
    nodes.resize(N);
    
    rep(i, N-1){
        int from, to;
        cin >> from >> to;
        from--;
        to--;
        nodes[from].push_back(to);
        nodes[to].push_back(from);
    }
    int distance_from_aoki[N], distance_from_takahashi[N];
    dfs(-1, u, nodes, distance_from_takahashi);
    dfs(-1, v, nodes, distance_from_aoki);

    int ans = 0;
    rep(i,N){
        if( distance_from_takahashi[i] < distance_from_aoki[i] ){
            ans = max(ans, distance_from_aoki[i] - 1);
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 12928
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <queue>
#define PIE 3.14159265358979
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;


int N,M;
vector<pair<int,ll> > G[100005];
vector<ll> V;
vector<pair<ll,pair<int,int> > > E;


class union_find{
    int n;
    vector<int> par;
    vector<int> rank;
public:
    union_find(int n){  //初期化
        this->n=n;
        par = vector<int>(n,0);
        rep(i,n){par[i]=i;}
        rank = vector<int>(n,0);
    }
    int find(int x){    //親
        if(par[x]==x){
            return x;
        }else{
            par[x]=find(par[x]);
            return par[x];
        }
    }
    void unite(int x,int y){    //結合
        x=find(x);
        y=find(y);
        if(x==y){return;}
        if(rank[x]<rank[y]){
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y])rank[x]++;
        }
    }
    bool same(int x,int y){     //同じグループか判定
        return find(x)==find(y);
    }
};



int main(){
    cin>>N>>M;
    union_find uf(N);
    vector<ll> vsum,esum;
    vsum.resize(N,0),esum.resize(N,0);
    E.resize(M);
    rep(i,N){
        cin>>vsum[i];
    }
    rep(i,M){
        int a,b;ll y;
        cin>>a>>b>>y;
        a--,b--;
        E[i]=make_pair(y,make_pair(a,b));
    }
    sort(E.begin(),E.end());
    int ans = M;
    for(auto e: E){
        ll cost = e.first;
        int v1 = e.second.first,v2 = e.second.second;
        v1=uf.find(v1),v2=uf.find(v2);
        int par = uf.find(v1);
        if(v1!=v2){
            uf.unite(v1,v2);
            par=uf.find(v1);
            vsum[par]=vsum[v1]+vsum[v2];
            esum[par]=esum[v1]+esum[v2]+1;
        }else{
            esum[par]++;
        }
        if(vsum[par]>=cost){
            ans -= esum[par];
            esum[par]=0;
        }
    }
    cout<<ans<<endl;
    
}



Measured memory_bytes: 6528