akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

signed main(void)
{
	int n, x[3], cnt_0;
	cin >> n;
	vector<int> a(n);
	map<ll, ll> mp;
	bool ok;

	cnt_0 = 0;
	rep(i, n) 
	{
		cin >> a[i];
		if (a[i] == 0)
			cnt_0++;
		mp[a[i]]++;
	}
	if (cnt_0 == n)
		ok = true;
	else if (n % 3 == 0)
	{
		if (cnt_0 == n / 3 && mp.size() == 2)
			ok = true;
		else
		{
			if (mp.size() == 3)
			{
				ok = true;
				int i = 0;
				for(auto p : mp)
				{
					x[i++] = p.first;
					if (p.second != n / 3)
						ok = false;
				}
				if (ok && (!((x[0] ^ x[1] ^ x[2] )== 0)))
					ok = false;
			}
			else
				ok = false;
		}
	}
	else
		ok = false;
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>

int main() {
	int a, b, c;
	std::cin >> a >> b >> c;

	if (a == std::max({ a, b, c }))
		std::swap(a, c);
	if (b == std::max({ a, b, c }))
		std::swap(b, c);

	std::cout << a * b / 2 << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=10000+10,mod=1e9+7;
int ksm(int x,int y){
	int res=1;
	while(y){
		if(y&1) res=(ll)res*x%mod;
		y>>=1;
		x=(ll)x*x%mod;
	}
	return res;
}
int fac[maxn],ifac[maxn];
inline void init(int n){
	fac[0]=1;
	REP(i,1,n) fac[i]=(ll)i*fac[i-1]%mod;
	ifac[n]=ksm(fac[n],mod-2);
	DREP(i,n,1) ifac[i-1]=(ll)i*ifac[i]%mod;
}
inline int calc(int S,int x4){
	if(S==0 && x4==0) return 1;
	if(x4==0) return 0;
	return (ll)fac[S+x4-1]*ifac[S]%mod*ifac[x4-1]%mod;
}
int main(){
	init(maxn-10);
	int n=read(),A=read(),B=read(),C=read(),ans=0;
	if(B&1) return printf("0\n"),0;
	REP(x1,0,A) REP(x3,0,C/3){
		int x2=A-x1,x4=B/2,S=C-x3*3-x2;
		if(S<0) continue;
		ans=(ans+(ll)fac[x1+x2+x3+x4]*ifac[x1]%mod*ifac[x2]%mod*ifac[x3]%mod*ifac[x4]%mod*calc(S,x4))%mod;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,K;
  cin >> N >> K;
  
  vector<int> p(N);
  for(int i = 0; i < N; i++){
    int a;
    cin >> a;
    p.at(i) = a + 1;
  }
  /*
  for(int i = 0; i < N; i ++){
    cout << p.at(i) << " ";
  }
  cout << endl;
  */
  double m = 0;
  double sum = 0;
  for(int i = 0; i < N-K+1; i++){
    if(i == 0){
      for(int j = i; j < i + K; j++){
      	sum += p.at(j);
      }
    }
    else{
      sum += p.at(i + K - 1);
      //cout << p.at(i + K) << " ";
    }
    m = max(m, sum);
    //cout << sum << endl;
    sum -= p.at(i);
  }
  //cout << endl;
  
  double ans;
  ans = m / 2;
  
  cout << fixed << setprecision(12) << ans << endl;
}

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

int main(){

int n,min=1000001,max=-1000001;
long long sum=0;
cin>>n;
double a[n];

for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
    if(a[i]<min){
        min=a[i];
    }

    if(a[i]>max){
        max=a[i];
    }
}

cout<<min<<" "<<max<<" "<<sum<<endl;
return 0;
}


Measured memory_bytes: 3284
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int ans=n%k;
    if (ans>0) ans=1;
    printf("%d",ans);
    return 0;
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            int x = Math.Max(input[0], input[1]);
            int y = Math.Min(input[0], input[1]);

            while (y > 0)
            {
                int temp = x % y;
                x = y;
                y = temp;
            }

            Console.WriteLine(x);
        }
    }
}

Measured memory_bytes: 9168
n,m = map(int,input().split())
A = list(map(int,input().split()))
L = [2,5,5,4,5,6,3,7,6]
dp = [-float('inf')]*(n+1)
dp[0] = 0
for i in range(1,n+1):
    for j in range(m):
        if i-L[A[j]-1] < 0:
            None
        else:
            dp[i] = max(dp[i-L[A[j]-1]]+1, dp[i])
A.sort()
A.reverse()
cur = n
ans = ''
while cur != 0:
    for i in range(m):
        temp = A[i]
        if cur-L[temp-1] >= 0:
            if dp[cur-L[temp-1]] == dp[cur]-1:
                ans = ans+str(temp)
                cur -= L[temp-1]
                break
print(ans)


Measured memory_bytes: 3400
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {        
    int n;
    cin >> n;
    vector<int> v(n + 2, 0);
    for (int i = 1; i <= n; i++) {
        cin >> v[i];
    }
    int s = 0;
    for (int i = 1; i < v.size(); i++) {
        s += abs(v[i] - v[i - 1]);
    }
    for (int i = 1; i < v.size() - 1; i++) {
        cout << s - abs(v[i] - v[i - 1]) - abs(v[i + 1] - v[i]) + abs(v[i + 1] - v[i - 1]) << endl;
    }
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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;
}

int main()
{
  INT(N);
  int x;
  int flag=0;
  REP(i,N+1){
    if(i*(i+1)/2==N){
      x=i;
      flag=1;
      break;
    }
  }

  if(flag==1){
    cout << "Yes" << endl;
    cout << x+1 << endl;
    vector<vector<int>> vec(x+1,vector<int> ());
    int cnt = 1;
    REP(i,x){
      FOR(j,i+1,x+1){
        vec[i].push_back(cnt);
        vec[j].push_back(cnt);
        cnt++;
      }
    }
    REP(i,x+1){
      cout << x << " ";
      REP(j,x){
        cout << vec[i][j];
        if(j!=x-1){
          cout << " ";
        }
      }
      cout << endl;
    }
  }else{
    cout << "No" << endl;
  }
}

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int M = min(a, b);
  int m = max(a+b-n, 0);
  printf("%d %d\n", M, m);
  return 0;
}

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

int main() {
  string a,b,c;
  cin >> a >> b >> c;
  if((a[a.size()-1] == b[0]) && (b[b.size()-1] == c[0])) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}

func main() {
	n := nextInt()
	vs := make([]int, 0, n)

	for index := 0; index < n; index++ {
		vs = append(vs, nextInt())
	}

	sort.Sort(sort.IntSlice(vs))

	tmp := make([]float64, 0, n+1)
	for index := 0; index < n-1; index++ {
		if index == 0 {
			v := (float64(vs[index]) + float64(vs[index+1])) / 2
			tmp = append(tmp, v)
		} else {
			v := (float64(vs[index+1]) + tmp[index-1]) / 2
			// fmt.Printf("%#v %#v %#v\n", float64(vs[index+1]), tmp[index-1], v)
			tmp = append(tmp, v)
		}
	}

	// fmt.Printf("%#v\n", tmp)

	// if n%2 != 0 {
	// 	fmt.Println((tmp[n-1] + float64(vs[n-1])) / 2)
	// 	return
	// }
	fmt.Println(tmp[len(tmp)-1])
}


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

int main(){
  int a = 0, b = 0;
  string str;

  cin >> str;

  for(int i = 0; i < 3; i++){
    if(str.at(i) == 'A'){
      a++;
    }else if(str.at(i) == 'B'){
      b++;
    }
  }

  if(a > 0 && b > 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#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 s_len = s.length();
  cout << s[0] << s_len - 2 << s[s_len - 1] << endl;
    
  return 0;
}

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

int main()
{
    int W, H , x, y, r;
    cin >> W >> H >> x >> y >> r;
    bool flag = true;
    if(x+r > W || y+r > H)
        flag = false;
    if(x - r < 0 || y - 0 < 0)
        flag = false;
    if(flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

}

Measured memory_bytes: 1156
module Main where

import Control.Applicative
import Numeric
import Data.Char

main :: IO ()
main = do
  { ln <- getLine
  ; putStrLn (map conv ln)
  }

conv :: Char -> Char
conv c | isLower c = toUpper c
       | otherwise = toLower c
--
getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords .  map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""




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

using namespace std;

long long mem[100005];
int arr[100005];
int n,k;

long long go(int ind)
{
	if(ind==n-1) return 0;
	if(ind>n-1) return (1LL<<50);
	if(mem[ind]!=-1) return mem[ind];
	mem[ind]=go(ind+1)+abs(arr[ind]-arr[ind+1]);
	for(int i=1;i<=k;i++)
		mem[ind]=min(mem[ind],go(ind+i)+abs(arr[ind+i]-arr[ind]));
	return mem[ind];
}

int main()
{
	cin >> n >> k;
	for(int i=0;i<n;i++)
		cin >> arr[i];
	memset(mem,-1,sizeof mem);
	cout << go(0) << endl;
}

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

int main() {
  int input_k, s;
  cin >> input_k >> s;
  long long result = 0;
  int i, j, k;
  for (i = 0; i <= input_k; i++) {
    for (j = i; j <= input_k; j++) {
      for (k = j; k <= input_k; k++) {
        if (i + j + k == s) {
          if (i == j && j == k) {
            result += 1;
          } else if (i == j || j == k || i == k) {
            result += 3;
          } else {
            result += 6;
          }
        }
      }
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
	    int x = scan.nextInt();
	    int y = scan.nextInt();


	   	System.out.println( x * y + " " + (x + y) * 2 );



	}

}

Measured memory_bytes: 26144
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
 #define PI 3.141592653
using namespace std;

void solve(){
	int k; cin>>k; 
	string s; cin>>s;
	for(int i=0; i<min(k,(int)s.length()); i++){
		cout<<s[i];
	}
	if(s.length()>k) cout<<"...";

}


int main()
{ 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout<<fixed<<setprecision(12);
	int t =1; //cin>>t;
	for(int i=1; i<=t; i++){
		solve();
		cout<<"\n";
	}
	return 0;

}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <algorithm>
#include <cassert>
#include <string>
#include <climits>
#include <numeric>
#include <cmath>

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

using namespace std;
using ll = long long;

int main()
{
	ll N;
	cin >> N;
	vector<ll> p(5);
	ll a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	ll minMove = min({a, b, c, d, e});
	cout << (N + minMove - 1) / minMove + 4 << endl;
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<< "\n"


int main(){
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+')cout << a+b << endl;
        else if(op=='-')cout << a-b << endl;
        else if(op=='*')cout << a*b << endl;
        else if(op=='/')cout << a/b << endl;
        else break;
    }
    return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t,p,q,x,c1,c2,c3;
    string n,m,z;
    vector<ll>v;
    cin>>n>>m;
    z=n+m;
    p=0;
    for(ll i=0; i<z.size(); i++)
    {
      p=p*10+z[i]-'0';
    }
    //cout<<p<<endl;
    x=sqrt(p);

    if(x*x==p) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}







Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m, x, y int
	fmt.Scanf("%d %d %d %d", &n, &m, &x, &y)
	xs := make([]int, n)
	ys := make([]int, m)
	for i := 0; i < n; i++ {
		fmt.Scan(&xs[i])
	}
	for i := 0; i < m; i++ {
		fmt.Scan(&ys[i])
	}
	sort.Sort(sort.IntSlice(xs))
	sort.Sort(sort.IntSlice(ys))
	if xs[n-1] < ys[0] && ys[0] > x && ys[0] <= y {
		fmt.Println("No War")
	} else {
		fmt.Println("War")
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
#include <algorithm>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?c=getchar():0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){if(a<b)a=b;}
template<class T1,class T2>inline void apmin(T1 &a,const T2 &b){if(b<a)a=b;}
const int N=200010,O=1000000007;
int x[N],v[N],lst[N],*vlst[N];
int f[N],stk[N],ss=0;
inline bool lcmp(int a,int b){
	return x[a]<x[b];
}
inline bool vcmp(int *a,int *b){
	return *a<*b;
}
struct intv{
	int l,r;
	inline friend bool operator < (const intv &a,const intv &b){
		return a.r!=b.r?a.r<b.r:a.l<b.l;
	}
}ints[N];
namespace B{
	int c[N],n;
	inline void init(int _n){
		memset(c+1,0,(n=_n)<<2);
	}
	inline void add(int x,int v){
		for(;x<=n;(c[x]+=v)%=O,x+=x&-x);
	}
	inline int sum(int x){
		int ans=0;
		for(;x;(ans+=c[x])%=O,x^=x&-x);
		return ans;
	}
	inline int ask(int l,int r){
		return (sum(r)-sum(l-1)+O)%O;
	}
}
int main(){
	int n=ni;
	for(int i=1;i<=n;i++){
		x[i]=ni,v[i]=ni,lst[i]=i,vlst[i]=v+i;
	}
	sort(lst+1,lst+n+1,lcmp);
	sort(vlst+1,vlst+n+1,vcmp);
	for(int i=1;i<=n;i++){
		*vlst[i]=i;
	}
	int val=v[lst[1]];
	for(int i=1;i<=n;i++){
		apmax(val,v[lst[i]]);
		ints[i].r=val;
	}
	val=v[lst[n]];
	for(int i=n;i>=1;i--){
		apmin(val,v[lst[i]]);
		ints[i].l=val;
	}
	sort(ints+1,ints+n+1);
	B::init(n+1);
	B::add(1,1);
	for(int i=1;i<=n;i++){
		B::add(ints[i].r+1,B::ask(ints[i].l,ints[i].r+1));
	}
	printf("%d\n",B::ask(n+1,n+1));
	return 0;
}

Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#define M 4001
int main(){
  int N,Ma,Mb;cin>>N>>Ma>>Mb;
  vector<int>A(N),B(N),C(N);
  for(int i=0;i<N;i++)cin>>A[i]>>B[i]>>C[i];
  int DP[40][10*40+1][10*40+1];
  fill_n((int*)DP,(int*)(40*(10*40+1)*(10*40+1)),M);
  
  for(int i=0;i<N;i++)DP[i][0][0]=0;
    
  DP[0][A[0]][B[0]]=C[0];
  for(int i=1;i<N;i++){
    for(int a=0;a<=10*40;a++){
      for(int b=0;b<=10*40;b++){
        DP[i][a][b]=min(DP[i-1][a][b],(a>=A[i]&&b>=B[i]?DP[i-1][a-A[i]][b-B[i]]+C[i]:M));
      }
    }
  }
  int ans=M;
  for(int i=1;Ma*i<=400&&Mb*i<=400;i++)ans=min(ans,DP[N-1][Ma*i][Mb*i]);
  cout<<(ans==M?-1:ans)<<endl; 
  assert(M>0);
}

Measured memory_bytes: 25344
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
P p1=P(-1,-1),p2=P(-2,-2),a[100000];
int p[100002],r[100002],n,m,k;
int dx[8]={-1,-1,-1,0,0,1,1,1},dy[8]={-1,0,1,-1,1,-1,0,1};
int dx2[16]={-2,-2,-2,-2,-2,-1,-1,0,0,1,1,2,2,2,2,2},dy2[16]={-2,-1,0,1,2,-2,2,-2,2,-2,2,-2,-1,0,1,2};
bool check(int x,int y,int z){return x>=-z&&x<n+z&&y>=-z&&y<m+z;}

void init(){for(int i=0;i<100002;i++)p[i]=i,r[i]=0;}
int find(int x){return (p[x]==x)?x:(p[x]=find(p[x]));}
void unite(int x,int y) {
  x=find(x),y=find(y);
  if(x==y)return;
  if(r[x]<r[y])p[x]=y;
  else{p[y]=x;if(r[x]==r[y])r[x]++;}
}
bool same(int x,int y){return find(x)==find(y);}

map<P,int> ma;
void C(int &x,int &y){
  if(check(x,y,0)) return;
  if(y==-1||x==n) x=-1,y=-1;
  else x=-2,y=-2;
}

int main() {
  init();
  cin >> n >> m >> k;
  ma[p1]=0;
  ma[p2]=1;
  for(int i=0,x,y; i<k; i++) {
    cin >> x >> y;
    a[i]=P(x,y);
    int z=ma.size();
    ma[a[i]]=z;
    for(int j=0; j<8; j++) {
      int xx=x+dx[j],yy=y+dy[j];
      C(xx,yy);
      if(ma.count(P(xx,yy))) unite(z,ma[P(xx,yy)]);
    }
  }
  int ans=same(ma[p1],ma[p2])?0:2;
  for(int i=0; ans>1&&i<k; i++) {
    for(int j=0; j<16; j++) {
      int x=a[i].first+dx2[j],y=a[i].second+dy2[j];
      if(!check(x,y,1)) continue;
      C(x,y);
      if(!ma.count(P(x,y))) continue;
      if(same(ma[p1],ma[a[i]])&&same(ma[p2],ma[P(x,y)])) ans=1;
      if(same(ma[p2],ma[a[i]])&&same(ma[p1],ma[P(x,y)])) ans=1;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10892
#include <stdio.h>

int main(int argc, char const *argv[]) {

  int N, A, B;
  scanf("%d %d %d", &N, &A, &B);
  char S[N + 2];
  scanf("%s", S);

  int cnt = A + B;
  int cnt_ = B;
  for (int i = 0; i < N; i++) {
    if (S[i] == 'a') {
      if (cnt > 0) {
        printf("Yes\n");
        cnt -= 1;
      }else{
        printf("No\n");
      }
    }else if (S[i] == 'b') {
      if (cnt > 0 && cnt_ > 0) {
        printf("Yes\n");
        cnt -= 1;
        cnt_ -= 1;
      }else{
        printf("No\n");
      }
    }else if(S[i] == 'c'){
      printf("No\n");
    }
  }
  return 0;
}


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

int main() {
  int N, Norg;
  int sum = 0;
  cin >> N;
  Norg = N;
  sum += N % 10;
  for (int i=0; i < 8; i++) {
    N /= 10;
    sum += N % 10;
  }
  if (Norg % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main(){
  int n;
  cin  >> n;
  map<string, int> mp;
  for(int i=0; i<n; i++){
    string a;
    cin >> a;
    if(mp.count(a)){
      mp[a]++;
    }
    else{
      mp[a] = 1;
    }
  }
  int m = 0;
  for(auto p : mp){
    m = max(m,p.second);
  }
  for(auto p: mp){
    if(p.second == m){
      cout << p.first << endl;
    }
  }
}



Measured memory_bytes: 25216
#include"bits/stdc++.h"
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	long long a,b,ans,mo=1E9+7;
	a=min(n,m);
	b=max(n,m);
	if(b-a>1)
		ans=0;
	else if(b==a){
		ans=2;
		while(a){
			ans*=a;
			ans%=mo;
			--a;
		}
		while(b){
			ans*=b;
			ans%=mo;
			--b;
		}
	}
	else{
		ans=1;
		while(a){
			ans*=a;
			ans%=mo;
			--a;
		}
		while(b){
			ans*=b;
			ans%=mo;
			--b;
		}
	}
	cout<<ans;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
dath = list(map(int, input().split()))
datab = []
ishigh = [True] * n
for i in range(m):
    a,b = map(int, input().split())
    #print(a,b)
    a-=1
    b-=1
    #print(ishigh)
    if dath[a] >= dath[b]:
        ishigh[b] = False
    if dath[a] <= dath[b]:
        ishigh[a] = False
#print(ishigh)
res = 0
for i in range(len(ishigh)):
    if ishigh[i] is True:
        res += 1
print(res)

Measured memory_bytes: 84832
S = input()
n = len(S)
*S, = map(int, S[::-1])
R = [0]*2019

p = 0
for i, s in enumerate(S):
    q = 10**(i % 224) % 2019
    p += s*q
    p %= 2019
    R[p] += 1

ans = R[0]
for r in R:
    ans += r*(r-1)//2

print(ans)


Measured memory_bytes: 10992
#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for i in range(n):
    a=list(map(int,input().split()))
    res=[a[i]*b[i] for i in range(m)]
    if sum(res)+c>0:
        ans+=1
print(ans)


Measured memory_bytes: 3316
n=int(input())
a=list(map(int,input().split()))
b=a[0]
c=0
for i in range(1,n):
    if a[i]<b:
        c+=b-a[i]
        b = a[i]+b-a[i]
    else:
        b = a[i]
print(c)

Measured memory_bytes: 32188
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
const int Mod=998244353;
int fpow(int a,int b)
{
	int ans=1,t=a;
	while(b)
	{
		if(b&1)ans=(long long)ans*t%Mod;
		t=(long long)t*t%Mod;
		b>>=1;
	}
	return ans;
}
int fac[500010],inv[500010];
int C(int x,int y)
{
	if(x<0||y<0||x-y<0)return 0;
	return (long long)fac[x]*inv[y]%Mod*inv[x-y]%Mod;
}
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	int N=max(n,m);
	fac[0]=1;
	for(int i=1;i<=N;i++)
		fac[i]=(long long)fac[i-1]*i%Mod;
	inv[N]=fpow(fac[N],Mod-2)%Mod;
	for(int i=N;i>=1;i--)
		inv[i-1]=(long long)inv[i]*i%Mod;
	int ans=0;
	for(int i=0;i<=min(n,m);i++)
	{
		int sum=(long long)C(n,i)*C(m,i)%Mod*fac[i]%Mod*fpow(n+1,m-i)%Mod*fpow(m+1,n-i)%Mod;
		if(i&1)ans=(ans-sum+Mod)%Mod;
		else ans=(ans+sum)%Mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=("; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;


ll gcd(ll a, ll b) {
	if (b > a) swap(a, b);
	if (a % b == 0) return b;

	return gcd(b, a % b);
}

int main()
{
	// 入力
	ll N;
	cin >> N;

	vec A(N);
	REP(i, N) {
		cin >> A[i];
	}

	vec gcdl(N, 0);
	vec gcdr(N, 0);

	gcdl[1] = A[0];
	FOR(i, 2, N) {
		gcdl[i] = gcd(gcdl[i - 1], A[i - 1]);
	}

	gcdr[N - 2] = A[N - 1];
	IFOR(i, N - 2, 0) {
		gcdr[i] = gcd(gcdr[i + 1], A[i + 1]);
	}

	ll ans = 0;
	ans = max(gcdr[0], gcdl[N - 1]);

	// vdebug(gcdl);
	// vdebug(gcdr);
	FOR(i, 1, N - 1) {
		ans = max(ans, gcd(gcdl[i], gcdr[i]));
	}

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

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

int main(){
	int n,p[20],cnt=0;
	cin>>n;
	for (int i =0;i<n;i++) cin>>p[i];
	
	for(int i =0;(i+2)<n;i++){
		if (p[i]<p[i+1]&&p[i+1]<p[i+2]||
			p[i]>p[i+1]&&p[i+1]>p[i+2])
			cnt++;
	}
	

	cout<<cnt<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N,Q;
typedef long long ll;
const int INF=INT_MAX;
struct LazySegmentTree{
  private:
  int n;
  vector<int> node,lazy;
  vector<bool> lazyFlag;
  
  public:
  LazySegmentTree(vector<int> v){
    int sz=(int)v.size();
    n=1;  while(n<sz)n*=2;
    node.resize(2*n-1);
    lazy.resize(2*n-1,INF);
    lazyFlag.resize(2*n-1,false);
    for(int i=0;i<sz;i++)node[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--){node[i]=node[2*i+1]+node[2*i+2];}
  }
  void lazyEvaluate(int k,int l,int r){
    if(lazyFlag[k]){
      node[k]=lazy[k]*(r-l);
      if(r-l>1){
        lazy[2*k+1]=lazy[2*k+2]=lazy[k];
        lazyFlag[2*k+1]=lazyFlag[2*k+2]=true;
      }
      lazyFlag[k]=false;
    }
  }
  void update(int a,int b,int x,int k=0,int l=0,int r=-1){
    if(r<0)r=n;
    lazyEvaluate(k,l,r);
    if(b<=l || r<=a)return;
    if(a<=l && r<=b){
      lazy[k]=x;
      lazyFlag[k]=true;
      lazyEvaluate(k,l,r);
    }
    else{
      update(a,b,x,2*k+1,l,(l+r)/2);
      update(a,b,x,2*k+2,(l+r)/2,r);
      node[k]=node[2*k+1]+node[2*k+2];
    }
  }
  ll getsum(int a,int b,int k=0,int l=0,int r=-1){
    if(r<0)r=n;
    lazyEvaluate(k,l,r);
    if(b<=l || r<=a)return 0;
    if(a<=l && r<=b)return node[k];
    ll vl=getsum(a,b,2*k+1,l,(l+r)/2);
    ll vr=getsum(a,b,2*k+2,(l+r)/2,r);
    return vl+vr;
  }
};

int main(){
  cin >> N >> Q;
  LazySegmentTree seg(vector<int>(N,0));
  for(int i=0;i<Q;i++){
    int q,s,t; cin >> q >> s >> t;
    if(q==0){
      int x; cin >> x;
      seg.update(s,t+1,x);
    }
    else{
      cout << seg.getsum(s,t+1) << endl;
    }
  }
}


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

int my_max (vector<int> &T,int N){
if (N == 1){
return T.at(0);
}

int kari_max = max (T.at(N - 1), my_max(T, N - 1) );
    return kari_max;
}

int main() {
  string S;
  cin >> S;
  int N = S.size();
  
  vector<int> T(N, 0);
  
  for (int i= 0; i < N; i++) {
   if ( S.at(i) == 'A' || S.at(i) == 'T' || S.at(i) == 'C' || S.at(i) == 'G' ) {
  T.at(i) = 1;
   }
} 
  
  for (int i= 1; i < N; i++) {
   if (T.at(i) == 1 && T.at(i - 1) != 0) {
     T.at(i) += T.at(i - 1);
   }
} 
   int C = my_max(T, N);
  cout << C << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

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

    if(k*500 >=x) dunk("Yes");
    else dunk("No");
}

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

int main() {
  int n,s,total,max,min;
  while(cin>>n, n) {
    cin>>s;
    max = min = total = s;
    for(int i=0; i<n-1; ++i) {
      cin>>s;
      if(s < min) min = s;
      if(s > max) max = s;
      total += s;
    }
    total = total - min - max;
    cout<<total/(n-2)<<endl;
  }
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
xmax = max(x)
ymin = min(y)
if(xmax < ymin and X < ymin and xmax < Y):
  print('No War')
else:
  print('War')


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

using namespace std;

int main(){
	int n;
	string s;
	cin >> n;
	cin >> s;
	for(auto x:s){
		char c = (char)(x + n);
		if (c > 'Z'){
			c = c - 26;
		}
		cout << c;
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

 
void solve(){
    string a;
    cin >> a;
    int ans = 0;
    int cnt = 0;
    for(int i = 0; i < a.size(); i++){
        if(a[i] == 'A' || a[i] == 'C' || a[i] == 'G' || a[i] == 'T'){
            cnt++;
        }
        else cnt = 0;
        ans = max(cnt, ans);
    }
    cout << ans;
}

 
int main() {
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n;
int32_t main(){
CODE_START;
cin>>n;
cout<<(1000-n%1000)%1000<<endl;
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>

using namespace std;

int main() {
  size_t N;
  cin >> N;

  vector<size_t> A;
  for (size_t i = 0; i < N; i++) {
    size_t a;
    cin >> a;
    A.emplace_back(a);
  }

  if (A.size() == 2) {
    if (A[0] < A[1]) {
      cout << A[1] - A[0] << endl;
    } else {
      cout << A[0] - A[1] << endl;
    }
    return 0;
  }

  size_t sumA = A[0];
  size_t idxA = 1;
  size_t sumB = 0;
  size_t idxB = N - 1;

  while (true) {
    if (sumA <= sumB) {
      sumA += A[idxA];
      idxA++;
    } else {
      sumB += A[idxB];
      idxB--;
    }

    if (idxA == idxB) {
      if (sumA <= sumB) {
        sumA += A[idxA];
      } else {
        sumB += A[idxA];
      }
      break;
    }
  }

  if (sumA <= sumB) {
    cout << sumB - sumA << endl;
  } else {
    cout << sumA - sumB << endl;
  }

  return 0;
}


Measured memory_bytes: 2420
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int[] d = new int[N];
		for (int i=0;i<N;i++) {
			d[i]=Integer.parseInt(sc.next());
		}
		Arrays.sort(d);
		if (N%2==1) {
			System.out.println(0);
		} else {
			System.out.println(d[N/2]-d[N/2-1]);
		}
	}
}

Measured memory_bytes: 49284
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   string s;
           cin>>s;
           rep(i,0,4)cout<<s[i];
           cout<<" ";
           rep(i,4,12)cout<<s[i];
           cout<<endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
using namespace std;
int A[100100],L[100100],P[100100];
int n,ans;

void simple_DP(){
    //添字が一つずれていることに注意
    A[0]=-1;
    P[0]=-1;

    for(int i=1;i<=n;++i){//DP about A[i]
        int k=0;
        for(int j=0;j<i;++j){//define recurrence relation
            if(L[j]>L[k] && A[j]<A[i]){
                k=j;
            }
            L[i]=L[k]+1;
            P[i]=k;
        }
    }

    ans=0;
    for(int i=1;i<=n;++i){
        ans=max(ans,L[i]);
    }

    cout<<ans<<endl;
    /*for debug
    for(int i=1;i<=n;++i){
        cout<<L[i]<<endl;
    }
    */
}

void LIS(){
    int length=1;
    L[0]=A[0];

    for(int i=1;i<n;++i){
        if(L[length-1]<A[i]){
            L[length++]=A[i];
        }
        else{
            *lower_bound(L,L+length,A[i])=A[i];
        }
    }
    cout<<length<<endl;
}

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


    LIS();

    //simple_DP(); TLE
}


Measured memory_bytes: 3872
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  long a, b, k;
  cin >> a >> b >> k;
  if(a < k) {
    b = max(b-(k-a), 0L);
    a = 0;
  } else {
    a = a - k;
  }
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 3660
import sys
sys.setrecursionlimit(10**8)
n=int(input())
t=[int(i) for i in sys.stdin]
if n==1:
  print(t[0])
  exit()
def gcd(x,y):
  if y==0:
    return x
  return gcd(y,x%y)
x=t[0]
for i in range(1,n):
  y=x*t[i]//gcd(x,t[i])
  x=y
print(y)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include<set>
using namespace std;
#define INF 100000
#define MAX 100000
#define MOD 1000000007n
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> p;
//typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

int main(){
    ll K,ans[100];
    cin>>K;
    int N=50;
    for(int i=0;i<N;i++){
        ans[i]=i;
    }
    ll n=K/N,x=K%N;
    for(int i=0;i<N;i++){
        ans[i]+=n;
        if(i+1<=x) ans[i]+=(N-x+1);
        else ans[i]+=(-x);
    }
    cout<<N<<endl;
    for(int i=0;i<N;i++){
        cout<<ans[i]<<endl;
    }
}



Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;

int main() {
	ll x;
	cin >> x;
	//bool arr[1000000] = { true };
	vector<bool>arr(1000001, true);

	for (int i = 2; i < sqrt(1000001); i++) {
		if (arr[i]) {
			for (int j = 2 * i; j <= 1000000; j += i) {
				arr[j] = false;
			}
		}
	}
	for (int i = 2; i < 1000001; i++) {
		if (x<=i&&arr[i]) {
			cout << i << endl;
			exit(0);
		}
		
	}
	//	cout << "hello world" << endl;
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int N = 1005;

intt a, b, n;

int main() {

	FAST;

	cin >> n >> a >> b;
	intt k = n / (a + b);
	intt ans = k * a;
	intt r = n % (a + b);
	ans += min(r, a);
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define endl "\n"
#define mt make_tuple
#define mp make_pair

template <typename T1, typename T2>
bool umax(T1 &a, const T2&b) { return a < b ? a = b, 1 : 0;}
template <typename T1, typename T2> 
bool umin(T1 &a, const T2 &b) {return a > b ? a = b, 1 : 0;}
template <typename T>
T sqr(T a) {return a * a;}
const int mod = 1000000007;
template <typename T1, typename T2>
void modadd(T1 &a, const T2 &b) {
    a += b;

    if (a >= mod)
        a -= mod;
}

mt19937 rng(20010709);
const int INF = 1000000001;
const int N = 1 << 21;

int n, h[200005], a[200005];
ll fenw[200005];

ll get(int index);
void add(int index, ll value);

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

    cin >> n;

    for (int i = 1; i <= n; i++)
        cin >> h[i];
    for (int i = 1; i <= n; i++)
        cin >> a[i];

    for (int i = 1; i <= n; i++)
        add(h[i], get(h[i] - 1) + a[i]);

    cout << get(n) << endl;

    return 0;
}

void add(int index, ll value) {
    for (; index <= n; index |= index + 1)
        umax(fenw[index], value);
}

ll get(int index) {
    ll result = 0;

    for (; index >= 0; index = (index & (index + 1)) - 1)
        umax(result, fenw[index]);

    return result;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (K); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
const int mod = 1000000007;

int main(void){
  int n, w;
  cin >> n >> w;
  vector<int> weight(n), value(n);
  REP(i, n) cin >> weight[i] >> value[i];

  vector<vector<ll>> dp(n+1, vector<ll>(w+1, 0));
  REP(i, n){
    REP(j, w+1){
      chmax(dp[i+1][j], dp[i][j]);

      if(j + weight[i] > w) continue;
      chmax(dp[i+1][j+weight[i]], dp[i][j] + value[i]);
    }
  }
  cout << dp[n][w] << endl;
  return 0;
}

Measured memory_bytes: 80256
sx, sy, tx, ty = map(int, input().split())
X, Y, U, D, L, R = tx - sx, ty - sy, "U", "D", "L", "R"
XX, YY = X+1, Y+1

print(D+R*XX+U*YY+L*XX+D*Y+R*X+U*YY+L*XX+D*YY+R)

Measured memory_bytes: 38384
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 100005
#define INF 1000000005LL
#define INFTY 100000005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

struct Node{int p,rs,lc;};

ll K;
int n,d1[SIZE],dn[SIZE];
Node T[SIZE];
set<int> G[SIZE];
int cnt;

void bfs(int s,int d[]){
	queue<int> q;
	q.push(s);
	cnt=0;
	for(int i=1;i<=n;i++)d[i]=INFTY;
	d[s]=0;
	int u;
	while(!q.empty()){
		u = q.front();q.pop();
		cnt++;
		for(set<int>::iterator it=G[u].begin();it!=G[u].end();it++){
			if(d[*it]!=INFTY)continue;
			d[*it]=d[u]+1;
			q.push(*it);
		}
	}
}

int main()
{
	scanf("%d",&n);
	int x,y;
	for(int i=0;i<(n-1);i++){
		scanf("%d %d",&x,&y);
		G[x].insert(y);
		G[y].insert(x);
	}

	bfs(1,d1);
	bfs(n,dn);
	int minv = 9999999;
	int mid;

	if(d1[n]%2==0){
		for(int i=1;i<=n;i++){
			if(d1[i]==dn[i] && d1[i]<minv){
				mid = i;
				minv = d1[i];
			}
		}
		for(set<int>::iterator it=G[mid].begin();it!=G[mid].end();it++){
			if(dn[*it] == minv-1){
				G[mid].erase(*it);
				G[*it].erase(mid);
				break;
			}
		}
	}else{
		for(int i=1;i<=n;i++){
			if(abs(d1[i]-dn[i])==1 && d1[i]<minv){
				mid = i;
				minv = d1[i];
			}
		}
		for(set<int>::iterator it=G[mid].begin();it!=G[mid].end();it++){
			if(dn[*it] == minv){
				G[mid].erase(*it);
				G[*it].erase(mid);
				break;
			}
		}
	}
	//cut
	
	bfs(1,d1);
	//printf("(%d)",cnt);
	if(cnt>n/2)printf("Fennec\n");
	else printf("Snuke\n");

	return 0;
}


Measured memory_bytes: 16256
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define pr(a) cout << (a) << endl
#define PR(a,b) cout << (a) << " " << (b) << endl
#define F first
#define S second
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000001;
const ll MAXL=1000000000000000001LL;
const ll mod=1000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main() {
  set<int> s;
  for(int i=1; i<10; i++) {
    s.insert(i);
    s.insert(i*10+i);
    for(int j=0; j<10; j++) {
      s.insert(i*1000+j*100+j*10+i);
      s.insert(i*100+j*10+i);
    }
  }
  int ans=0,dis=MAX;
  int n;
  cin >> n;
  tr(it,s) {
    if(abs(*it-n)<dis) {
      dis=abs(*it-n);
      ans=*it;
    }
  }
  pr(ans);
  return 0;
}


Measured memory_bytes: 1204
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

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

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
        	int N = in.nextInt();
        	int H = in.nextInt();
        	int W = in.nextInt();
        	int a = N - H + 1;
        	int b = N - W + 1;
        	out.println(a * b);
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

    }
}



Measured memory_bytes: 22484
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

a_b=abs(a-b)
a_c=abs(a-c)
a_d=abs(a-d)
a_e=abs(a-e)

b_c=abs(b-c)
b_d=abs(b-d)
b_e=abs(b-e)

c_d=abs(c-d)
c_e=abs(c-e)

d_e=abs(d-e)
if a_e > k:
    print(":(")
else:
    print("Yay!")


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

class Main {

	void solve() {

		int n = inint();
		String s = instr();
		
		int abcNum = 0;
		
		for (int i=0; i<s.length()-2; i++) {
			if (s.substring(i, i+3).equals("ABC")) {
				
				abcNum++;
			}
		}
		
		out.println(abcNum);

	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}

	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

	public char[][] incharmap(int h, int w) {
		char[][] a = new char[h][w];
		for (int i=0; i<h; i++) {
			String temp = in.next();
			for (int j=0; j<w; j++) {
				a[i][j] = temp.charAt(j);
			}
		}
		return a;
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	int num=0,sum=0;
	if(b==1){
		cout<<'0'<<endl;
		return 0;
	}
	while(sum<b)
	{
		if(sum+a>=b){
			printf("%d\n",num+1);
			return 0;
		}
		else sum+=a-1,num++;
	}
}

Measured memory_bytes: 256
//
//AtCoder Beginner Contest 160
//C - Traveling Salesman around Lake
//

#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define zero(a) memset(a, 0, sizeof(a))

using ll = long long;

int main()
{
    int k, n;

    cin >> k >> n;

    vector<int> a(n);

    rep(i, n) cin >> a[i];
    a.push_back(a[0] + k);

    int lenMax = 0;
    rep(i, n){
        lenMax = max(lenMax, a[i+1] - a[i]);
    }

    cout << k - lenMax << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main()
{
    int i, n, input, a, b;
    long long sum;
    cin >> n;
    sum = 0;
    a = -1000000;
    b = 1000000;
    for(i=1; i<=n; i++)
    {
        cin >> input;
        if (input > a)  {
            a = input;
        }
        if (input < b)  {
            b = input;
        }
        
        sum = sum + input; 
    }
    cout << b << " " << a << " " << sum << endl;
}



Measured memory_bytes: 3116
n = gets.to_i
a, b = gets.split.map(&:to_i)
p = gets.split.map(&:to_i)
c1 = c2 = c3 = 0
p.each do |x|
  if x <= a
    c1 += 1
  elsif x <= b
    c2 += 1
  else
    c3 += 1
  end
end
puts [c1, c2, c3].min


Measured memory_bytes: 1788
#-*- coding:utf-8 -*-
"""
2020年, AtCoder社は年商10億円を超え, プログラミング教育にも手を出すようになった.
ある日行われたテストでは, 1才児は Hello world を出力するプログラムを, 2才児は整数A,Bを入力してA+Bを出力するプログラムを書かなければならない.
高橋君はこのテストを受けているが, 突然自分が何才なのかが分からなくなってしまった.
そこで, 最初に自分の年齢N(Nは1または2)を入力し, N=1ならば Hello World と出力し, N=2ならばA,Bを入力してA+Bを出力するプログラムを作ることにした.
高橋君に代わって, このようなプログラムを作りなさい.
"""
def kadai1():
    print("Hello World")


def kadai2():
    A = int(input())
    B = int(input())
    print(A + B)


def main():
    N = int(input())
    if N == 1:
        kadai1()
    else:
        kadai2()


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int n,a,b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int pass = 0;
    int pass_b = 0;
    rep(i,n) {
        if(s[i] == 'a' && a+b>pass) {cout << "Yes" << endl; pass++;}
        else if(s[i] == 'b' && a+b>pass && b>pass_b) {cout << "Yes" << endl; pass++;pass_b++;}
        else {cout << "No" << endl;}
    }
}

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

int main(){
	int m, n;
	
	scanf(" %d %d", &m, &n);
	
	int ans=0;
	for(int i=0; i<m; ++i){
		int t=0;
		for(int j=0; j<n; ++j){
			int a;
			scanf(" %d", &a);
			t+=a;
		}
		if(ans<t) ans=t;
	}
	
	printf("%d\n", ans);
}

Measured memory_bytes: 1188
import sys
def main():
    for line in sys.stdin:
        m, f, r = map(int, line.split())
        if m == -1 and f == -1 and r == -1:
            break
        else:
            total = m + f
            if m == -1 or f == -1:
                print("F")
            elif total >= 80:
                print("A")
            elif 65 <= total < 80:
                print("B")
            elif 50 <= total < 65:
                print("C")
            elif 30 <= total < 50:
                if r >= 50:
                    print("C")
                else:
                    print("D")
            elif total < 30:
                print("F")


if __name__ == "__main__":
    main()

Measured memory_bytes: 7792
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int t = sc.nextInt();
			if(t==0)break;
			int n = sc.nextInt();
			
			for(int i=0;i<n;i++){
				t += (sc.nextInt() - sc.nextInt());
			}
			
			if(t<=0) System.out.println("OK");
			else System.out.println(t);
		}
	}	
}

Measured memory_bytes: 23264