akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        int a,b,c;
        //?¨??????\??????????????????????????§????????????
    	Scanner scanner = new Scanner(System.in);
    	//??\????????????int??????????????????
    	a = scanner.nextInt();
    	b = scanner.nextInt();
    	c = scanner.nextInt();
    	//a????????§??????
    	if(a > b && a > c){
    		if(b > c){
    			System.out.println(c+" "+b+" "+a);
    		}
    		else{
    			System.out.println(b+" "+c+" "+a);
    		}
    	}
    	//b????????§??????
    	else if(b > a && b >c){
    		if(a > c){
    			System.out.println(c+" "+a+" "+b);
    		}
    		else{
    			System.out.println(a+" "+c+" "+b);
    		}
    	}
    	//c????????§??????
    	else{
    		if(a > b){
    			System.out.println(b+" "+a+" "+c);
    		}
    		else{
    			System.out.println(a+" "+b+" "+c);
    		}
    	}
    }
}

Measured memory_bytes: 26128
#include <iostream>
//#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
ll INF = 1000000000000 ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}]

int main(){
	ll n ; cin >> n ;
	string s ; cin >> s ;
	vll r(n+1,0),w(n+1,0) ;
	for(int i=1;i<=n;i++){
		r.at(i) += r.at(i-1)+(s.at(i-1)=='R') ;
		w.at(i) += w.at(i-1)+(s.at(i-1)=='W') ;
	}
	ll ans = INF ;
	for(int i=0;i<=n;i++){
		ans = min(ans,w.at(i)+max(0LL,r.at(n)-r.at(i)-w.at(i))) ;
 	}
	cout << ans << endl ;
}



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

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

int main() {
    int n, k;
    cin >> n >> k;
    VI a(n);
    REP(i,n) a[i] = in();
    VI dp(k + 1);
    FOR(i,1,k){
        for (int x : a){
            if (i - x >= 0 && dp[i - x] == 0) dp[i] = 1;
        }
    }
    cout << (dp[k] ? "First" : "Second") << endl;
    return 0;
}


Measured memory_bytes: 640
import sys
string =[]
for j in sys.stdin:
    string.append(j)
string2 = []
for k in string:
    string2.append(k.strip("\n"))


string3 = ''.join(string2) 

alphabet = list("abcdefghijklmnopqrstuvwxyz")
string3 = string3.lower()   
for i in alphabet:
    print(f'{i} : {string3.count(i)}')



Measured memory_bytes: 5576
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

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

    cout << (30 <= X ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  ll X,Y;
  cin >> X >> Y;
  int count = 0;
  while(Y>=X)
  {
    count ++;
    X *= 2;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <functional>
using namespace std;
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#define	ll long long
#define	ull unsigned long long
#define	vi vector<int>
#define	vll vector<long long>
#define	pii pair<int,int>
#define	pll pair<long long,long long>
#define	PB push_back
#define	MP make_pair
#define	ff first
#define	ss second
#define	IT iterator
#define	IOS ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define	LB cout<<"\n"
#define	CS <<" "<<
#define	DB cout<<"> "
#define	endl "\n"
#define	loop(x,y) for(int x=0;x<y;++x)
#define	loop1(x,y) for(int x=1;x<=y;++x)
#define	MS(x,y) memset(x,y,sizeof(x))

int a[3][3];

int main(){
	loop(i,3) loop(j,3) cin >> a[i][j];
	if((a[0][0]-a[1][0])==(a[0][1]-a[1][1]) && (a[0][1]-a[1][1])==(a[0][2]-a[1][2])
		&& (a[2][0]-a[1][0])==(a[2][1]-a[1][1])&&(a[2][1]-a[1][1])==(a[2][2]-a[1][2]))
		cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int x,y,d,cnt=0;
	scanf("%d%d%d",&x,&y,&d);
	for(int i=x;i<=y;i++){
		if(i%d==0){
			cnt++;
		}
	}
	printf("%d",cnt);
	
	return 0;
} 

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

typedef long long ll;

int gcd(int a, int b){
  if(b==0) return a;
  return gcd(b, a%b);
}

int main() {
  int N,X; cin >> N >> X;
  vector<int> x(N+1);
  x[N] = X;
  for(int i=0; i<N; i++) cin >> x[i];

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

  vector<int> diff;
  for(int i=0; i<N; i++){
    diff.push_back(abs(x[i+1]-x[i]));
  }

  int ma=diff[0];
  for(int i=0; i<diff.size(); i++){
    ma = gcd(ma,diff[i]);
  }

  cout << ma << endl;
}

Measured memory_bytes: 1276
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
count=0
for i in range(N):
  if A[i]+A[i+1]<=B[i]:
    count+=A[i]+A[i+1]
    A[i+1]=0
  elif A[i]<=B[i]:
    count+=B[i]
    A[i+1]=A[i+1]-(B[i]-A[i])
  else:
    count+=B[i]
print(count)
              
    

Measured memory_bytes: 18476
from logging import getLogger, StreamHandler, DEBUG
logger = getLogger(__name__)
handler = StreamHandler()
handler.setLevel(DEBUG)
logger.setLevel(DEBUG)
logger.addHandler(handler)

import sys

def saySame(s, sw, index):
    return (sw[index] == 'S' and s[index] == 'o') or (sw[index] == 'W' and s[index] == 'x')
    
def match(s, sw, index, N):
    if saySame(s,sw,index):
        return sw[(index - 1 + N) % N] == sw[(index + 1 + N) % N]
    else:
        return sw[(index - 1 + N) % N] != sw[(index + 1 + N) % N]

N = int(input())
s = input()

for j in range(4):
    sw = ""
    if j%2==0:
        sw+= 'S'
    else:
        sw+= 'W'

    if (int(j/2))%2==0:
        sw+= 'S'
    else:
        sw+= 'W'
#    logger.debug(sw)


    for i in range(N-2):
        if saySame(s,sw,i+1):
            sw+=sw[i]
        else:
            if sw[i] == 'S':
                sw+='W'
            else:
                sw+='S'

#        logger.debug(sw)

    if match(s,sw,0,N) and match(s,sw,N-1,N):
        print(sw)
        sys.exit()

print(-1)


Measured memory_bytes: 4588
n, c, k = gets.split.map(&:to_i)
ts = n.times.map { gets.to_i }.sort
cnt = 0
num = 0
t_first = -10_000_000_000
ts.each do |t|
  if t_first + k < t || num >= c
    cnt += 1
    t_first = t
    num = 0
  end

  num += 1
end
puts cnt


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

struct edge{
    int to,cost;
    edge(){
        to = 0; cost = 0;
    }
    edge(int t,int c){
        to = t;
        cost = c;
    }
};

int n;
//vector<pair<int,int> > G[100001]; //cost to
vector<edge> G[100001];
bool visited[100001];

const long long int INF = 1000000000000;

long long int  prim(){

    priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > que;

    long long int res = 0;

    fill(visited,visited+n,false);

    que.push(make_pair(0,0));

    while(!que.empty()){
        pair<int,int> p = que.top(); que.pop();

        int v = p.second, cst = p.first;

        if(visited[v]){
            continue;
        }
        visited[v] = true;
        res += cst;
        for(int i=0; i<G[v].size(); i++){
            edge e = G[v][i];
            que.push(make_pair(e.cost, e.to));
            //que.push(make_pair(G[v][i].first, G[v][i].second));
        }

    }

    return res;

}

int main() {

    cin >> n;

    int ed;

    cin >> ed;

    int a, b, c;

    for (int i = 0; i < ed; i++) {
        scanf(" %d %d %d", &a, &b, &c);
        edge e;
        e.cost = c;
        e.to = b;
        G[a].push_back(e);
        e.to = a;
        G[b].push_back(e);
        //G[a].push_back(make_pair(c, b));
        //G[b].push_back(make_pair(c, a));
    }

    cout << prim() << endl;

    return 0;
}

Measured memory_bytes: 10008
#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; ++i)
#define int long long
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
using namespace std;
typedef pair<int, int> P;
struct edge {
	int to, cost;
};
// other libs
int gcd(int a, int b) {
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

class dijkstra {
  private:
	int V;
	int d[100002];
	priority_queue<P, vector<P>, greater<>> que;

  public:
	dijkstra(int v, int s, vector<edge> G[]) {
		V = v;
		update(s, G);
	}

	void update(int s, vector<edge> G[]) {
		fill(d, d + V + 1, 100000000000ll);
		d[s] = 0;
		que.push(make_pair(0, s));
		while (!que.empty()) {
			P p = que.top();
			que.pop();
			int v = p.second;
			if (d[v] < p.first) continue;
			rep(i, G[v].size()) {
				edge e = G[v][i];
				if (d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					que.push(make_pair(d[e.to], e.to));
				}
			}
		}
	}

	int find(int e) {
		return d[e];
	}
};
template<typename T>
class Union_Find {
  private:
	vector<T> t, s;

  public:
	Union_Find(T max_length) {
		rep(i, max_length + 1) {
			t.push_back(i);
			s.push_back(1);
		}
	}

	void Union(T x, T y) {
		if (same(x, y)) return;
		T tx = Find(x), ty = Find(y);
		if (s[tx] < s[ty]) {
			s[ty] += s[tx];
			t[tx] = ty;
		}
		else if (s[tx] > s[ty]) {
			s[tx] += s[ty];
			t[ty] = tx;
		}
		else if (tx > ty) {
			t[tx] = ty;
			s[ty] += s[tx];
		}
		else {
			t[ty] = tx;
			s[tx] += s[ty];
		}
	}
	T Find(T n) {
		if (t[n] == n)
			return n;
		else
			return t[n] = Find(t[n]);
	}

	bool same(T x, T y) {
		return Find(x) == Find(y);
	}

	T get_Size(size_t a) {
		return s[a];
	}
};
bool ifPrime(int n) {
	if (n == 1) return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) return false;
	}
	return true;
}

set<int> prime_num_factor(int n) {
	if (n < 2) return set<int>();
	set<int> prime;
	prime.insert(2);
	for (int i = 3; i <= n; i++) {
		for (int it : prime) {
			if (it * it > i) {
				prime.insert(i);
				break;
			}
			if (i % it == 0) break;
		}
	}
	return prime;
}
vector<int> makeDivisors(int n) {
	vector<int> re;
	REP(i, 1, sqrt(n) + 1) {
		if (n % i == 0) {
			re.push_back(i);
			if (i != n / i) re.push_back(n / i);
		}
	}
	return re;
}
int modPow(int a, int n, int mod) {
	int ret = 1;
	while (n) {
		if (n & 1) ret = ret * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return ret;
}
signed main(signed argc, char* argv[]) {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	string s;
	cin>>n>>s;
	if(s.substr(0,n/2)==s.substr(n/2))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


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

int main(){
    int n,ans=0,pre,now;
    cin >> n;
    cin >> pre;
    while(cin >> now){
        if(now==pre){
            ans++;
            cin >> pre;
        }else{
            pre=now;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

int inv(int n) {
    int m = P, y = 0, v = 1;
    while (1) {
        int q = m / n;
        int r = m % n;
        if (r == 0) return v < 0 ? v + P : v;
        y -= v * q;
        swap(y, v);
        m = n;
        n = r;
    }
}

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

    int n = s.size();

    vector<int> x(n + 1), y(n + 1);
    x[0] = y[0] = 1;
    for (int i = 1; i <= n; i++) {
        x[i] = (ll)x[i - 1] * 2 % P;
        y[i] = (ll)y[i - 1] * 3 % P;
    }

    ll r = 0;

    int q[256] = {};
    for (int i = 0; i < n; i++) {
        q[s[i]]++;
    }

    ll h = y[q['?']];
    ll j = inv(3);

    int p[256] = {};
    for (int i = 0; i < n; i++) {
        q[s[i]]--;
        if (s[i] == 'B' || s[i] == '?') {
            ll t = h * (((ll)p['A'] + p['?'] * j) % P) % P * (((ll)q['C'] + q['?'] * j) % P) % P;
            if (s[i] == '?') t *= j, t %= P;
            //cout << t << endl;
            r += t;
            r %= P;
        }
        p[s[i]]++;
    }

    cout << r << endl;

    return 0;
}

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

int main() {
	int h, w;
	cin >> h >> w;
	while (h != 0 && w != 0) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
		cin >> h >> w;
	}
}


Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long t,j;
    cin>>t;
    long long a=0,b=0,c=0,d=0 ;
for(j=0;j<t;j++){
    string s;
    cin>>s;
    if(s=="AC")
    a++;
    if(s=="WA")
    b++;
    if(s=="TLE")
    c++;
    if(s=="RE")
    d++;
}cout<<"AC"<<" "<<'x'<<" "<<a<<endl;
cout<<"WA"<<" "<<'x'<<" "<<b<<endl;
cout<<"TLE"<<" "<<'x'<<" "<<c<<endl;
cout<<"RE"<<" "<<'x'<<" "<<d<<endl;
    return 0;
}


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

int pow(int x, int n) {
  int ans = 1;
  for(int i = 0; i < n; i++) {
    ans *= x;
  }
  return ans;
}

int main() {
  while(1) {
    int dat[3];
    cin >> dat[0] >> dat[1] >> dat[2];
    if(dat[0] == 0 && dat[1] == 0 && dat[2] == 0) break;

    int n;
    cin >> n;

    for(int i = 0; i < n; i++) {
      int r;
      cin >> r;

      bool flag = false;
      for(int j = 0; j < 3; j++) {
	if(pow(dat[j], 2)+pow(dat[(j+1)%3], 2) < pow(r*2, 2)) {
	  flag = true;
	  break;
	}
      }
      if(flag) {
	cout << "OK" << endl;
      } else {
	cout << "NA" << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
    int N,K;
    cin >> N >> K;
    vector<long long> h(N);
    for(int i = 0; i < N;i++)cin >> h[i];
    
    sort(h.begin(),h.end());
    
    long long res = 1LL<<60;
    for(int i = 0; i + K - 1 < N;i++)res = min(res,h[i+K-1]-h[i]);
    cout << res <<endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while (scan.hasNextInt()) {
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		if (((a==5)&&(b==5)&&(c==7))||((a==5)&&(b==7)&&(c==5))||((a==7)&&(b==5)&&(c==5))) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		}

	}

}


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

double dp[303][303][303];
int n;

void calc(int i, int j, int k)
{
    if (dp[i][j][k] >= 0)
        return;
    if (i)
        calc(i - 1, j, k);
    if (j)
        calc(i + 1, j - 1, k);
    if (k)
        calc(i, j + 1, k - 1);

    dp[i][j][k] = (i ? dp[i - 1][j][k] * i : 0) + (j ? dp[i + 1][j - 1][k] * j : 0) +
                  (k ? dp[i][j + 1][k - 1] * k : 0) + n;
    dp[i][j][k] *= 1.0 / (i + j + k);
}

int main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    vector<int> cnt(5);
    int a;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        cnt[a]++;
    }

    memset(dp, -1, sizeof dp);
    dp[0][0][0] = 0.0;
    calc(cnt[1], cnt[2], cnt[3]);
    printf("%.10lf\n", dp[cnt[1]][cnt[2]][cnt[3]]);

    return 0;
}


Measured memory_bytes: 217728
n = int(input())
d, x = map(int, input().split())
a = list([int(input()) for i in range(n)])

c = 0

for i in range(n):
  cd = 0
  count = 1
  for j in range(d):
    if cd + a[i] <= d - 1:
      cd = cd + a[i]
      count += 1
  
  c = c+count
    
print(c + x)

Measured memory_bytes: 9076
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e,f;
  cin >> a >> b >> c >> d;
  e = a + b;
  f = c + d;
  if (e == f)
    cout << "Balanced" << endl;
  else if (e > f)
    cout << "Left" << endl;
  else 
    cout << "Right" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		char c = s.charAt(0);
		if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o' ) {
			System.out.println("vowel");
		}else {
			System.out.println("consonant");
		}
	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int M = 4010;

int f[M][M];
int n, m, k;
int main()
{
	cin >> n >> m >> k;
	f[0][0] = 1;
	for (int i = 1; i < M; i ++)
	{
		int cur = 0;
		for (int j = 0; j < M; j ++)
		{
			cur += f[i - 1][j];
			cur %= mod;
			if (j >= k) cur = cur + mod - f[i - 1][j - k];
			cur %= mod;
			f[i][j] = cur;
		}
	}
	//for(int i = 1; i <= 10; i ++, puts(""))
        //for(int j = 1; j <= 10; j ++)   
         //   cout << f[i][j] << " ";
	int ans = 0;
	for (int i = 1; i <= m; i ++)
		if (i % (k - 1) == m % (k - 1))
		{
			int len = (n + i - 1) / (k - 1);
			ans += f[len][i];
			ans %= mod;
		}

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



Measured memory_bytes: 63104
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
typedef pair<ll,ll> P;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
    ll N; cin>>N;
    vector<P> d;
    rep(i,N){
        ll X,L; cin>>X>>L;
        d.pb(mp(X+L,X-L));
    }
    sort(d.begin(),d.end());
    ll ans=0;
    ll memory=-INF;
    rep(i,N){
        if(d.at(i).second>=memory){
            ans++;
            memory=d.at(i).first;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2420
#include<stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b) {
  return *(int*)a - *(int*)b;
}

int lower_bound(int *arr, int num, int key){
	int min, max, mid;
	min = 0;
    max = num;
	mid = (min + max) / 2;
	while((min + 1 != mid || mid + 1 != max) && mid != min){
		if(key > arr[mid]) {
          min = mid;
        } else {
          max = mid + 1;
        }
		mid = (min + max) / 2;
	}
	if(arr[min] >= key) {
      return min;
    } else if(arr[mid] >= key) {
      return mid;
    } else if(arr[max] >= key) {
      return max;
    } else {
	  return num;
    }
}

int main(void){
  int N;
  int Parts[3][100000];
  int i, j;
  long long x, y;
  long long sum = 0;

  scanf("%d", &N);

  for (i = 0; i < 3; i++) {
    for (j = 0; j < N; j++) {
      scanf("%ld", &Parts[i][j]);
    }
    qsort(Parts[i], N, sizeof(int), compare_int);
  }
  
  for(i=0; i<N; i++){
	x = lower_bound(Parts[0], N, Parts[1][i]);
	y = lower_bound(Parts[2], N, Parts[1][i]+1);
	sum += x * (N - y);
  }
  
  /*
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      for(k = 0; k < N; k++){
        if (Parts[1][j] > Parts[0][k]) {
          if(Parts[2][i] > Parts[1][j]) {
            sum++;
          }
        } else {
          break;
        }
      }
    }
  }
  */
    
  printf("%lld\n", sum);
  
  return 0;
}


Measured memory_bytes: 1780
def minimumNumberOfBus(a, c, k):
    foo = 0
    a = sorted(a)
    cur = 0
    while cur<len(a):
        departing_time = a[cur]+k
        space = c
        while space>0 and cur<len(a) and a[cur]<=departing_time:
            cur += 1
            space -= 1
        foo += 1
    return foo

def main():
    n, c, k = [int(x) for x in raw_input().strip().split()]
    a = [0 for i in xrange(n)]
    for i in xrange(n):
        a[i] = int(raw_input().strip())
    print minimumNumberOfBus(a, c, k)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
int32_t main()
{
	vector<int> h(26);
	string s;
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		vector<int> tmp(26);
		cin>>s;
		for(auto j:s)tmp[j-'a']++;
		if(i==0)
		{
			for(auto j:s)h[j-'a']++;
		}
		for(int j=0;j<26;j++)
		h[j]=min(h[j],tmp[j]);
		
	}
	string ans="";
	for(int i=0;i<26;i++)
	{
		ans+=string(h[i],i+'a');
	}
	cout<<ans;
} 

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

int main(void)
{
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  vector<int> x(N), y(M);
  for (int j=0; j < N; ++j) {
    cin >> x[j];
  }
  for (int j=0; j < M; ++j) {
    cin >> y[j];
  }
  bool flag = false;
  for (int j=X+1; j <= Y; ++j) {
    bool f = true;
    for (int &k:x) {
      if (k >= j) {
        f = false;
        break;
      }
    }
    if (!f) continue;
    for (int &k:y) {
      if (k < j) {
        f = false;
        break;
      }
    }
    if (f) {
      flag = true;
      break;
    }
  }
  if (flag) {
    cout << "No War" << endl;
  } else {
    cout << "War" << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
#define rep(i, n) for(int i = 0; i < n; i++)
const int inf9 = 1e9; const lint inf18 = 1e18;
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 = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // 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); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; 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; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint P(int n, int r){ if(r < 0 || n < r) return 0; return (fact[n] * inv[n - r] % mod); } lint C(int p, int q){ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
template<class itr, class itr2> bool next_sequence2(itr first, itr last, itr2 first2, itr2 last2){ itr now = last; itr2 now2 = last2; while(now != first){ now--, now2--; (*now)++; if((*now) == (*now2)){ (*now) = 0; }else{ return true; } } return false; }
inline int at(lint i, int j){ return (i >> j) & 1; }

int main(){
    lint X, N;
    cin >> N >> X;
    lint A = X, B = N - X;
    lint ans = N;
    if(A < B){
        swap(A, B);
    }
    while(B){
        ans += A / B * 2 * B;
        A %= B;
        swap(A, B);
    }
    ans -= A;
    cout << ans << endl;
}


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


using namespace std;
using ll= long long;
using pii = pair<int, int>;

const int oo = 1e9 + 7;
const int mod = 1e9 + 7;


int main (){
    int w, a, b;
    cin >> w >> a >> b;
    if (b > a + w){
        cout << b - a - w << endl;
    }
    else if (a > b + w){
        cout << a - b - w << endl;
    }
    else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

string s;

int main() {
    cin >> s;
    int slen = s.length();
    int ans = 0;
    for(int i = slen-2; i >= 0; --i) {
        int nlen = i;
        if(nlen % 2 != 0) {
            int half = nlen/2 + 1;
            string sfst = s.substr(0, half);
            string ssnd = s.substr(half, half);
            if(sfst == ssnd) {
                ans = nlen;
                break;
            }
        }
    }

    cout << ans+1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define MAX 100
int main(void){
    // Your code here!
    int n;
    int T_point=0,H_point=0;    
    char Taro[MAX],Hanako[MAX];
    
    scanf("%d", &n);
    for(;n>0;n--){
        scanf(" %s %s", &Taro, &Hanako);
        if(strcmp(Taro, Hanako)==0){
            T_point+=1;
            H_point+=1;
        }
        else if(strcmp(Taro, Hanako)>0){
            T_point+=3;
        }
        else if(strcmp(Taro, Hanako)<0){
            H_point+=3;
        }
    }
    printf("%d %d\n", T_point, H_point);
    
    return 0;
}


Measured memory_bytes: 2144
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

import itertools
import math

ans = 0
for l in list(itertools.permutations(range(n))):
    tmp = 0
    for i in range(len(l) - 1):
        tmp += math.sqrt((xy[l[i]][0] - xy[l[i+1]][0]) ** 2 + (xy[l[i]][1] - xy[l[i+1]][1]) ** 2)
    ans += tmp
print(ans / len(list(itertools.permutations(range(n)))))


Measured memory_bytes: 47708
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    string s; cin >> s;
    cout << (s[0] == s[2] ? "Yes" : "No") << endl;
}

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

using namespace std;

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

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int l, r, d;
	cin >> l >> r >> d;
	int res = 0;
	FOR (i, l, r + 1) {
	  if (i % d == 0) res++;
	}
	cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 3480
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
const int INF=1000000000;
typedef long long int lli;
typedef pair<int,int> P;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int MAX_N=1000;
int X1[MAX_N],X2[MAX_N],Y1[MAX_N],Y2[MAX_N];
bool fld[MAX_N*6][MAX_N*6];
int w,h,n;

int compress(int *x1,int *x2,int wh){
	vector<int> xs;
	
	for(int i=0; i<n; ++i){
		for(int d=-1; d<=1; ++d){
			int tx1=x1[i]+d,tx2=x2[i]+d;
			if(0<=tx1&&tx1<wh) xs.push_back(tx1);
			if(0<=tx2&&tx2<wh) xs.push_back(tx2);
		}
	}
	
	sort(xs.begin(),xs.end());
	xs.erase(unique(xs.begin(),xs.end()),xs.end());
	
	for(int i=0; i<n; ++i){
		x1[i]=find(xs.begin(),xs.end(),x1[i])-xs.begin();
		x2[i]=find(xs.begin(),xs.end(),x2[i])-xs.begin();
	}
	return xs.size();
}

int main(){
	while(cin>>w>>h){
		if(w==0&&h==0) break;
		cin >> n;
		for(int i=0; i<n; ++i){
			cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
		}
		w=compress(X1,X2,w);
		h=compress(Y1,Y2,h);
		
		memset(fld,0,sizeof(fld));
		
		for(int i=0; i<n; ++i){
			for(int y=Y1[i]; y<Y2[i]; ++y){
				for(int x=X1[i]; x<X2[i]; ++x){
					fld[y][x]=true;
				}
			}
		}
		/*
		for(int i=0; i<h; ++i){
			for(int j=0; j<w; ++j){
				if(fld[i][j]) cout << "M";
				else cout << "L";
			}
			cout << "\n";
		}
		*/
		int ans=0;
		for(int y=0; y<h; ++y){
			for(int x=0; x<w; ++x){
				if(fld[y][x]) continue;
				++ans;
				
				queue<P> que;
				que.push(P(x,y));
				while(!que.empty()){
					int sx=que.front().first,sy=que.front().second;
					que.pop();
					
					for(int i=0; i<4; ++i){
						int tx=sx+dx[i],ty=sy+dy[i];
						if(tx<0||w<=tx||ty<0||h<=ty) continue;
						if(fld[ty][tx]) continue;
						que.push(P(tx,ty));
						fld[ty][tx]=true;
					}
				}
			}
		}
		cout << ans << "\n";
	}
	return 0;
}

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

int isPrime(int x){
  for(int i=2; i*i<=x; i++){
    if(x%i == 0) return 0;
  }
  return 1;
}

int main(){
  int n; cin >> n;
  int ans=0;
  for(int i=0; i<n; i++){
    int x; cin >> x;
    ans += isPrime(x);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 1164
program prob3
    implicit none
    integer::h, w, k, i, j, l, cnt, it, jt
    integer, allocatable::c(:,:), tmp(:,:), tmpp(:,:)
    character(len=10)::s
    read(*,*) h, w, k
    allocate(c(h,w), tmp(h,w), tmpp(h,w))
    do i = 1, h
        read(*,*) s
        do j = 1, w
            if(s(j:j) .eq. ".") then
                c(i,j) = 0
            else
                c(i,j) = 1
            end if
        end do
    end do
    cnt = 0
    do i = 0, 2**h-1
        tmp = c
        it = i
        do j = 1, h
            if(mod(it,2) == 1) tmp(j,:) = 0
            it = it/2
        end do
        do j = 0, 2**w-1
        	tmpp = tmp
            jt = j
            do l = 1, w
                if(mod(jt,2) == 1) tmpp(:,l) = 0
                jt = jt/2
            end do
            if(sum(tmpp) == k) cnt = cnt + 1
        end do
    end do
    write(*,*) cnt
    deallocate(c,tmp,tmpp)
    stop
end program

Measured memory_bytes: 2824
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
import pprint
sys.setrecursionlimit(10 ** 9)

INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

class BIT:
    def __init__(self, size):
        self.bit = [0] * size
        self.size = size
        self.total = 0

    def add(self, i, w):
        x = i + 1
        self.total += w
        while x <= self.size:
            self.bit[x - 1] += w
            x += x & -x
        return

    def sum(self, i):
        res = 0
        x = i + 1
        while x:
            res += self.bit[x - 1]
            x -= x & -x
        return res

    def interval_sum(self, i, j): # i <= x < j の区間
        return self.sum(j - 1) - self.sum(i - 1) if i else self.sum(j - 1)

def main():
    N = I()
    s = list(S())
    Q = I()
    D = defaultdict(lambda : BIT(N))
    for i in range(N):
        D[s[i]].add(i,1)
    for j in range(Q):
        qi,i,c = LS()
        if qi == "1":
            i = int(i) - 1
            D[s[i]].add(i,-1)
            D[c].add(i,1)
            s[i] = c
        else:
            l,r = int(i)-1, int(c)
            result = 0
            for k in range(97,123):
                if D[chr(k)].interval_sum(l,r):
                    result += 1
            print(result)

if __name__ == '__main__':
    main()

Measured memory_bytes: 163924
import numpy as np

l = [int(input()) for _ in range(5)]

n = np.array(l)
n = 1000 - n
n %= 10

idx = np.argsort(n)
t = 0
for i in idx[:-1]:
    t += l[i]
    if(n[i] != 0):
        t = (t+10)-t%10
t += l[idx[-1]]
print(t)

Measured memory_bytes: 12472
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

const int MAX_N = 100050;
int N;
long long a[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N;
    
    for (int i = 1; i <= N; i++) {
        std::cin >> a[i];
    }

    for (int i = 1; i <= N; i++) {
        if (a[i] % 2 == 1) {
            std::cout << "first" << std::endl;
            return 0;
        }
    }

    std::cout << "second" << std::endl;
    return 0;
}

Measured memory_bytes: 1024
#pragma region cp-helper
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(a, b)
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls int
#define give main()
const int mod = 1000000007;
#pragma endregion

pls give {
    AC;
    int n, a;
    cin >> n >> a;
    if (n%500 <= a) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,m,k;
  cin>>n>>m>>k;

  bool flag=false;
  
  rep(i,n+1){
    rep(j,m+1){
      flag|=(j*(n-i)+i*(m-j)==k);
    }
  }

  Yes(flag);


}

Measured memory_bytes: 256
n = int(input())
arr = list(map(lambda n: format(int(n), '060b')[::-1], input().split()))

mod = 10 ** 9 + 7

res = 0
power_of_two = 1
for d in range(60):
    one = sum(x[d] == "1" for x in arr)
    res += one * (n - one) * power_of_two
    res %= mod
    power_of_two *= 2
    power_of_two %= mod

print(res)


Measured memory_bytes: 155864
#!/usr/bin/env python3
import sys


def solve(N: int, X: int, L: "List[int]"):
    d = 0
    for i, l in enumerate(L, 1):
        d += l      
        if d > X:
            print(i)
            return  
    else:
        print(i+1)
    return

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X, L)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <set>
#include <math.h>
#define pai 3.14159265358979323846264338327950288;
#define keta(n) cout << fixed << setprecision((n));

int main()
{
  int n;
  int i = 1;

  while (true) {
    cin >> n;
    if (n == 0) {
      break;
    }
    cout << "Case " << i << ": " << n << endl;
    i++;
  }
  return 0;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
#define ll long long
const ll inf = 1e18;
int main(){
  int n;
  scanf("%d",&n);
  vector<ll> c(3,0);
  vector<ll> dp(3,0);
  for(int i=0;i<n;++i){
    for(int j=0;j<3;++j)cin>>c[j];
	vector<ll> ndp(3,0);
    for(int j=0;j<3;++j){
      for(int k=0;k<3;++k){
        if(j !=k){
          ndp[k] = max(ndp[k],dp[j]+c[k]);
        }
      }
    }
    dp = ndp;
  }
  ll ans = 0;
  for(int i=0;i<3;++i)ans = max(ans,dp[i]);
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

#define endl "\n";
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,bool> pllb;
typedef pair<pair<ll,ll>,ll> plll;

const ll N = 110;
const ll INF = 1e17;
const ll N2 = 1e5+10;
const int MOD = 1e9+7;

ll n,w;
ll weight[N],val[N];
ll memo[N][N2];

ll dp(int idx,int v)
{
    if(idx==n)
    {
        if(v==0)
            return 0;
        else
            return 1e14;

    }
    ll &ret = memo[idx][v];
    if(~ret)
        return ret;
    ret = dp(idx+1,v);
    ret = min(ret,dp(idx+1,max((ll)0, v-val[idx]))+weight[idx]);
}


int main()
{
    fastio
    #ifndef ONLINE_JUDGE
        //freopen("input.txt","r",stdin);
        //freopen("out.txt","w",stdout);
    #endif


    memset(memo,-1,sizeof memo);
    cin >> n >> w;
    int sum = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> weight[i] >> val[i];
        sum+=val[i];
    }
    ll ans = 0;
    for(int i = 0; i <= sum; i++)
    {
        ll temp = dp(0,i);
        if(temp<=w)
            ans = i;
    }
    cout << ans << endl;

}


Measured memory_bytes: 86272
import java.util.Scanner;

public class Main {
  public static void main (String[] args) { 
    Scanner input = new Scanner(System.in);
    
    while (input.hasNext()) {
      int N = input.nextInt();
      int[][] happiness = new int[N][3];
      
      for (int i = 0; i < happiness.length; ++i) {
        for (int j = 0; j < happiness[i].length; ++j) {
          happiness[i][j] = input.nextInt();
        }
      }
      
      for (int i = 1; i < happiness.length; ++i) {
        for (int j = 0; j < happiness[i].length; ++j) {
          int maxPrev = 0;
          for (int k = 0; k < happiness[i].length; ++k) {
            if (j != k) {
              maxPrev = Math.max(maxPrev, happiness[i - 1][k]);
            }
          }
            
          happiness[i][j] += maxPrev;
        }
      }
      
      int maxHappiness = 0;
      for (int i = 0; i < happiness[N - 1].length; ++i) {
        maxHappiness = Math.max(maxHappiness, happiness[N-1][i]);
      }
      
      System.out.println(maxHappiness);
    }
  }
}

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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

int main(){

    ll n, x, y; cin >> n >> x >> y;
    vvi G(n, vi(n, 0));
    rep(i, n){
        rep(j, n){
            G[i][j] = abs(i-j);
        }
    }

    rep(i, n){
        rep(j, n){
            G[i][j] = min(G[i][j], min(G[i][x-1]+G[y-1][j]+1, G[i][y-1]+G[x-1][j]+1));
        }
    }

    vll ans(n-1, 0);
    rep(i, n-1){
        rep2(j, i+1, n){
            ans[G[i][j]-1]++;
        }
    }

    rep(i, n-1) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 19040
n = int(input())
a = list(map(int, input().split()))
b = []
c = {}

ans = 0
for i in range(n):
    b.append(a[i]+i+1)
    x = -a[i]+i+1
    if x in c:
        c[x] += 1
    else:
        c[x] = 1
for i in range(n):
    if b[i] in c:
        ans += c[b[i]]
print(ans)

Measured memory_bytes: 46140
#include <iostream>
using namespace std;
using ll = long long;
ll dp[1000005] = {0};
pair<int, int> p[10];
int main()
{
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < k; ++i)
    {
        cin >> p[i].first >> p[i].second;
    }
    const int mod = 998244353;
    dp[1] = 1;
    for (int i = 1; i < n; ++i)
    {
        dp[i] += dp[i - 1];
        for (int j = 0; j < k; ++j)
        {
            if (i + p[j].first <= n)
            {
                dp[i + p[j].first] = (dp[i + p[j].first] + dp[i]) % mod;
                if (i + p[j].second + 1 <= n)
                    dp[i + p[j].second + 1] = (dp[i + p[j].second + 1] - dp[i] + mod) % mod;
            }
        }
    }
    cout << int(dp[n] % 998244353);
}

Measured memory_bytes: 5208
n,x,y=list(map(int,input().split()))
l=[0]*n
for i in range(1,n):
    for j in range(i+1,n+1):
        if j<=x or i>=y:#1,6
            l[j-i]+=1
        elif i<=x and x<j and j<y:#2
            l[min(j-i,x+y-i-j+1)]+=1
        elif i<=x and j>=y:#3
            l[x-y+j-i+1]+=1
        elif x<i and j<y:#4
            l[min(j-i,y-x+i-j+1)]+=1
        else:
            l[min(j-i,i+j-x-y+1)]+=1
for k in range(1,n):
    print(l[k])
    

Measured memory_bytes: 47068
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func main() {
	io := NewIo()
	defer io.Flush()

	A := io.NextInt()
	B := io.NextInt()
	T := io.NextInt()

	io.PrintLn(B * (T / A))

}


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

int main() {
  int a,b,c,d;
  cin >> a>>b>>c>>d;
  if (a+b < c+d) {
    cout <<"Right"<<endl;
  }
  else if (a+b > c+d) {
    cout<<"Left"<<endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define yes {cout << "Yes"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a + b + c >= 22 ? "bust" : "win");
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    int v, x, y, z;
    double a;
    cin >> v >> x;
    y =  v / x;
    z = v % x;
    a = (double) v / x;
    cout << y << " " << z << " " << fixed << setprecision(5) << a << endl;
}




Measured memory_bytes: 3240