akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>
#include <map>

using namespace std;

pair<int, int> max_kay(map<int, int>& m) {
  int max = 0;
  int key = m.begin()->first;
  for (map<int, int>::iterator it = m.begin(); it != m.end(); it++) {
    if (max < it->second) {
        max = it->second;
        key = it->first;
    }
  }
  return make_pair(key, max);
}

int main(int argc, const char * argv[]) {
    
    int n;
    cin >> n;

    map<int, int> e, o;

    for(int i=0; i<n; i=i+2){
        int et, ot;
        cin >> et;
        cin >> ot;
        e[et]++;
        o[ot]++;
    }

    pair<int, int> em1 = max_kay(e);
    pair<int, int> om1 = max_kay(o);

    if (em1.first == om1.first) {
        e[em1.first]=0;
        pair<int, int> em2 = max_kay(e);
        o[om1.first]=0;
        pair<int, int> om2 = max_kay(o);
        if ( om2.second + em1.second >  om1.second + em2.second)
            cout <<  ( n/2 - om2.second) + (n/2 - em1.second) << endl;
        else 
            cout <<  ( n/2 - om1.second) + (n/2 - em2.second) << endl;
    }
    else {
        cout <<  ( n/2 - om1.second) + (n/2 - em1.second) << endl;
    }


    return 0;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
typedef long long int ll;

int main(int argc, char const *argv[]) {
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  if (K % 2 == 0) {
    ll ans = A - B;
    if (abs(ans) > pow(10, 18)) {
      cout << "unfair" << endl;
    } else {
      cout << ans << endl;
    }
  } else {
    ll ans = B - A;
    if (abs(ans) > pow(10, 18)) {
      cout << "unfair" << endl;
    } else {
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]
def adjacency_list(N, edges):
    g = make_list(N, 0)
    for a, b in edges: g[a].append(b), g[b].append(a)
    return g
def tree_utils(start, g):
    parent, children, depth, q = [-1]*len(g), make_list(len(g), 0), [-1]*len(g), deque([start]); depth[start] = 0
    while q:
        i = q.popleft()
        for j in g[i]:
            if depth[j] != -1: parent[i] = j
            else: depth[j] = depth[i] + 1; children[i].append(j), q.append(j)
    return parent, children, depth
def graph_distance(start, g):
    dist, q = [-1] * len(g), deque([start]); dist[start] = 0
    while q:
        i = q.popleft()
        for j in g[i]:
            if dist[j] == -1: dist[j] = dist[i] + 1; q.append(j)
    return dist

sys.setrecursionlimit(1000000)
dire, dire8 = [[1, 0], [0, 1], [-1, 0], [0, -1]], [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets, ALPHABETS = "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD, INF = 1000000007, float("inf")

def main():
    N, u, v = LI()
    AB = LIR1(N-1)
    max_dist = [None] * N
    g = adjacency_list(N, AB)
    udist = graph_distance(u-1, g)
    vdist = graph_distance(v-1, g)

    ans = vdist[u-1] - 1
    for ud, vd in zip(udist, vdist):
        if ud < vd:
            ans = max(ans, vd - 1)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 107324
#include <iostream>
#include <map>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

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

const int MAX = 1000001;
bool pri[MAX];
vector<int>v;
map<int,pair<int,int> >pos;
int field[1201][1201];
int N,M;

void make(){
  int cnt = 2;
  int c = 1;
  int x = 500,y=500;
  int cc = 0;
  field[500][500] = 1;
  pos[1] = make_pair(500,500);

  while(cnt < 1000000){
    for(int i=0; i<4; i++){
      if(cc == 2){cc = 0; c++;}
      int nx = x, ny = y;
      for(int j=0; j<c; j++){
	nx += dx[i];
	ny += dy[i];
	pos[cnt] = make_pair(ny,nx);
	field[ny][nx] = cnt++;
      }

      x = nx, y = ny;
      cc++;
    }
  }
}

void createPrime(){
  fill(pri,pri+MAX,1);
  pri[0] = pri[1] = 0;
  for(int i=2; i*i<MAX; i++){
    for(int j=2*i; j<MAX; j+=i){
      pri[j] = false;
    }
  }

  for(int i=2; i<MAX; i++) if(pri[i]) v.push_back(i);
}

bool compare(pair<int,int>p, pair<int,int>p2){
  if(p.first == p2.first){
    return p.second > p2.second;
  }
  return p.first > p2.first;
}

int main(){
  make();
  createPrime();

  while(cin >> M >> N,M|N){
    pair<int,int> p = pos[N];
    int sx = p.second, sy = p.first;
    bool F = false;

    static bool used[1200][1200];
    static pair<int,int> dp[1200][1200];
    memset(used,0,sizeof(used));
    memset(dp,0,sizeof(dp));

    if(binary_search(v.begin(),v.end(),field[sy][sx])){
      dp[sy][sx].first = 1;
      dp[sy][sx].second = field[sy][sx];
    }
    used[sy][sx] = true;

    for(int i=sy; i<=1000; i++){
      for(int j=0; j<=1000; j++){
	for(int k=-1; k<=1; k++){
	  if(!used[i][j])continue;
	  int nx = j + k;
	  if(nx < 0 || nx > 1000)continue;
	  if(field[i+1][nx] > M)continue;

	  used[i+1][nx] = true;
	  int value = binary_search(v.begin(),v.end(),field[i+1][nx]);
	  
	  if(value){
	    //	    cout << "i = " << i << " j = " << nx << endl;
	    //	    cout << field[i+1][nx] << endl;
	    if(dp[i+1][nx].first < dp[i][j].first + 1){
	      dp[i+1][nx].first = dp[i][j].first + 1;
	      dp[i+1][nx].second = field[i+1][nx];
	    }
	  } else {
	    dp[i+1][nx] = max(dp[i+1][nx],dp[i][j]);
	  }
	}
      }
    }

    vector<pair<int,int> >ans;

    for(int i=0; i<=1000; i++){
      for(int j=0; j<=1000; j++){
	if(field[i][j] > M)continue;
	if(dp[i][j].first == 0)continue;
	ans.push_back(dp[i][j]);
      }
    }


    if(ans.size() == 0){cout << "0 0" << endl;}
    else{
      sort(ans.begin(),ans.end(),compare);
      cout << ans[0].first << " " << ans[0].second << endl;
    }

  }

  return 0;
}

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

#define ll long long int 
#define ull unsigned long long int
#define db double
#define ld long double
#define MOD 1000000007
#define inf (1LL << 62)
#define pi acos(-1.0)
#define si(a) scanf("%lld",&a)
#define sd(n) scanf("%lf", &n)
#define for1(i, stop) for(ll i = 1; i <= stop; i++)
#define for0(i, stop) for(ll i = 0; i < stop; i++)
#define rep1(i, start) for(ll i = start; i >= 1; i--)
#define rep0(i, start) for(ll i = (start-1); i >= 0; i--)
#define loop(i, start, stop, inc) for(ll i = start; i <= stop; i += inc)
#define pb(v,a) v.push_back(a)
#define pll pair <ll, ll>
#define mp make_pair
#define pbp(v,a,i) v.push_back(make_pair(a,i)) 
#define srt(v) sort(v.begin(),v.end())
#define rv(v) reverse(v.begin(),v.end())
#define ms(n, i) memset(n, i, sizeof(n))
#define debug printf("Debug\n");
#define en '\n'



#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main()
{
	_fastio
	string s;
	ll k;
	cin>>k>>s;
	if(s.size()<=k)
		cout<<s<<en;
	else
	{
		for(ll i=0;i<k;i++)
			cout<<s[i];
		cout<<"..."<<en;
	}
}

Measured memory_bytes: 3652
x,y = gets.chomp.split(" ").map(&:to_i)
if x >= 0 && y >= 0
  if x < y
    puts y-x
  else
    puts x-y+2 if y != 0
    puts x-y+1 if y == 0
  end
elsif x >= 0 && y < 0
  if x < -y
    puts -y-x+1
  else
    puts x+y+1
  end
elsif x < 0 && y > 0
  if -x < y
    puts y+x+1
  else
    puts -x-y+1
  end
elsif x < 0 && y <= 0
  if x < y
    puts -x+y
  else
    puts -y+x+2 if y != 0
    puts -y+x+1 if y == 0
  end
end

Measured memory_bytes: 14404
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) (int)((a).size())
typedef long long ll;
typedef pair<int,int> PI;

int main(int argc, char *argv[])
{
  int n,m;
  cin >> n >> m;
  vector<PI> in;
  rep(i,m){
    int c,d;
    cin >> c >> d;
    in.pb(mp(c,d));
  }
  sort(ALL(in));

  int ans = 0;
  int cur = 0;
  
  for(int i = 0; i < m; i){
    int la = in[i].S;
    int fi = in[i].F;
    
    while(i < m &&  in[i].F <= la){
      la = max(la,in[i].S);
      ++i;
    }
    
    ans += la - cur;
    ans += la - fi;
    cur = fi;
  }
  ans += n-cur+1;
  
  cout << ans << endl;
}

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

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

    if( a < c && a < b && b > c) cout << "Yes"<< endl;
    else if( a > c && a > b && b < c) cout << "Yes"<< endl;
    else cout << "No" << endl;
}

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

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define vrep(v, i) for(int i = 0; i < (v).size(); i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define FI first
#define SE second
#define dump(a, n) for(int i = 0; i < n; i++)cout << a[i] << "\n "[i + 1 != n];
#define dump2(a, n, m) for(int i = 0; i < n; i++)for(int j = 0; j < m; j++)cout << a[i][j] << "\n "[j + 1 != m];
using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef complex<double> cd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
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;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << p.first << " " << p.second; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << itr->first << ":" << itr->second; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}


int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  cout << n - k + 1 << endl;
  return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int main() {
	int a, b;

	std::cin >> a >> b;
	if (a == b) {
		std::cout << 0 << std::endl;
		return 0;
	}
	if (a%b == 0) {
		std::cout << 0 << std::endl;
		return 0;
	}
	std::cout << 1 << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
const double EPS = 1e-10;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

//geometory
class Vector{
public:
	double x, y;

	Vector(double x = 0, double y = 0) :x(x), y(y) {}
	Vector operator + (Vector v) { return Vector(x + v.x, y + v.y); }
	Vector operator - (Vector v) { return Vector(x - v.x, y - v.y); }
	Vector operator * (double a) { return Vector(a*x, a*y); }
	Vector operator / (double a) { return Vector(a / x, a / y); }
	Vector operator +=(Vector v) {
		x += v.x;
		y += v.y;
		return *this;
	}
	Vector operator -=(Vector v) {
		x -= v.x;
		y -= v.y;
		return *this;
	}
	Vector operator *= (double a) {
		x *= a;
		y *= a;
		return *this;
	}
	Vector operator /=(double a) {
		x /= a;
		y /= a;
		return *this;
	}

	bool operator < (Vector p) { return (x != p.x) ? (x < p.x) : (y < p.y); }
	bool operator == (Vector p) { return (fabs(x - p.x) < EPS) && (fabs(y - p.y) < EPS); }

	double abs() { return sqrt(norm()); }
	double norm() { return x * x + y * y; }
	double equals(double a, double b) { return fabs(a - b) < EPS; }

	double dot(Vector b) { return x * b.x + y * b.y; }
	double cross(Vector b) { return x * b.y - y * b.x; }

	bool isOrthogonal(Vector b) { return equals(this->dot(b), 0.0); }
	bool isParallel(Vector b) { return equals(this->cross(b), 0.0); }

};
typedef Vector Point;

typedef struct{
	Point p1, p2;
}Segment;

Point project(Segment s, Point p) {
	Vector base = s.p2 - s.p1;
	double r = base.dot(p-s.p1) / base.norm();
	return s.p1 + base * r;
}
//end of geometry


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

	
	int xp1, yp1, xp2, yp2;
	cin >> xp1 >> yp1 >> xp2 >> yp2;
	Point p1(xp1,yp1);
	Point p2(xp2,yp2);
	Segment s = { p1,p2 };


	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int xpi, ypi;
		cin >> xpi >> ypi;
		Point ret = project(s,Point(xpi,ypi));
		cout << setprecision(20) << ret.x << " " << ret.y << endl;
	}

	return 0;
}


Measured memory_bytes: 3304
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		double r = scan.nextDouble();
		
		System.out.printf("%.5f %.5f\n",Math.PI * r * r, 2 * Math.PI * r);
		
	}

}



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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    rep(k, N) {
        cout << A[k];
        if (k != N - 1)
            cout << " ";
    }
    cout << endl;

    for (int i = 1; i < N; ++i) {
        int v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            --j;
        }
        A[j + 1] = v;

        rep(k, N) {
            cout << A[k];
            if (k != N - 1)
                cout << " ";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3064
//kruskal tree
#include <cstdio>
#include <algorithm>
using namespace std;
#define M 9999
int parent[M],a[M],b[M];
pair<int,int>node[M];
int root(int a){return parent[a]==a?a:parent[a]=root(parent[a]);}
int differ(int a,int b){
	int x=root(a),y=root(b);
	if(x==y)return 0;
	return 1;
}
int unite(int a,int b){
	int x=root(a),y=root(b);
	if(x==y)return 0;
	if(x<y)parent[x]=y;else parent[y]=x;
	return 1;
}
int main(){
	int i,j,n,m,r,R;
	for(;scanf("%d%d",&n,&m),n;printf("%d\n",R)){
		for(i=0;i<m;i++)scanf("%d%d%d",a+i,b+i,&node[i].first),node[i].second=i,a[i]--,b[i]--;
		sort(node,node+m);
		for(R=-1,i=0;i<m;i++){
			for(j=0;j<n;j++)parent[j]=j;
			for(j=i;j<m;j++)if(unite(a[node[j].second],b[node[j].second]))r=node[j].first-node[i].first;
			for(j=1;j<n&&!differ(0,j);j++);
			if(j==n&&(R==-1||R>r))R=r;
		}
	}
}

Measured memory_bytes: 1152
#include <cstdio>
#include <algorithm>
#include <map>


using namespace std;

int main(void)
{
	int b,r,g,c,s,t,coin,t2;
	
	while(1){
		scanf("%d %d %d %d %d %d",&b ,&r ,&g ,&c,&s ,&t);
		if(!(b||r||g||c||t))	break;
		/*t2=b*5+r*3;
		t-=b*5+r*3+s;*/
		coin=100+b*95+r*63+g*7+c*2-t*3+3*s;
		printf("%d\n" ,coin);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/
signed main(){
	int n,k;
	cin>>n>>k;
	int ans=0;
	rep(i,n){
		int h;cin>>h;
		ans+=h>=k;
	}
	cout<<ans<<endl;


	return 0;
}



Measured memory_bytes: 3584
#include <iostream>
#include <sstream>
#include <cmath>
using namespace std;
int main()
{
	string a,b;
	double n;
	cin>>a>>b;
	a=a+b;
	stringstream ss;
	ss << a;
	ss >> n;
	if(sqrt(n)==floor(sqrt(n)))
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

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

long long gcd(long long x, long long y){
  if(x < y) swap(x,y);
  if(!y) return x;
  return gcd(y,x%y);
}

int main(){
  int N;
  cin >> N;
  vector<long long> T(N);
  for(int i = 0; i < N; ++i) cin >> T[i];
  long long lcm = 1;
  for(int i = 0; i < N; ++i){
    lcm /= gcd(lcm,T[i]);
    lcm *= T[i];
  }
  cout << lcm << endl;
  return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, i = map(int, readline().split())

    print(N - i + 1)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9124
N = int(input())
S = list(input())

r = g = b = 0
for i in range(N):
    if S[i] == 'R':
        r += 1
    if S[i] == 'G':
        g += 1
    if S[i] == 'B':
        b += 1
ans = r * g * b

for i in range(N):
    for j in range(i+1, N):
        dif = 2*j - i
        if dif >= N:
            break
        if S[i] != S[j] and S[i] != S[dif] and S[j] != S[dif]:
            ans -= 1
print(ans)

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

// データ構造を定義する機能。classと似てる
//（Cardクラス作ったよ的な感じ。Cardストラクト作ったよ的な）
struct Card {
  char suit;
  int num;
};  //セミコロン忘れずに

//配列出力処理
void output(struct Card a[], int n) {
  rep(i, n) {
    if (i > 0) {
      cout << " ";
    }
    cout << a[i].suit << a[i].num;
  }
  cout << endl;
}

// bubble Sort
// 安定ソート
void bubbleSort(struct Card a[], int n) {
  // int cnt = 0;
  bool flag = true;
  while (flag) {
    flag = false;
    for (int i = n - 1; i > 0; i--) {
      if (a[i].num < a[i - 1].num) {
        swap(a[i], a[i - 1]);
        // cnt++;
        flag = true;
      }
    }
  }
  output(a, n);
  // cout << cnt << endl;
}

// selection Sort
// 安定ソートではない
void selectionSort(struct Card a[], int n) {
  // int cnt = 0;
  rep(i, n) {
    int minIndex = i;
    for (int j = i; j < n; j++) {
      if (a[j].num < a[minIndex].num) {
        minIndex = j;
      }
    }
    swap(a[i], a[minIndex]);
    // if (i != minIndex) cnt++;  // 交換回数の条件はiとminIndexが異なる場合
  }
  output(a, n);
  // cout << cnt << endl;
}

//安定判定
bool isStable(struct Card a[], struct Card b[], int n) {
  rep(i, n) {
    if (a[i].suit != b[i].suit) return false;
    // return来たら、その場でその時の戻り値もって呼び出し元へいく
  }
  return true;
}

// O(n^2)
int main() {
  int n;
  Card a[40], b[40];
  cin >> n;
  rep(i, n) cin >> a[i].suit >> a[i].num;
  // rep(i, n) cin >> b[i].suit >> b[i].num;
  rep(i, n) b[i] = a[i];  //↑と同等処理
  bubbleSort(a, n);
  cout << "Stable" << endl;  // バブルソートは安定だから
  selectionSort(b, n);
  if (isStable(a, b, n)) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
  return 0;
}



Measured memory_bytes: 3100
#include<cstdio>
#include<queue>
#include<algorithm>
#define rep(i,b,e) for ( int i = b; i <= e; i++ )
using namespace std;

#define MAX 100
#define INFTY (1<<21)
int n, M[MAX+1][MAX+1];

class State{
    public:
    int p, e;
    State( int p = 0, int e = 0 ): p(p), e(e){}
    bool operator < ( const State &s ) const{
	return e > s.e;
    }
};

int dijkstra( int s, int t ){
    priority_queue<State> PQ;
    bool visited[MAX+1];
    int d[MAX+1];
    rep(i,1,n){
	visited[i] = false;
	d[i] = INFTY;
    }
    PQ.push(State(s, 0));
    d[s] = 0;
    State u;
    while( !PQ.empty() ){
	u = PQ.top(); PQ.pop();
	if ( u.p == t ) return u.e;
	visited[u.p] = true;
	rep(v,1,n){
	    if ( M[u.p][v] == INFTY || visited[v] ) continue;
	    if ( d[v] > d[u.p] + M[u.p][v] ){
		d[v] = d[u.p] + M[u.p][v];
		PQ.push(State(v, d[v]));
	    }
	}
    }
    return -1;
}

main(){
    int k, m, s, t, e;
    while(1){
	scanf("%d %d", &n, &k);
	if ( n == 0 && k == 0 ) break;
	rep(i,1,n) rep(j,1,n) M[i][j] = INFTY;
	rep(i,1,k){
	    scanf("%d %d %d", &m, &s, &t);
	    if ( m ){
		scanf("%d", &e);
		M[s][t] = min( M[s][t], e );
		M[t][s] = M[s][t];
	    } else printf("%d\n", dijkstra(s, t));
	}
    }
}

Measured memory_bytes: 864
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>
#include <cstring>
using namespace std;

typedef long long llint;
typedef long double ld;
#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> q;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(){
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++)cin >> a[i];
	reverse(a,a+n);
	cout << a[0];
	for(int i=1;i<n;i++){
		cout << " " << a[i];
	}
	cout << endl;
}

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



Measured memory_bytes: 3100
# Problem A - Colorful Transceivers

a, b, c, d = map(int, input().split())
d_1 = abs(a - c)
d_2 = abs(b - a)
d_3 = abs(c - b)

if d_1<=d or (d_2<=d and d_3<=d):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38256
n,m=map(int,input().split())
import numpy as np
data = np.zeros([n,2],dtype=np.int)
for i in range(n):
    a,b=map(int,input().split())
    data[i] = [a,b]
    
#print(data)

data_sort = data[np.argsort(data[:, 0])]
#print(data_sort)

honsu = 0
money = 0
idx = 0
while(honsu<m):
    if (m-honsu)>data_sort[idx,1]:
        money+=data_sort[idx,0]*data_sort[idx,1]
        honsu += data_sort[idx,1]
        idx+=1
    else:
        money+=data_sort[idx,0]*(m-honsu)
        honsu += data_sort[idx,1]
        idx+=1
    #print(money)
    #print(honsu)
        
print(money)

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

int main() {
  int N;
  cin >> N;
  
  int sum=1;
  for(int i=1; i<=N; i++) sum*=i;
  int sub = sum;
  vector<int> pn(N),qn(N);
  for(int i=0;i<N; i++) pn[i]=i+1;
  for(int i=0;i<N; i++) qn[i]=i+1;
  
  vector<int> p(N),q(N);
  for(int i=0; i<N; i++) cin >> p[i];
  for(int i=0; i<N; i++) cin >> q[i];
  
  int a=0,b=0,k=1;
  for(int i=0; i<N; i++){
  	for(int j=0; j<N; j++){
    	if(p[i] == pn[j]) {
          a += sum*j/(N-i);
          pn.erase(pn.begin()+j);
          break;
        }
    }
    if(i==0) k=N+1;
    k--;
    sum /= k;
  }
  sum = sub;
  k=1;
  for(int i=0; i<N; i++){
  	for(int j=0; j<N; j++){
    	if(q[i] == qn[j]) {
          b += sum/(N-i)*j;
          qn.erase(qn.begin()+j);
          break;
        }
    }
    if(i==0) k=N+1;
    k--;
    sum /= k;
  }
  a++; b++;
  if(a<b) swap(a,b);
  cout << a-b << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://onlinejudge.u-aizu.ac.jp/courses/library/7/DPL/4/DPL_4_A>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
ll solve(){
    ll res = 0;
    ll N,V; cin >> N >> V;
    vector<ll> a(N),b(N),c(N),d(N);
    for(auto& in:a) cin >> in;
    for(auto& in:b) cin >> in;
    for(auto& in:c) cin >> in;
    for(auto& in:d) cin >> in;
    
    map<ll,ll> mp;
    for(int i = 0; i < N;i++){
        for(int j = 0; j < N;j++){
            mp[a[i]+b[j]]++;
        }
    }
    for(int i = 0; i < N;i++){
        for(int j = 0; j < N;j++){
            res += mp[V-c[i]-d[j]];
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}



Measured memory_bytes: 128164
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
using namespace std;

int main(void)
{
    int n;
    cin >> n;
    if(n % 2 == 0){cout << n << endl;}
    else{cout << n * 2 << endl;}
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<iomanip>
#include<math.h>
#include<bits/stdc++.h>
int main(){
  int n,d,i,j,k;
  cin>>n>>d;
  int a[n][d];
  for(i=0;i<n;i++){
    for(j=0;j<d;j++){
      cin>>a[i][j];
    }
  }
  double sum;
  int count=0;
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      sum=0;
      for(k=0;k<d;k++){
        sum=sum+abs((a[i][k]-a[j][k])*(a[i][k]-a[j][k]));
      }
      double z=sqrt(sum);
      int y=(int)z;
      if(y*10==z*10)
        count++;
    }
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

constexpr double pi = 3.141593;

int main() {
	double pos_x = 0;
	double pos_y = 0;
	int degree = 0;
	
	while (true) {
		int norm, deg;
		std::scanf("%d,%d", &norm, &deg);
		if (norm == 0 && deg == 0) {
			break;
		}
		
		double theta = degree * pi / 180.0;
		pos_y += norm * std::sin(theta);
		pos_x += norm * std::cos(theta);
		degree += deg;
	}
	
	std::cout << static_cast<int>(pos_y) << std::endl;
	std::cout << static_cast<int>(pos_x) << std::endl;
}

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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define rept(i,n) for(ll (i)=0;(i)<=(ll)(n);(i)++)
#define reps(i,s,n) for(ll (i)=(s);(i)<(ll)(n);(i)++)
#define repst(i,s,n) for(ll (i)=(s);(i)<=(ll)(n);(i)++)
#define repr(i,n) for(ll (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, m;
ll x[100000], y[100000], ans;

int main() {
	cin >> n >> m;
	rep(i,n) cin >> x[i];
	rep(i,m) cin >> y[i];
	
	// https://drive.google.com/open?id=16JCe0lMPnx5SHPLK6Lih6Oqr0Od9ZVwp
	// こんな感じで式変形 O(n+m)
	ll xs = 0, ys = 0;
	repst(k,1,n) xs = (xs + (k-1)*x[k-1] - (n-k)*x[k-1])%mod;
	repst(l,1,m) ys = (ys + (l-1)*y[l-1] - (m-l)*y[l-1])%mod;
	ans = (xs * ys)%mod;
	cout << ans << ln;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main(){
  int a, b;
  scanf("%d",&a);
  scanf("%d",&b);
  if(a < b) {
    if(b-a == b-1) {
      printf("Alice\n");
    }
    else {
     printf("Bob\n");
    }
  }
  else if(b < a) {
    if(a -b == a-1) {
      printf("Bob\n");
    }
    else {
      printf("Alice\n");
    }
  }
  else {
    printf("Draw\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)

signed main(){
    int N;
    cin>>N;
    
    int n=N%10;
    
    if(n==2||n==4||n==5||n==7||n==9) cout<<"hon"<<endl;
    else if(n==3) cout<<"bon"<<endl;
    else cout<<"pon"<<endl;
}



Measured memory_bytes: 3052
#include <iostream>
#include <deque>
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main()
{
	int k;
	cin >> k;
	long long int sum=0;
	int i,j,x;
	for(i=1; i<=k; i++)
		for(j=1; j<=k; j++)
			for(x=1; x<=k; x++)
				sum+= __gcd(__gcd(i,j), x);
	cout << sum;

	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  int N; cin >> N;
  int k = (1 + sqrt(1 + 8 * N)) / 2;
  if (2 * N != k * (k - 1)) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  cout << k << endl;
  cout << k - 1;
  for (int i = N - k + 2; i <= N; i++) cout << " " << i;
  cout << endl;

  for (int i = 1; i < k; i++) {
    cout << k - 1;
    int j = i * (i - 1) / 2 + 1;
    int l = i;
    bool downward = true;
    while (j != (k - i) * (k - i + 1) / 2) {
      cout << " " << j;
      if (j >= N - k + 2 && j <= N) downward = false;
      if (downward) {
        j += l + 1;
        l++;
      } else {
        j -= l - 1;
        l--;
      }
    }
    cout << " " << j << endl;
  }
}

Measured memory_bytes: 3492
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t n;
  int64_t a=100;
  cin >> n;
  int count=0;
  for(int i=0; i<n ; i++){
    a+=a/100;
    count++;
    if(a>=n) break;
  }
  cout << count << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  ll a, b, x;
  cin >> a >> b >> x;
  ll al = 0, ar = 0;
  if(a != 0) al = (a-1)/x;
  else al--;
  ar = b/x;
  cout << ar - al << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
using namespace std;
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(10)
#define highest(x) (63 - __builtin_clzl(x))

int main(){
    int N;
    cin >> N;
    int max_A = 0, min_A = 2e9;
    for(int i = 0; i < N; i++){
        int A;
        cin >> A;
        max_A = max(max_A, A);
        min_A = min(min_A, A);
    }
    cout << max_A - min_A << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
using P = pair<int,int>;
#define MOD 1000000007

int main()
{
  ll N,M;cin>>N>>M;
  vector<ll> p(M+1);
  vector<string> S(M+1);
  for (ll i=1;i<=M;i++)
    cin>>p[i]>>S[i]; 
  
  vector<ll> wa(N+1,0);
  vector<bool> ac(N+1,false);
  
  for (ll i=1;i<=M;i++)
  {
    if (S[i]=="AC") ac[p[i]]=true;
    
    if (S[i]=="WA" && ac[p[i]]==false) 
      wa[p[i]]++;
  }
  
  ll ac_num=0;
  ll wa_num=0;
  for (int i=1;i<=N;i++)
  {
    if (ac[i]==true){
      ac_num++;
      wa_num += wa[i];
    }
  }
  
  cout<<ac_num<<" "<<wa_num<<endl;
}

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

a = list(map(int,input().split()))

ball = [-1 for i in range(N)]

for i in range(N):
    num=N-i
    s = 0
    for i in range(N//num):
        if ball[(N//num - i)*num-1]!=-1:
            s+=ball[(N//num - i)*num-1]
        else:
            ball[(N//num - i)*num-1]=(a[num-1]-s)%2
ans = []
for i in range(N):
    if ball[i]==1:
        ans.append(i+1)

print(len(ans))
if len(ans)!=0:
    print(*ans)

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

int main(){
    int n, m;
    cin >> n >> m;
    vii Graph(n);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        Graph[a].emplace_back(b);
        Graph[b].emplace_back(a);
    }
    queue<int> q;
    vector<bool> seen(n, false);
    vi pre_v(n, -1);
    q.push(0);
    while ( !q.empty() )
    {
        int v = q.front(); q.pop();
        for( int next_v : Graph[v]){
            if( seen[next_v] ) continue;
            // cout << "v:" << v << ", next_v: " << next_v << endl;
            seen[v] = true;
            pre_v[next_v] = v; 
            seen[next_v] = true;
            q.push(next_v);
        }
    }
    cout << "Yes" << endl;
    for( int i = 1; i < n; ++i){
        cout << ++pre_v[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 10136
#include <bits/stdc++.h>
using namespace std;
int main (){
    long long N,M,minprice,num=0,ans=0,i;
    cin >> N >> M;
//多次元配列でなくpairで配列を作ることでソートを可能に
//int と　long longは演算不可
    vector<pair<long long,long long>> v(N);

    for(i=0;i<N;i++){
        cin >> v.at(i).first >> v.at(i).second;
    }
    sort(v.begin(),v.end());//sortは第一基準

    for(i=0;num<M;i++){
        num += v.at(i).second;//M本超えるのはi(i+1)店目
    }
    for(long long j=0;j<i;j++){
        ans += v.at(j).first*v.at(j).second;
    }
    ans += (M-num)*v.at(i-1).first;

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

ll dp[101][10001];

int main() {
  int n;
  ll W;
  cin >> n >> W;
  ll v[n], w[n];
  REP(i, n) cin >> v[i] >> w[i];
  ll INF = 1e18;
  REP(i, n * 100 + 1) dp[0][i] = INF;
  dp[0][0] = 0;
  REP(i, n) REP(j, n * 100 + 1) {
    if (j < v[i]) {
      dp[i + 1][j] = dp[i][j];
    } else {
      dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
    }
  }
  RREP(i, n * 100 + 1) {
    if (dp[n][i] <= W) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 10996
#include <stdio.h>

int main()
{
  int N, i, j, flag=1, work, count=0, minj, A[100];

  //input number that is used this program
  scanf("%d", &N);
  for(i=0;i<N;i++){
    scanf("%d", &A[i]);
  }

  //do selection sort
  for(i=0; i<N; i++){
    minj=i;
    for(j=i; j<N; j++){
      if(A[j] < A[minj]){
	minj = j;
      }
    }
    if(minj != i){
      work=A[i];
      A[i]=A[minj];
      A[minj] =work;
      count++;
    }
  }

  //out put sort's result
  for(i=0;i<N;i++){
    if(i==N-1){
      printf("%d",A[i]);
      break;
    }
    printf("%d ", A[i]);
  }

  printf("\n%d\n", count);
  
  return 0;
}

Measured memory_bytes: 600
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

long long isPrime(long long n){
  long long i;
  if(n < 2LL){
    return 0LL;
  }
  else if(n == 2LL){
    return 1LL;
  }
  if(n % 2LL == 0LL){
    return 0LL;
  }
  for(i = 3LL; i * i <= n; i += 2LL){
    if(n % i == 0LL){
      return 0LL;
    }
  }
  return 1LL;
}

int main(){
  ll x;
  cin>>x;
  rep(i,x,x+100000){
    if(isPrime(i)==1){
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;

int main() {
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> a(q);
	rep(i, q) cin >> a.at(i);
	vector<int> score(n, k - q);
	rep(i, q) score.at(a.at(i) - 1)++;
	rep(i, n) {
		if (score.at(i) > 0) cout << "Yes" << '\n';
		else cout << "No" << '\n';
	}
}

Measured memory_bytes: 1408
N, M = gets.split.map(&:to_i)

cities = []

cities_n = []

ids = []


M.times do |i|
  p, y = gets.split.map(&:to_i)
  cities.push([p, y, i])
end

cities.sort!{|a, b| a[1] <=> b[1]}


cities.each do |i|
  p_ = i[0]
    
  if(cities_n[p_].nil?)
    cities_n[p_] = 1
  else
    cities_n[p_] += 1
  end
  
  n = cities_n[p_]

  id1 = p_.to_s.rjust(6,'0')
         
  id2 = n.to_s.rjust(6,'0')

  id = id1.to_s + id2.to_s
  
  ids.push([id, i[2]])

end

ids.sort!{|a, b| a[1] <=> b[1]}

ids.each do |i|
  puts i[0]
end



Measured memory_bytes: 28520
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

long long cnt3or5(long long lastNum){
    long long cnt3 = lastNum / 3;
    long long cnt5 = lastNum / 5;
    long long cnt15 = lastNum / 15;
    return (cnt3 + cnt5 - cnt15);
}

long long numsLen(long long lastNum){

    if(lastNum == 0){
        return 0;
    }

    long long ret = 0;
    
    long long temp = 1;
    long long digit = 1;
    while(temp * 10 < lastNum){
        long long cnt = 9 * temp - (cnt3or5(temp * 10 - 1) - cnt3or5(temp - 1));
        ret += digit * cnt;
        temp *= 10;
        digit++;
    }

    long long tempCnt = (lastNum - temp + 1) - (cnt3or5(lastNum) - cnt3or5(temp - 1));
    ret += digit * tempCnt;
    
    return ret;
}

long long strLen(long long lastNum){
    long long cnt3 = lastNum / 3;
    long long cnt5 = lastNum / 5;
    long long cnt15 = lastNum / 15;
    cnt3 -= cnt15;
    cnt5 -= cnt15;

    long long ret = 0;
    ret += numsLen(lastNum);

    ret += (cnt3 + cnt5) * 4;
    ret += cnt15 * 8;

    return ret;
}

string fizzBuzz(long long num){
    if(num == 0){
        return "";
    }
    if(num % 3 == 0 && num % 5 == 0){
        return "FizzBuzz";
    }
    else if(num % 3 == 0){
        return "Fizz";
    }
    else if(num % 5 == 0){
        return "Buzz";
    }
    else{
        return to_string(num);
    }
}

int main(){

    long long s;
    cin >> s;

    long long left = 0;
    long long right = 100000000000000000LL;
    long long center;

    while(left + 1 < right){
        center = (left + right) / 2;
        long long len = strLen(center);

        if(len < s){
            left = center;
        }
        else{
            right = center;
        }
    }

    long long tempLen = strLen(left);
    string ansBase = "";
    int startIndex = s - tempLen - 1;
    left++;
    while(tempLen < s + 20){
        string temp = fizzBuzz(left);
        tempLen += (int)temp.size();
        ansBase += temp;
        left++;
    }

    cout << ansBase.substr(startIndex, 20) << endl;

    return 0;
}


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

int main() {
   int N;
   cin >> N;
   int count=0;
   for(int i=1; i<=N; i++) {
      if(i < 10) count++;
      else if(i >= 100 && i < 1000) count++;
      else if(i >= 10000 && i < 100000) count++;
   }
   cout << count << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <queue>
#include <bitset>
#include <sstream>

using namespace std;
typedef long long ll;

vector<bool> seen;
void dfs(vector<vector<pair<ll,ll>>> &A, vector<ll> &Kyori, ll v){
        seen[v] =true;

        for(auto i : A[v]){
                ll next_v = i.first;
                if(seen[next_v]) continue;
                Kyori[next_v] = Kyori[v] + i.second;
                dfs(A, Kyori,next_v);

        }
}

int main(){
        ll N;
        cin >> N;
        vector<vector<pair<ll,ll>>> A(N);
        vector<ll> Kyori(N, 0);
        int a, b, c;
        for(ll i=0; i<N-1; i++){
                cin >> a;
                cin >> b;
                cin >> c;
                A[a-1].push_back(make_pair(b-1,c));
                A[b-1].push_back(make_pair(a-1,c));
        }
        ll Q, K;
        cin >> Q >> K;
        seen.assign(N, false);
        dfs(A, Kyori, K-1);


        int x,y;
        vector<pair<ll,ll>> ans;
        for(ll i=0; i<Q; i++){
                cin >> x >> y;
                ans.push_back(make_pair(x,y));
        }
        for(auto i : ans){
                cout << Kyori[i.first-1] + Kyori[i.second-1] << endl;
        }


}


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

using namespace std;

#define forn(i, n) for(int i=0;i<int(n);i++)

int main(){
	string s; cin >> s;
	int n = s.size();
	if(s.size() == 0){ cout << 0; return 0;}
	int contMax = 1000000;
	vector<int> p (2);
	iota(p.begin(), p.end(), 0);
	string colors = "01";
	do{
		string t;
		int cont = 0;
		forn(i, n){
			t+=colors[p[i%2]];
			cont+= t[i] != s[i];
		}
		contMax = min(contMax, cont);
	}while(next_permutation(p.begin(), p.end()));
	cout << contMax << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define pb emplace_back
using namespace std;
using ll = long long;
const int maxn = 300010;
signed main(){
	ios_base::sync_with_stdio(0), cin.tie(0);
	string a;
	cin >> a;
	if (a[1] == 'B') a[1] = 'R';
	else a[1] = 'B';
	cout << a << '\n';
}



Measured memory_bytes: 3612
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 2000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int main() {
	int n;
	cin >> n;
	int xoring = 0;
	vector<int> wow;
	REP(i, n) {
		int a;
		cin >> a;
		wow.push_back((a ^ (a-1)));
		xoring ^= a;
	}
	sort(wow.begin(), wow.end(), greater<int>());
	int ans = 0;
	for (int i = 0;i < n;++i) {
		int now = wow[i];
		if ((now ^ xoring) < xoring) {
			ans++;
			xoring ^= now;
		}
	}
	if (xoring == 0) {
		cout << ans << endl;
	}
	else {
		cout << -1 << endl;
	}
	
return		0;
}

Measured memory_bytes: 892