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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long H = sc.nextLong();
		long W = sc.nextLong();

		if (H == 1 || W == 1) {
			System.out.println("1");
		} else if ((H * W) % 2 == 0){
			System.out.println((H*W)/2);
		} else {
			System.out.println(((H*W)+1)/2);
		}
	}
}

Measured memory_bytes: 20560
#include <cstdio>
#include <iostream>
#include <iomanip>

#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>

using namespace std;

#define MAX_N 100
double x[MAX_N];
double y[MAX_N];
int town[MAX_N];

int main() {

  // -----------------------------
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  // input
  int N;
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> x[i] >> y[i];
  }
  
  // -----------------------------
  
  for (int i = 0; i < N; i++) {
    town[i] = i;
  }

  sort(town, town + N);

  double ave = 0.0;
  int num = 0;
  
  do {

    double temp;
    double total_dist = 0.0;
    
    for (int i = 0; i < N - 1; i++ ) {
      
      temp = pow( x[ town[i+1] ] - x[ town[i] ], 2) + pow( y[ town[i+1] ] - y[ town[i] ], 2);
      temp = sqrt(temp);
      total_dist += temp;
      
    }

    ave = ave + total_dist;
    num++;
    
  } while (std::next_permutation(town, town + N));

  cout << fixed << (double) ave / num << endl;
  
}


Measured memory_bytes: 892
#include <iostream>
#include <string>
 
int main(void)
{
    std::string cards, cardsShuffled;
    while (std::cin >> cards, cards != "-")
    {
        int shuffleNum;
        std::cin >> shuffleNum;
        int h = 0;
        for (int i = 0; i < shuffleNum; i++)
        {
            int temp;
            std::cin >> temp;
            h += temp;
        }
        h %= cards.size();
        cardsShuffled = cards.substr(h, cards.size() - h) + cards.substr(0, h);
        std::cout << cardsShuffled << '\n';
        cards.clear();
        cardsShuffled.clear();
    }
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
/////////////////////////(๑•﹏•๑｀)/////////////////////////
int main() {
	ll N; SCLLD(N);
	vector<ll> A,B,C;
	REP(i,N){
		ll x; SCLLD(x);
		A.PB(x);
	}
	REP(i,N){
		ll x; SCLLD(x);
		B.PB(x);
	}
	REP(i,N){
		ll x; SCLLD(x);
		C.PB(x);
	}

	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	sort(C.begin(),C.end());

	ll ans = 0;

	REP(i,N){
		ll b = B[i];
		ll ait = lower_bound(A.begin(),A.end(),b) - A.begin();
		ll cit = lower_bound(C.begin(),C.end(),b+1) - C.begin();

		ll a = ait;
		ll c = N - cit;

		ans += a * c;
	}

	PRINTLLD(ans);
	return 0;
}

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

  ld r;
  cin >> r;

  cout << 2 * r * 3.1415 << '\n';




  
  return 0;
}

Measured memory_bytes: 3804
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

//#define int ll

using namespace std;



signed main(void)
{
	//変数の宣言
	int n,m;
	int h,w;
	static char s[20][1010];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int temp3=0;
	static int vec[1010];
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;
	static char stemp[100010];
	
	//データの読み込み


	scanf("%d %d %d",&h,&w,&m);
//	scanf_s("%d %d %d",&h,&w,&m);


//	scanf("%s",&s);
//	scanf_s("%s",&s,110);




/*	//scanf("%c",&dummy);
	scanf_s("%c",&dummy);
	for(i=0;i<n;i++){
//		scanf("%c",&s[i]);
		scanf_s("%c",&s[i]);
	}*/


	for(i=0;i<h;i++){
		scanf("%s",&s[i]);
//		scanf_s("%s",&s[i],1010);
	}


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

//	clock_t start=clock();

	int ExpH=(1<<(h-1));
	int cut[20];
	static int vec2[1010];
	int reset=0;

	ans=INFINT;

	for(i=0;i<ExpH;i++){
		for(j=0;j<h;j++){
			if(j==0){
				cut[j]=0;
			}else if(i&(1<<(j-1))){
				cut[j]=cut[j-1];
			}else{
				cut[j]=cut[j-1]+1;
			}
		}

		/*for(j=0;j<h;j++){
			printf("%d",cut[j]);
		}
		printf("\n");*/

		for(j=0;j<h;j++){
			vec[j]=0;
		}

		temp=0;

		for(j=0;j<w;j++){
			for(k=0;k<h;k++){
				vec2[k]=0;
			}

			for(k=0;k<h;k++){
				vec2[cut[k]]=vec2[cut[k]]+(s[k][j]-'0');
			}

			flag=1;
			for(k=0;k<h;k++){
				if(vec[k]+vec2[k]>m){
					flag=0;
				}
			}

			if(flag==1){
				for(k=0;k<h;k++){
					vec[k]=vec[k]+vec2[k];
				}
				reset=1;
			}else if(flag==0 && reset==1){
				for(k=0;k<h;k++){
					vec[k]=0;
				}
				temp++;
				j--;
				reset=0;
			}else{
				temp=INFINT;
				continue;
			}
		}

		/*for(j=0;j<h;j++){
			printf("%d",cut[j]);
		}
		printf(":%d+%d\n",temp,cut[h-1]);*/

		ans=min(ans,temp+cut[h-1]);
	}

	printf("%d",ans);

//	clock_t end=clock();

	//	printf("計算部分終了\n");

	//出力
	
	//printf("%d",(d[i-1][j-1]+1)/2);

//	printf("time=%lf",(double)(end-start)/CLOCKS_PER_SEC);
	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 256
package main

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

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b > 0 {
		a, b = b, a%b
	}
	return a
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

type segmentTree struct {
	data   []int
	offset int
}

func newSegmentTree(n int) segmentTree {
	var result segmentTree
	t := 1
	for t < n {
		t *= 2
	}
	result.offset = t - 1
	result.data = make([]int, 2*t-1)
	return result
}

func (st segmentTree) updateAll(a []int) {
	for i, v := range a {
		st.data[st.offset+i] = v
	}
	for i := st.offset - 1; i > -1; i-- {
		st.data[i] = gcd(st.data[i*2+1], st.data[i*2+2])
	}
}

func (st segmentTree) update(index, value int) {
	i := st.offset + index
	st.data[i] = value
	for i >= 1 {
		i = (i - 1) / 2
		st.data[i] = gcd(st.data[i*2+1], st.data[i*2+2])
	}
}

func (st segmentTree) query(start, stop int) int {
	result := 0
	l := start + st.offset
	r := stop + st.offset
	for l < r {
		if l&1 == 0 {
			result = gcd(result, st.data[l])
		}
		if r&1 == 0 {
			result = gcd(result, st.data[r-1])
		}
		l = l / 2
		r = (r - 1) / 2
	}
	return result
}

func main() {
	N := readInt()
	A := readInts(N)

	st := newSegmentTree(N)
	st.updateAll(A)

	result := st.query(1, N)
	for i := 1; i < N-1; i++ {
		result = max(result, gcd(st.query(0, i), st.query(i+1, N)))
	}
	result = max(result, st.query(0, N-1))

	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

func readInts(n int) []int {
	result := make([]int, n)
	for i := 0; i < n; i++ {
		result[i] = readInt()
	}
	return result
}


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

using namespace std;
#define next _next
#define y1 _y1
#define y2 _y2
#define lowbit(x) (x&(-x))
#define lc ((rt)<<1)
#define rc ((rt)<<1|1)
#define mid  ((l+r)>>1)
#define clr(a, b) memset(a,b,sizeof(a))

#ifdef __LOCAL_DEBUG__
# define _debug(fmt, ...) fprintf(stderr, "\033[94m%s: " fmt "\n\033[0m", \
    __func__, ##__VA_ARGS__)
#define dg(a) cout <<"\033[94m" <<#a << "\033[0m = "<< a << endl;
#else
#define _debug(...) ((void)0)
#define dg(a)((void)0)
#endif

typedef long long ll;
typedef long double ld;
const ld pi = acos(-1);
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const int maxn = static_cast<int>(5e3 + 7);

int cnt[maxn][maxn];

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n, m, q;
    cin >> n >> m >> q;
    while (m--) {
        int l, r;
        cin >> l >> r;
        cnt[1][r]++;
        cnt[l + 1][r]--;
    }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            cnt[i][j] += cnt[i - 1][j] + cnt[i][j - 1] - cnt[i - 1][j - 1];
    while (q--) {
        int l, r;
        cin >> l >> r;
        cout << cnt[l][r] << endl;
    }

}


Measured memory_bytes: 9728
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
  int x;
  int top = 0; //配列の一番上を表す
  int num[100];
  char s[100];

  while (scanf("%s", s) != EOF) {
    if (s[0] != '+' && s[0] != '-' && s[0] != '*') {
      num[top] = atoi(&s[0]);
      top++; //スタックに値を積んだ時点でtop++
    } else if (s[0] == '+') {
      num[top - 2] += num[top - 1];
      top--;
    } else if (s[0] == '-') {
      num[top - 2] -= num[top - 1];
      top--;
    } else if (s[0] == '*') {
      num[top - 2] *= num[top - 1];
      top--;
    }
  }

  printf("%d\n", num[0]);

  return 0;
}


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

int main(){
  int n,i,a,b,c,d,e,f,g,h;
  for(;scanf("%d",&n),n;){
    vector<pair<int,int> >v;
    for(;n--;)scanf("%d%d%d%d%d%d%d%d%d",&i,&a,&b,&c,&d,&e,&f,&g,&h),v.push_back(make_pair(a*60+b+c*60+d+e*60+f+g*60+h,i));
    sort(v.begin(),v.end());
    printf("%d\n%d\n%d\n",v[0].second,v[1].second,v[v.size()-2].second);
  }
}

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

int main(){
	string s;
	cin >> s;
	int num  = 0;
	REP(i, 3){
		if(s[i] == '1')
			num++;
	}
	cout << num << endl;
}


Measured memory_bytes: 3564
#include<iostream>
#include<string>
using namespace std;
int main(){
  int d[]={31,29,31,30,31,30,31,31,30,31,30,31};
  string s[]={"Thursday",
	      "Friday","Saturday","Sunday","Monday","Tuesday","Wednesday",};
  int i,j;
  int a,b;
  cin>>a>>b;
  while(a!=0){
    int o=0;
    for(i=1;i<a;i++) o+=d[i-1];
    o+=b-1;
    //cout << o << endl;
    cout << s[o%7] << endl;
    cin>>a>>b;
  }
  return 0;
}



Measured memory_bytes: 3208
import math

def main():
	N = int(input())
	c = [[0] * 10 for i in range(10)]
	for i in range(1, N + 1):
		digit = int(math.log10(i)) + 1
		c[i // (10 ** (digit - 1))][i % 10] += 1

	cnt = 0
	for i in range(10):
		for j in range(10):
			cnt += c[i][j] * c[j][i]

	print(cnt)



main()

Measured memory_bytes: 9372
#include<stdio.h>
char s[101];
a(p){return s[p]==0?0:s[p]=='0'?x(p+1):y(p+1);}
b(p){return s[p]==0?1:s[p]=='0'?y(p+1):x(p+1);}
w(p){return s[p]==0?0:s[p]=='0'?b(p+1):y(p+1);}
x(p){return s[p]==0?0:s[p]=='0'?0:z(p+1);}
y(p){return s[p]==0?0:s[p]=='0'?x(p+1):0;}
z(p){return s[p]==0?0:s[p]=='0'?w(p+1):b(p+1);}
main(n)
{
	for(;scanf("%s",s),s[0]!='#';)
		puts(a(0)?"Yes":"No");
	exit(0);
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FL          freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 1 * 1e5 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-9;
int dx[] = {1, 0}, dy[] = {0, 1};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0 ,1, 1, 1, 0, -1, -1, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int sumMod(int a, int b){return 0LL + a + b > mod ? a + b - mod : a + b;}
int H, W;
char v[1005][1005];
int dp[1005][1005];
int f(int i, int j){
    if(i == H - 1 && j == W - 1)
        return 1;
    int &ans = dp[i][j];
    if(ans == -1){
        ans = 0;
        for(int k = 0; k < 2; k++){
            int x = i + dx[k];
            int y = j + dy[k];
            if(x >= 0 && x < H && y >= 0 && y < W && v[x][y] == '.')
                //ans = (ans % mod + f(x, y)% mod) % mod;
                ans = sumMod(ans, f(x, y));
        }
    }
    return ans;
}
int main(){
    //FL;
    FIN;
    cin >> H >> W;
    for(int i = 0; i < H; i++)
        for(int j = 0; j < W; j++)
            cin >> v[i][j];
    cls(dp, -1);
    cout << f(0, 0) << '\n';
    EjecuteTime;
    return 0;
}       

Measured memory_bytes: 8680
#include<iostream>
using namespace std;
int a,b,c,d;
string s;
main(){
    cin>>a>>b>>c>>d;
    for(int i=0;i<d-b;i++)s+='U';
    for(int i=0;i<c-a;i++)s+='R';
    for(int i=0;i<d-b;i++)s+='D';
    for(int i=0;i<c-a;i++)s+='L';
    s+='L';
    for(int i=0;i<d-b+1;i++)s+='U';
    for(int i=0;i<c-a+1;i++)s+='R';
    s+="DR";
    for(int i=0;i<d-b+1;i++)s+='D';
    for(int i=0;i<c-a+1;i++)s+='L';
    s+='U';
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;

long long factorial(long long N){
    long long res = 1;
    for(long long i = 2; i <= N; i++){
        res = (res * i) % MOD;
    }
    return res;
}

int main(){
    long long N, M;
    cin >> N >> M;
    long long ans = 0;
    long long dis = abs(N - M);
    if(dis < 2){
        ans = factorial(N) * factorial(M) % MOD;
        if(dis == 0)ans = ans * 2 % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
Data = []
for _ in range(H):
    List = list(map(int,input().split()))
    Data.append(List)
Ans = []
for i in range(H-1):
    for j in range(W):
        if Data[i][j] % 2 != 0:
            Data[i][j] -= 1
            Data[i+1][j] += 1
            Ans.append([i,j,i+1,j])
for j in range(W-1):
    if Data[H-1][j] % 2 != 0:
        Data[H-1][j] -= 1
        Data[H-1][j+1] += 1
        Ans.append([H-1,j,H-1,j+1])

print(len(Ans))
for ans in Ans:
    print( "{} {} {} {}".format(ans[0]+1,ans[1]+1,ans[2]+1,ans[3]+1))
    

Measured memory_bytes: 25960
s = input()
n = len(s)
R = [0]*n
L = [0]*n

r = -1
l = -1
for i in range(n):
  if s[-1-i] == 'R':
    r += 1
    R[-1-i] = r
  else:
    r = -1
  
  if s[i] == 'L':
    l += 1
    L[i] = l
  else:
    l = -1
    
ans = [0]*n
for i in range(n):
  if s[i] == 'R':
    p = R[i]  
    if p % 2 == 1:
      p += 1
    ans[i+p] += 1
  else:
    p = L[i]  
    if p % 2 == 1:
      p += 1
    ans[i-p] += 1
    
print(*ans)    

Measured memory_bytes: 15224
N = int(input())
A = [int(i) for i in input().split(' ')]

AA = []
for i,a in enumerate(A):
    AA.append(tuple([a,i]))

AA = sorted(AA,reverse=True)
DP =[]
for _ in range(N+1):
    DP.append([0]*(N+1))

for i,a in enumerate(AA):
    for x in range(i+1):
        y = i - x
        if x+ 1 <= N:
            DP[x+1][y] = max(DP[x+1][y], DP[x][y]+a[0]*abs(x-a[1]))
        if y+1 <= N:
            DP[x][y+1] = max(DP[x][y+1], DP[x][y]+a[0]*abs(N- 1 - y - a[1]))

MAX = 0
for x in range(N):
    y = N - x
    MAX = max(DP[x][y],MAX)

print(MAX)

Measured memory_bytes: 106124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderGrandContest010
{
    class ProgramA
    {
        private const string kYes = "YES";
        private const string kNo = "NO";
        static void Main(string[] args)
        {
            string szTotal = Console.ReadLine();
            int nTotal = int.Parse(szTotal);
            long[] arr = new long[nTotal];

            int nEven = 0;
            string szLine = Console.ReadLine();
            string[] szSplittedLine = szLine.Split(' ');
            
            for (int i = 0; i < szSplittedLine.Length; ++i)
            {
                long a = long.Parse(szSplittedLine[i]);
                if( a % 2 == 0) { ++nEven; }
                arr[i] = a;
            }

            int nOdd = nTotal - nEven;
            
            // 奇数が1個残る場合は無理
            if( nOdd % 2 != 0) { Console.WriteLine(kNo); return; }

            // 奇数ペアを消し、半分の偶数が生まれる
            nEven += nOdd / 2;
            // あ、もう必ず1個の偶数が残る
            Console.WriteLine(kYes);
        }
    }
}


Measured memory_bytes: 12504
s = gets.chomp.split('')
all = ('a'..'z').to_a
if s.size == 26
  if s.join == all.reverse.join
    puts (-1)
  else
    s.pop
    loop do
      if s[-1] == 'z'
        s.pop
        next
      else
        s[-1] = all[all.find_index(s[-1]) + 1]
      end
      if s.uniq.size == s.size
        puts s.join
        exit
      end
    end
  end
else
  puts s.join + (all - s).first
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define line cout<<"------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
#define inf (int)1e9+7
using namespace std;
ll n ;
ll w[109],val[109];
ll dp[100009];
ll weight;
int  main()
{
    cin>>n>>weight;
    for(ll i=1;i<=100007;i++) dp[i]=inf;
    for(ll i=0;i<n;i++)
    {
        cin>>w[i]>>val[i];
        for(ll j=100005;j>=val[i];j--)
        {
            dp[j]=min(dp[j],dp[j-val[i]]+w[i]);
        }
    }
    for( ll i=100005;i>=0;i--)
    {
        if(dp[i]<=weight)
        {
            cout<<i<<endl;
            return 0;
        }
    }



}


Measured memory_bytes: 1024
import sys,os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
    from math import gcd
else:
    from fractions import gcd
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    MOD = 10**9+7

    N,M = LMIIS()
    A = [0]*N
    for i in range(N):
        A[i] = input()
    B = [0]*M
    for i in range(M):
        B[i] = input()
    if M > N:
        print('No')
        return
    for i in range(N-M+1):
        for j in range(N-M+1):
            found = True
            for k in range(M):
                for l in range(M):
                    if A[i+k][j+l] != B[k][l]:
                        found = False
                        break
                if not found:
                    break
            if found:
                print('Yes')
                return
    print('No')



if __name__ == '__main__':
    main()

Measured memory_bytes: 64364
#include <stdio.h>

int main()
{
    int times;
    scanf("%d",&times);
    int second, minute, hour;
    second = times % 60;
    minute = times / 60;
    hour = minute /60;
    minute = minute % 60;
    printf("%d:%d:%d\n",hour,minute,second);
    return 0;
}


Measured memory_bytes: 2140
from math import factorial
MOD = 10**9+7

def com(n, r):
    X = Y = 1
    if r < 0 or n < r:
        return 0
    if n-r < r:
        r = n-r
    for i in range(1, r+1):
        Y = Y*i % MOD
        X = X*(n-i+1) % MOD
    Y = pow(Y, MOD-2, MOD)
    return X*Y

x, y = list(map(int, input().split()))

dif = max(x, y) - min(x, y)
small = min(x, y)
tie = small-dif
res = tie % 3
num = tie / 3  

if res != 0:
  print(0)
else:
  print(com(int(num*2+dif), int(num))%MOD)
  

Measured memory_bytes: 3064
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m = LI()
graph = [[] for _ in range(n)]
for _ in range(m):
    a,b = LI()
    graph[a-1].append(b-1)

def dfs(s,lst,graph,check):
    lst.append(s)
    check[s] = False
    for v in graph[s]:
        if check[v]:
            dfs(v,lst,graph,check)
    return lst
L = []
for i in range(n):
    c = [True]*n
    l = dfs(i,[],graph,c)
    l.sort()
    L.append(l)

ans = [[] for _ in range(n)]
for i in range(n):
    for j in L[i]:
        if i in L[j]:
            ans[i].append(j+1)
for i in range(n):
    print(*ans[i])


Measured memory_bytes: 9936
A=int(input())
B=int(input())
C=int(input())
X=int(input())

M=[]
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            V=500*i+100*j+k*50
            M.append(V)
print(M.count(X))

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

class Dinic:
    def __init__(self, v):
        self.vertice = v
        self.inf = int(1e9)
        self.graph = [[] for i in range(v)]
        self.level = [0]*v
        self.iter = [0]*v
    
    def add_edge(self, fr, to, cap):
        self.graph[fr].append([to, cap, len(self.graph[to])])
        self.graph[to].append([fr, 0, len(self.graph[fr])-1])
    
    def bfs(self, s):
        self.level = [-1]*self.vertice
        que = deque([])
        self.level[s] = 0
        que.append(s)

        while que:
            v = que.popleft()
            for i in range(len(self.graph[v])):
                e = self.graph[v][i]
                if e[1] > 0 and self.level[e[0]] < 0:
                    self.level[e[0]] = self.level[v] + 1
                    que.append(e[0])
    
    def dfs(self, v, t, f):
        if v == t:
            return f
        for i in range(self.iter[v], len(self.graph[v])):
            self.iter[v] = i
            e = self.graph[v][i]
            if e[1] > 0 and self.level[v] < self.level[e[0]]:
                d = self.dfs(e[0], t, min(f, e[1]))
                if d > 0:
                    e[1] -= d
                    self.graph[e[0]][e[2]][1] += d
                    return d
        return 0
    
    def max_flow(self, s, t):
        flow = 0
        while True:
            self.bfs(s)
            if self.level[t] < 0:
                return flow
            self.iter = [0]*self.vertice

            f = self.dfs(s, t, self.inf)
            while f:
                flow += f
                f = self.dfs(s, t, self.inf)
    
def main():
    n = int(input())
    red = [list(map(int, input().split())) for _ in range(n)]
    blue = [list(map(int, input().split())) for _ in range(n)]
    
    flow = Dinic(n*2+2)
    for i in range(n):
        flow.add_edge(0, i+1, 1)
        flow.add_edge(n+i+1, 2*n+1, 1)
        for j in range(n):
            if red[i][0] < blue[j][0] and red[i][1] < blue[j][1]:
                flow.add_edge(i+1, n+j+1, 1)
    
    
    ans = flow.max_flow(0, 2*n+1)
    print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9704
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

int main() {
	int a[1010][1010];
	f(i, 1010) {
		f(j, 1010)a[i][j] = 0;
	}
	int h, w, x, y, z;
	int s, ans;
	scanf("%d %d %d %d", &h, &w, &x, &y);
	f(i, y) {
		f(j, x) {
			a[i][j] = 0;
		}
		f(j, w - x) {
			a[i][j + x] = 1;
		}
	}
	f(i, h-y) {
		f(j, x) {
			a[y + i][j] = 1;
		}
		f(j, w - x) {
			a[y + i][j + x] = 0;
		}
	}
	f(i, h) {
		f(j, w) {
			printf("%d", a[i][j]);
		}
      			printf("\n");
}


	return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) string((s).rbegin(), (s).rend())
#define MP make_pair
#define X first
#define Y second

using namespace std;

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



int d[] = {-4, -1, 1, 4};

void test(){
}

int main(){


	string s = "01234567";
	map<string, int> m;
	m[s] = 0;
	queue<pair<int, string > > q;
	q.push(MP(0, s));

	while(!q.empty()){
		int pos = q.front().first;
		string s = q.front().second;
		q.pop();

		rep(i, 4){
			int npos = pos+d[i];
			if(npos < 0 || npos >= 8) continue;
			// 3-4は交換不可
			if(pos == 3 && npos == 4) continue;
			if(pos == 4 && npos == 3) continue;
			string t = s;
			swap(t[pos], t[npos]);
			if(m.find(t) != m.end()) continue;
			m[t] = m[s]+1;
			q.push(MP(npos, t));
		}
	}

	while(1){
		char c;
		string s;
		int zeropos;
		rep(i, 8){
			if(!(cin >> c))return 0;
			if(c == '0')zeropos = i;
			s += c;
		}
		cout << m[s] << endl;
	}

	return 0;
}

Measured memory_bytes: 3452
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

double a, b, x;

bool cond(double mid){
    mid = 90.0 - mid;
    mid = mid * PI /180.0;
    double taka = tan(mid) * b;
    if(taka <= a){
        return taka * b / 2.0 >= x;
    }else{
        return taka * b /2.0 / (taka * taka) * (taka * taka - (taka - a) * (taka - a)) >= x;
    }
}

int main(){
    cin >> a >> b >> x;
    x /= a;
    double l = 0.0, r = 90.0;
    REP(ttt, 30){
        double mid = (l + r)/2;
        if(cond(mid))l = mid;
        else r = mid;
    }
    cout << fixed << setprecision(13) << l << endl;
}

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

constexpr long long mod{1000000007};

int main()
{
	int N;
	scanf("%d", &N);
	std::vector<int> C(N);
	for (auto& e: C)
	{
		scanf("%d", &e);
		e--;
	}
	std::vector<long long> dp(N + 1);
	std::vector<int> pre(200000, -1);
	dp[0] = 1;
	for (int i{}; i < N; i++)
	{
		if (pre[C[i]] >= 0 && pre[C[i]] < i - 1)
			dp[i + 1] = dp[pre[C[i]] + 1];
		dp[i + 1] = (dp[i + 1] + dp[i]) % mod;
		pre[C[i]] = i;
	}
	printf("%lld\n", dp[N]);
	
	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;

int main()
{
	int N, K; cin >> N >> K;

	string S; cin >> S;

	S[K-1] = S[K-1] + 'a' - 'A';

	cout<<S<<endl;

	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define fi first
#define se second
#define int long long
//template

//main
signed main(){
  int K;cin>>K;
  if(K<1000){
    Cout(2);
    int a=K/2+1,b=K/2+1;
    if(K%2){a++;b--;}
    cout<<a<<" "<<b<<endl;
  }
  else{
    Cout(50);
    std::vector<int> v(50,K/50);
    for(int i=0;i<50;i++)v[i]+=i;
    for(int i=0;i<K%50;i++){
      for(int j=0;j<50;j++){
        if(j==i)v[j]+=50;
        else v[j]--;
      }
    }
    for(int i=0;i<50;i++){
      if(i)cout<<" ";
      cout<<v[i];
    }
    cout<<endl;
  }
}


Measured memory_bytes: 256
/*
 * Author:  heyuhhh
 * Created Time:  2020/3/8 20:03:44
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << '\n'; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;

int A, B, M;
int a[N], b[N];
int x[N], y[N], c[N];

void run() {
    cin >> A >> B >> M;
    for(int i = 1; i <= A; i++) cin >> a[i];
    for(int i = 1; i <= B; i++) cin >> b[i];
    for(int i = 1; i <= M; i++) {
        cin >> x[i] >> y[i] >> c[i];   
    }
    int ans = *min_element(a + 1, a + A + 1) + *min_element(b + 1, b + B + 1);
    for(int i = 1; i <= M; i++) {
        ans = min(ans, a[x[i]] + b[y[i]] - c[i]);   
    }
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int x,y;
  cin >> x >> y;
  for(int i=0;i<=x;i++){
    if(2*i+4*(x-i)==y){
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;


  return 0;
}


Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.Scanner;


public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
	
		ArrayList<Integer> in = new ArrayList<Integer>();
		ArrayList<Integer> out = new ArrayList<Integer>();
		for(; scanner.hasNext();)
		{
			int n = scanner.nextInt();
			if(n == 0)
			{
				int s = in.size() -1;
				out.add(in.get(s));
				in.remove(s);
			}
			else
			{
				in.add(n);
			}
		}
		
		for(Integer id : out)
		{
			System.out.println(id);
		}
	}
}

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

#define log(x) cout << (x) << endl
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
using ll = long long;

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

	ll c = 0;
	rep (i, n) {
		cin>>x;
		c += x-1;
	}

	log(c);

	return 0;
}



Measured memory_bytes: 256
/**
  *  Worg
  */
#include <iostream>
#include <algorithm>

int cost[10][10];

void Optimize() {
  for (int k = 0; k < 10; k++) {
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        cost[i][j] = std::min(cost[i][j], cost[i][k] + cost[k][j]);
      }
    }
  }
}

int main() {
  int h, w; std::cin >> h >> w;

  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      std::cin >> cost[i][j];
    }
  }

  Optimize();

  int answer = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int x; std::cin >> x;

      if (x == 1 || x == -1) continue;

      answer += cost[x][1];
    }
  }

  std::cout << answer << '\n';

  return 0;
}


Measured memory_bytes: 256
//* AuThOr GaRyMr *//
//Codeforces ID: GaryMr
//Atcoder ID: Gary
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	LL sum;
	int n;
	sum=0;
	cin>>n;
	rep(i,n){
		LL ai;
		cin>>ai;
		sum=(sum|bool(ai%2));
	}
	cout<<((sum&1)? "first":"second")<<endl;
	return 0;
}


Measured memory_bytes: 256
s=list(input())
num=[]
str1="<"
if s[0]=="<":
    num1=1
else:
    num.append(0)
    str1=">"
    num1=1
for i in range(len(s)-1):
    if str1==s[i+1]:
        num1+=1
    else:
        if str1=="<":
            str1=">"
        else:
            str1="<"
        num.append(num1)
        num1=1
num.append(num1)
ans=0
if str1=="<":
    num.append(0)
for i in range(len(num)//2):
    ans+=((num[i*2]+1)*num[i*2])//2
    ans+=((num[i*2+1]+1)*num[i*2+1])//2
    ans-=min(num[i*2],num[i*2+1])
print(ans)


Measured memory_bytes: 15136
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::cmp;

fn main() {
    let (n, mut h) = get!(usize, i64);
    let mut a_max = 0;
    let mut bs = Vec::new();
    for _ in 0..n {
        let (a, b) = get!(i64, i64);
        a_max = cmp::max(a_max, a);
        bs.push(b);
    }
    bs.sort_by(|a, b| b.cmp(a));
    let mut r = 0;
    for b in bs.into_iter() {
        if a_max >= b {
            println!("{}", r + (h + a_max - 1) / a_max);
            return;
        }
        h -= b;
        r += 1;
        if h <= 0 {
            println!("{}", r);
            return;
        }
    }
    println!("{}", r + (h + a_max - 1) / a_max);
}

Measured memory_bytes: 3216
def mission(a, n):
    fail = False
    b = []
    for x in range(n):
        if a[x] % 2 == 1:
            fail = True
        b.append(a[x] / 2)
    if fail:
        return 0
    else:
        return 1 + mission(b, n)



n = int(input())
a = [int(x) for x in input().split()]
print(mission(a, n))

Measured memory_bytes: 3188
N = int(input())
T = [int(x) for x in input().split()]
M = int(input())
A = []
for i in range(M):
	p,x=map(int,input().split())
	A.append(T[p-1]-x)

T_SUM = sum(T)
for a in A:
	print(T_SUM-a)

Measured memory_bytes: 3060
x,n=map(int,input().split())
p=list(map(int, input().split()))

if n==0:
    print(x)
    exit()

for i in range(51):
    if (x+i not in p) and (x-i not in p):
        print(x-i)
        exit()
    if (x+i in p) and (x-i not in p):
        print(x-i)
        exit()
    if (x+i not in p) and (x-i in p):
        print(x+i)
        exit()
    


Measured memory_bytes: 9100
n=int(input())
a=[0]+[int(x) for x in input().split()]
b=[0]*(n+1)
 
for s in range(n,0,-1):
    i=s
    t=0
    while i<=n:
        t += b[i]
        i += s
    if a[s]!=t%2:
        b[s]=1
print(b.count(1))
for i in range(1,n+1):
    if b[i]==1:
        print(i)

Measured memory_bytes: 7276
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
#include<stack>
#include<tuple>
#include<numeric>
#include<cassert>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<int,ll>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_N = 100005;
const ll lmod = 1e9+7;

int main(){
  int n,m;
  cin >> n >> m ;
  int ans = 1;
  rep(i,m) ans *= 2;
  ans *= (100*(n+18*m));
  cout << ans << endl;
  return 0;
}

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

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);                      \
	cin.exceptions(cin.failbit);
#define int long long int //Comment when Unnecessary
#define ll long long
#define sz(a) (int)((a).size())
#define all(a) a.begin(), a.end()
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define pii pair<int, int>
#define vi vector<int>
#define F first
#define S second
#define endl "\n" // Remove on Interactive

const int N = 300009;
const int mod = 1000000007;

int32_t main()
{
	IOS;
	int n, W;
	int w[N], v[N];
	vector<int> dp(N, INT_MAX);
	vector<int> prevDp(N, INT_MAX);
	cin >> n >> W;
	rep(i, 0, n)
	{
		cin >> w[i] >> v[i];
	}
	dp[0] = 0;
	prevDp = dp;
	rep(i, 0, n)
	{
		rep(j, v[i], N)
		{
			dp[j] = min(prevDp[j], prevDp[j - v[i]] + w[i]);
		}
		prevDp = dp;
	}
	for (int i = (N - 1); i >= 0; i--)
	{
		if (dp[i] <= W)
		{
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 7040
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

vector<pair<int,int>> p;
set<pair<int,int>> q;

/*----------------------------------------------------------------*/
signed main(){

    int n,m;
    cin >> n >> m;
    int k[11];
    int s[11][11];
    int p[11];
    rep(i,m){
        cin >> k[i];
        rep(j,k[i])cin >> s[i][j];
    }
    rep(i,m)cin >> p[i];

    int ans = 0;
    for(int bit = 0;bit < (1LL<<n);bit++){
        int f = 1;
        rep(i,m){
            int cnt = 0;
            rep(j,k[i]){
                if(bit&(1LL<<(s[i][j]-1)))cnt++;
            }
            if(cnt%2 != p[i]){
                f = 0;
                break;
            }
        }
        if(f)ans++;
    }
    cout << ans << endl;



	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://sumitrust2019.contest.atcoder.jp/tasks/sumitb2019_d

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
  int c1,c5,c10,c50,c100,c500;
  scanf("%d%d%d%d%d%d",&c1,&c5,&c10,&c50,&c100,&c500);
  if(c1 + 5*c5 + 10*c10 + 50*c50 + 100*c100 + 500*c500 >= 1000) printf("1\n");
  else printf("0\n");
  return 0;
}

Measured memory_bytes: 3164
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
using namespace std;

long long gcd(long long a, long long b) {
  if(b > a) {
    long long tmp = b;
    b = a;
    a = tmp;
  }

  long long r = a % b;
  while(r > 0) {
    a = b;
    b = r;
    r = a % b;
  }

  return b;
}

int main(){
  int n;
  long long x;
  cin >> n >> x;
  vector<long long> y(n);

  long long ans = -1;
  for(int i=0;i<n;++i) {
    long long val;
    cin >> val;
    y[i] = abs(val - x);
    if(i > 0) {
      ans = gcd(y[i], ans);
    } else {
      ans = y[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
from math import sin, cos, pi, sqrt
a,b,C = map(int,input().split())
S = a*b*sin(C*pi/180)/2
c= sqrt(a**2+b**2-2*a*b*cos(C*pi/180))
h= S*2/a
print(S)
print(a+b+c)
print(h)


Measured memory_bytes: 5704
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>

using namespace std;

using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const int inf = 1e+9;

const ll mod = 1000000007;
const int max_e = 2010;
int n;
ll bit[max_e];

void init() {
	rep(i, max_e) {
		bit[i] = 0;
	}
}

void add(int key, int v) {
	for(int x = key; x < max_e; x += x & (-x)) {
		bit[x] += v;
	}
}

ll sum(int key) {
	ll ans = 0;
	for(int x = key; x > 0; x -= x & (-x)) {
		ans += bit[x];
	}
	return ans;
}




int main() {
	init();

	ll n, k;
	cin >> n >> k;

	ll a[n];
	rep(i, n) {
		cin >> a[i];
	}

	vector<ll> a0(n,0);
	vector<ll> d(n,0);

	for (int i = n - 1; i >= 0; i--) {
		a0[i] = sum(a[i] - 1);
		add(a[i], 1);
	}

	for (int i = n - 1; i >= 0; i--) {
		d[i] = sum(a[i] - 1);
		add(a[i],1);
	}
	ll first = 0;
	ll second = 0;
	for (int i = 0; i < n; i++) {
		first += a0[i];
		second += d[i];
	}

	ll d0 = second - first;
	first = first % mod;
	d0 = d0 % mod;
	ll ans = (first * k) % mod;

	ll dk =(k * (k - 1) / 2) % mod;
	ans = (ans + dk * d0) % mod;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define M 1000000007
#define ll long long int
#define F first
#define S second
#define INF (int)1000000000
const int N = 1e5+5;
#define maax(a,b,c) max((int)a,max((int)b,(int)c))
#define miin(a,b,c) min((int)a,min((int)b,(int)c))
#define mp make_pair
#define int long long
#define all(a) a.begin(),a.end()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define inf (long long) 1e18
#define vl vector<ll>
#define sz(a) (ll)a.size()
#define I insert
#define mem(a,b) memset(a,b,sizeof(a))
#define fr(i,m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define fre(i,m, n) for (int i = (int)(n); i <= (int)(m); i--)
#define rall(x) (x).rbegin(), (x).rend()
#define TIME    cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
//void __print(int x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}//
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
typedef pair<int, int> PII;
int aa[100005];
int gcd(int a,int b)
{
	if(b==0) return a;
	else return gcd(b,a%b);
}
bool is_prime(int n)
{
	if(n==1) return true;
	int g=sqrt(n);
	for(int i=2;i<=g;i++)
	{
		if(n%i==0) return true;
	}
	return false;
}
int b[N];
int check(int n)
{
	if(b[n]!=0) return b[n];
	int h=0,y=n;
	while(n)
	{
		h++,n/=10;
	}
	b[y]=h;
	return h;
}
int a[100000000];
int aha(int n)
{int y=0;
    while(n%10!=0) n/=10;
	while(n)
	{
		y+=n%10;n/=10;
	}
	return y;
}
int lol(int n)
{
	int y=0;
	fr(i,1,INF)
	{
		if(a[i]!=0) y=a[i];
		else 
		{
			if(i%10==0) y=aha(i);
			else y++;
		}
		a[i]=y;//debug(i,y);
		if(y==n) return i; 
	}
	return 0;
}

int poo()
{
    int x,y,z;cin>>x>>y>>z;int a,b;cin>>a>>b;
    if((2*x)<min(y,z))
    {
    	cout<<0<<"\n";return 0;
	}
	int y1=max(y,z);
	cout<<(y1-x)+1<<"\n";
	return 0;
}

int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0);
    int t;cin>>t;//int y=aha(28000);cout<<y<<" ";
//    while(t--) poo();
    (t<30)?cout<<"No\n":cout<<"Yes";
    return 0;	
} 
//no of pairs of an array => ((n)*(n+1))/2;
//(1,2) (1,3) (1,4) (2,3) (2.4) (3,4)
//i>>j = i/(2^j)
//set-> all elements are unique and sorted ^_^?


Measured memory_bytes: 3564
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	static Scanner in = new Scanner(System.in);

	public static void main(String[] args) {
		int N = in.nextInt();
		String A = in.next();
		String B = in.next();
		String C = in.next();

		int change = 0;
		for (int i = 0;i < N; i++) {
			char ac = A.charAt(i);
			char bc = B.charAt(i);
			char cc = C.charAt(i);
			HashSet<Character> set = new HashSet<Character>(Arrays.asList(ac, bc, cc));
			change += set.size() - 1;
		}
		System.out.println(change);
	}
}


Measured memory_bytes: 23252