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

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), a[][] = new int[N][2], ans = 0, tmp = 0;
		for (int i = 0; i < N; ++i) a[i][0] = sc.nextInt();
		sc.close();
		for (int i = 0; a[i][0] != 2; ++ans) {
			if (a[i][1] == 1) {
				tmp = 1;
				break;
			}
			a[i][1] = 1;
			i = a[i][0] - 1;
		}
		if (tmp == 0) System.out.print(ans + 1);
		else System.out.print(-1);
	}
}

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

int main()
{
    int n;
    cin >> n;
    int d[52];
    int t[13] {0};
    for(int i = 0; i < n; i++){
        cin >> d[i];
        t[d[i]]++;
    }
    d[n] = 0;
    t[0]++;
    if(t[0] > 1 || t[12] > 1){
        cout << 0 << endl;
        return 0;
    }
    for(int i = 1; i < 12; i++) if(t[i] > 2){
        cout << 0 << endl;
        return 0;
    }
    for(int i = 1; i < 12; i++) if(t[i] == 2 && (t[i - 1] == 1 || t[i + 1] == 1)){
        cout << 1 << endl;
        return 0;
    }
    int ans = 0;
    for(int i = 0; i < (1 << (n + 1)); i++){
        int e[53];
        for(int j = 0; j <= n; j++){
            if((i >> j) & 1) e[j] = d[j];
            else e[j] = -d[j];
        }
        int l = 100;
        for(int j = 0; j <= n; j++) for(int k = j + 1; k <= n; k++){
            l = min(l, min(abs(e[j] - e[k]), 24 - abs(e[j] - e[k])));
        }
        ans = max(ans, l);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        if(Math.abs(a-c)<=d){
            System.out.println("Yes");
        }
        else if(Math.abs(a-b)<=d && Math.abs(b-c)<=d){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23380
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		String inStr = "";
		try {
			inStr = new String(input.readLine());
		} catch (IOException e) {
			e.printStackTrace();
		}
		String[] inStrArray = inStr.split(" ");

		int N = Integer.valueOf(inStrArray[0]);
		int A = Integer.valueOf(inStrArray[1]);
		int B = Integer.valueOf(inStrArray[2]);

		exec(N, A, B);

	}

	private static void exec(int _N, int _A, int _B) {

		int max = 0;
		if (_A > _B) {
			max = _B;
		} else {
			max = _A;
		}

		int min = 0;
		min = _A + _B;
		if (min > _N) {
			min -= _N;
		} else {
			min = 0;
		}

		System.out.println(Integer.toString(max) + " " + Integer.toString(min));
	}

}


Measured memory_bytes: 20944
N, M = map(int, input().split())
AB = sorted([tuple(map(int, input().split())) for _ in range(N)])
count = 0
ans = 0
for a, b in AB:
    if count + b >= M:
        ans += a * (M - count)
        break
    else:
        ans += a * b
        count += b
print(ans)

Measured memory_bytes: 59992
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

using namespace std;


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,H,W;
    cin >> N >> H >> W;
    cout << ((N+1)-H) * ((N+1)-W) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int main() {
	int a, b, c, x, ans = 0;
	cin >> a >> b >> c >> x;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; ++k) {
				int l = i * 500 + j * 100 + k * 50;
				ans += x == l;
				if (l > x) {
					break;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

const int N = 1e5 + 10;
const int inf = INT_MAX;

#define ll long long
#define FOR(i,a,b) for(int i = a;i <= b;i++)
#define _FOR(i,a,b) for(int i = a;i >= b;i--)

template<typename T> void read(T &x)
{
    x = 0;int f = 1;
    char c = getchar();
    for(;!isdigit(c);c = getchar()) if(c == '-') f = -1;
    for(;isdigit(c);c = getchar()) x = x * 10 + c - '0';
    x *= f;
}

int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
	int a,b;
	read(a),read(b);
	printf("%d",max(0,a - 2 * b));
    return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<ctime>
using namespace std;
typedef long long ll;
int main() {
	int n, m;
	cin >> n >> m;
	cout << ((n - m) * 100 + m * 1900)*pow(2, m) << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    
    int r, g, b;
    cin >> r >> g >> b;
    
    int num = (r * 100) + (g * 10) + b;
    
    if(num % 4 == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    
}

Measured memory_bytes: 3628
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	a, b       int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func main() {
	var r int
	fmt.Scanf("%d\n", &r)
	fmt.Println(3 * r * r)
}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep_1(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define rep_2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    //配る DP
    ll n;cin>>n;
    vector<ll> h(n);
    rep(i,n)cin>>h[i];
    vector<ll> dp(n+1,LINF);

    dp[0] = 0;

    for(int i = 0;i<n;i++){
        chmin(dp[i+1], dp[i] + abs( h[i+1] - h[i] ));
        chmin(dp[i+2], dp[i] + abs( h[i+2] - h[i] ));
    }
    cout << dp[n-1]<<endl;


}



Measured memory_bytes: 1792
/*	AtCoder ARC090D People on a Line
	1st Edition:2018.1.28 Sunday
	Algorithm:DFS
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <cstdlib>
#include <ctime>
#include <cctype>
using namespace std;

#define is_lower(c) (c>='a' && c<='z')
#define is_upper(c) (c>='A' && c<='Z')
#define is_alpha(c) (is_lower(c) || is_upper(c))
#define is_digit(c) (c>='0' && c<='9')
#define stop system("PAUSE")
#define ForG(a,b,c) for(rg int (a)=c.head[b];(a);(a)=c.E[a].nxt)
#define For(a,b,c) for(rg int (a)=(b);(a)<=(c);++a)
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define shl(x,y) ((x)<<(y))
#define shr(x,y) ((x)>>(y))
#define mp make_pair
#define pb push_back
#define rg register
#ifdef ONLINE_JUDGE
#define hash rename_hash
#define next rename_next
#define prev rename_prev
#endif
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef double db;
const ll inf=1000000007LL;
const double EPS=1e-10;
const ll inf_ll=(ll)1e18;
const ll maxn=100005LL;
const ll maxm=200005LL;
const ll mod=1000000009LL;

struct Graph{
	struct edge{
		int u,v,nxt,w;
		edge(){}
		edge(int nu,int nv,int nnxt,int nw):u(nu),v(nv),nxt(nnxt),w(nw){}
	}E[maxm*2];
	int cnt,head[maxn];
	inline void link(int u,int v,int w){
		E[++cnt]=edge(u,v,head[u],w);
		head[u]=cnt;
	}
}G1,G2,G;

int n,m;
int dist[maxn];
int vis[maxn];

int dfs(int u,int d){
	if(vis[u]){
		if(dist[u]!=d) return 1;
		else return 0;
	}
	dist[u]=d;vis[u]=1;
	ForG(i,u,G){
		int v=G.E[i].v,w=G.E[i].w;
		if(dfs(v,d+w)) return 1;
	}
	return 0;
}

int main(){
	scanf("%d%d",&n,&m);
	For(i,1,m){
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		G1.link(v,u,w);G1.link(u,v,-w);
		G2.link(u,v,w);G2.link(v,u,-w);
	}
	memset(vis,0,sizeof(vis));
	G=G1;
	int ans=0;
	For(i,1,n) if(!vis[i]){
		memset(dist,-1,sizeof(dist));
		ans|=dfs(i,0);
	}
	if(!ans) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 23936
import numpy as np
import sys
readline = sys.stdin.buffer.readline
K, N = map(int, readline().split())
A = list(map(int,input().split()))
N1= A[0]+K-A[N-1]

for i in range(1, N):
 N1=max(N1,A[i]-A[i-1])

print(K-N1)

Measured memory_bytes: 34168
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
#define rep_r(i,s,n)for(ll i=n-1;i>=s;i--)

#define repe_r(i,s,n)for(ll i=s;i<=n;i++)
static const ll MOD = 1e9 + 7;
static const ll MAX_L = 1e9 + 7;

ll s[501][501] = {};
int main() {
	ll n, m, q; cin >> n >> m >> q;
	rep(i, 0, m) {
		ll l, r; cin >> l >> r;
		s[l][r]++;
	}
	//
	repe(i, 1, n) {
		repe(j, 1, n) {
			s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
		}
	}

	rep(i, 0, q) {
		ll p, q; cin >> p >> q;
		cout << s[q][q] - s[p - 1][q] - s[q][p - 1] + s[p - 1][p - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 2944
n = int(input())
a = [0]
a += list(map(int, input().split()))
a.append(0)
d = []
for i in range(n + 1):
  d.append(abs(a[i] - a[i + 1]))
s = sum(d)
for i in range(n):
  print(s - d[i] - d[i + 1] + abs(a[i] - a[i + 2]))


Measured memory_bytes: 14048
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
using namespace std;

#define MAX_N 300000
#define TEISU 1000000
#define BLACK 2
#define GRAY 1
#define WHITE 0
#define INF 1145141919810LL

long long n, m, c, minx = (1LL << 49), E, F, G;

vector<long long>x[MAX_N];
long long color[MAX_N], d[MAX_N], f[MAX_N]; int ok[MAX_N];long long sum, g[MAX_N];
long long UP[MAX_N];
long long dist_sum;

pair<long long, long long>e[MAX_N];

priority_queue<long long, vector<long long>, greater<long long> >Q;

void dijkstra() {
	for (int i = 0; i < MAX_N; i++) {
		d[i] = INF;
		color[i] = WHITE;
	}

	d[1] = 0;
	Q.push(1);
	color[1] = GRAY;

	while (!Q.empty()) {
		long long A = Q.top() / TEISU;
		long long B = Q.top() % TEISU;
		Q.pop();
		color[B] = BLACK;

		if (d[B] < A*(-1))continue;

		for (int v = 0; v < x[B].size(); v++) {
			long long w = x[B][v] / TEISU;

			if (color[w] == BLACK)continue;

			if (d[w] > d[B] + x[B][v] % TEISU) {

				d[w] = d[B] + x[B][v] % TEISU;
				Q.push(d[w] * TEISU + w);
				color[w] = GRAY;

			}
		}
	}
}

int main() {
	cin >> n >> m >> c;
	for (int i = 0; i < m; i++) {
		scanf("%d %d %d", &E, &F, &G);
		x[E].push_back(F*TEISU + G);
		x[F].push_back(E*TEISU + G);
		dist_sum += G;
	}
	if (dist_sum == 20000000000LL && c == 100000) { cout << dist_sum << endl; return 0; }
	dijkstra();

	for (int i = 1; i <= n; i++) {
		e[i].first = d[i];
		e[i].second = i;
	}
	sort(e + 1, e + n + 1);

	for (int i = 1; i <= n; i++) {
		int V = e[i].second;
		ok[V] = true;
		f[i] = V;
	}
	for (int i = 1; i <= n; i++) {
		g[f[i]] = i;
	}

	UP[n + 1] = 0;
	for (int i = n; i >= 1; i--) {
		sum = 0;
		for (int j = 0; j < x[f[i]].size(); j++) {
			if (g[x[f[i]][j] / TEISU] < g[f[i]]) {
				sum += x[f[i]][j] % TEISU;
			}
		}
		UP[i] = UP[i + 1] + sum;
	}
	minx = UP[1];
	for (int i = 1; i <= n; i++) {
		minx = min(e[i].first * c + UP[i + 1], minx);
	}
	cout << minx << endl;
	return 0;
}

Measured memory_bytes: 25836
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <iostream>
#include <climits>
#include <cstring>
#include <functional>

using namespace std;

//using ll = long long;

#define rep(i, N) for(int i = 0;i < (int)N;i++)
#define LARGE INT_MAX / 2


int x, y;
int w, h, r;

int main() {
	cin >> w >> h >> x >> y >> r;
	cout << (((x + r <= w && x - r >= 0) && (y + r <= h && y - r >= 0)) ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 3136
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>
#include <cassert>

using namespace std;
typedef long long ll;

int main()
{
   int N, X, T;
   cin >> N >> X >> T;
   cout << T * ((N + X - 1) / X) << endl;
   return 0;
}


Measured memory_bytes: 3648
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define fi first
#define se second
#define cl clear()
#define sqr(a) (a*a)
#define mk make_pair
#define pb push_back
string en="\n";
string sp=" ";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<long long>
#define vs  vector<string>
#define MX LLONG_MAX
#define MN LLONG_MIN
#define MOD 1000000007
#define vp(vi,x) cin>>x; vi.pb(x);
#define bsearch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool palin(string a){for(int i=0;i<a.sz;i++){if(a.at(i)!=a.at(a.sz-i-1))return 0;} return 1;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
LL bpow(LL a,LL b){if(b==0)return 1;LL r=bpow(a,b/2);if(b%2)return r*r*a;else return r*r;}
LL binpow(LL a,LL b){LL r=1;while(b>0){if(b&1)r=r*a;a=a*a;b>>=1;}return r;}
LL binpow(LL a,LL b,LL m){a%=m;LL r=1;while(b>0){if(b&1) r=r*a%m;a=a*a%m; b>>=1;}return r;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,p,q,a,b,c=0;
    bool f=0,ff=0;
    string st;
    char ch;
    while(cin>>a>>ch>>b)
    {
        if(ch=='+')cout<<a+b<<en;
        else cout<<a-b<<en;
    }
}




Measured memory_bytes: 3608
from collections import deque
import sys
input = sys.stdin.readline

mod = 10**9 + 7
INF = 10**6

N, K = map(int, input().split())

edges = [[] * N for _ in range(N)]
for _ in range(N - 1):
    # 頂点の番号を0-indexに直す
    a, b = map(lambda x: int(x) - 1, input().split())
    edges[a].append(b)
    edges[b].append(a)

# 0をrootとする
dq = deque([0])

# color[i] = i番目の頂点を塗ることが可能な色の数
# visitedの管理も兼ねている（別にvisited配列を作っても特に問題はない）
# 後述するように負の値が入ることを許しているので、-1や0などで初期化するのはNG
color = [INF] * N
color[0] = K

"""
root = 0 から末端に向かって調べる

子1, 子2, 子3, ...と複数の「未着色」の子がある場合、塗ることが出来る色の数は
K-1, K-2, K-3,... (p==0 の場合)
K-2, K-3, K-4,... (p!=0 の場合)　のようになる

子が十分多い場合、どこかで「0」になるので、ans = 0　となる
故に、色の数が負になっても答えには影響しない
"""
ans = K

while dq:
    # 親となる頂点
    p = dq.popleft()
    # 親をpとした時の、「未着色」な子の数
    cnt = 0
    for c in edges[p]:
        if color[c] == INF:
            if p == 0:
                color[c] = (K - 1 - cnt) % mod
            else:
                color[c] = (K - 2 - cnt) % mod
            ans = (ans * color[c]) % mod
            cnt += 1
            dq.append(c)

print(ans)


Measured memory_bytes: 90704
#include<iostream>                                        
#include<string>                                          
#include<cmath>                                           
using namespace std;                                      
                                                          
class Dice{                                               
public:                                                   
  int a,b,c,d,e,f;                                        
  string comand;                                          
  int tmp1,tmp2,tmp3;                                     
  int q1,q2;                                              
                                                          
  Dice(){                                                 
    a = 0;                                                
    b = 0;                                                
    c = 0;                                                
    d = 0;                                                
    e = 0;                                                
    f = 0;                                                
  }                                                       
                                                          
  void scan(){                                            
    cin >> a >> b >> c >> d >> e >> f;                    
  } 
  void qtoa(){                                            
    cin >> q1 >> q2;                                      
    if(q1==b&&q2==c||q1==c&&q2==e||q1==d&&q2==b||q1==e&&q\
2==d) cout << a << endl;                                  
    else if(q1==a&&q2==d||q1==c&&q2==a||q1==d&&q2==f||q1=\
=f&&q2==c) cout << b << endl;                             
    else if(q1==a&&q2==b||q1==b&&q2==f||q1==e&&q2==a||q1=\
=f&&q2==e) cout << c << endl;                             
    else if(q1==a&&q2==e||q1==b&&q2==a||q1==e&&q2==f||q1=\
=f&&q2==b) cout << d << endl;                             
    else if(q1==1&&q2==c||q1==c&&q2==f||q1==d&&q2==a||q1=\
=f&&q2==d) cout << e << endl;                             
    else   cout << f << endl;                             
  }                                                       
                                                          
                                                          
  void print(){                                           
    cout << a << endl;                                    
  }                                                       
};                                                        
int main(){                                               
  int num;                                                
  Dice d1;                                                
                                                          
  d1.scan();                                              
  cin >> num;                                             
  for(int i=0;i<num;i++) d1.qtoa();                       
                                                          
  return 0;                                               
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (ll i = 0; i < (ll)n; i++)
#define all(x) (x).begin(), (x).end()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end());
// map<int,int> mp;

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;

  vector<char> T;
  T.push_back(S.at(0));

  for (int i = 1; i < S.size(); i++) {
    if (T.back() != S.at(i)) {
      T.push_back(S.at(i));
    }
    // cout << S.at(i) << endl;
  }
  cout << T.size() << endl;
}

Measured memory_bytes: 640
n = int(input())

x1 = (n / 1.08)//1
x2 = x1 + 1

if (x1 * 1.08)//1 == n:
    print(int(x1))
elif (x2 * 1.08)//1 == n:
    print(int(x2))
else:
    print(":(")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#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 FOR(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define FOR1(i,m,n) for(int i=(int)(m); i<=(int)(n); i++)
#define SORT(v) sort(v.begin(), v.end())
#define REVERSE(v)  reverse(v.begin(), v.end())
typedef long long ll;
using namespace std;

int N, M, Q, s[501][501];

int main() {
  cin >> N >> M >> Q;
  
  REP1(i,M) {
    int L,R; cin >> L >> R;
    s[L][R]++;
  }
  
  REP1(i,N) {
    REP1(j,N) {
        s[i][j] += s[i-1][j];
        s[i][j] += s[i][j-1];
        s[i][j] -= s[i-1][j-1];
    }
  }

  REP1(i,Q) {
    int p,q;
    cin >> p >> q;
    cout << s[q][q] - s[p-1][q] - s[q][p-1] + s[p-1][p-1] << endl;
  }
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 100 + 10;
const int MOD = 1e9 + 7;

int32_t main(){
    boost;

    
    //code
    
    int n , x;
    cin >> n >> x;
    int a[n];
    for(int i = 0 ; i < n ; ++i){
    	cin >> a[i];
    }

    int rem , ans = 0;
    for(int i = 0 ; i < n-1 ; ++i){
    	if(a[i] + a[i+1] > x){
    		// if(a[i+1] >= a[i]){
    			rem = (a[i+1] + a[i] - x);
    			ans += rem;
    			if(a[i+1] >= rem)
    				a[i+1] -= rem;
    			else{
    				rem -= a[i+1];
    				a[i] -= rem;
    				a[i+1] = 0;
    			} 
    		// }
    		// else{
    		// 	rem = a[i] + a[i+1] - x;
    		// 	ans += rem;
    		// 	if(a[i] >= rem){
    		// 		a[i] -= rem; 
    		// 	}
    		// 	else{
    		// 		rem -= a[i];
    		// 		a[i] = 0;
    		// 		a[i+1] -= rem;
    		// 	}
    		// }
    	}
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a=scanner.nextInt();
		int b=scanner.nextInt();
		int c=scanner.nextInt();
		int count=0;
		while(true) {
			if(c%a==0) {
				count=count+1;
			}
			if(a==b) {
				break;
			}

			a=a+1;

		}
		System.out.println(count);
	}
}




Measured memory_bytes: 26252
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int Nod = 0, x, pow = 1;
  int n, N, S = 0;
  string Number;

  cin >> N;

//桁数計算
n = N;
while(n != 0){
  n = n / 10;
  Nod++;
}

vector<int> vec(Nod);

//桁ごとの数字を求める
n = N;
for(int i = Nod; i > 0; i--){
  //10^Nod-i乗を計算
  for(int j = 0; j < i - 1; j++){
    pow = pow * 10;
  }
  
  //桁数ごとに格納
  vec.at(i-1) = n / pow;
  n = n - vec.at(i-1) * pow;  

  pow = 1; //powを初期化

}

for(int i = 0; i < Nod; i++){
  S = S + vec.at(i);
}

if(N % S == 0){
  cout << "Yes" << endl;
}
else{
  cout << "No" << endl;
}

}


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

namespace output{
    void __(short x){cout<<x;}
    void __(unsigned x){cout<<x;}
    void __(int x){cout<<x;}
    void __(long long x){cout<<x;}
    void __(unsigned long long x){cout<<x;}
    void __(double x){cout<<x;}
    void __(long double x){cout<<x;}
    void __(char x){cout<<x;}
    void __(const char*x){cout<<x;}
    void __(const string&x){cout<<x;}
    void __(bool x){cout<<(x?"true":"false");}
    template<class S,class T>
    void __(const pair<S,T>&x){__(DEBUG?"(":""),__(x.first),__(DEBUG?", ":" "),__(x.second),__(DEBUG?")":"");}
    template<class T>
    void __(const vector<T>&x){__(DEBUG?"{":"");bool _=0;for(const auto&v:x)__(_?DEBUG?", ":" ":""),__(v),_=1;__(DEBUG?"}":"");}
    template<class T>
    void __(const set<T>&x){__(DEBUG?"{":"");bool _=0;for(const auto&v:x)__(_?DEBUG?", ":" ":""),__(v),_=1;__(DEBUG?"}":"");}
    template<class T>
    void __(const multiset<T>&x){__(DEBUG?"{":"");bool _=0;for(const auto&v:x)__(_?DEBUG?", ":" ":""),__(v),_=1;__(DEBUG?"}":"");}
    template<class S,class T>
    void __(const map<S,T>&x){__(DEBUG?"{":"");bool _=0;for(const auto&v:x)__(_?DEBUG?", ":" ":""),__(v),_=1;__(DEBUG?"}":"");}
    void pr(){cout<<"\n";}
    template<class S,class... T>
    void pr(const S&a,const T&...b){__(a);if(sizeof...(b))__(' ');pr(b...);}
}

using namespace output;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,char> pic;
typedef pair<double,double> pdd;
typedef pair<ld,ld> pld;
typedef vector<int> vi;
typedef vector<ll> vl;

#define pb push_back
#define fox(i,x,y) for(int i=(x);i<=(y);i++)
#define foxr(i,x,y) for(int i=(y);i>=(x);i--)

const int MN = 5e5+5;
ll N, i, j, in[MN], ans, dp[MN];
string s; vi adj[MN]; queue<int> q;

int main(){
    cin >> s; N = (ll)s.size();
    s.insert(s.begin(),' ');
    for(i=1;i<=N;i++){
        if(s[i]=='>') in[i]++, adj[i+1].pb(i);
        else in[i+1]++, adj[i].pb(i+1);
    }
    for(i=1;i<=N+1;i++){
        if(!in[i]) q.push(i);
    }
    while(q.size()){
        int x=q.front(); q.pop();
        ans += dp[x];
        for(auto v : adj[x]){
            dp[v]=max(dp[v],dp[x]+1);
            if(!(--in[v])) q.push(v);
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 35844
N=int(input())
A=list(map(int,input().split()))
Alice=0
Bob=0

for i in range(1,N+1):
  if i%2==0:
    pick_bob=max(A)
    Bob+=pick_bob
    A.remove(pick_bob)
  else:
    pick_alice=max(A)
    Alice+=pick_alice
    A.remove(pick_alice)
    
print(Alice-Bob)

Measured memory_bytes: 3060
#include <vector>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#define R register
inline int read(){
	R int x; R bool f; R char c;
	for (f=0; (c=getchar())<'0'||c>'9'; f=c=='-');
	for (x=c^'0'; (c=getchar())>='0'&&c<='9'; x=(x<<1)+(x<<3)+(c^'0'));
	return f?-x:x;
}
#define M (1<<18)
#define MN 200005
int T[M<<1],n,q,cost[MN],cnt;
std::vector<int> rang[MN];
inline void rw(int k,int v){for (k+=M; k; k>>=1) if (T[k]<=v) return; else T[k]=v;}
inline int query(int l,int r){
	R int res=0x3f3f3f3f;
	for (l+=M-1,r+=M+1; l^r^1; l>>=1,r>>=1){
		if (~l&1) res=std::min(T[l^1],res);
		if ( r&1) res=std::min(T[r^1],res);
	}return res;
}
int main(){
	n=read();for (R int i=1; i<=n; ++i)
		cost[i]=read()?1:-1,cnt+=(bool)(!(~cost[i]));
	q=read();for (R int i=1,x,y; i<=q; ++i)
		x=read(),y=read(),rang[x].push_back(y);
	memset(T,0x3f,sizeof(T));rw(0,0);
	for (R int i=1; i<=n; ++i){
		for (auto j : rang[i]){
			R int res = T[i+M-1];
			res=std::min(res,query(std::max(i-1,1),j));
			rw(j,res);
		}rw(i,T[i+M-1]+cost[i]);
	}
	printf("%d\n",T[n+M]+cnt);
	return 0;
}

Measured memory_bytes: 11776
from sys import stdin
H,W = [int(x) for x in stdin.readline().rstrip().split()]
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
A = [ind+1 for ind,j in enumerate(A) for i in range(j)]
for i in range(H):
    if i % 2 == 0:
        for j in A[i*W:i*W+W]:
            print(j,end=" ")
    else:
        for j in A[i*W:i*W+W][::-1]:
            print(j,end=" ")
    print("")

Measured memory_bytes: 3880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false


int main(void){
    ll X;
    cin >> X;
    X-=400;
    X/=200;
    cout << 8-X << endl;
    
    
    return 0;
}



Measured memory_bytes: 3628
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int h,w;
string s[440];
bool vis[440][440]={false};
int typ[2];
int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};
void dfs(int i, int j)
{
	vis[i][j]=true;
	if(s[i][j]=='#')
		++typ[0];
	else
		++typ[1];
	for(int k=0;k<4;++k)
	{
		int x=i+dx[k];
		int y=j+dy[k];
		if(x>=0&&x<h&&y>=0&&y<w&&vis[x][y]==false&&s[i][j]!=s[x][y])
			dfs(x,y);
	}
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli res=0ll;
    cin>>h>>w;
    for(int i=0;i<h;++i)
    	cin>>s[i];
    for(int i=0;i<h;++i)
    	for(int j=0;j<w;++j)
    	{
    		if(vis[i][j])
    			continue;
    		if(s[i][j]=='.')
    			continue;
    		typ[0]=0;
    		typ[1]=0;
    		dfs(i,j);
    		res+=1ll*typ[0]*typ[1];
    	}
    cout<<res<<endl;
}

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

namespace AGC002
{
    public class A
    {
        private void Run()
        {
            var input = Console.ReadLine().Trim().Split();
            var A = long.Parse(input[0]);
            var B = long.Parse(input[1]);
            if (A <= 0 && 0 <= B) { Console.WriteLine("Zero "); }
            else if (0 < A) { Console.WriteLine("Positive"); }
            else { Console.WriteLine((B - A) % 2 == 0 ? "Negative" : "Positive"); }
        }

        public static void Main()
        {
            var old = Console.Out;
            using (var writer = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Console.SetOut(writer);
                new A().Run();
                Console.Out.Flush();
                Console.SetOut(old);
            }
        }
    }
}


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

typedef long long ll;
ll INF = 1e+18;


int main() 
{
  int a; cin >> a;
  cout << a + (a * a) + (a * a * a) << endl;
}


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

int main() {
  int a; cin >> a;
  string s; cin >> s;
  cout << ((a>=3200) ? s : "red") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int cards[128][14] = {{0}};
    int i, N;
    scanf("%d", &N);
    for(i = 0; i < N; i++) {
        char c; int cn;
        scanf("%c", &c); 
        scanf("%c %d", &c, &cn);
        cards[c][cn] = 1;
    }

    for(i = 1; i <= 13; i++) {

        if(cards['S'][i] == 0) {
            printf("S %d\n", i);
        }
    }
    for(i = 1; i <= 13; i++) {

        if(cards['H'][i] == 0) {
            printf("H %d\n", i);
        }
  }
  for(i = 1; i <= 13; i++) {

        if(cards['C'][i] == 0) {
            printf("C %d\n", i);
        }
  }
  for(i = 1; i <= 13; i++) {

        if(cards['D'][i] == 0) {
            printf("D %d\n", i);
        }
  }

}



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

int main(){
  int K, S;
  int count = 0;
  cin >> K >> S;
  for(int i = 0; i <= K;i++){
    for(int j = 0; j <= K; j++){
      if(0<= (S-i-j)&(S-i-j)<=K){
        count++;
      }
    }
  }
  cout << count << endl;
}


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

#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define VPII vector<PII>
#define LD long double
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000 // array max range

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(11);
    cerr << fixed << setprecision(6);
    string s;
    cin >> s;
    if(s[s.size()-1] == 's'){
        cout << s + "es" << endl;
    }else{
        cout << s + "s" << endl;
    }
    return 0;
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a, b) ((a) > (b) ? (a) : (b))
int main(void)
{
long N;

  scanf("%ld", &N);
  if (N%10 == 7) {
    printf("Yes\n");
  } else if ((N/10)%10 == 7) {
    printf("Yes\n");
  } else if ((N/100) == 7) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
    
  return 0;
}


Measured memory_bytes: 1644
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   int N;
   cin >> N;
   int H[N];
   int sum[N];
   int ans = 0;
   memset(sum, 0, sizeof(sum));
   for (int i = 0; i < N; i++) cin >> H[i];
   for (int i = N - 2; i >= 0; i--) {
      if (H[i + 1] <= H[i]) sum[i] = sum[i + 1] + 1;
      chmax(ans, sum[i]);
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>

using namespace std;

int n , m;

inline int check(int x) {
	register int sum = 0;
	while(x) {
		sum += x % 10;
		x /= 10;
	}
	return sum;
}

int main() {
	
	cin >> n;
	
	m = check(n);
	
	if(n%m == 0)	puts("Yes");
	else	puts("No");
	
	return 0;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

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

    vector<lli> divider_n;
    for(lli i = 1; i * i <= n; ++i){
        if(n % i == 0){
            divider_n.push_back(i);
            if(i * i != n){
                divider_n.push_back(n / i);
            }
        }
    }

    lli ans = 0;
    for(lli i = 1; i < divider_n.size(); ++i){
        lli m = divider_n[i] - 1;
        //cout << "m[" << i << "] = " << m << endl;
        //cout << n << " / " << m << " = " << n / m << endl;
        //cout << n << " % " << m << " = " << n % m << endl;
        if(n / m == n % m){
            ans += m;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
	int H, W;
	cin >> H >> W;
	vector<string> N(H);
	for(int i = 0; i < H; i++){
		cin >> N.at(i);
	}
	for(int i = -2; i < W; i++){
		cout << "#";
    }
	cout << endl;
	for(int i = 0; i < H; i++){
		cout << "#" << N.at(i) << "#" << endl;
    }
	for(int i = -2; i < W; i++){
		cout << "#";
    }
}

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

int main()
{
    int n;
    double ans;
    cin >> n;
    vector<double> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    ans = ( a[0] + a[1] ) / 2;
    for (int i=2; i<n; i++) {
        ans = ( ans + a[i] ) / 2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
   cin>>n;
   map<int,int>mp;
   int no = 1;
   for(int i=0; i<n; i++)
   {
       int x;
       cin>>x;
       if(mp[x])no=0;
       mp[x]=1;
   }
   if(no)cout<<"YES\n";
   else cout<<"NO\n";
}


Measured memory_bytes: 9600
#include "bits/stdc++.h"
using namespace std;
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
int main(){
    int a,b;
    cin>>a>>b;
    if(a==b){
        cout<<"Draw"<<endl;
    }else if(a==1){
        cout<<"Alice"<<endl;
    }else if(b==1){
        cout<<"Bob"<<endl;
    }else if(a>b){
        cout<<"Alice"<<endl;
    }else if(b>a){
        cout<<"Bob"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pi 3.1415926536
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define N 1000000007
#define INF (1ll<<60) - 1
#define M 998244353
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define nrep(i,a,b) for(int i=a;i>=b;i--)
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t,i,j,l,h,x,k,y,q,n;
    cin>>t;
    cout<<t+t*t+t*t*t;	
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io();
    double n, d; cin >> n >> d;
    vector< vector<double> > v(n, vector<double>(d));
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < d; ++j){
            cin >> v[i][j];
        }
    }
    int ans = 0;
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            double val = 0;
            for(int k = 0; k < d; ++k){
                val += (abs(v[i][k] - v[j][k]) * abs(v[i][k] - v[j][k]));
            }
            val = sqrt(val);
            if(val == (ll)val) ++ans;
        }
    }    
    return cout << ans << '\n', 0;
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
const int mod = 1000000007;
ll modpow(ll a, int b) { return b ? modpow(a * a % mod, b / 2) * (b % 2 ? a : 1) % mod : 1; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }



void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  int n, W;
  cin >> n >> W;
  int maxv = 100005; // debuged
  vector<ll> dp(maxv, INF);
  dp[0] = 0;

  rep(i, n) {
    int w, v;
    cin >> w >> v;
    for (int j = maxv; j >= 0; --j) {
      chmin(dp[v + j], dp[j] + w);
    }
  }
  for (int i = maxv - 1; i >= 0; --i) {
    if (dp[i] <= W) {
      cout << i << endl;
      return;
    }
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
  ll n,k;
  cin >> n >> k;
  vll a(n);
  rep(i,0,n) cin >> a[i];
  
  vll sum;
  rep(i,0,n){
    ll s=0;
    rep(j,i,n){
     s+=a[j];
     sum.eb(s); 
    }
  }
  sort(all(sum));
  
  ll ans=0;
  repr(bit,40,0){
    ll now=ans+(1ll<<bit);
    ll cnt=0;
    for(ll c:sum) {
      if((now&c)==now) cnt++;
    }
      if(cnt>=k) ans=now;
  }
 cout << ans << endl;
}

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

Measured memory_bytes: 6384
#include <iostream>
#include <fstream>
#include <string>
#include<cmath>
#include<queue>

using namespace std;

int main()
{

    char a[30];
    string s;
    int count = 0;
    int i,j,n;

    cin >> s;
    n = s.length();
    
    for (i = 0 ; i <= n ; i++)
    {
        a[i]=s[i];
    }
    for (i = 0 ; i <= n-1 ; i++)
    {
        for (j = i + 1 ; j <= n+1 ; j++)
        {
            if (a[i] == a[j])
            {
                count = count + 1;
            }
        }
    }
    if (count != 0)
        cout << "no" << endl;
    else
        cout << "yes" << endl;
};

Measured memory_bytes: 256
n,m,x,y = map(int, input().split())
X = list(map(int,input().split()))
Y = list(map(int,input().split()))

X = sorted(X)
Y = sorted(Y)

if (X[n-1]<Y[0]) and X[n-1]<y and Y[0]>x:
    print('No War')
else:
    print('War')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Nmax = 5000;
const ll P = 1e9+7;
int N, X[Nmax], Y[Nmax];
vector<vector<int>> graph;
vector<int> nchild;
vector<vector<pair<ll, ll>>> dp;
vector<ll> n_pair;

int dfs_nchild(int v, int p){
	int ret = 1;
	for(int u: graph[v]){
		if(u==p) continue;
		ret += dfs_nchild(u, v);
	}
	nchild[v] = ret;
	return ret;
}

void dfs(int v, int p){
	dp[v][0] = {1, 0};
	int n = 1;
	for(int u: graph[v]){
		if(u==p) continue;
		dfs(u, v);
		vector<pair<ll, ll>> tmp(N);
		for(int x=0; x<n; x++){
			for(int y=0; y<nchild[u]; y++){
				tmp[x+y+1].first += dp[v][x].first * dp[u][y].first;
				tmp[x+y+1].first += dp[v][x].second * dp[u][y].second;
				tmp[x+y+1].first %= P;
				tmp[x+y+1].second += dp[v][x].first * dp[u][y].second;
				tmp[x+y+1].second += dp[v][x].second * dp[u][y].first;
				tmp[x+y+1].second %= P;
				tmp[x].first += dp[v][x].first * dp[u][y].second % P * n_pair[y+1];
				tmp[x].first += dp[v][x].second * dp[u][y].first % P * n_pair[y+1];
				tmp[x].first %= P;
				tmp[x].second += dp[v][x].first * dp[u][y].first % P * n_pair[y+1];
				tmp[x].second += dp[v][x].second * dp[u][y].second % P * n_pair[y+1];
				tmp[x].second %= P;
			}
		}
		n += nchild[u];
		dp[v] = tmp;
		//cout << v <<" "<<u<< endl;
		//for(int x=0; x<nchild[v]; x++) cout << dp[v][x].first << " ";
		//cout << endl;
		//for(int x=0; x<nchild[v]; x++) cout << dp[v][x].second << " ";
		//cout << endl;
	}
}



int main(){
	cin >> N;
	for(int i=0; i<N-1; i++){
		cin >> X[i] >> Y[i];
		X[i]--; Y[i]--;
	}
	graph.resize(N);
	for(int i=0; i<N-1; i++){
		graph[X[i]].push_back(Y[i]);
		graph[Y[i]].push_back(X[i]);
	}

	nchild.resize(N);
	dfs_nchild(0, -1);
	n_pair.resize(N+1);
	n_pair[0] = 1;
	for(int i=2; i<=N; i++){
		n_pair[i] = (i-1)*n_pair[i-2]%P;
	}

	dp.resize(N, vector<pair<ll, ll>>(N));
	dfs(0, -1);

	ll ans = 0;
	for(int x=0; x<N; x++){
		ans -= dp[0][x].second * n_pair[x+1];
		ans += dp[0][x].first * n_pair[x+1];
		ans += P;
		ans %= P;
	}
	cout << ans << endl;

	return 0;
}


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

#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)

bool isSorted(vector<ll> v, ll size) {
    ll lastNum = v[0];
    for (ll i = 1; i < size; i++) {
        if (lastNum > v[i]) {
            return false;
        }
        lastNum = v[i];
    }
    return true;
}

int main(int argc, const char * argv[]) {
    
    ll N;
    cin >> N;
    vector<ll> data = vector<ll>(N, 0);
    for (ll i = 0; i < N; i++) {
        cin >> data[i];
    }
    
    bool result = false;
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < N; j++) {
            ll temp = data[j];
            data[j] = data[i];
            data[i] = temp;
            result = result || isSorted(data, N);
            data[i] = data[j];
            data[j] = temp;
        }
    }
    
    cout << (result ? "YES" : "NO");
    
    return 0;
}


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

int main() {
    queue <string> Q;
    map <string, int> M;
    string start = "01234567";
    Q.push( start );
    M[start] = 0;
    int dr[4] = { 0, 0, 1, -1 };
    int dc[4] = { 1, -1, 0, 0 };
    while ( !Q.empty() ) {
        string node = Q.front();
        Q.pop();

        for ( int i = 0; i < 8; i++ ) {
            if ( node[i] != '0' ) continue;
            for ( int k = 0; k < 4; k++ ) {
                string next_node = node;
                int c = i%4;
                int r = i/4;
                int nr = r + dr[k];
                int nc = c + dc[k];
                if ( nr < 0 || nr >= 2 || nc < 0 || nc >= 4 ) continue;
                int ni = nr * 4 + nc;
                swap( next_node[i], next_node[ni] );
                if ( M.count( next_node ) ) continue;
                M[next_node] = M[node] + 1;
                Q.push( next_node );
            }
        }
    }

    int C[8];
    while ( cin >> C[0] ) {
        for ( int i = 1; i < 8; i++ ) cin >> C[i];
        string s;
        for ( int i = 0; i < 8; i++ ) s += (char)( C[i] + '0' );
        cout << M[s] << endl;
    }
}

Measured memory_bytes: 2136
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 2e5+5;
int main() {
	ll a,b,n;
	cin>>a>>b>>n;
	ll maxx = 0;
//	cout<<maxx<<endl;
	maxx = max((a*(min(b-1,n)))/b,maxx);
	cout<<maxx<<endl;
    return 0;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<long long> a(n), b(n);
  for(int i = 0; i < n; ++i) cin >> a[i] >> b[i];
  long long ans = 0;
  for(int i = n - 1; i >= 0; --i){
    a[i] += ans;
    if(a[i] % b[i] == 0) continue;
    ans += b[i] - a[i] % b[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792