akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

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

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

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



int n, x;
string s;

signed main() {
	cin >> s;
	n = s.size();
	rep(i,n) if ((i%2==0 && s[i]=='0') || (i%2 && s[i]=='1')) x++;
	cout << min(x, n-x) << endl;
}

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

int main() {
    string s;
    cin>>s;
    int la=-1,rz=-1;
    rep(i,s.size()){
        if(la==-1 && s[i]=='A') la=i;
        if(s[i]=='Z') rz=i;
    }
    cout<<rz-la+1<<endl;
    return 0;
}

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

using namespace std;

class Book{
public:
  string title,author;
  int date;
};

int getDate(string &s){
  for(int i = 0 ; i < (int)s.size() ; i++){
    if(s[i] == '/'){
      s[i] = ' ';
    }
  }
  int y,m,d;
  stringstream ss(s);
  ss >> y; ss >> m; ss >> d;
  return y*10000 + m*100 + d;
}

int main(){
  int N;
  string str;
  bool blank = false;
  cin >> N;
  vector<Book> books(N);
  for(int i = 0 ; i < N ; i++){
    cin >> books[i].title >> books[i].author >> str;
    books[i].date = getDate(str);
  }
  int Q;
  cin >> Q;
  while(Q--){
    if(blank){ cout << endl; }
    blank = true;
    string s[4];
    int S = 0;
    for(int i = 0 ; i < 4 ; i++){
      cin >> s[i];
      if(s[i] == "*"){
        S |= (1<<i);
      }
    }
    vector<string> res;
    for(int i = 0 ; i < N ; i++){
      bool ok = true;
      for(int j = 0 ; j < 4 ; j++){
        if(S >> j & 1){ continue; }
        if(j == 0){
          if(books[i].title.find(s[j]) == string::npos){
            ok = false;
          }
        }else if(j == 1){
          if(books[i].author.find(s[j]) == string::npos){
            ok = false;
          }
        }else if(j == 2){
          int date = getDate(s[j]);
          if(date > books[i].date){
            ok = false;
          }
        }else{
          int date = getDate(s[j]);
          if(books[i].date > date){
            ok = false;
          }
        }
      }
      if(ok){
        res.push_back(books[i].title);
      }
    }
    for(auto x : res){
      cout << x << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1252
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
const int inf = 1e+9;
struct Graph{
  vector<vector<int>> edge;
  int node;
  vector<bool> f;
  vector<bool> col;
  vector<int> label;
  int mc;
  
  Graph(int _node){
    node = _node;
    edge.resize(node);
    f.assign(node,0);
    col.resize(node);
    label.resize(node);
    mc = 0;
  }

  void add(int from,int to){
    edge[from].push_back(to);
  }
  
  bool bipa_check(int x,bool c){
    f[x] = true;
    col[x] = c;
    int vs = edge[x].size();
    rep(i,vs){
      int w = edge[x][i];
      if(f[w]){
	if(col[w] == c) return false;	      
      }
      else if(!bipa_check(w,!c)) return false;
    }
    return true;
  }

  int bfs(int x){
    queue<int> q;
    label[x] = 1;
    q.push(x);
    int res = 1;
    while(!q.empty()){
      int x = q.front();
      q.pop();
      for(auto &w:edge[x]){
	if(label[w]!=-1) continue;

	label[w] = label[x] +1;
	res = max(res,label[w]);
	q.push(w);
      }
    }
    return res;
    
    
  }




  int dfs(int x,int c){
    f[x] = true;
    label[x] = c;
    cout << c << "\n";
    int vs = edge[x].size();
    rep(i,vs){
      int w = edge[x][i];
      if(f[w]){
	if(label[w]%2 == c%2) return inf;	      
      }
      else if(dfs(w,c+1)==inf) return inf;
    }
    return  mc = max(c,mc);
  }

  void reset(){
    label.assign(node,-1);
    f.assign(node,0);
    mc = 0;
  }

  void check(){
    rep(i,node) cout << i << ":" << label[i] << "\n";

  }
};
int main()
{
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n)  cin >> s[i];

  Graph gp(n);

  rep(i,n) rep(j,n){
    if(s[i][j]=='1') gp.add(i,j);
  }

  int res = 0;
  if(!gp.bipa_check(0,1)){
    cout << -1 << "\n";
  }
  else{
    rep(i,n){
      gp.reset();
      //   cout << i << "******\n";
      res = max(res,gp.bfs(i));
      //      gp.check();
    }
    cout << res << "\n";
  }
  return 0;
}


Measured memory_bytes: 512
import java.io.*;
import java.util.*;

public class Main {
    static long ret = 0;
    public static long[] count(int[] a, int l, int r, boolean isLeft) {
        if (r == l + 1) {
            if (a[l] >= 0) ret++;
            return new long[]{a[l]};
        }
        int mid = (r + l) >> 1;
        long[] left = count(a, l, mid, true);
        long[] right = count(a, mid, r, false);
        for (long v: left) {
            int lo = 0, hi = right.length;
            while (lo < hi) {
                int m = (lo + hi) / 2;
                if (right[m] + v >= 0) {
                    hi = m;
                } else {
                    lo = m + 1;
                }
            }
            ret += right.length - lo;
        }
        long[] ret = new long[r - l];
        long prev = 0;
        if (isLeft) {
            for (int i = 0; i < r - l; i++) {
                ret[i] = prev + a[r - 1 - i];
                prev = ret[i];
            }
        } else {
            for (int i = 0; i < r - l; i++) {
                ret[i] = prev + a[l + i];
                prev = ret[i];
            }
        }
        Arrays.sort(ret);
        return ret;
    }

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int k = sc.nextInt();
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt() - k;
        }
        count(a, 0, n, true);
        System.out.println(ret);
    }

    public static class Scanner {
        StringTokenizer st;
        BufferedReader br;
        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }
        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
            return st.nextToken();
        }
        public int nextInt() throws IOException{
            return Integer.parseInt(next());
        }
    }
}

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

int main(){
  int a, b, c;
  cin >> a >> b;
  c = a * b % 2;
  if(c == 0) cout << "Even" << endl;
  else if(c == 1) cout << "Odd" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ld = long double;
const ld PI = 3.14159265358979;
ld a, b, x;

bool check(ld ang) {
	ang = ang * PI / 180.0;
	ld s = b / tan(ang);

	ld area = b * s / 2.0;
	if (s > a) {
		ld sf = (s - a) / s;
		area -= area * sf * sf;
	}

	return area * a >= x;
}

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

	cin >> a >> b >> x;

	ld l = 0;
	ld r = 90;

	ld ans = 0;
	for (int i = 0; i < 400; i++) {
		ld m = (l + r) / 2;
		if (check(m)) {
			ans = m;
			l = m;
		}
		else {
			r = m;
		}
	}

	cout << fixed << setprecision(10);
	cout << ans << '\n';
}


Measured memory_bytes: 4132
#include<iostream>
using namespace std;
int factorial(int n,int lim)
{
  int res = 1;
  while(lim--)
  {
    res*=n;
    n--;
  }
  return res;
}
int main()
{
  int N,M;
  int a=0,b=0;
  scanf("%d %d",&N,&M);
  if(N>1)
    a=factorial(N,2)>>1;
  if(M>1)
    b=factorial(M,2)>>1;
  printf("%d\n",a+b);
  return 0;
}

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

using namespace std;

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

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

    int a, b;
    cin >> a >> b;
    int sockets = 1;
    int ans = 0;
    while (sockets < b) {
        sockets += a - 1;
        ++ans;
    }

    cout << ans << '\n';
    
    return 0;
}



Measured memory_bytes: 256
n = int(input())
s1 = input()
s2 = input()
mod = 10**9 + 7
ans = -1
for i, c in enumerate(s1):
    if i==0:
        if s1[i]==s2[i]:
            ans = 3
        else:
            ans = 6
    else:
        if s1[i-1]==s1[i] and s2[i-1]==s2[i]:
            continue
        elif s1[i-1]==s2[i-1] and s1[i]==s2[i]:
            ans *= 2
        elif s1[i-1]==s2[i-1] and s1[i]!=s2[i]:
            ans *= 2
        elif s1[i-1]!=s2[i-1] and s1[i]==s2[i]:
            ans *= 1
        else:
            ans *= 3
        ans %= mod
print(ans%mod)

Measured memory_bytes: 3064
import java.util.*

fun main() {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val a = sc.next().toLong()
        val b = sc.next().toLong()
        val c = sc.next().toLong()
        val d = sc.next().toLong()
        pw.println(arrayOf(a * c, b * c, a * d, b * d).max()!!)
    }
}


Measured memory_bytes: 40368
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=998244353;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	int n;cin>>n;
	ll l[100010],r[100010];
	for(int i=0;i<n;i++){
		cin>>l[i]>>r[i];
	}
	sort(l,l+n,greater<ll>());
	sort(r,r+n);
	ll s=0,ans=0;
	for(int i=0;i<n;i++){
		s+=l[i];
		ans=max(s,ans);
		s-=r[i];
		ans=max(s,ans);
	}
	s=0;
	for(int i=0;i<n;i++){
		s-=r[i];
		ans=max(s,ans);
		s+=l[i];
		ans=max(s,ans);
	}
	cout<<ans*2<<endl;
	return 0;
}


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

bool inte(double a){
	double c = floor(a)-a;
	if(c==0){
		return true;
	}
	else {
	return false;
	}
}

double dist(int d,vector<int> x,vector<int> y){
	double sum=0;
	for(int i=0;i<d;i++){
		sum =sum +pow((x.at(i)-y.at(i)),2);
	}
	
	sum = pow(sum,0.5);
	return sum;
}

	
	

int main() {
	int N,d;
	cin >> N>> d;
	vector<vector<int>> coo (N,vector<int>(d));
	
	for(int i=0;i<N;i++){
		for(int k=0;k<d;k++){
			cin >> coo.at(i).at(k);
		}
	}
	
	int count=0;
	
	for (int i=0;i<N-1;i++){
		for(int k=i+1;k<N;k++){
			if(inte(dist(d,coo.at(i),coo.at(k)))){
				count ++;
			}
		}
	}
	
	cout <<count<<endl;

}



Measured memory_bytes: 1020
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int N,d[100000];
	cin>>N;
	for(int i=0;i<N;i++)cin>>d[i];
	sort(d,d+N);
	if(N%2)cout<<"0";
	else cout<<d[N/2]-d[N/2-1];
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
using namespace std ;
int n, w;
std::vector<pair<int,ll>> inp;
vector<vector<ll>> dp;

ll knapsack(int i=0,int curr_wt = w)
{
    if(i == n) return 0;
    if(dp[i][curr_wt] == -1)
    {
        ll ans = knapsack(i+1,curr_wt);
        if(curr_wt - inp[i].first >=0)
        {
            ans = max (ans , knapsack(i+1,curr_wt - inp[i].first) + inp[i].second);
        }
        dp[i][curr_wt] = ans;
        return ans;
    }
    else return dp[i][curr_wt];
}

int main()
{
    cin>>n>>w; 
    inp.resize(n);
    
    for(int i=0;i<n;i++)
    {
        cin>>inp[i].first;
        cin>>inp[i].second;
    }
    dp.assign(n+1,vector<ll> (w+1,-1));
    cout<<knapsack()<<endl;
}

Measured memory_bytes: 83192
#include<bits/stdc++.h>
using namespace std;
long long mod=1e9+7;
map<long long,long long> mp;
long long f(long long k)
{
    if (mp[k]) return mp[k];
    if (k==0) return mp[k]=1;
    if (k==1) return mp[k]=2;
    if (k%2==0) return mp[k]=(2*f(k/2-1)+f(k/2))%mod;
    return mp[k]=(f(k/2-1)+2*f(k/2))%mod;
}
int main()
{
     long long n;
     cin>>n;
     cout<<f(n)<<endl;
     return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;

class Main {
	final static long MOD = 1000000007;
	public static void main(String args[]) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int l = s.length();
		if(isPal(s,0,l-1) && isPal(s, 0, (l-3)/2) && isPal(s, (l+1)/2, l-1))
			System.out.println("Yes");
		else
			System.out.println("No");
	}

	static boolean isPal(String n, int l, int u) {
		while(l<u) {
			if(n.charAt(l)!=n.charAt(u))
				return false;
			l++;
			u--;
		}
		return true;
	}

	static int nextInt()throws IOException{
		InputStream in = System.in;
		int ans=0;
		boolean flag=true;
		byte b=0;
		boolean neg=false;
		while ((b>47 && b<58) || flag){
			if(b==45)
				neg=true;
			if(b>=48 && b<58){
				ans=ans*10+(b-48);
				flag=false;
			}
			b=(byte)in.read();
		}
		if(neg)
			return -ans;
		return ans;
	}

	static long nextLong()throws IOException{
		InputStream in=System.in;
		long ans=0;
		boolean flag=true;
		byte b=0;
		while ((b>47 && b<58) || flag){
			if(b>=48 && b<58){
				ans=ans*10+(b-48);
				flag=false;
			}
			b=(byte)in.read();
		}
		return ans;
	}
	static String next()throws Exception{
		StringBuilder sb=new StringBuilder(1<<16);
		InputStream in=System.in;
		byte b=0;
		do{
			if(!isWhiteSpace(b))
				sb.append((char)b);
			b=(byte)in.read();
		}while(!isWhiteSpace(b) || sb.length()==0);
		return sb.toString();
	}
	static boolean isWhiteSpace(byte b){
		char ch=(char)b;
		return ch=='\0' || ch==' ' || ch=='\n';
	}
}

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

const int maxn = 2010;

int n, m, mx, ans, cnt, cur;
std::vector<int> g[maxn];

void dfs(int u, int par, int dist) {
	if(dist * 2 <= m) {
		++cur;
	}
	else {
		++cnt;
		return;
	}
	for (int v: g[u]) {
		if(v != par) {
			dfs(v, u, dist + 1);
		}
	}
	return;
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i < n; ++i) {
		int u, v;
		scanf("%d%d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for (int u = 1; u <= n; ++u) {
		mx = cur = 0;
		for (int v: g[u]) {
			cnt = 0;
			dfs(v, u, 1);
			if(m & 1) {
				mx = std::max(mx ,cnt);
			}
		}
		ans = std::max(ans, cur + mx);
	}
	printf("%d\n", n - ans - 1);
	return 0;
}

Measured memory_bytes: 384
import math
A,B,H,M = map(int, input().split())
a = H*60 + M
b = M*12
c = min(abs(a-b), 60*12-abs(a-b))
ans = math.sqrt(A*A+B*B-2*A*B*math.cos(c*2*math.pi/(60*12)))
print(ans)

Measured memory_bytes: 9508
x = int(input())
if x<=599 and x>=400:
  print(8)
elif x<=799 and x>=600:
  print(7)
elif x<=999 and x>= 800:
  print(6)
elif x<=1199 and x>= 1000:
  print(5)
elif x<=1399 and x>= 1200:
  print(4)  
elif x<=1599 and x>= 1400:
  print(3)
elif x<=1799 and x>= 1600:
  print(2)
elif x<=1999 and x>= 1800:
  print(1)

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

int main() {
  string s;
  cin >> s;
  vector<int> cnt(3, 0), ans(3, 1);
  for (int i = 0; i < 3; i++) cnt[s[i]-'a']++;
  if (cnt == ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll mod=1e9+7;
int main()
{
    ll a,b,c;
    ll l;
    ll n;

    ll i,j,k;
    ll mn=0;
    cin>>n;
    vector<ll>v;
    ll cnt=0;
    ll cum[n+10]= {0};
    for(j=0; j<n; j++)
    {
        cin>>a;
        v.push_back(a);
        if(!j)
            cum[j]=a;
        else
            cum[j]=cum[j-1]+a;
    }
    for(j=1; j<n; j++)
    {
        a=cum[j-1]%mod;
        b=v[j]%mod;
        cnt+=(a*b)%mod;
        cnt%=mod;

    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 6900
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	if a == b && b == c && a == c {
		fmt.Println(1)
	} else if a != b && b != c && a != c {
		fmt.Println(3)
	} else {
		fmt.Println(2)
	}
}

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

int N;
int A[20];
int x[20][20];
int y[20][20];

int counter(int x) {   //1の数を数える関数
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1); 
}

void solve() { //出力するだけで返り値がないので、void
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> A[i];
        for(int j = 1; j <= A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }  //ここまで入力
    int ans = 0;
    for(int bits = 1; bits < (1 << N); bits++) {  //全パターン
        bool ok = true;  //フラグ
        for(int i = 1; i <= N; i++) {   //そのパターンでの各自の真偽をチェック
            if(!(bits & (1 << (i-1)))) continue;   //不親切ならskip
            for(int j = 1; j <= A[i]; j++) {       //正直なら、発言をそれぞれチェック
                if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
            }   //今回のパターンと発言が不一致かどうかを、XORで判断
        }
        if(ok) ans = max(ans, counter(bits));
    }
    cout << ans << endl;
    return;
}

int main() {
    solve();  //関数を実行するだけ
    return 0;
}

       


        
        

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9 + 7;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a = 1, b = 1, c = 1;
    int N; cin >> N;
    for(int i = 0; i < N; ++i){
        a *= 10;
        a %= INF;
        b *= 8;
        b %= INF;
        c *= 9;
        c %= INF;
    }
    ll ret = a - 2*c + b;
    ret %= INF;
    ret = (ret+INF)%INF;
    cout << ret << '\n';
    return 0;
}

Measured memory_bytes: 3632
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n)
	fmt.Scan(&m)

	if n%2 == 0 {
		for i := 0; i < m; i++ {
			if i%2 == 0 {
				fmt.Println(1+i/2, n-i/2)
			} else {
				fmt.Println(n/2-1-i/2, n/2+1+i/2)
			}
		}
	} else {
		for i := 0; i < m; i++ {
			fmt.Println(1+i, n-i)
		}
	}
}


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

using namespace std;

#define int long long
#define MP make_pair

constexpr int INF = 1LL << 60;
constexpr int MOD = 998244353;
constexpr double EPS = 1.0e-9;

typedef pair<int, int> pii;
typedef pair<int, pii> pipii;

int n, m;

inline int dist(int l, int r) {
    return min(r - l, (n + l - r) % n);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(16);

    cin >> n >> m;
    int l = 3, r = n, pre = 0;

    cout << "1 2" << endl;
    for (int i = 1; i < m; i++) {
        int d = dist(l, r);
        if (d == pre || (d == n / 2 && n % 2 == 0)) {
            r--;
        }
        cout << l << " " << r << endl;
        pre = dist(l, r);
        l++;
        r--;
    }
}


Measured memory_bytes: 3652
#include <stdio.h>

int main(void){
  int i,n,m,count[1000001],res;
  char s[1000001];
  
  while(scanf("%d",&n),n){
    scanf("%d %s",&m,s);
    
    for(i=0;i<1000001;count[i]=0,i++);
    
    for(i=m-1;i>1;i--)
      if(s[i]=='I' && s[i-1]=='O' && s[i-2]=='I')
        count[i-2]=count[i]+1;
    
    for(i=0,res=0;i<m;i++)if(count[i]>=n)res++;
    
    printf("%d\n",res);
  }
  
  return 0;
}

Measured memory_bytes: 0
N, Q=map(int,raw_input().split())
S=raw_input()
T=[0]*N
for i in range(1,N):
  if S[i-1:i+1]=="AC":
    T[i]=T[i-1]+1
  else:
    T[i]=T[i-1]
for _ in range(Q):
  l,r=map(int,raw_input().split())
  ans=T[r-1]
  if l>1:
    ans-=T[l-2]
    if S[l-2:l]=="AC":
      ans-=1
  print ans

Measured memory_bytes: 8436
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		double a,b,c,d,e,f;
		double x[] = new double[1000];
		double y[] = new double[1000];
		int i = 0;
		while(sc.hasNext()){
			a = sc.nextDouble();
			b = sc.nextDouble();
			c = sc.nextDouble();
			d = sc.nextDouble();
			e = sc.nextDouble();
			f = sc.nextDouble();
			if(a == 0 && b != 0){
				y[i] = c/b;
				x[i] = ((f*b)-(c*e))/(d*b);
				} else if(a != 0 && b == 0){
				x[i] = c/a;
				y[i] = ((f*a)-(c*d))/(a*e);
			} else if(d == 0 && e != 0){
				y[i] = f/e;
				x[i] = ((c*e)-(b*f))/(a*e);
			} else if(d != 0 && e ==0){
				x[i] = f/d;
				y[i] = ((c*d)-(a*f))/(b*d);
			} else {
				y[i] = ((f*a)-(d*c))/((a*e)-(b*d));
				x[i] = (c-(b*y[i]))/a;
			}
			i++;
		}
		for(int j = 0; j < i; j++){
			System.out.printf("%.3f",x[j]);
			System.out.print(" ");
			System.out.printf("%.3f",y[j]);
			System.out.println();
		}
	}
}

Measured memory_bytes: 28400
from math import *
import fractions
import sys
import collections
import itertools
import pprint
from collections import deque
from heapq import *
import copy
N=int(input())
points=[list(map(int,input().split())) for _ in range(N)]


chebmax0=-float("inf")
chebmin0=float("inf")
chebmax1=-float("inf")
chebmin1=float("inf")

#chebmax0→x-yのmax
for l in points:
    chebmax0=max(chebmax0,l[0]-l[1])
for l in points:
    chebmin0=min(chebmin0,l[0]-l[1])
for l in points:
    chebmax1=max(chebmax1,l[0]+l[1])
for l in points:
    chebmin1=min(chebmin1,l[0]+l[1])
#print(chebmin1,chebmax1,chebmin0,chebmax0)
print(max(chebmax0-chebmin0,chebmax1-chebmin1))

Measured memory_bytes: 112260
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        String s,t;
        int a,b;
        String u;
        s = scan.next();
        t = scan.next();
        a = scan.nextInt();
        b = scan.nextInt();
        u = scan.next();
        if(u.equals(s)) a-=1;
        else b-=1;
        System.out.printf(a+" "+b);
    }
}

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

bool pairsort( const pair<int, int>& firstElof, const pair<int, int>& secondElof )
{
	return firstElof.first < secondElof.first;
}
int main()
{
	
	int n, m;
	cin >> n >> m;
	vector< pair<int, int> > v(n);
	for( int i = 0; i < n; ++i )
	{
		cin >> v[i].first >> v[i].second;
	}
	
	sort( v.begin(), v.end(), pairsort );

	long long ans = 0;
	for( pair<int, int> p : v )
	{
		if( p.second >= m )
		{
			ans += (long long)p.first*m;
			cout << ans << endl;
			return 0;
		}
		else
		{
			ans += (long)p.first*p.second;
			m -= p.second;
		}
	}

	return 0;
}

Measured memory_bytes: 1024
solve :: (Ord a) => [a] -> [[a]]
solve list = reverse answers
    where (answers,_,_) = foldl sortstep ([], 0, list) list

insert':: (Ord a) => [a] -> a -> [a]
insert' [] e = [e]
insert' list@(x:xs) e
    | e >= x = x : (insert' xs e)
    | otherwise = e : list

sortstep :: (Ord a) => ([[a]], Int, [a]) -> a -> ([[a]], Int, [a])
sortstep ([], _, list) _ = ([list], 1, list)
sortstep (current@(x:xs), n, list) e = (next:current, n+1, list)
    where next = (insert' (take n x) e) ++ (drop (n+1) list)

main = do
    n <- getLine
    strlist <- getLine >>= return . words
    let list = map read strlist :: [Int]
    mapM putStrLn $ map (unwords . map show) $ solve list



Measured memory_bytes: 4212
from collections import defaultdict

N = int(input())
ctr = defaultdict(int)
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            res = x**2 + y**2 + z**2 + x*y + y*z + z*x
            ctr[res] += 1

for n in range(1, N + 1):
    print(ctr[n])


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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

int main(void) {
    string a;
    cin >> a;

    vector<ll> abc(26);
    ll n = a.size();
    for(int i=0;i<n;i++) {
        abc.at(a.at(i)-'a')++;
    }

    ll ans;
    ans = n * (n-1) / 2;
    for(int i=0;i<26;i++) {
        ans -= abc.at(i) * (abc.at(i)-1) / 2;
    }
    ans++;

    // for(ll i=0;i<26;i++) {
    //     cout << abc.at(i) << "/";
    // }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

    int n,a,b,c,x;
    while(cin>>n>>a>>b>>c>>x,n||a||b||c||x){
        vector<int> y(n);
        for(int i=0;i<n;i++) cin>>y[i];
        int cnt=0,idx=0;;
        while(true){
            if(x==y[idx]) idx++;
            if(idx==n) break;
            cnt++;
            if(cnt>10000) break;
            x = (a*x+b)%c;
        }
        if(cnt>10000) cout<<-1<<endl;
        else cout<<cnt<<endl;
    }
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
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; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;



int main(){
  ll x;
  cin >> x;
  vector<ll> vec;
  vec.push_back(0);
  ll piv = 1;
  while(1){
    t1 = (ll)pow(piv,5);
    vec.push_back(piv);
    vec.push_back(-piv);
    if(pow(piv,5) - pow(piv-1,5) > 1e9){
      break;
    }
    piv++;
  }
  sort(all(vec));

  ull len = vec.size();
//  rep(i,len){
//    cout << vec[i] << " ";
//  }
  //cout << len << endl;
  bool fin = false;
  rep(i,len){
    REP(j,i+1,len){
      if((ll)pow(vec[j],5) - (ll)pow(vec[i],5) == x){
        cout << vec[j] << " ";
        cout << vec[i] << endl;
        fin = true;
        break;
      }
    }
    if(fin){
      break;
    }
  }

}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
map<string,int> M;
vector<string> NG[41];
string A[41];
int n,B[41],ans;
ull g[41];
int Sum[41];

void dfs(int pos,int sum,ull U){
  ans=max(ans,sum);
  if(pos==n)return;
  if(ans>=sum+Sum[pos]) return;
  
  dfs(pos+1,sum,U);
  if((U&(1LL<<pos))==0)dfs(pos+1,sum+B[pos],U|g[pos]);
  
}

int main(){
  while(cin>>n,n){
    M.clear();
    
    for(int i=0,C;i<n;i++){
      cin>>A[i]>>B[i]>>C;
      Sum[i]=B[i];
      M[A[i]]=i;
      NG[i].resize(C);
      for(int j=0;j<C;j++)cin>>NG[i][j];
    }
    
    for(int i=n-2;i>=0;i--) Sum[i]+=Sum[i+1];
    
    for(int i=0;i<n;i++){
      g[i]=1LL<<i;
      for(int j=0;j<(int)NG[i].size();j++)g[i]|=1LL<<M[NG[i][j]];
    }
    ans=0;
    dfs(1,B[0],g[0]);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int k,p;
  for(int i=0; i<n; i++){
    cin >> k >> p;
    if(k%p==0) cout << p << endl;
    else cout << k%p << endl;
  }
  return 0;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i, e, n) for (int i = e; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const ll inf=1000000000007;

int main() {
  ll n,a,b,c,d,e;
  cin >> n >> a >> b >> c >> d >> e;
  ll mn= min(min(min(a,b),c),min(d,e));
  ll ans = (n-0.5)/mn +5;
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define MAX 200005

int n,k;
int ball[MAX];
int cnt[MAX];

bool cmp(int a, int b)
{
    return a>b;
}
int main()
{
    cin>>n>>k;
    // int t = n;
    for(int i=1;i<=n;++i)
    {
        cin>>ball[i];
        ++cnt[ball[i]];
    }
    // int m = 0;
    sort(cnt+1,cnt+1+n, cmp);
    int sum = 0;
    for(int i=1;i<=k;++i)
    {
        sum+=cnt[i];
    }
    int ans = n-sum;
    cout<<ans;
    // for(int i=1;i<=n;++i)
    // {
    //     m = max(m,cnt[i]);
    // }
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
#define ll long long
#define loop(a) loopi(i,a)
#define loopi(i,a) for(int i=0; i<(a); i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pow2(x) (1ll<<(x))
 
using namespace std;
 
const int Mod=1e9+7;

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	ll a,b;
	cin >> a >> b;
	cout << a*b/(__gcd(a,b)) << "\n";
	return 0;
}


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

int main()
{
    char s[101];
    cin.get(s, 101);
    bool c=false;
    for (int i=0; i<strlen(s); i++)
    {
        if (s[i]=='C')
            c=true;
        if (s[i]=='F' && c==true)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
n = int(input())
lstA = list(map(int,input().split()))
lstB = list(map(int,input().split()))

ans = 0
for i in range(n):
    if lstB[i] < lstA[i]:
        ans += lstB[i]
    elif lstB[i] > (lstA[i] + lstA[i+1]):
        ans += lstA[i] + lstA[i+1]
        lstA[i+1] = 0
    else:
        ans += lstB[i]
        lstA[i+1] -= lstB[i] - lstA[i]
print(ans)

Measured memory_bytes: 18624
#include <iostream>
using namespace std;
int main(void){
    int a, b, c, d;
    int n;
    int sum = 0; //条件を満たす組み合わせの数

    while(cin >> n){
        for(a = 0; a <= 9; a++){
            for(b = 0; b <= 9; b++){
                for(c = 0; c <= 9; c++){
                    for(d = 0; d <= 9; d++){
                        if(a + b + c + d == n) sum++; 
                    }
                }
            }
        }
        cout << sum << endl;
        sum = 0;
    }
}



Measured memory_bytes: 3068
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        for(int i = 1;;i++){
            int x = sc.nextInt();
            if(x==0){
                break;
            }
            else {
                System.out.println("Case " + i + ": " + x);
            }
        }
    }
}


Measured memory_bytes: 41336
#define ENABLE_DEBUG 0
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/
void err() {
    std::cout << -1 << '\n';
    exit(0);
}
auto cmn=[](auto&x,auto y){if(x>y){x=y;return true;}return false;};
int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    usize n;
    std::cin >> n;
    vec<i64> a(n+1);
    for (i64&x: a) std::cin >> x;

    if (a.at(n)==0) err();

    if (n==0) {
        if (a.at(0)==1) {
            std::cout << 1 << '\n';
            return 0;
        } else {
            err();
        }
    }

    if (a.at(0)!=0) err();

    vec<i64> b(n+1);
    std::partial_sum(a.rbegin(), a.rend(), b.rbegin());
    b.at(0) = 1;
    for (usize i=0; i<n; i++) {
        if (b.at(i) < a.at(i)) err();
        cmn(b.at(i+1), (b.at(i)-a.at(i))*2);
    }
    DEBUG(a, b);
    if (b.at(n) < a.at(n)) err();

    i64 ans = std::accumulate(ALL(b), 0ll);
    std::cout << ans << '\n';
}


Measured memory_bytes: 5148
/**
 * code generated by Junayed Kader
 * Student of Computer Science
 * @author
 */

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>
using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu ()
{
    cerr << endl;
}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}

ll gcd ( ll a, ll b )
{
    return __gcd ( a, b );
}
ll lcm ( ll a, ll b )
{
    return a * ( b / gcd ( a, b ) );
}
ll max(ll a,ll b)
{
    return a>b?a:b;
}
ll min(ll a,ll b)
{
    return a<b?a:b;
}
const int mx = 1e5+123;
int point[mx][4], n;
int dp[mx][4];
int solve(int i , int w)
{
    if(i>n) return 0;
    if(dp[i][w]!=-1) return dp[i][w];
    int ret = 0;
    for(int j = 1; j<=3; j++)
    {
        if(j!=w )
        {
            ret= max(ret, point[i][j]+solve(i+1, j) );
        }
    }
    dp[i][w] = ret;
    return dp[i][w];

}

void _case()
{

    cin>>n;
    for(int i  = 1; i<=n; i++)
    {
        cin>>point[i][1]>>point[i][2]>>point[i][3];
    }
    mem(dp,-1);
    cout<<solve(1,0)<<endl;

}
int main()
{
    optimize();
    _case();

    return 0;
}



Measured memory_bytes: 14488
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A[] = new int[N];
    
    for(int i=0; i<N; i++){
      A[i]=sc.nextInt();
    }
    
    for(int i = N-1; i>=0; i-=2){
      System.out.print(A[i]+" ");
    }
    for(int i = N%2; i<N; i+=2){
      System.out.print(A[i]+" ");
    }
  }
}

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

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

    int ans = 0;
    for(int y=0; y<11; ++y){
        for(int x=0; x<5; ++x){
            int a = (y + 1) * 7 + x + 2;
            a *= 9;
            if(a % 11 == k)
                ans += (n + 8 - y) / 11;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
ans = 0
m = abs(A - T + H[0] * 0.006)
for i in range(N):
  d = T - H[i] * 0.006
  a = abs(A - d)
  if m >= a:
    m = a
    ans = i + 1
print(ans)


Measured memory_bytes: 3060
N = int(input())
A = list(map(int,input().split()))
ans = 1
flag = 0
for i in range(N-1):
    if A[i+1] < A[i] and flag == 0:
        flag = 1 #減少
    elif A[i+1] > A[i] and flag ==0:
        flag = 2 #増加
    elif flag == 1 and (A[i+1] > A[i]):
        ans += 1 #リストを区切る
        flag = 0 
    elif flag == 2 and (A[i+1] < A[i]):
        ans += 1
        flag = 0
    #A[i+1] == A[i] のときはリストを区切らず次のiへ
print(ans)


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

using namespace std;

#define rep(i,m,n) for(long i=m;i<n;i++)


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

  
  long res=0;
 vector<long> a(n),b(n),c(n-1);
  rep(i,0,n) {
    cin >> a[i];
    a[i]--;
  }
  rep(i,0,n) cin >> b[i];
   rep(i,0,n-1) cin >> c[i];
  
  
  res+=b[a[0]];
  rep(i,1,n){
   res+=b[a[i]];
    if(a[i]==a[i-1]+1) res+=c[a[i-1]];

  }
  
  
 

   cout << res << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#define rgi register int
using namespace std;
const double eps=1e-6;
int n,a[105];
double b[105],ans,fans;
int main()
{
	scanf("%d",&n);
	for(rgi i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		b[i]=1.0/a[i];
	}
	for(rgi i=1;i<=n;++i)
		ans+=b[i];
	fans=1.0/ans;
	printf("%.5lf",fans);
	return 0;
}

Measured memory_bytes: 128
local n=io.read("n")
local f={}
for i=1,n do
    f[i]={}
    for j=0,9 do
        f[i][j]=io.read("n")
    end
end
local p={}
for i=1,n do
    p[i]={}
    for j=0,10 do
        p[i][j]=io.read("n")
    end
end

local max=-math.maxinteger
for bit=1,(1<<10)-1 do
    local gain=0
    for i=1,n do
        local open=0
        for j=0,9 do
            if (bit>>j&1)>0 and f[i][j]~=0 then
                open=open+1
            end
        end
        gain=gain+p[i][open]
    end
    if max<gain then
        max=gain
    end
end
print(max)

Measured memory_bytes: 2784
import numpy as np

H, W = map(int, input().split())

a = []
for i in range(H):
    a.append(list(map(int, input().replace("#","1").replace(".","0"))))

a = np.array(a)

d1 = (np.sum(a, axis=1) == 0)
d2 = (np.sum(a, axis=0) == 0)

ret = []

for i in range(H):
    tmp = ""
    if d1[i]:
        continue
    for j in range(W):
        if d2[j]:
            continue
        tmp = tmp + str(a[i,j])
    ret.append(tmp.replace("1","#").replace("0","."))
        

print(*ret,sep="\n")
        


Measured memory_bytes: 12516
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;

int main() {
	ll X, Y;
	cin >> X >> Y;
	int ans = 0;
	while (X <= Y) {
		ans++;
		X *= 2;
	}

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

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

const int maxN=310;
const int Mod=1e9+7;
const int inf=2000000000;

int n,m;
vector<pair<int,int> > Vp[maxN];
int F[maxN][maxN][maxN];

void Plus(int &x,int y);
int main(){
    scanf("%d%d",&n,&m);
    for (int i=1;i<=m;i++){
        int l,r,x;scanf("%d%d%d",&l,&r,&x);Vp[r].push_back(make_pair(l,x));
        if (x>r-l+1){
            puts("0");return 0;
        }
    }
    F[1][0][0]=3;int Ans=0;
    for (int i=1;i<=n;i++){
        int mn1=inf,mn2=inf,mn3=inf,mx1=0,mx2=0,mx3=0;
        for (int j=0,sz=Vp[i].size();j<sz;j++){
            if (Vp[i][j].second==1) mn1=min(mn1,Vp[i][j].first),mx1=max(mx1,Vp[i][j].first);
            if (Vp[i][j].second==2) mn2=min(mn2,Vp[i][j].first),mx2=max(mx2,Vp[i][j].first);
            if (Vp[i][j].second==3) mn3=min(mn3,Vp[i][j].first),mx3=max(mx3,Vp[i][j].first);
        }
        for (int j=0;j<i;j++)
            for (int k=0;k<=j;k++){
                if (k&&j==k) continue;
                if (j>=mn1) continue;
                if (j<mx2||k>=mn2) continue;
                if (k<mx3) continue;
                if (!F[i][j][k]) continue;
                if (i==n) Plus(Ans,F[i][j][k]);
                Plus(F[i+1][j][k],F[i][j][k]);
                Plus(F[i+1][i][k],F[i][j][k]);
                Plus(F[i+1][i][j],F[i][j][k]);
            }
    }
    printf("%d\n",Ans);return 0;
}
void Plus(int &x,int y){
    x+=y;if (x>=Mod) x-=Mod;return;
}

Measured memory_bytes: 112896
/*
[ ( ^ _ ^ ) ]
*/

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


public class Main {
    int INF = (int)1e9;
    long MOD = 1000000007;

    long abs(long x) {
        return Math.abs(x);
    }

    long min(long ... x) {
        long rs = x[0];
        for(long y: x) rs = Math.min(rs, y);
        return rs;
    }

    long[][] dp;

    void solve(InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        int m = in.nextInt();
        long[] w = new long[n];
        long[] v = new long[n];
        int s = 0;
        for(int i=0; i<n; i++) {
            w[i] = in.nextInt();
            v[i] = in.nextInt();
            s += v[i];
        }
        // for(int i=0; i<=n; i++) {
        //     dp[i][0] = Long.MAX_VALUE;
        // }
        dp = new long[n+1][s+1];
        for(int j=1; j<=s; j++) {
            dp[0][j] = INF*10000l;
        }
        for(int i=1; i<=n; i++) {
            for(int j=1; j<=s; j++) {
                dp[i][j] = dp[i-1][j];
                if(j-v[i-1]>=0) {
                    dp[i][j] = min(dp[i][j], dp[i-1][(int)(j-v[i-1])] + w[i-1]);
                }
            }
        }
        // for(long[] x: dp) show("", x);
        for(int i=s; i>=0; i--) {
            if(dp[n][i]<=m) {
                out.println(i);
                return;
            }
        }
        // out.println(dp[n][m]);
    }
    

    public static void main(String[] args) throws IOException {
        if(args.length>0 && args[0].equalsIgnoreCase("d")) {
            DEBUG_FLAG = true;
        }
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;//in.nextInt();
        long start = System.nanoTime();
        while(t-- >0) {
            new Main().solve(in, out);
        }
        long end = System.nanoTime();
        debug("\nTime: " + (end-start)/1e6 + " \n\n");
        out.close();
    }
    
    static boolean DEBUG_FLAG = false;
    static void debug(String s) {
        if(DEBUG_FLAG) System.out.print(s);
    }
    
    public static void show(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
    
    static class InputReader {
        static BufferedReader br;
        static StringTokenizer st;
    
        public InputReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

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

typedef struct {
	int price;
	int zyanru;
} book_t;

int memo[11][2000];

book_t books[2000];
int zyanru_pos[12];

int calc_max(int nowzyanru,int nownum,int maxnum);

int qsort_comp(const void* x,const void* y) {
	const book_t* a=(const book_t*)x;
	const book_t* b=(const book_t*)y;
	/*ツジツδδδ督δ仰づ個渉クツ渉づソツーツト*/
	if((a->zyanru)>(b->zyanru))return 1;
	if((a->zyanru)<(b->zyanru))return -1;
	/*ツ値ツ段ツづ個降ツ渉づソツーツト*/
	if((a->price)<(b->price))return 1;
	if((a->price)>(b->price))return -1;
	/*ツ督ッツつカ*/
	return 0;
}


int main(void) {
	int N,K;
	int i;
	int currentzyanru;
	scanf("%d %d",&N,&K);
	for(i=0;i<N;i++) {
		scanf("%d %d",&books[i].price,&books[i].zyanru);
	}
	qsort(books,N,sizeof(book_t),qsort_comp);
	currentzyanru=0;
	zyanru_pos[0]=0;
	for(i=0;i<N;i++) {
		if(books[i].zyanru!=currentzyanru) {
			currentzyanru=books[i].zyanru;
			zyanru_pos[currentzyanru]=i;
		}
	}
	for(i=currentzyanru+1;i<=11;i++)zyanru_pos[i]=N;
	printf("%d\n",calc_max(1,0,K));
	return 0;
}

int calc_max(int nowzyanru,int nownum,int maxnum) {
	int current_book_price;
	int result;
	int result_max=0;
	int sell_now;
	int sell_now_max;
	if(nowzyanru>10 || nownum>=maxnum)return 0;
	if(memo[nowzyanru][nownum]>0)return memo[nowzyanru][nownum]-1;
	/*ツ債。ツづ個ジツδδδ督δ仰づ個本ツづーツつ「ツつュツづつ板づェツづゥツつゥ*/
	sell_now_max=maxnum-nownum;
	if(sell_now_max>zyanru_pos[nowzyanru+1]-zyanru_pos[nowzyanru]) {
		sell_now_max=zyanru_pos[nowzyanru+1]-zyanru_pos[nowzyanru];
	}
	current_book_price=0;
	/*ツ債。ツづ個ジツδδδ督δ仰づ個本ツづーツつ「ツつュツづつ板づゥツつゥ*/
	for(sell_now=0;sell_now<=sell_now_max;sell_now++) {
		if(sell_now>0) {
			current_book_price+=
				books[zyanru_pos[nowzyanru]+sell_now-1].price;
			result=current_book_price+sell_now*(sell_now-1);
		} else result=0;
		/*ツ篠淞づ個ジツδδδ督δ仰づーツ陳イツづ猟づゥ*/
		result+=calc_max(nowzyanru+1,nownum+sell_now,maxnum);
		if(result>result_max)result_max=result;
	}
	/*ツ個仰嘉環づーツδδつつオツづ陛板つキ*/
	memo[nowzyanru][nownum]=result_max+1;
	return result_max;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

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

int main()
{
	ll N, M;
	ll ans;

	cin >> N >> M;
	if (N >= 2 && M >= 2) ans = (N - 2) * (M - 2);
	else if (N == 1 && M >= 2) ans = M - 2;
	else if (N >= 2 && M == 1) ans = N - 2;
	else ans = 1;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()

int main(){
    int n;
    cin >> n;
    vector <int> a(n);
    rep(i,n) cin >> a[i];

    int tmp=1;
    int count = 0;
    for(int i=0; i<n; i++){
        if(a[i] == tmp){
            tmp ++; 
            count ++;
        }
    }

    if(count ==0) cout << -1 << endl;
    else cout << n - count << endl;

}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
	int a,b,c,d,e,f;
	scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
	if((e-a)>f){
		printf(":(");
	}else{
		printf("Yay!");
	}
	return 0;
}
	

Measured memory_bytes: 128