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

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

        if (N % 2 == 1) {
            System.out.println(0);
            return;
        }

        long res = 0;
        N /= 2;
        while (N > 0) {
            res += N / 5;
            N /= 5;
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 35172
#include<bits/stdc++.h>
using namespace std;
int main(){
int A,B,Q;
  cin>>A>>B>>Q;
  vector<int64_t>s(A+2);
  s.at(0)=-10000000010;
  for(int i=1;i<=A;i++)
    cin>>s.at(i);
  s.at(A+1)=20000000010;
  vector<int64_t>t(B+2);
  t.at(0)=-10000000010;
  for(int i=1;i<=B;i++)
    cin>>t.at(i);
  t.at(B+1)=20000000010;
  for(int i=0;i<Q;i++){
  int64_t x;
    cin>>x;
    auto itr=lower_bound(s.begin(),s.end(),x);
    int k=distance(s.begin(),itr);
    int64_t S1=s.at(k)-x;
    int64_t S2=s.at(k-1)-x;
     auto itr1=lower_bound(t.begin(),t.end(),x);
    int l=distance(t.begin(),itr1);
    int64_t T1=t.at(l)-x;
    int64_t T2=t.at(l-1)-x;
      int64_t a=S1+min(abs(T2-S1),abs(T1-S1));
    int64_t b=abs(S2)+min(abs(T2-S2),abs(T1-S2));
    int64_t c=T1+min(abs(T1-S1),abs(T1-S2));
    int64_t d=abs(T2)+min(abs(T2-S1),abs(T2-S2));
    int64_t ans=min(min(a,b),min(c,d));
    cout<<ans<<endl;
      
  
  }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 30;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int n, p; cin >> n >> p;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int even=0, odd=0;
  rep(i, n) {
    if(a[i]%2==0)++even;
    else ++odd;
  }
  ll c[51][51];
  c[0][0] = 1;
  for(int i = 1; i <= 50; ++i) {
    c[i][0] = c[i][i] = 1;
    for(int j = 1; j < i; ++j) {
      c[i][j] = c[i-1][j]+c[i-1][j-1];
    }
  }
  if(p==0) {
    ll ans = 0;
    for(int s = 0; s <= odd; s += 2) {
      ans += c[odd][s];
    }
    ans *= (ll)pow(2, even);
    cout << ans << endl;
  }
  else {
    ll ans = 0;
    for(int s = 1; s <= odd; s += 2) {
      ans += c[odd][s];
    }
    ans *= (ll)pow(2, even);
    cout << ans << endl;
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 2000
#define LL long long
int l[maxn+5];
int main(){
	int n;scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",l+i);
	sort(l,l+n);l[n]=maxn;
	int L,R;LL ans=0;
	for(int i=0;i<n;i++){
		L=0,R=0;
		for(int j=i+1;j<n;j++){
			while(l[L]<=l[j]-l[i])L++;
			while(l[R]<l[j]+l[i])R++;
			ans+=R-L-(L<=i)-(R>j);
		}
	}
	printf("%d",ans/3);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int cal(vector<int>a,int n){
	int sum=0;
	for(int i=0;i<a.size();i++){
		sum+=(a[i]-n)*(a[i]-n);
	}
	return sum;
}

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	int sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	int min=1000000,x;
	for(int i=-100;i<101;i++){
		x=cal(a,i);
		min=(min<x)?min:x;
	}
	cout<<min<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 10000

typedef double Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int n, m, p, a, b;
int ti[8];

typedef pair<Edge, int> P;

Weight dist[1<<8][30];
bool visited[1<<8][30];
  
Weight dijkstra(const Graph &g, int s, int t) {
  REP(i,1<<n) REP(j,g.size()) {
    dist[i][j] = INF;
    visited[i][j] = 0;
  }
  dist[0][s] = 0;
  int ma = 0;
  priority_queue<P> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(P(Edge(-2, s, 0),0)); !Q.empty(); ) {
    Edge e = Q.top().first;
    int S = Q.top().second;
    Q.pop();
    if (t == e.dst) return dist[S][e.dst];
    if (dist[S][e.dst] < e.weight) continue;
    if (visited[S][e.dst]) continue;
    visited[S][e.dst] = 1;
    FOR(f,g[e.dst]) {
      REP(i,n) {
        if ((S>>i)&1) continue;
        if (visited[S|1<<i][f->dst]) continue;
        double cost = e.weight+f->weight/ti[i];
        if (dist[S|(1<<i)][f->dst] > cost) {
          dist[S|(1<<i)][f->dst] = cost;
          Q.push(P(Edge(f->src, f->dst, cost), S|(1<<i)));
        }
      }
    }
    ma = max(ma,(int)Q.size());
  }
  // cout << ma << endl;
  return INF;
}


int main() {
  while(cin>>n>>m>>p>>a>>b,n) {
//    cout << n <<m<<p<< endl;
    a--;b--;
    REP(i,n) cin >> ti[i];
    Graph g(m);
    REP(i,p) {
      int x,y,z;
      cin >> x >> y >> z;
      x--;y--;
      g[x].push_back(Edge(x,y,z));
      g[y].push_back(Edge(y,x,z));
    }
    double res = dijkstra(g, a, b);
    if (res == INF)
      cout << "Impossible" << endl;
    else
      printf("%.8lf\n",res);
  }
}

Measured memory_bytes: 9660
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;



/* Name of the class has to be "Main" only if the class is public. */
public class Main
 
 
{
    static Scanner in = new Scanner(System.in);
   
    public static void solve()
    {
        int n=in.nextInt();
        in.nextLine();
        String s=in.nextLine();
        
        if(s.length()<=n)
        {
            System.out.println(s);
        }
        else
        {
            System.out.println(s.substring(0,n)+"...");
        }
        
    }
    

    
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		
		int t=1;
		//in.nextLine();
		
		while(t>0)
		{
		    
		    solve();
		    t--;
		}
		
		
	
	//	System.out.println(x);
	}
}


Measured memory_bytes: 38640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int N; cin >> N;
    vel a(N); rep(i,N) cin >> a[i];
    vel l(N,0LL),r(N,0LL);

    rep(i,N-1) l[i+1] = __gcd(l[i], a[i]);
    for(int i = N-1; i>= 1; i--) r[i-1] = __gcd(r[i], a[i]);

    ll ans = 0;
    rep(i,N) ans = max(ans, __gcd(l[i], r[i]));

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



Measured memory_bytes: 2560
#include <stdio.h>

int n;
int a[100000];
int tmp;
int cnt=0;
int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d", &a[i]);
  }
  for(int i=0;i<n-1;i++){
    if(i+1==a[i]){
      cnt++;
      tmp=a[i];
      a[i]=a[i+1];
      a[i+1]=tmp;
    }
  }
  if(n==a[n-1]){
    cnt++;
  }
  printf("%d\n", cnt);
}


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

int main(){
	char x,a;
	while(1){
		scanf("%c",&x);
		if(islower(x)){
			a = toupper(x);
			cout << a;
		}else if(isupper(x)){
			a = tolower(x);
			cout << a;
		}else{
			cout << x;
	}
		if(x == '\n'){
			break;
		}
	}
	return 0;
}

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

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


void dfs(int x, int y) {
  island[x][y] = '0';
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i], ny = y + dy[i];
    if (0 <= nx && nx < 12 && 0 <= ny && ny < 12
	&& island[nx][ny] == '1') {
      dfs(nx, ny);
    }
  }
  return;
}

void solve() {
  int res = 0;
  for (int i = 0; i < 12; i++) {
    for (int j = 0; j < 12; j++) {
      if (island[i][j] == '1') {
	dfs(i, j);
	res++;
      }
    }
  }
  cout << res << endl;
}


int main(void) {
  while (cin >> island[0][0]) {
    for (int i = 0; i < 12; i++) {
      for (int j = 0; j < 12; j++) {
	if (i == 0 && j == 0) continue;
	cin >> island[i][j];
      }
    }
    solve();
  }

  return 0;
}

Measured memory_bytes: 1144
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

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

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  for(int i = 0; i < N; i++) cin >> A[i], A[i] -= (i + 1);
  sort(all(A));
  ll b = A[N / 2], ans = 0;
  for(int i = 0; i < N; i++) ans += abs(A[i] - b);
  cout << ans << endl;
  return 0;
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    vll snukes;

    vi digits(15);
    auto put = [&]() {
        ll v = 0;
        for (int i = 14; i >= 0; i--)
            v = 10 * v + digits[i];
        snukes.push_back(v);
    };

    for (int lead = 0; lead < 15; lead++) {
        fill(all(digits), 0);
        for (digits[lead] = 1; digits[lead] <= 9; digits[lead]++) {
            put();

            for (int second = lead - 1; second >= 0; second--) {
                for (int trail = 0; trail < second; trail++)
                    digits[trail] = 9;
                for (int between = second + 1; between < lead; between++)
                    digits[between] = 0;
                for (digits[second] = 0; digits[second] <= 9; digits[second]++)
                    put();
            }
        }
    }

    auto dsum = [](ll v) { ll tot = 0; while (v) { tot += v % 10; v /= 10; } return tot; };

    sort(all(snukes));
    snukes.erase(unique(all(snukes)), snukes.end());

    vll good = { snukes.back() };
    for (int i = snukes.size() - 2; i >= 0; i--) {
        if (snukes[i] * dsum(good.back()) <= good.back() * dsum(snukes[i]))
            good.push_back(snukes[i]);
    }
    reverse(all(good));

    ll K;
    cin >> K;
    for (int i = 0; i < K; i++)
        cout << good[i] << "\n";

    return 0;
}



Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	n, _ := strconv.Atoi(input())
	m, _ := strconv.Atoi(input())
	x := make([]int, m)
	for i := 0; i < m; i++ {
		x[i], _ = strconv.Atoi(input())
	}

	ans := 0
	if n < m {
		sort.Ints(x)
		diffList := make([]int, m-1)
		for i := 0; i < m-1; i++ {
			diffList[i] = x[i+1] - x[i]
		}
		sort.Sort(sort.Reverse(sort.IntSlice(diffList)))
		ans = x[m-1] - x[0]
		for i := 0; i < n-1; i++ {
			ans -= diffList[i]
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 2944
N, A, B, C, D = map(int,input().split())
S = list(input())
S = [0] + S
for i in range(A,C):
    if S[i] == S[i+1] == '#':
        print('No')
        exit()
for i in range(B,D):
    if S[i] == S[i+1] == '#':
        print('No')
        exit()
if C < D:
    print('Yes')
else:
    if S[B-1] == S[B+1] == '.':
        print('Yes')
        exit()
    else:
        count = 0
        for i in range(B,D):
            if S[i] == S[i+1] == S[i+2] == '.':
                print('Yes')
                exit()
    print('No')

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	string n;
	cin >> n;
	cout << (n[0] == '9' || n[1] == '9' ? "Yes" : "No") << endl;
	return 0;
}


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

const int maxn = 205;
int N;
int adj[maxn][maxn];

int color[maxn];

bool stop = false;
void fill(int i, int c) {
    if (stop) {
        return;
    }
    color[i] = c;
    for (int j = 0; j < N; j++) {
        if (adj[i][j]) {
            if (color[j] != -1 && (c&1) == (color[j]&1)) {
                stop = true;
                return;
            }
            else if (color[j] == -1) {
                fill(j,c+1);
            }
        }
    }
}

int main() {
    cin >> N;
    int m = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            char c; cin >> c;
            adj[i][j] = c-'0';
            if (adj[i][j] == 1) m++;
        }
    }
    //look for odd cycles
    //and fill in bipartite at the same time
    int res = 0;
    for (int j = 0; j < N; j++) {
        memset(color,-1,sizeof color);
        queue<int> q;
        q.push(j);
        color[j] = 0;
        while (!q.empty()) {
            int f = q.front(); q.pop();
            for (int k = 0; k < N; k++) {
                if (adj[f][k]) {
                    if (color[k] != -1 && (color[f]&1) == (color[k]&1)) {
                        cout << -1 << '\n';
                        exit(0);
                    }
                    else if (color[k] == -1) {
                        color[k] = color[f] + 1;
                        q.push(k);
                    }
                }
            }        
        }
        int ans = 0;
        for (int i = 0; i < N; i++) {
            ans = max(ans,color[i]);
        }
        /*
        cout << j << ": " << ans << '\n';
        for (int i = 0; i < N; i++) {
            cout << i << ":: " << color[i] << '\n';
        }
        */
        res = max(res,ans);
    }
    cout << (res+1) << '\n'; 
}


Measured memory_bytes: 384
// Undone
#include <bits/stdc++.h>
using namespace std;
int calc(string a) {
  string r = a;
  sort(r.begin(), r.end());
  string l = r;
  reverse(l.begin(), l.end());
  return (stoi(l) - stoi(r));
}

signed main() {
  int _a, L;
  while (cin >> _a >> L, _a+L) {
    vector<int> used(1000000, 0), when(1000000, 0);
    int ans = 0;
    while (0 == 0) {
      string a = to_string(_a);
      while (a.length() < L) {
        a.insert(0, "0");
      }
      _a = stoi(a);
      used[_a] = 1;
      when[_a] = ans;
      _a = calc(a);
      ans++;
      if (used[_a] == 1) {
        cout << when[_a] << " " << _a << " " << (ans-when[_a]) << endl;
        break;
      }
    }
  }
}




Measured memory_bytes: 10952
#include<bits/stdc++.h>
    using namespace std;
    #define PAIN___ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define ll long long int
    #define fi first
    #define se second
    #define pb push_back
    #define pii pair < ll, ll >
    #define mp make_pair
    #define vec vector < ll >
    #define vecp vector < pii  >
    #define forl(i,q1,n,q2) for(ll i=q1;i<q2;i++)
    #define null NULL
    #define mm 1000005



    vec v[mm];
    int main()
    {
        PAIN___;
        ll t;
        t=1;
        while(t--)
        {
            ll a[3];
            forl(i,0,n,3)cin>>a[i];
            sort(a,a+3);
            cout<<a[0]+a[1]<<endl;


    }
    }



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

int main() {
  long long a, b;
  cin >> a >> b;
  
  if (a%2 != b%2){
    cout << "IMPOSSIBLE" << endl;
  }else{
    cout << (a+b)/2 << endl;
  }
  
  return 0;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN=std::numeric_limits<int>::max(); 
#define ll long long

int main()
{
	ll n,w,i,j,k;
	cin>>n>>w;
	ll wc[n][2];
	ll dp[w+1];
	memset(dp,0,sizeof(dp));
	
	
	
	for(i=0;i<n;i++)
		for(j=0;j<2;j++)
			cin>>wc[i][j];
	
	for(i=0;i<n;i++)
	{
		for(j=w;j>=wc[i][0];--j)
			dp[j]=max(dp[j],dp[j-wc[i][0]]+wc[i][1]);
	}

	cout<<dp[w]<<endl;
	
}

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

int main(){
	int x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	vector<int> r(a);
	vector<int> g(b);
	vector<int> w(c);
	for(int i=0;i<a;i++){
		cin >> r.at(i);
	}
	for(int i=0;i<b;i++){
		cin >> g.at(i);
	}
	for(int i=0;i<c;i++){
		cin >> w.at(i);
	}
	sort(r.begin(),r.end());
	sort(g.begin(),g.end());
	sort(w.begin(),w.end());
	
	vector<int> n(x+y+c);
	for(int i=0;i<x;i++){
		n.at(i)=r.at(a-1-i);
	}
	for(int i=0;i<y;i++){
		n.at(x+i)=g.at(b-1-i);
	}
	for(int i=0;i<c;i++){
		n.at(x+y+i)=w.at(c-1-i);
	}
	sort(n.begin(),n.end());
	long long int ans=0;
	for(int i=0;i<x+y;i++){
		ans = ans + n.at(x+y+c-1-i);
	}
	cout << ans << endl;
}


Measured memory_bytes: 2560
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n, m;
	ll sum = 0, sum2 = 0;
	scanf("%d%d", &m, &n);
	int tmp, bef;
	scanf("%d", &bef);
	if (m == 2) {
		sum += (bef == 1);
		sum2 += (bef == 2);
	}
	rep(i, n - 1) {
		scanf("%d", &tmp);
		if(m != 2)sum += (bef == tmp);
		else {
			sum += (int)(tmp != (1 + (i % 2)));
			sum2 += (int)(tmp != (2 - (i % 2)));
		}
		if (bef != tmp)bef = tmp;
		else bef = INF;
	}
	if (m != 2)printf("%lld\n", sum);
	else printf("%lld\n", min(sum, sum2));

	Please AC;
}



Measured memory_bytes: 3216
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        string tmp = System.Console.ReadLine();
        int max_index = Convert.ToInt32(tmp);
        string line = System.Console.ReadLine();
        string[] ab = line.Split(' ');
        long[] a = new long[max_index];
        for(int i = 0; i < max_index; i++){
            a[i] = Convert.ToInt64(ab[i]);
        }
        long max_value = a.Max();
        long min_value = a.Min();
        long sum_value = a.Sum();
        Console.WriteLine("{0} {1} {2}",min_value,max_value,sum_value);
    }
}

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

int main (void) {
    int n;
    cin >> n;
    vector<int> x(n);
    int sum = 0;
    for (int i = 0; i < n; i ++ ) {
        cin >> x.at(i);
        sum += x.at(i);
    }
    
    int avg = sum / n;
    int32_t v_min = 0;
    for (int tmp = avg - 4; tmp < avg + 4; tmp++) {
        int32_t v = 0;
        for (auto X : x) {
            v += pow(X - tmp, 2);
        }
        if (tmp == avg - 4) {
            v_min = v;
        } else {
            v_min = min(v, v_min);
        }
    }
    
    cout << v_min << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define INF 10e7
using namespace std;

int cost[100][100];

int main(void){
	int n,m,s,g1,g2;
	while(cin >> n >> m >> s >> g1 >> g2,n|m|s|g1|g2){
		s--,g1--,g2--;
		for(int i=0;i<100;i++)
			for(int j=0;j<100;j++)
				cost[i][j]=(i==j)?0:INF;

		for(int i=0;i<m;i++){
			int b1,b2,c;
			cin >> b1 >> b2 >> c;
			b1--,b2--;
			cost[b1][b2]=c;
		}

		for(int k=0;k<n;k++)
			for(int i=0;i<n;i++)
				for(int j=0;j<n;j++)
					cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);

		int ans=INF;
		for(int i=0;i<n;i++)
			ans=min(ans,cost[s][i]+cost[i][g1]+cost[i][g2]);
		cout << ans << endl;
	}				
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define mp make_pair
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<30;
const ll LINF=1LL<<60;
const double eps=1e-5;
const ll MOD=1e9+7;
ll a[20][20];
int main(){
    int n;cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    vector<ll> s(1<<n),dp(1<<n);
    for(int i=0;i<(1<<n);i++){
        for(int j=0;j<n;j++){
            for(int k=j+1;k<n;k++){
                if((i&(1<<j))&&(i&(1<<k)))s[i]+=a[j][k];
            }
        }
    }
    for(int i=0;i<(1<<n);i++){
        int mask=(~i&((1<<n)-1));
        for(int j=0;;j=(j-mask)&mask){
            dp[i|j]=max(dp[i|j],dp[i]+s[j]);
            if(j==mask)break;
        }
    }
    cout<<dp[(1<<n)-1]<<endl;
}   


Measured memory_bytes: 1408
import bisect

# LIS
N = int(input())
L = list(map(int, input().split()))
L.sort()

# shorter first
# c > b >a
count = 0
for i in range(0, N-1):
  for j in range(i+1, N):
    index = bisect.bisect_left(L, L[i]+L[j])
    count += max(0, index-(j+1))
print(count)

Measured memory_bytes: 3188
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("avx,tune=native")

#include <bits/stdc++.h>

using namespace std;

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

template<typename T>
using pq_gt = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using pq_lt = priority_queue<T, vector<T>, less<T>>;

#define se second
#define fi first
#define pb push_back

vector<int> seq[2];
int sum1,sum2;
int dp[16000];

bool check(int idx, int k) {
	for(int i = 0; i <=k; ++i) {
		dp[i] = 0;
	}
	dp[0] = 1;
	for(int j:seq[idx]) {
		for(int i = k; i>=j; --i) {
			if(dp[i-j]) {
				dp[i]=1;
			}
		}
	}
	return dp[k]==1;
}

int main() {
    ios::sync_with_stdio(false);
    string str;
    cin>>str;
    int a,b;
    cin>>a>>b;
    int cnt = 0, parity = 0;
    int i = 0;
    while(i<str.size() && str[i]=='F') {
    	i++;
    	cnt++;
    }
    int diff1 = abs(cnt-a);
    cnt = 0;
    for( ; i < str.size(); ++i) {
    	if(str[i]=='T') {
    		if(cnt!=0) {
    			seq[parity].pb(cnt);
    			cnt = 0;
    		}
    		parity = 1 - parity;
    	} else {
    		cnt++;
    	}
    }
    if(cnt) {
    	seq[parity].pb(cnt);
    }
    for(int i:seq[0]) {
    	sum1+=i;
    }
    diff1 = sum1-diff1;
    if(diff1%2 || diff1<0) {
    	cout<<"No\n";
    	return 0;
    }
    diff1/=2;
    if(!check(0, diff1)) {
    	cout<<"No\n";
    	return 0;
    }
    for(int i:seq[1]) {
    	sum2+=i;
    }
    int diff2 = sum2-abs(b);
    if(diff2%2 || diff2<0) {
    	cout<<"No\n";
    	return 0;
    }
    diff2/=2;
    if(!check(1,diff2)) {
    	cout<<"No\n";
    	return 0;
    }
    cout<<"Yes\n";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int  N,A[100000],ans = -1;
	bool B[100000];

	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> A[i];
		A[i]--;
	}

	for (int i = 0; i < N; i++)
		B[i] = false;

	for (int i = 0,k = 0; i < N; i++) {
		if (B[k] == true)break;
		B[k] = true;		
		k = A[k];
		if (k == 1) {
			ans = i+1;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

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

vector<pair<int, int>> graph[100005];
vector<pair<pair<int, int>, int>> edges;

int n, m;
int s, t;
long long dist1[100005];
long long cnt1[100005];
long long dist2[100005];
long long cnt2[100005];

const long long mod = 1000000007;

void fill(int from, long long* dist, long long* cnt) {
  priority_queue<pair<long long, int>> pq;
  pq.push({0, from});
  while (!pq.empty()) {
    auto top = pq.top();
    pq.pop();
    long long d = -top.first;
    int x = top.second;
    if (dist[x] == -1) {
      dist[x] = d;
    } else {
      continue;
    }
    for (auto nxt : graph[x]) {
      int y = nxt.first;
      int dd = nxt.second;
      if (dist[y] == -1) {
        pq.push({-d-dd, y});
      }
    }
  }
  cnt[from] = 1;
  for (int ni = 1; ni <= n; ni++) {
    pq.push({-dist[ni], ni});
  }
  while (!pq.empty()) {
    auto top = pq.top();
    pq.pop();
    long long d = -top.first;
    int x = top.second;
    for (auto nxt : graph[x]) {
      int y = nxt.first;
      int dd = nxt.second;
      if (dist[y] == dist[x] + dd) {
        cnt[y] += cnt[x];
        cnt[y] %= mod;
      }
    }
  }
}

int main() {
  cin >> n >> m;
  cin >> s >> t;
  for (int mi = 0; mi < m; mi++) {
    int u, v, d;
    cin >> u >> v >> d;
    graph[u].push_back({v, d});
    graph[v].push_back({u, d});
    edges.push_back({{u, v}, d});
  }
  memset(dist1, -1, sizeof(dist1));
  memset(dist2, -1, sizeof(dist2));
  fill(s, dist1, cnt1);
  fill(t, dist2, cnt2);
  long long sdist = dist1[t];
  long long ans = cnt1[t] * cnt1[t] % mod;
  for (int ni = 1; ni <= n; ni++) {
    if (dist1[ni] * 2 == sdist && dist2[ni] * 2 == sdist) {
      ans += mod - cnt1[ni] * cnt1[ni] % mod * cnt2[ni] % mod * cnt2[ni] % mod;
      ans %= mod;
    }
  }
  for (int mi = 0; mi < m; mi++) {
    int u = edges[mi].first.first;
    int v = edges[mi].first.second;
    int d = edges[mi].second;
    if (dist1[u] * 2 < sdist && dist2[v] * 2 < sdist && dist1[u] + dist2[v] + d == sdist) {
      ans += mod - cnt1[u] * cnt1[u] % mod * cnt2[v] % mod * cnt2[v] % mod;
      ans %= mod;
    } else if (dist1[v] * 2 < sdist && dist2[u] * 2 < sdist && dist1[v] + dist2[u] + d == sdist) {
      ans += mod - cnt1[v] * cnt1[v] % mod * cnt2[u] % mod * cnt2[u] % mod;
      ans %= mod;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 18580
#include <bits/stdc++.h>
using  namespace std;
int main(){
    long long n, m, a, ans, check;
  	bool flag = false;
    long long temp = pow(10, 9) + 7;
    cin >> n >> m;
    long long A[n+1];
    for(int i=0;i<n+1;i++){
        A[i] = 1;
    }
    for(int i=0;i<m;i++){
        cin >> a;
        A[a] = -1;
    }
    for(int i=2;i<n+1;i++){
        if(A[i]!=-1){
          	check = 0;
            if(A[i-1]==-1 && A[i-2]==-1){
                flag = true;
                break;
            }
            if(A[i-1]!=-1){
                check += A[i-1];
            }
            if(A[i-2]!=-1){
                check += A[i-2];
            }
          	A[i] = check%temp;
        }
    }
  	if(flag){
      ans=0;
    }else{
      ans=A[n];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
fun main(args : Array<String>) {
    val b = (0 until readLine()!!.toInt()).map { readLine()!! }
    val r = (0 until readLine()!!.toInt()).map { readLine()!! }
    val a = b.toSet().map { str -> b.count{it==str} - r.count{it==str} } + 0
    println(a.max())
}


Measured memory_bytes: 33640
from heapq import heappush, heappop

N = int(input())
xs = []
for i in range(N):
  a, b = map(int, input().split())
  heappush(xs, (-a-b,a,b))

y = 0
for i in range(N):
  x,a,b = heappop(xs)
  if i % 2 == 0:
  	y += a
  else:
    y -= b

print(y)

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

class in{
public:
  long long s, n;
  bool operator<(const in& another) const{
    return s > another.s;
  }
};

void solve(){
  int n; cin >> n;
  vector<in> a(n + 1);
  for(int i = 0; i < n; i++){
    cin >> a[i + 1].s;
    a[i + 1].n = i + 1;
  }
  sort(a.begin() + 1, a.end());
  //for(int i = 1; i <= n; i++) cout << a[i].s << " " << a[i].n << endl;
  vector<vector<long long> > dp(n + 1, vector<long long>(n + 1));
  dp[0][0] = 0;
  for(int i = 1; i <= n; i++){
    dp[i][0] = dp[i - 1][0] + a[i].s * abs(n - i + 1 - a[i].n);
    for(int l = 1; l < i; l++){
      long long right = dp[i - 1][l] + a[i].s * abs(n - (i - l) + 1 - a[i].n);
      long long left = dp[i - 1][l - 1] + a[i].s * abs(a[i].n - l);
      dp[i][l] = max(right, left);
    }
    dp[i][i] = dp[i - 1][i - 1] + a[i].s * abs(a[i].n - i);
    /*for(int l = 0; l <= i; l++){
      cout << "dp[" << i << "][" << l << "] = " << dp[i][l] << endl;
    }*/
  }
  long long ans = 0;
  for(int i = 1; i <= n; i++){
    for(int l = 0; l <= i; l++){
      ans = max(dp[i][l], ans);
    }
  }
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 34620
import java.util.Scanner;

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

        int roopTimes = Integer.parseInt(sc.nextLine());
        int customerSum = 0;
        for (int i = 0; i < roopTimes; i++){
            int startCustomer = sc.nextInt();
            int endCustomer = sc.nextInt();
                    //Integer.parseInt(sc.nextLine());  //改行文字が残らないように
            customerSum += (endCustomer-startCustomer) + 1;
        }
        System.out.println(customerSum);
    }
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	long N, x;
	cin >>N >>x;
	vector<long> a(N, 0);
	long S=0;
	for (long i=0; i<N; i++) {
		cin >>a.at(i);
		S +=a.at(i);
	}
	if (S==x) {
		cout <<N <<endl;
		return 0;
	} else if (S<x) {
		cout <<N-1 <<endl;
		return 0;
	}
	sort(a.begin(), a.end());
	while (S>x) {
		S -=a.at(N-1);
		N--;
	}
	cout <<N <<endl;
	return 0;
}



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

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef map<string, int> m;
typedef vector<int> vi;
typedef vector<string> vs;

const ll MAX_H = 1e3, MAX_W = 1e3, MAX_P = 1e6, mod = 998244353, INF = 1e7;
//qsort
int asc(const void* a, const void* b) {
	return *(int*)a - *(int*)b;
}
//変数置き場
int H, W, N;
char maze[MAX_H][MAX_W + 1];
int sx, sy;
int hp = 1;
int res = 0;
int d[MAX_H][MAX_W];

int dx[4] = { 0,1,0,-1 }; int dy[4] = { 1,0,-1,0 };
void bfs() {
	if (hp > N) return;
	rep(i, H) {
		rep(j, W) d[j][i] = INF;
	}
	queue<P> q;
	q.push(P(sx, sy)); d[sx][sy] = 0;

	while (!q.empty()) {
		P p = q.front(); q.pop();

		rep(i, 4) {
			int nx = p.first + dx[i], ny = p.second + dy[i];

			if (nx >= 0 && nx < W && ny >= 0 && ny < H && maze[nx][ny] != 'X'&& d[nx][ny]==INF) {
				d[nx][ny] = d[p.first][p.second] + 1;
				if (maze[nx][ny] == '0' + hp) {
					res += d[nx][ny];
					sx = nx; sy = ny;
					hp++;
					bfs();
					break;
				}
				q.push(P(nx, ny));
			}
		}
	}
	return;
}

int main() {
	//入力
	cin >> H >> W >> N;
	rep(i, H) {
		rep(j, W) {
			cin >> maze[j][i];
			if (maze[j][i] == 'S') {
				sx = j;
				sy = i;
			}
		}
	}
	bfs();
	cout << res << endl;

	return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  for (int i = 0; i < n / 2; i++) {
    if (s[i] != s[n - 1 -  i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

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

  int64_t sum = 0,
          lastOne = -1;
  for (int i = 0; i < n; i++) {
    int64_t a, b;
    cin >> a >> b;

    sum += a;
    if (a > b and (lastOne < 0 or lastOne > b)) {
      lastOne = b;
    }
  }

  if (lastOne < 0) {
    cout << 0 << endl;
    return 0;
  }

  cout << sum - lastOne << endl;

  return 0;
}

Measured memory_bytes: 384
a,b,c,d,e,f = map(int,input().split())
maxm = 100*a
maxs = 0
water = set()
suger = set()
for i in range(31):
    for j in range(31):
        if i*a*100 + j*b*100 <= f and i*a*100 + j*b*100 > 0:
            water.add(i*a*100+j*b*100)
for i in range(f+1):
    for j in range(f+1):
        suger.add(c*i+d*j)
for i in water:
    for j in suger:
        if i*e//100 >= j and i+j <= f:
            tmpm = i + j
            tmps = j
            if tmps*maxm > maxs*tmpm:
                maxm = tmpm
                maxs = tmps
print(maxm,maxs)

Measured memory_bytes: 47064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n,m,l;
    cin>>n>>m>>l;
    if(n+m+l>=22){
        cout<<"bust"<<endl;
    }
    else{
        cout<<"win"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin >> N;
    int count = 0;
    for(int i = 1;i <= N;i++){
        if(i % 2 == 1){
            count++;
        }
    }
    cout << (double)count / N << endl;
}

Measured memory_bytes: 3176
import java.util.*;


public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String[] data = sc.nextLine().split(" ");

    int a = Integer.parseInt(data[0]);
    int b = Integer.parseInt(data[1]);
    int c = Integer.parseInt(data[2]);

    if (a+b+c >= 22) {
        System.out.println("bust");
    }else{
        System.out.println("win");
    }
  }
}

Measured memory_bytes: 21716
from collections import Counter
import copy
from itertools import combinations


def A(x):
  return 'Yes' if x >= 30 else 'No'


def B(N, D, X, Y):
  ans = 0
  for i in range(N):
    Di = X[i]**2 + Y[i]**2
    if Di <= D**2:
      ans += 1
  return ans


def main():
  N, D = map(int, input().split())
  X = []
  Y = []
  for i in range(N):
    Xi, Yi = map(int, input().split())
    X.append(Xi)
    Y.append(Yi)
  print(B(N, D, X, Y))


if __name__ == '__main__':
  main()


Measured memory_bytes: 25392
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
//#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  string s;cin>>s;
  int n=(int)s.length();
  bool flag=true;
  if(s[0]!='A')flag=false;
  int cnt=0;
  for(int i=2;i<=n-2;i++){
    if(s[i]=='C')cnt++;
  }
  if(cnt!=1)flag=false;
  int buf=0;
  rep(i,n){
    if(s[i]<='Z'&&s[i]>='A')buf++;
  }
  if(buf!=2)flag=false;
  if(flag){
    cout<<"AC"<<endl;
  }
  else
  {
    cout<<"WA"<<endl;
  }
  
  return 0;
}


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

int main() {
  int H,W; 
  cin >> H >> W;
  
  // 上辺
  for(int i = 0; i < W+2; i++){
    cout << "#";
  }
  cout << endl;
  
  // 囲う部分
  string str;
  for(int i = 0; i < H; i++){
    cin >> str;
    cout << "#" << str << "#"<< endl;
  }
  
  //　底辺
  for(int i = 0; i < W+2; i++){
    cout << "#";
  }
  
  
  
}


Measured memory_bytes: 256
from collections import deque
# dequeは両端へのアクセスが早い　O(1)

N = int(input())
#辺の集合を隣接リストとして入力
E = [[] for i in range(N+1)] #２次元配列 N個の箱を用意する 
edge_order = []
for i in range(N-1):
    a, b = map(int, input().split())
    E[a].append(b) #　頂点をindexとする箱
    edge_order.append(b) # 辺の数をカウント、idとしてそれらも確保
#print(E)

#頂点１から幅優先探索
queue = deque([1])
color = [0] * (N+1)
while queue:
    V = queue.popleft()
    c = 1
    for i in E[V]:
        if c == color[V]:
            c += 1
        color[i] = c
        c += 1
        queue.append(i)

print(max(color))
for i in edge_order:
    print(color[i])

Measured memory_bytes: 18676
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			String s = in.next();
			String t = in.next();
			List<Character> sc = new ArrayList<>();
			List<Character> tc = new ArrayList<>();
			for(int i = 0; i < s.length(); i++) {
				sc.add(s.charAt(i));
			}
			for(int i = 0; i < t.length(); i++) {
				tc.add(t.charAt(i));
			}
			
			Collections.sort(sc);
			Collections.sort(tc, Comparator.reverseOrder());
			
			String s_ = "";
			String t_ = "";
			
			for(int i = 0; i < s.length(); i++) {
				s_ += sc.get(i);
			}
			for(int i = 0; i < t.length(); i++) {
				t_ += tc.get(i);
			}
			if(s_.compareTo(t_) < 0) {
				out.println("Yes");
			}else {
				out.println("No");
			}
		}
	}
	
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

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

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}


Measured memory_bytes: 21460
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin>>n;
  string s;
  cin>>s;
  int cntr = 0;
  for(auto&&c:s) {
    if (c == 'R') ++cntr;
  }
  int cntw = 0;
  int mn = cntr;
  for(auto&&c:s) {
    if (c == 'R') --cntr;
    else ++cntw;
    mn = min(mn, max(cntr, cntw));
  }
  cout<<mn<<endl;
  return 0;
}


Measured memory_bytes: 3764
main :: IO ()
main = do
  [a, b] <- map read . words <$> getLine :: IO [Int]
  if a `mod` 3 == 0 ||
     b `mod` 3 == 0 ||
     (a + b) `mod` 3 == 0
    then putStrLn "Possible"
    else putStrLn "Impossible"


Measured memory_bytes: 508
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <random>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int lli;
typedef pair<int,int> pii;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

inline bool CompareByB(const pii x,const pii &y){
	return x.second>y.second;
}

class SegmentTree{
	private:
	int size;
	public:
	vector<int> data1;
	vector<int> data2;
	void Init(int n){
		size=1;
		while(size<n) size*=2;
		data1=vector<int>(size*2,0);
		data2=vector<int>(size*2,0);
	}
	void Update(int k,int val){
		k+=size-1;
		data1[k]=val;
		data2[k]=k-size+1;
		while(k>0){
			k=(k-1)/2;
			if(data1[2*k+1]>data1[2*k+2]){
				data1[k]=data1[k*2+1];
				data2[k]=data2[k*2+1];
			}else{
				data1[k]=data1[k*2+2];
				data2[k]=data2[k*2+2];
			}
		}
	}
	int GetMaxVal(){
		return data1[0];
	}
	int GetMaxId(){
		return data2[0];
	}
};

int N;

bool Check(int x,vector<pii> &seq){
	SegmentTree tree;
	tree.Init(x);
	lli sum=0;
	REP(i,0,x-1){
		sum+=seq[i].first;
		tree.Update(i,seq[i].first);
	}
	REP(i,x-1,N){
		if(i==x-1){
			sum+=seq[i].first;
			tree.Update(i,seq[i].first);
		}else{
			if(tree.GetMaxVal()>seq[i].first){
				sum-=tree.GetMaxVal()-seq[i].first;
				tree.Update(tree.GetMaxId(),seq[i].first);
			}
		}
		if(sum<=(lli)seq[i].second*x) return true;
	}
	return false;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> N;
	vector<pii> seq(N);
	REP(i,0,N){
		int a,b;
		cin >> a >> b;
		seq[i]=MP(a,b); //放出量A,許容量B
	}
	sort(seq.begin(),seq.end(),CompareByB);
	int lb=0,ub=N;
	while(true){
		if(ub-lb==1){
			if(Check(ub,seq)) lb=ub;
			break;
		}
		int mid=(lb+ub)/2;
		if(Check(mid,seq)) lb=mid;
		else ub=mid;
	}
	cout << lb << endl;
	return 0;
}

Measured memory_bytes: 11656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 500 + 50;
ll n;
int main(){ 
	while(cin >> n){
	ll a,b,c;
	if(n == 2) a = 1, b = c = 2;
	if(n == 3) a = 2, b = 2, c = 3;
	if(n == 4) a = b = c = 3;
	if(n > 4){
		if(n & 1){
			for(a = 2; a <= 3500; a++)
				for(b = 2; b <= 3500; b++){
					ll up = n * a * b;
					ll down = 4*a*b-n*b-n*a;
					if(down <= 0) continue;
					if(up%down == 0){
						cout << a << " " << b << " " << up/down;
						return 0;
					}
				
				}
		}
		else{
			a = b = n;
			c = n / 2;
		}
	}
	cout << a << " " << b << " " << c;
	}
    return 0;
}


Measured memory_bytes: 256