akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


bool check(vint a) {
    int sz = a.size();
    int p = a[0];
    srep(i, 1, sz) {
        if (abs(p-a[i]) > 1) return false;
        p = a[i];
    }
    return true;
}

void update(vint& a) {
    int sz = a.size();
    int id = 0;
    while (1) {
        while (1) {
            if (a[id] < 9) {
                a[id]++;
                break;
            }
            else {
                id++;
                if (id >= sz) {
                    a = {};
                    rep(i, sz) a.push_back(0);
                    a.push_back(1);
                    return;
                }
            }
            
        }
        rrep(i, id) a[i] = max(a[id]-(id-i), 0);
        if (check(a)) return;
    }
}

int main() {
    int k;
    cin >> k;
    vint a = {1};
    rep(i, k-1) update(a);
    ll ans = 0, d = 1;
    for (int ai : a) {
        ans += ai*d;
        d *= 10;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
  string input;

  cin >> input;

  vector<char> str_vec(input.begin(), input.end());

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

  if (str_vec[0] == str_vec[1] && str_vec[1] != str_vec[2] &&
      str_vec[2] == str_vec[3]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main() {
  int N,K;
  int l[60];
  int sum = 0;
 
  cin >> N>> K;
  for(int i=0;i<N;i++){
    cin >> l[i];
  }
  
  sort(l,l+N,greater<int>());
  for(int i=0;i<K;i++){
    sum += l[i];
  }
  cout << sum<<endl;
  return 0;
}

Measured memory_bytes: 3528
#include <cstdio>
#include <algorithm>
using std::sort;

const int MAXN =200000;

void new_exclude(int *a,int N)
{
	int i,b[MAXN];
	for(i=0;i<N;i++)
		b[i]=a[i];
	sort(b,b+N);
	
	for(i=0;i<N;i++){
		if(a[i]<b[N/2])
			printf("%d\n",b[N/2]);
		else
			printf("%d\n",b[N/2-1]);
	}

}


int main(void)
{
	
	int i,N,a[MAXN];
	scanf("%d",&N);
	for(i=0;i<N;i++)
		scanf("%d",a+i);

	new_exclude(a,N);
	return 0;

}




Measured memory_bytes: 3712
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

mn = None
for i in range(N):
    x = abs(A - (T - H[i] * 0.006))
    if mn is None or x < mn[1]:
        mn = (i, x)
print(mn[0] + 1)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){

	int A[200001]={0};
	int N;
	int chk;
	cin >> N ;

	for(int i = 0; i < N -1 ; i++){
		cin >> chk;
        A[chk]++;
    }
	for(int i=1; i <= N; i++){
		cout << A[i] << " ";
	}
	cout << endl;

	return 0;
}

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

int main(){
    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());
    if(s<t) cout << "Yes" << endl;
    else  cout <<  "No" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	
	if (a == b) {
		if (b != c) {
			cout << "Yes" << endl;
		}
		else { cout << "No" << endl; }
	}
	else if (b == c) {
		if (c != a) {
			cout << "Yes" << endl;
		}
		else { cout << "No" << endl; }
	}
	else if (c == a) {
		if (a != b) {
			cout << "Yes" << endl;
		}
		else { cout << "No" << endl; }
	}
	else {
		cout << "No" << endl;
	}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct UnionFind
{
    vector<ll> par;
    vector<ll> rank;
    vector<ll> sz;
    UnionFind(ll n) : par(n), rank(n), sz(n)
    {
        for(ll i = 0; i < n; i++)
        {
            par[i] = i;
            rank[i] = 0;
            sz[i] = 1;
        }
    }
    ll root(ll x)
    {
        if(par[x] == x) return x;
        else return par[x] = root(par[x]);
    }
    void unite(ll x, ll y)
    {
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(rank[x] < rank[y])
        {
            par[x] = y;
            sz[y] += sz[x];
        }
        else
        {
            par[y] = x;
            sz[x] += sz[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
    bool same(ll x, ll y)
    {
        return root(x) == root(y);
    }
    ll size(ll x)
    {
        x = root(x);
        return sz[x];
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> vp(n);
    for(int i = 0; i < n; i++)
    {
        cin >> vp[i];
    }
    vector<int> vx(m);
    vector<int> vy(m);
    for(int i = 0; i < m; i++)
    {
        cin >> vx[i] >> vy[i];
    }
    UnionFind tree(n+1);
    for(int i = 0; i < m; i++)
    {
        ll x = vx[i];
        ll y = vy[i];
        if(!tree.same(x, y))
        {
            tree.unite(x, y);
        }
    }
    int ans = 0;
    for(ll i = 0; i < n; i++)
    {
        if(tree.same(i+1, vp[i])) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3712
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String w = sc.next();
		
		// 計算
		String result = "Yes";
		char[] c = w.toCharArray();
		Arrays.sort(c);
		char now = ' ';
		int cnt = 0;
		for(int i = 0; i < c.length; i++){
		    if(now == c[i]){
		        cnt++;
		    }else{
		        if(cnt%2 == 1){
		            result = "No";
		            break;
		        }else{
		            cnt = 1;
		            now = c[i];
		        }
		    }
		}
		if(cnt%2 == 1) result = "No";
		
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}



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


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL getd(LL N) {
	LL ans = 0;

	while(N > 0) {
		N /= 10;
		ans++;
	}

	return ans;
}

int main(){

	LL N; cin >> N;


	LL ans = INF2;
	for (LL i = 1; i*i <= N; i++) {
		if (N%i == 0) {
			LL da = getd(i);
			LL db = getd(N / i);

			ans = min(ans, max(da, db));
		}
	}

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

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    ll N, K;
    cin >> N >> K;
    int num[N];
    fill(num, num + N, 0);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        num[a - 1]++;
    }
    sort(num, num + N);
    reverse(num, num + N);
    ll ans = N;
    for (int i = 0; i < K; i++) {
        ans -= num[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
import sys
a, b, c = map(int, input().split())
 
if a > b:
  for i in range(b, a):
    if i == c:
      print('Yes')
      sys.exit(0)
else:
  for i in range(a, b):
    if i == c:
      print('Yes')
      sys.exit(0)

print('No')

Measured memory_bytes: 3060
#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 <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    double a, b, s;
    cin >> a >> b >> s;

    double ans;
    double x = (2.0 * s) / (a * a) - b;
    if(x >= 0.0){
        ans = atan2(b - x, a);
    }
    else{
        double y = (2.0 * s) / (a * b);
        ans = atan2(b, y);
    }
    ans *= 180.0 / M_PI;
    printf("%.10f\n", ans);

    return 0;
}


Measured memory_bytes: 384
package main

import "fmt"

func nextInt() int {
	var x int
	fmt.Scan(&x)
	return x
}

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func main() {
	N := nextInt()

	type whenWhere struct {
		t, x, y int
	}
	flgNG := false
	pre := whenWhere{0, 0, 0}
	for range make([]struct{}, N) {
		now := whenWhere{nextInt(), nextInt(), nextInt()}
		t := now.t - pre.t
		h := abs((now.x + now.y) - (pre.x + pre.y))

		if h > t || t%2 != h%2 {
			flgNG = true
		}
		pre = now
	}
	if !flgNG {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 5504
N,M = (int(x) for x in input().split())
num = [-10]*N

ans = True

for i in range(M):
    s,c = (int(x) for x in input().split())

    if num[s-1] == -10 or num[s-1] == c:
        num[s-1] = c
    else:
        ans = False
        break

#最小値の値を求める
if num[0] == -10:
    if N != 1:
        num[0] = 1
    else:
        num[0] = 0
        
for i in range(1,N):
    if num[i] == -10:
        num[i] = 0
        
if N != 1:
    if num[0] == 0:
        ans = False

if ans:
    for s in num:
        print(s,end='')

    print()

else:
    print(-1)



Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String S = sc.next();
      String T = S.replace("/","");
      int U = Integer.parseInt(T);
      if(U<=20190430){
        System.out.println("Heisei");
      }else{
        System.out.println("TBD");
      }
    }
}

Measured memory_bytes: 35544
from functools import reduce
N, M = map(int, input().split())
A, B = zip(*sorted((list(map(int, input().split())) for _ in range(N))))
ans = reduce(lambda acc, t: (acc[0] + t[0] * min(max(0, M - acc[1]), t[1]), acc[1] + t[1]), zip(A, B), (0, 0))[0]
print(ans)


Measured memory_bytes: 35796
#include<bits/stdc++.h>
using namespace std;
long long int mod97=1000000007;
double pi=3.1415926536;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
bool rev(long long int a,long long int b)
{
    if(a>b)return true;
    else return false;
}
bool compa(pair<string,pair<int,int>>a,pair<string,pair<int,int>>b)
{
    if(a.first==b.first)
    {
        if(a.second.first>b.second.first)
        return true;
        else
        return false;
    }
    if(a.first<b.first)
    return true;
    else 
    return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    long long int n,k;
    cin>>n>>k;
    long long int a[n];
    for(long long int i=0;i<n;i++)cin>>a[i];
    long long int pre=1;
    long long int p[n-k+1];
    p[0]=1;
    for(long long int i=0;i<k;i++)
    p[0]+=a[i];
    for(long long int i=1;i<=n-k;i++)
    {
        p[i]=p[i-1]-a[i-1];
        p[i]=p[i]+a[i+k-1];
    }
    //for(auto x:p)
    //cout<<x<<" ";cout<<endl;
    for(long long int i=k;i<n;i++)
    {
        if(p[i-k+1]>p[i-k])
        {
            cout<<"Yes"<<endl;
        }
        else
        cout<<"No"<<endl;
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    int count=1;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 6764
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
string s,t;
  cin>>s>>t;
  int n=s.size();
  map<char,int> mas,mat;
  rep(i,0,n){
   mas[s[i]]++;
   mat[t[i]]++;
  }
  int cnt[2][220000];
  rep(i,0,n){
   rep(j,0,2){
     cnt[j][i]=0; 
   }
  }
  for(auto v:mas){
    cnt[0][v.second]++; 
  }
  for(auto v:mat){
   cnt[1][v.second]++; 
  }
  bool ok=true;
  rep(i,0,n){
    if(cnt[0][i]!=cnt[1][i]) ok=false;
  }
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 5444
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

ll raise(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


string s;

void solve()
{
    cin >> s;
    int ans=0, cnt=1;
    for (int i=1; i<s.size(); ++i) {
        if (s[i]==s[i-1]) ++cnt;
        else{
            if (s[i-1]=='R') ans=max(ans,cnt);
            cnt=1;
        }
    } if (s[2]=='R') ans=max(ans,cnt); nout(ans);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

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

int main() {
	long long n,k,i,j,ans;
	cin >> n >> k;
	
	vector<long long> p(n),c(n);
	for(i=0; i<n; i++){
		cin >> p[i];
		p[i]--;
	}
	for(i=0; i<n; i++){
		cin >> c[i];
	}
	
	vector<long long> a(n,-1);
	long long beg,cur,cur2,res,m;
	
	beg=0; ans=-1e10; res=0;
	while(beg<n){
		if(a[beg]==1){ //checked?
			beg++;
		}else{
			//loop size check
			a[beg]=1;
			vector<long long> root(0);
			res=p[beg];
			root.push_back(c[res]);
			while(a[res]==-1){
				a[res]=1;
				res=p[res];
				root.push_back(c[res]);
			}
			
			m=root.size(); //loop size
          /*
          for(i=0; i<m; i++){
            cout << root[i] << ' ';
          }
          cout << endl;
          */
			vector<long long> mid(m+1,-1e10); // max of subloop
			mid[0]=0;
            for(i=0; i<m; i++){
              cur=0;
				for(j=0; j<m; j++){
					cur+=root[(i+j)%m];
					mid[j+1]=max(mid[j+1],cur);
				}
			}
			for(i=2; i<m; i++){
					mid[i]=max(mid[i-1],mid[i]);
			}
          /*
          for(i=0; i<m; i++){
            cout << mid[i] << ' ';
          }
          cout << endl;
          */
			cur2=-1e10;
			if(mid[m]>0){
				for(i=0; i<=min(m-1,k); i++){
					cur2=max(cur2,mid[i]+((k-i)/m)*mid[m]);
				}
			}else{
                i=min(m-1,k);
				cur2=max(cur2,mid[i]);
			}
			
			ans=max(ans,cur2);
		}
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 3808
using System;
using System.Collections.Generic;
using System.Linq;

namespace ForATCODER
{
    public class Program
    {
        public static void Main(string[] args)
        {

              long[] nm = s2larray(Console.ReadLine().Split(' '));
            long n = nm[0]; long m = nm[1];

          RESULT (((n) * (n - 1) / 2) + ((m) * (m - 1) / 2));


        }
    
    



    
      
      
        static int s2i(String s)
        {
            return Convert.ToInt32(s);
        }
        static long s2l(String s)
        {
            return Convert.ToInt64(s);
        }
        static void RESULT(double res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(long res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(ulong res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(int res)
        {
            Console.WriteLine(res);
        }
        static void RESULT(String res)
        {
            Console.WriteLine(res);
        }
        static String[] ReadLineAll(int count)
        {
            String[] res = new String[count];
            for (int i = 0; i < count; i++)
            {
                res[i] = Console.ReadLine();
            }
            return res;
        }

        static int[] s2iarray(String[] src)
        {
            int len = src.Length;
            int[] res = new int[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt32(src[i]);
            }
            return res;
        }
        static long[] s2larray(String[] src)
        {
            int len = src.Length;
            long[] res = new long[len];
            for (int i = 0; i < len; i++)
            {
                res[i] = Convert.ToInt64(src[i]);
            }
            return res;
        }
    }
}


Measured memory_bytes: 13268
N, M = map(int, input().split())
X = list(map(int, input().split()))

if N >= M:
    print(0)
else:
    distance = []
    X.sort()
    for i in range(M-1):
        distance.append(X[i+1]-X[i])
    distance.sort(reverse=True)
    print(sum(distance[N-1:]))

Measured memory_bytes: 13960
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,p=inf,ans=0,cnt=-1; cin>>n;
    rep(i,n){
        int h; cin>>h;
        if(p>=h) cnt++;
        else cnt=0;
        p=h;
        ans=max(cnt,ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int MAX_N = 100000;

bool is_prime[MAX_N];

void make_prime(){
  REP(i, MAX_N) is_prime[i] = true;
  is_prime[0] = is_prime[1] = false;
  FOR(i, 2, sqrt(MAX_N) + 1){
    if(!is_prime[i]) continue;
    for(int j = i + i; j < MAX_N; j += i) is_prime[j] = false;
  }
}

int main() {
  make_prime();
  int N;
  while(scanf("%d", &N) != EOF){
    int ans = 0;
    FOR(i, 1, N + 1) if(is_prime[i] && is_prime[N - i + 1]) ++ans;
    cout <<ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 1300
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

vector<long long> enum_divisors(long long N) {
	vector<long long> res;
	for (long long i = 1; i * i <= N; ++i) {
		if (N % i == 0) {
			res.push_back(i);
			// 重複しないならば i の相方である N/i も push
			if (N / i != i) res.push_back(N / i);
		}
	}
	// 小さい順に並び替える
	sort(res.begin(), res.end());
	return res;
}

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

	int ans = 0;
	rep(i, n + 1) {
		if (i % 2 == 0) continue;
		vector<ll> res = enum_divisors(i);
		if (res.size() == 8) {
			++ans;
		}
	}
	cout << ans << endl;
	system("pause");
}




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

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

  int n;
  cin>>n;
  int x;
  int curr_min = 1e9;
  int ans = 0;
  for(int i=0; i<n; ++i){
    cin>>x;
    curr_min = min(x, curr_min);
    if( x == curr_min ){
      ans++;
    }
  }
  cout<<ans<<'\n';

	return 0;
}


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

int main(){
	int num;
	cin >> num;
	int temp = num;
	int total = 0;
	while(int(temp/10)>=1){
		total = total + temp%10;
		temp = int(temp/10);
	}
	total = total + temp;
	if (num%total==0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

int main()
{
    char i;
    cin >> i;
    printf("%c\n", i+1);

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();

        solver(A, B);
    }

    public static void solver(int A, int B) {
        if(B % A == 0){
            out.println(A+B);
        } else {
            out.println(B - A);
        }
    }
}

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

int com(int x){
  int ans = 1;
  for(int i = 1; i <= x; i++){
    ans *= i;
  }
  return ans;
}

int main() {
  int N;
  cin >> N;
  vector<int> p(N), q(N), P(N), Q(N);
  for(int i = 0; i < N; i++){
    cin >> p.at(i);
    P.at(i) = p.at(i);
  }
  for(int i = 0; i < N; i++){
    cin >> q.at(i);
    Q.at(i) = q.at(i);
  }
  
  int ans = 0;
  //cout << "p q p q r" << endl;
  for(int i = 0; i < N; i++){
    int re = com(N - i - 1);
    int ansa = 0;
    //cout << P.at(i) << " " << Q.at(i) << " ";
    if(i == 0){
      ansa = (p.at(i) - q.at(i)) * re;
    }
    else{
      for(int j = 0; j < i; j++){
        if(P.at(i) > P.at(j)){
          p.at(i)--;
        }
        if(Q.at(i) > Q.at(j)){
          q.at(i)--;
        }
      }
      ansa = (p.at(i) - q.at(i)) * re;
    }
    //cout << p.at(i) << " " << q.at(i) << " ";
    ans += ansa;
    //cout << re << endl;
  }
  
  cout << abs(ans) << endl;
    
}

Measured memory_bytes: 256
l = gets.chomp
while l != '#' do
    right = ['y','u','i','o','p','h','j','k','l','n','m']
    count = 0
    rightFlug = right.include?(l[0])
    
    l.length.times do |i|
        if right.include?(l[i]) != rightFlug
            count += 1
            rightFlug = right.include?(l[i])
        end
    end
    
    p count
    l = gets.chomp
end



Measured memory_bytes: 6860
#include <iostream>
#include <cstdlib>
#define ll long long
#define ar array
using namespace std;
const int N = 1e5;
int arr[N][3];
int dp[N][3];

int main(){
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>arr[i][0]>>arr[i][1]>>arr[i][2];

    dp[0][0] = arr[0][0];
    dp[0][1] = arr[0][1];
    dp[0][2] = arr[0][2];

    for(int i=1; i<n; i++){
        for(int j=0; j<3; j++){
            dp[i][j] = max(dp[i-1][(j+1)%3]+arr[i][j], dp[i-1][(j+2)%3]+arr[i][j]);
        }
    }
    cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<endl;

}

Measured memory_bytes: 5520
import heapq

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(map(lambda x: x * (-1), A))
heapq.heapify(A)

for _ in range(M):
    tmp = heapq.heappop(A) * (-1)
    tmp //= 2
    heapq.heappush(A, tmp * (-1))

print(-sum(A))


Measured memory_bytes: 85028
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (int i = j; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define n_p(v) next_permutation(v.begin(),v.end())
#define to_ll(b) stoll(b)
#define MOD 1000000007
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	string s;
	cin>>s;
	rep(i,0,s.size()){
		if(s[i]==',') s[i]=' ';
	}
			
	cout<<s;
	return 0;
}

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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


void solve(long long H, long long W){
    if(H == 1 || W == 1) cout << 1 << endl;
    else if(H % 2 == 1 && W % 2 == 1) cout << (H * W + 1) / 2 << endl;
    else cout << H * W / 2 << endl; 
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    solve(H, W);
    return 0;
}


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


namespace Test1 {





    class ClassMain {


        static bool[,] ok = new bool[9, 9];
        static int[,] puzzle = new int[9, 9];

        static void puzzlePrint() {
            for (int iy = 0; iy < 9; iy++) {
                for (int ix = 0; ix < 9; ix++) {
                    if (ok[iy, ix]) { Console.Write(" " + puzzle[iy, ix]); }
                    else { Console.Write("*" + puzzle[iy, ix]); }
                } 
                Console.WriteLine();
            }
        }

        static void puzzleCheck() {
            for (int ix = 0; ix < 9; ix++) {
                for (int iy = 0; iy < 9; iy++) {
                    if (!tateCheck(ix, iy)) { ok[iy, ix] = false; continue; }
                    if (!yokoCheck(ix, iy)) { ok[iy, ix] = false; continue; }
                    if (!sikakuCheck(ix, iy)) { ok[iy, ix] = false; continue; }
                }
            }
        }


        static bool tateCheck(int x, int y) {
            int n = puzzle[y, x];
            for (int i = 0; i < 9; i++) {
                if(i==y){continue;}
                if (n == puzzle[i, x]) { return false; }
            }
            return true;            
        }
        static bool yokoCheck(int x, int y) {
            int n = puzzle[y, x];
            for (int i = 0; i < 9; i++) {
                if (i == x) { continue; }
                if (n == puzzle[y, i]) { return false; }
            }
            return true;
        }
        static bool sikakuCheck(int x, int y) {
            int n = puzzle[y, x];
            int baseX = x - x% 3;
            int baseY = y - y % 3;
            for (int ix = baseX; ix < baseX + 3; ix++) {
                for (int iy = baseY; iy < baseY + 3; iy++) {
                    if (ix == x && iy == y) { continue; }
                    if (puzzle[iy, ix] == n) { return false; }
                }
            }
            return true;
        
        }




        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int n = int.Parse(line);
                if (n == 0) { break; }
                for (int i = 0; i < n; i++) {
                    //puzzle load.
                    for(int j=0; j<9; j++){
                        int[] ints = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                        for (int k = 0; k < 9; k++) {
                            puzzle[j, k] = ints[k];
                            ok[j, k] = true;
                        }
                    }
                    puzzleCheck();
                    puzzlePrint();
                    if (i < n - 1) { Console.WriteLine(); }
                }
                break;
            }
        }
    
    }



    
}

Measured memory_bytes: 18388
def readinput():
    n=int(input())
    s=input()
    s=' '+s
    return n,s

def main(n,s):
    count=0
    all=set(['R','G','B'])
    for i in range(1, n-1):
        l1=s[i]
        for j in range(i+1, n):
            l2=s[j]
            if l1==l2:
                continue
            l3=(all - set([l1,l2])).pop()
            ij=j-i
            sub1=s[j+1:j+ij]
            sub2=s[j+ij+1:]
            count+=sub1.count(l3)
            count+=sub2.count(l3)
    return count

def main2(n,s):
    count=0
    nr=s.count('R')
    ng=s.count('G')
    nb=s.count('B')
    all=set(['R','G','B'])
    for i in range(1, n-1):
        l1=s[i]
        for j in range(i+1, n):
            l2=s[j]
            if l1==l2:
                continue
            ij=j-i
            jk=ij
            k=j+jk
            if(k>n):
                break
            l3=s[k]
            if l3==l1 or l3==l2:
                continue
            count+=1
    return nr*ng*nb-count



if __name__=='__main__':
    n,s=readinput()
    ans=main2(n,s)
    print(ans)
       

Measured memory_bytes: 9184
import java.util.*;

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] cites = new int[N];
        Map<Integer, Integer> map = new HashMap<>();

        for (int i=1; i<N+1; i++) {
            map.put(i, 0);
        }
        for (int i=0; i<M; i++) {
            int ai = sc.nextInt();
            map.put(ai, map.get(ai) + 1);
            int bi = sc.nextInt();
            map.put(bi, map.get(bi) + 1);
        }

        for (int i=1; i<N + 1; i++) {
            System.out.println(map.get(i));
        }
    }
}



Measured memory_bytes: 21972
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
#define MAXN 110

typedef long long ll;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

struct rectangle {
    int area, width, height;
};

bool comp(const rectangle& a, const rectangle& b) {
    return a.area < b.area;
}

int n, w, d;

int main(void) {
    while (1) {
        cin >> n >> w >> d;
        if (n == 0 && w == 0 && d == 0) break;
        vector<rectangle> rec;
        rectangle init;
        init.area = w*d; init.width = w; init.height = d;
        rec.push_back(init);
        for (int i = 0; i < n; i++) {
            int p, s;
            cin >> p >> s;
            rectangle temp = rec[p-1];
            rec.erase(rec.begin()+(p-1));
            s = s % (temp.width+temp.height);
            if (s < temp.width) {
                rectangle rec1, rec2;
                rec1.width = s;
                rec1.height = temp.height;
                rec1.area = rec1.width * rec1.height;
                rec2.width = temp.width - s;
                rec2.height = temp.height;
                rec2.area = rec2.width * rec2.height;
                if (rec1.area < rec2.area) {
                    rec.push_back(rec1); rec.push_back(rec2);
                } else {
                    rec.push_back(rec2); rec.push_back(rec1);
                }
            } else {
                rectangle rec1, rec2;
                rec1.width = temp.width;
                rec1.height = s - temp.width;
                rec1.area = rec1.width * rec1.height;
                rec2.width = temp.width;
                rec2.height = temp.height - rec1.height;
                rec2.area = rec2.width * rec2.height;
                if (rec1.area < rec2.area) {
                    rec.push_back(rec1); rec.push_back(rec2);
                } else {
                    rec.push_back(rec2); rec.push_back(rec1);
                }
            }
        }
        sort(rec.begin(), rec.end(), comp);
        cout << rec[0].area;
        for (int i = 1; i <= n; i++) {
            cout << " " << rec[i].area;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1224
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

n,x = lr()
a = lr()
w = []
ans=0
for i in range(n-1):
    w.append((a[i]+a[i+1])-x)
for i in range(n-1):
    s,t = a[i],a[i+1]
    ret = 0
    if w[i] > 0:
        if t >= w[i]:
            ans+=w[i]
            ret=w[i]
            a[i+1]-=w[i]
        else:
            ans+=w[i]
            ret=t
            a[i+1]=0
    if i < n-2:
        w[i+1]-=ret
print(ans)


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

w = -1
flg = False
for h in range(1, 3500 + 1):
    for n in range(h, 3500 + 1):
        q = 4 * n * h - N * (n + h)
        #print(h, n, p, q)
        if q > 0:
            #q == 0: 1/wなしで4/Nに等しくなり不適（w無限大）
            #q < 0: p > 0より、w < 0となり不適
            p = N * n * h
            if p % q == 0:
                w = p // q
                flg = True
                break
    if flg:
        break
print(h, n, w)

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

int main(){
    int N;
    cin >> N;
    int sum = 0;
    int P1 = 0;
    int P2 = 0;
    int ans1 = 0;
    int ans2 = 0;
    vector<int> x(N);
    for(int i = 0; i < N; i++){
        cin >> x[i];
        sum += x[i];
    }
    if(sum%N == 0){
        P1 = sum/N;
        for(int i =0; i <N; i++){
        ans1 += pow(x[i]-P1,2);
        }
    }else{
        P1 = sum/N;
        P2 = sum/N+1;
        for(int i =0; i <N; i++){
            ans1 += pow(x[i]-P1,2);
            ans2 += pow(x[i]-P2,2);
        }
        ans1 = min(ans1,ans2);
    }
    
    cout << ans1 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	int a[8], b[8], p[8];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		p[i] = i + 1;
	}
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &b[i]);
	}
	int x = 0, y = 0, f1 = 1, f2 = 1;
	do {
		for (int i = 0; i < n; i++)
		{
			if (a[i] != p[i] && f1) {
				x++;
				break;
			}
			if (i == n - 1) {
				f1 = 0;
			}
		}
		for (int i = 0; i < n; i++)
		{
			if (b[i] != p[i] && f2) {
				y++;
				break;
			}
			if (i == n - 1) {
				f2 = 0;
			}
		}
	} while (next_permutation(p, p + n));
	int z = x - y > 0 ? x - y : y - x;
	printf("%d", z);
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
bool compare_by_b(pair<int, long long> a, pair<int, long long> b) {
    if(a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}
int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    int LR[510][510];
    vector<pair<int, int>> ques;
    rep(i, 0, M) {
        int L, R;
        cin >> L >> R;
        LR[L][R]++;
    }
    rep(i, 0, Q) {
        pair<int, int> p;
        cin >> p.first >> p.second;
        ques.push_back(p);
    }
    rep(i, 1, N + 1) {
        rep(t, 1, N + 1) { LR[i][t] += LR[i][t - 1]; }
    }
    rep(i, 1, N + 1) {
        rep(t, 1, N + 1) { LR[i][t] += LR[i - 1][t]; }
    }
    rep(i, 0, Q) {
        int L = ques[i].first;
        int R = ques[i].second;
        cout << LR[R][R] + LR[L-1][L-1] - LR[L - 1][R] - LR[R][L - 1] << endl;
    }
}

Measured memory_bytes: 2804
def solve():
    N = int(input())
    S = input()
    
    stack = 0
    ans = ""
    for i in range(N):
        if S[i] == '(':
            stack += 1
            ans += S[i]
        else:
            ans += S[i]
            if stack == 0:
                ans = '(' + ans
            else:
                stack -= 1
    else:
        if stack != 0:
            ans += ')' * stack
    
    print(ans)


    
if __name__ == '__main__':
    solve()

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n, l;
    cin >> n >> l;
    vector<string> v(n);
    for (int i = 0; i < n; ++i)
        cin >> v[i];
    sort(v.begin(), v.end());
    string t;
    for (int i = 0; i < n; ++i)
        t += v[i];
    cout << t << endl;
}


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

int main(){
  int x, y;
    
  for(int i = 0; i < 3000; i++){
    cin >> x >> y;
    int a = min(x,y);
    int b = max(x,y);
    if(x==0 && y==0){
      break;
    }
    cout << a << " " << b << endl;
  }
  return 0;
}


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


using namespace std;

int main(){
	
	int N,R;
	
	cin>>N;cin>>R;
	
	if(N >= 10){
		
		cout<<R;
		
	}else cout<<(100*(10-N))+R<<"\n";
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <functional>
#include <chrono>
#include <cstring>
#include <limits.h>

using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<lint> vl;
typedef pair<lint,lint> pll;

int main()
{
    ios_base::sync_with_stdio(0);    cin.tie(NULL);    cout.tie(NULL);

    int x, n; cin>>x>>n;
    vi p(n);
    set<int> ps;
    for (int &i : p){
        cin>>i;
        ps.insert(i);
    }

    for (int d = 0; true; d++){
        for (int candi : {x-d, x+d}){
            if (ps.count(candi) == 0) {
                cout<<candi;
                return 0;
            }
        }
    }

}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int sum;
int a[5];
bool bo[5];

void f(int p)
{
    if(p > 3)
    {
        if(sum == 7)
        {
            printf("%d", a[0]);
            for(int i = 1; i <= 3; i++)
            {
                if(bo[i]) printf("+");
                else printf("-");
                printf("%d", a[i]);
            }
            printf("=7");
            exit(0);
        }
        else
        {
            return;
        }
    }
    bo[p] = true;
    sum += a[p];
    f(p + 1);
    bo[p] = false;
    sum -= a[p] * 2;
    f(p + 1);
    sum += a[p];
}

int main()
{
    string s;
    cin>>s;
    for(int i = 0; i < 4; i++)
    {
        a[i] = s[i] - '0';
    }
    sum = a[0];
    f(1);
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    
    vector<pair<pair<string,int>,int>> rs(n);
    
    for(int i = 0;i<n;i++){
        cin >> rs[i].first.first >> rs[i].first.second;
        rs[i].first.second *= -1;
        rs[i].second = i+1;
    }
    
    sort(rs.begin(),rs.end());
    
    for(int i = 0;i<n;i++){
        cout << rs[i].second <<endl;;
    }    
    
    
    
    
}

Measured memory_bytes: 256
# ダメだったのでメモ再帰
# memo 1000000で通ったかどうかだけみればいいっぽい

n = gets.chomp.to_i
@memo = Array.new(n+1, -1)
@numset = [1]
roku = 6
while roku<=n
  @numset<<roku
  roku*=6
end
kyu = 9
while kyu<=n
  @numset<<kyu
  kyu*=9
end

# 1から始めるとそりゃあ間に合わんのは当然なので
@numset.sort!.reverse!

def rec(cur)
  return 0  if cur.zero?
  return @memo[cur] if @memo[cur]>0
  ret = 10**10
  @numset.each do |ni|
    if cur>=ni
      ret = [ret, rec(cur-ni)+1].min
    end
  end
  @memo[cur] = ret
  return ret
end

puts rec(n)


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

int main(){
    int n, x, y;
    cin >> n >> x >> y;
    int cnt[n + 10] = {};
    int dist;
    for (int b = 1; b < n; b++){
        for (int e = b + 1; e <= n; e++){
            if (e <= x) dist = e - b;
            else if (b <= x && x <= e && e <= y) dist = (x-b) + min(e-x, y-e+1);
            else if (b <= x && y <= e) dist = (e-b) - (y-x) + 1;
            else if (x <= b && e <= y) dist = min(e-b, (y-e)+(b-x)+1);
            else if (x <= b && b <= y && y <= e) dist = min(b-x+1, y-b) + (e-y);
            else dist = (e-b);
            cnt[dist]++;
        }
    }
    rep(i, n - 1) cout << cnt[i + 1] << endl;
    return 0;
}

Measured memory_bytes: 256
'''
無向グラフの橋の数を調べる
ループ無し/2重辺無し
'''

def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations
    #from itertools import accumulate, product, permutations
    from math import floor, ceil

    #mod = 1000000007

    node,m =map(int, input().split())
    edge = [list(map(int, input().split())) for _ in range(m)]
    res = 0

    def dfs(num):
        flag[num-1] = 1
        for x, y in edge:
            if x==num:
                if not flag[y-1]:
                    dfs(y)
            if y==num:
                if not flag[x-1]:
                    dfs(x)
    
    for i in range(m):
        bridge = edge.pop(i)
        flag = [0]*node
        s = edge[0][0]
        dfs(s)
        if not all(flag):
            res += 1
        edge.insert(i, bridge)
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 4076
s = int(input())
x1 = 10**9
x2 = 1
def ceil(a, b):
   return a // b + (a % b > 0)

y2 = ceil(s, x1)
y1 = 10**9 - s % 10**9
if y1 == 10**9:
    y1 = 0
print(0)
print(0)
print(x1)
print(y1)
print(x2)
print(y2)

Measured memory_bytes: 3060