akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n) ; i++)
constexpr auto INF = 2147483647;
static const double EPS = pow(10,-10);
typedef long long ll;
static int COUNTER_CLOCKWISE = 1;
static int CLOCKWISE = -1;
static int ONLINE_BACK = 2;
static int ONLINE_FRONT = -2;
static int ON_SEGMENT = 0;




class Vector2{
  public:
  double x, y;
  Vector2(){}
  Vector2(double x, double y): x(x), y(y) {}

  Vector2 operator + (Vector2 v) {
    return Vector2(x + v.x , y + v.y);
  }
  Vector2 operator - (Vector2 v) {
    return Vector2(x - v.x , y - v.y);
  }

  Vector2 operator * (double d){
    return Vector2(d*x, d*y);
  }

  double norm(){
    return pow(x,2) + pow(y,2);
  }

};

double dot(Vector2 a, Vector2 b){
  return a.x * b.x + a.y * b.y; 
}

double cross(Vector2 a, Vector2 b){
  return a.x * b.y - a.y*b.x;
}

Vector2 projection(Vector2 a, Vector2 b, Vector2 p){
  Vector2 base = b - a;
  Vector2 hypo = p - a;
  double norm_base = pow(base.x,2) + pow(base.y,2);

  Vector2 x;
  x = a + base*(dot(hypo,base) / norm_base);
  return x;
}

Vector2 refrection(Vector2 a, Vector2 b, Vector2 p){
  Vector2 v, p_projection;
  p_projection = projection(a,b,p); 
  v = p_projection + (p_projection - p);
  return v;
}

int ccw(Vector2 a, Vector2 b, Vector2 p){
  Vector2 hypo = p - a;
  Vector2 base = b - a;
  if(cross(base,hypo) > EPS) return COUNTER_CLOCKWISE;
  if(cross(base,hypo) < -EPS) return CLOCKWISE;
  if(dot(base,hypo) < -EPS) return ONLINE_BACK;
  if(hypo.norm() > base.norm()) return ONLINE_FRONT;
  return ON_SEGMENT;
}

bool intersect(Vector2 a,Vector2 b,Vector2 p,Vector2 q){
  int t1, t2;
  t1 =ccw(a,b,p)*ccw(a,b,q);
  t2 =ccw(p,q,a)*ccw(p,q,b);
  if(t1 <= 0 && t2 <= 0) return true;
  else return false;
}

Vector2 crossPoint(Vector2 a,Vector2 b,Vector2 p,Vector2 q){
  Vector2 base, hypo_1, hypo_2, v;
  base = b-a;
  hypo_1 = p-a;
  hypo_2 = q-a;
  double d1 = abs(cross(base, hypo_1)); 
  double d2 = abs(cross(base, hypo_2));
  double ratio = d1/(d1+d2);
  v = p + (hypo_2 - hypo_1)*ratio;
  return v;
}




int main(){
  Vector2 a,b,p,q,v;
  int queri;
  cin >> queri;
  rep(i,queri){
    cin >> a.x >> a.y >> b.x >> b.y;
    cin >> p.x >> p.y >> q.x >> q.y;
    v = crossPoint(a,b,p,q);
    cout << fixed << setprecision(10);
    cout << v.x << " " << v.y;
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3244
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
#include <climits>
using namespace std; 
#define ll long long int

ll f(ll n, ll a){
    if(n > a) return a;
    return f(n, a / n) + a % n;
}

int main(){
    ll n, s;
    cin >> n >> s;
    if(n == s){
        cout << n + 1;
        return 0;
    }
    for(ll i = 2; i * i <= n; ++i){
        if(f(i, n) == s){
            cout << i;
            return 0;
        }
    }
    ll ans = -1;
    for(ll i = 1; i * i <= n; ++i){
        ll p = (abs(n - s)) / i + 1;
        if(p != 1 && f(p, n) == s) ans = p;
    }
    cout <<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int N,X;cin>>N>>X;
    int d=0;
    int l;
    int ans=0;
    rep(i,N+1){
        if(i!=0){
            cin>>l;
            d+=l;
        }
        if(d<=X){
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int n;
int o_cnt =0;
int f_cnt = 0;
int a;

int main(){
  scanf("%d",&n);
  REP(i,n){
    scanf("%d",&a);
    if(a%2==1) o_cnt++;
    if(a%4==0) f_cnt++;
  }
  if(o_cnt+f_cnt==n){
    if(o_cnt > f_cnt +1){
      printf("No\n");
    }else{
      printf("Yes\n");
    }
  }else{
    if(o_cnt > f_cnt){
      printf("No\n");
    }else{
      printf("Yes\n");
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int M=998244353;
const int maxn=6005;
ll f[maxn],inv[maxn],nf[maxn],s[maxn][maxn],dp[maxn][maxn],c[maxn],u[maxn*2],v[maxn*2];
ll ans;
ll C(ll x,ll y){
    return f[x]*nf[y]%M*nf[x-y]%M;
}
void add(ll &x,ll y){
    x+=y; if (x>=M) x-=M;
}
void add1(int l,int r,ll x){
    add(u[l],x);
    add(u[r+1],M-x);
}
void add2(int l,int r,ll x){
    add(v[l],x);
    add(v[r+1],M-x);
}
int n,k;

int main(){
    cin >> n >> k;
    inv[1]=1; for (int i=2;i<maxn;i++) inv[i]=M-(M/i)*inv[M%i]%M;
    f[0]=nf[0]=1; for (int i=1;i<maxn;i++) f[i]=f[i-1]*i%M,nf[i]=nf[i-1]*inv[i]%M;
    dp[0][0]=1;
    for (int i=0;i<n;i++)
        for (int j=0;j<=min(i*2,k);j++)
            add(dp[i+1][j+1],dp[i][j]),
            add(dp[i+1][j+2],dp[i][j]);
    for (int i=0;i<=n;i++)
        for (int j=0;j<k;j++)
            (ans+=dp[i][j]*C(n,i))%=M;
    memset(dp,0,sizeof(dp));
    dp[0][0]=1; dp[1][1]=1;
    for (int i=1;i<n;i++)
        for (int j=0;j<=min(i*2,k);j++)
            add(dp[i+1][j+1],dp[i][j]),
            add(dp[i+1][j+2],dp[i][j]);
    for (int i=0;i<n;i++)
        for (int j=0;j<=k;j++)
            s[i+1][j+1]=dp[i][j];
    if (k%2==1){
        for (int i=(k+1)/2;i<=n;i++) (ans+=C(n,i))%=M;
    }
    for (int i=1+k%2;i<k;i+=2) for (int p=1;p<=i;p++) if (s[p][i]) {

        int r=(k-i)/2;
        int L=(k-i+1)/2,R=r*2;
        if (L<=R) {
            add1(L+p,R+p,s[p][i]*(2*r+p+1)%M);
            add2(L+p,R+p,M-s[p][i]);
        }
    }
    for (int i=1;i<=n;i++) add(u[i],u[i-1]),add(v[i],v[i-1]);
    for (int i=0;i<=n;i++) c[i]=(u[i]+v[i]*i)%M;
    for (int i=1;i<=n;i++) (ans+=c[i]*C(n,i))%=M;
    cout << (ans+M)%M << endl;
}


Measured memory_bytes: 424192
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define FORN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define FORR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll x, y;
	cin >> x >> y;
	if(abs(x-y) <= 1) puts("Brown");
	else puts("Alice");

	return 0;
}


Measured memory_bytes: 256
line = Array.new(gets.to_i){|i|i + 1}
gets.to_i.times do
  str = gets.split(",").map(&:to_i)
  line[str[0] - 1], line[str[1] - 1] = line[str[1] - 1], line[str[0] - 1]
end
puts line

Measured memory_bytes: 6100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		 Scanner scan = new Scanner(System.in);
		 
		 int N = scan.nextInt();
		 int Y = scan.nextInt();
		 
		 int kai_10000 = -1;
		 int kai_5000 = -1;
		 int kai_1000 = -1;
		 
		 loop: for (int i = 0; i <= N; i++ ) {
			 for (int j = 0; j <= N - i; j++ ) {
				 if (10000 * i + 5000 * j + 1000 * (N - i - j) == Y) {
						 kai_10000 = i;
						 kai_5000 = j;
						 kai_1000 = N - i - j;
						 break loop;
				 }
			 }
		 }

		 
		 System.out.println(kai_10000 + " " + kai_5000 + " " + kai_1000);

	}
}


Measured memory_bytes: 23764
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
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; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e11;
const long double PI = (acos(-1));


signed main() {
	int X;
	cin >> X;
	int money = 100;
	int ans = 0;
	while (money < X) {
		money *= 1.01;
		ans++;
	}
	cout << ans;
}

Measured memory_bytes: 3624
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

N = int(input())
A = [list(map(lambda n: int(n)-1, input().split())) for i in range(N)]
cur = [0 for i in range(N)]
que = [i for i in range(N)]
ans = 0
while len(que) > 0:
    done = {}
    que2 = []
    for n in que:
        if done.get(n):
            continue
        pair = A[n][cur[n]]
        if done.get(pair):
            continue
        if n == A[pair][cur[pair]]:
            cur[n] += 1
            cur[pair] += 1
            done[n] = True
            done[pair] = True
            if cur[n] < N-1:
                que2.append(n)
            if cur[pair] < N-1:
                que2.append(pair)
    if len(done) > 0:
        ans += 1
    que = que2
ok = True
for i in range(N):
    if cur[i] < N-1:
        ok = False
if ok:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 55260
# Generated by AtcoderGreedy on 2018-05-20
# AGC024 C
# Your code here

N = gets.chomp.to_i

arr = []
N.times do
  arr << gets.chomp.to_i
end

if arr[0] != 0
  puts(-1)
  exit 0
end

ops = 0
prev = 0
arr.drop(1).each do |a|
  succ_prev = prev + 1
  if succ_prev < a
    puts(-1)
    exit 0
  end
  ops += succ_prev != a ? a : 1
  prev = a
end

puts ops


Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int a, b, c, s, t, u, v, w;
cin >> a >> b >> c;
s = min (a,min(b, c));
t = max(a, max(b, c));
u = a + b+ c - s - t;
v = u - s;
w = t - u; 
cout << v + w << endl;
}


Measured memory_bytes: 256
num = int(input())
num_list = [int(a) for a in input().split()]
target = 1
ans = 0
flg = False

for i in range(num):
    if num_list[i] == target:
        target += 1
        flg = True
    else:
        ans += 1

if not flg:
    ans = -1

print(ans)

Measured memory_bytes: 24744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;


int sum[100010];

int main(int argc, char const *argv[])
{
	int n, q; cin >> n >> q;
	string s; cin >> s;
	vector<int> l(q), r(q); {
		rep(i, q) cin >> l[i] >> r[i];
	}

	rep(i, n - 1) {
		if (s[i] == 'A' && s[i + 1] == 'C') {
			sum[i + 2]++;
		}
	}

	rep(i, n) sum[i + 1] += sum[i];

	rep(i, q) {
		printf("%d\n", sum[r[i]] - sum[l[i]]);
	}

	return 0;
}

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

int main()
{
  int n, ans=1, no=0;
  int h[20];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  
  for(int i=1;i<n;i++){
    for(int j=0;j<i;j++){
      if(h[j]>h[i])	no=1;
    }
    if(no==0)	ans++;
    no=0;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def length(a, b):
    return ((a[0] - b[0])**2 + (a[1] - b[1])**2)**0.5

def solve_sim_equ(a, b, c, d, e, f):
    '''
    From Problem 0004.
    This function solves following equation.
    ax + by = c
    dx + ey = f
    '''
    if a==0 and d==0:
        if b==0 and e==0:
            return 0., 0.
        if b != 0:
            return 0., c/b+0.
        else:
            return 0., f/e+0.
    elif b==0 and e==0:
        if a != 0:
            return 0., d/a+0.
        else:
            return 0., a/d+0.

    if b == 0:
        a, d = d, a
        b, e = e, b
        c, f = f, c
    g = e / b
    x = (g*c - f) / (g*a - d)
    y = (c - a*x) / b
    return x+0., y+0.


def circumscribed_circle(x, y, z):
    def get_equ_coef(p, q):
        h_x = (p[0] + q[0]) / 2
        h_y = (p[1] + q[1]) / 2
        a = q[1] - p[1]
        b = p[0] - q[0]
        c = b * h_x - a * h_y
        return b, -a, c
    coef = get_equ_coef(x, y) + get_equ_coef(y, z)
    center = solve_sim_equ(*coef)
    r = length(center, x)
    return center, r


def main():
    N = int(input())
    for i in range(N):
        vs = [float(v) for v in input().split()]
        a = (vs[0], vs[1])
        b = (vs[2], vs[3])
        c = (vs[4], vs[5])
        center, r = circumscribed_circle(a, b, c)
        print('{0:.3f} {1:.3f} {2:.3f}'.format(center[0], center[1], r))


if __name__ == '__main__':
    main()

Measured memory_bytes: 7764
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
signed main(){
  int a,b,c;
  int k;
  cin>>a>>b>>c>>k;
  for(int i=0;i<k;i++){
    if(a>=b) b*=2;
    else if(b>=c) c*=2;
  }
  if(a<b&&b<c) cout<<"Yes\n";
  else cout<<"No\n";
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#define ll long long
using namespace std;

int main(){
    ll n,count=0;
    string s;
    cin >> n >> s;
    for (ll i = 2; i < n;i++){
        if(s[i-2]=='A'&&s[i-1]=='B'&&s[i]=='C'){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(int i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(int i=(a);i<(n);i++)cout<<(arr)[i]<<' ';

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}

int main(){
	fast;
	ld t, x;
	cin>>t>>x;
	cout<<fixed<<setprecision(5)<<t/x<<endl;
}

Measured memory_bytes: 3768
n,p=map(int,input().split())
l=list(map(lambda x:int(x)%2,input().split()))
a,b=0,0
for i in l:
  if i>0:
    a+=1
  else:
    b+=1
if a==0:
  if p==0:
    print(2**n)
  else:
    print(0)
else:
  print(2**(n-1))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int N, X;
  string S, T;
  cin >> N;
  if (N % 1000 == 0) cout << 0 << endl;
  else cout << 1000 - N % 1000 << endl;
}

Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main(){

int N,A,B;
int max,min;

 cin >> N >>A >>B;
 if(A>B)
 max =B;
 else if(B>A)
 max = A; 

if(A+B>N)
min = A+B-N;
else if(A+B<N)
 min =0;
 cout << max << " "<<min<< endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  vector<int> a(3), b(3);
  vector<int> cnt(4);
  rep(i, 3) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    cnt[a]++;
    cnt[b]++;
  }

  sort(cnt.rbegin(), cnt.rend());
  if (cnt[0] == 2 && cnt[1] == 2 && cnt[2] == 1 && cnt[3] == 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

}

Measured memory_bytes: 3580
n = int(input())
a,b = [],[]
for _ in range(n):
    x,y = map(int, input().split())
    a.append(x+y)
    b.append(y)

a = sorted(a)[::-1]

print(sum([a for i,a in enumerate(a) if i%2==0])-sum(b))


Measured memory_bytes: 12632
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b)
{
    long long r=0, t=0;
 
    if(a<b){
        t=a;
        a=b;
        b=t;
    }
    while(b!=0){
        r=a%b;
        a=b;
        b=r;
    }
 
    return a;
}        
long long lcm(long long a, long long b)
{
    return (a*b)/gcd(a, b);
}
int main(){
    long long a, b, ans=0;
    cin >> a >> b;
    ans=lcm(a, b);
    cout << ans <<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a)
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;

inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=500005;
//i_am_noob
int x,y;

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> x >> y;
    rep(x+1) if(i*2+(x-i)*4==y){
        print1("Yes");
        return 0;
    }
    print1("No");
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;


string to_string(string s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string) s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(char ch) {
	return string("'")+ch+string("'");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <class InputIterator>
string to_string (InputIterator first, InputIterator last) {
	bool start = true;
	string res = "{";
	while (first!=last) {
		if (!start) {
			res += ", ";
		}
		start = false;
		res += to_string(*first);
		++first;
	}
	res += "}";
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto &x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}";
	return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x){
	input>>x.F>>x.S;
	return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x){
	for(auto& i:x)
		input>>i;
	return input;
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif



const int mod=1e9+7;

int mul(int a,int b)
{
	return (a*1ll*b)%mod;
	}
	
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
	}
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
		}
	return res;
	}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=300005;

void solve()
{  
int n;
cin>>n;
vi a(n);
cin>>a;
int cnt=0;
for(int i=0;i<n;i++)if(a[i]<0)cnt++;
for(auto &i:a)i=abs(i);
sort(all(a));
if(cnt&1)
{
	cout<<accumulate(all(a),0ll)-2*a[0];
	}
else cout<<accumulate(all(a),0ll);
} 
	
	
   
	
	

signed main()
{   
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tc=1;
	//cin>>tc;
    for(int i=0;i<tc;i++)
	{
		//cout<<"Case #"<<i+1<<": "; 
        solve();
		}
	
	}


Measured memory_bytes: 640
def main():
    a, b, c = map(int, input().split())
    
    if ( max(a, b, c) * 3 - (a + b + c) ) % 2 == 0:
        print(int((max(a, b, c) * 3 - (a + b + c) ) / 2 ))
    else:
        print(int(( max(a, b, c) * 3 - (a + b + c) ) // 2 + 2 ))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

#define int ll

int n,x,ans=INF,cnt=0,amax=0,amin=INF;
int a[2020],b[2020];

signed main(){
    cin>>n>>x;
    rep(i,0,n){
        cin>>a[i];
        b[i]=a[i];
    }
    rep(i,0,n){
        cnt=0;
        rep(j,0,n){
            b[j]=min(b[j],a[(j-i+n)%n]);
            cnt+=b[j];
        }
        ans=min(ans,cnt+i*x);
    }
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>
#include <numeric>
#include <stack>
#include <map>
using namespace std;

int L, R;
int l, r;
int ans=2019;
int tmp;

int main(){
    cin >> L >> R;
    if (((L%2019)==0)||((R%2019)==0)){
        cout << 0 << endl;
    } else {
        l = L/2019;
        r = R/2019;
        if (l==r){
            for (int i=L; i<R; i++){
                for (int j=i+1; j<=R; j++){
                    tmp = ((i%2019)*(j%2019))%2019;
                    ans = min(ans, tmp);
                }    
            }
            cout << ans << endl;
        } else {
            cout << 0 << endl;
        }
    }
}


Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int a,b; R(a,b);
    int now=1;
    int AA=0;
    while(now<b){
        AA++;
        now+=a-1;
    }
    W(AA);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >>N;
    int v[N];
    vector<double> V;
    for(int i=0;i<N;i++){
        cin >> v[i];
        V.push_back(v[i]);
    }
    for(int i=0;i<N-1;i++){
        sort(V.begin(),V.end());
        V.push_back((V[0]+V[1])/2);
        V.erase(V.begin());
        V.erase(V.begin());
    }
    
    
    cout << V[0] << endl;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;
ll cnt =0;
typedef pair<int,int> P;
char mapa[100][100];
int d[100][100];
int h,w;

int bfs(){

    queue<P>que;
    que.push(P(1,1));
    d[1][1]=0;
    int dx[] = {0,0,-1,1};
    int dy[] = {1,-1,0,0};

    while(que.size()){

         P p=que.front(); que.pop();
            if(p.first == h && p.second == w){
                break;
            }

        for(int i=0;i<4;i++){
           
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];

            if(1<=nx && nx<=h && 1<=ny && ny<=w && mapa[nx][ny] != '#' && d[nx][ny] == INF ){
                que.push(P(nx,ny));
                d[nx][ny] = min(d[nx][ny],d[p.first][p.second] + 1);
            }
        }

    }
    if(d[h][w] == INF){
        return -1;
    }else{
        return d[h][w];
    }

}

int main(){
   
        cin  >> h >> w ;
        

    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin >> mapa[i][j];
            d[i][j] = INF;
            if(mapa[i][j] == '#'){
                cnt++;
            }
        }
    }

    int ret = bfs();

    int ans = w*h - cnt - ret-1;
    if(ret ==-1){
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using llu=unsigned long long;
#define mod 1000000007
#define mode 998244353
#define PI 3.14159265358979323846
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mms(x,y) memset(x,y,sizeof(x))
#define pqm priority_queue<ll,vector<ll>,greater<ll>>
#define pb push_back
#define um unordered_map
#define pr pair
#define mm multimap
#define ms multiset
#define mp make_pair
#define vr vector
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define inf INT_MAX
#define ninf INT_MIN
#define ff first
#define ss second
#define gcd __gcd
int main()
{
    fast;
    ll t,n,m,i,j,k;
    cin>>n;
    n=n*n;
    cout<<n;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma region Macros
#define ios\
    ios::sync_with_stdio(false);\
    cin.tie(nullptr);
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define VVEC(type, name, h, w)\
    VV<type> name(h, V<type>(w));\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
#define STR(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define CHAR(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define DOUBLE(...)\
    DOUBLE __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LD(...)\
    LD __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T &a) { cin >> a; }
template <class T> void scan(vector<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T Roundup_div(T x, T y) {return (x+(y-1))/y;}
template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
const ll INF = 1e18;
#pragma endregion

int main(){
    ios;
    INT(n);
    VEC(int, h, n);
    RREP(i, n - 1){
        fin(h[i] - h[i + 1] > 1, "No");
        if(h[i] - h[i + 1] == 1) h[i]--;
    }
    print("Yes");
}

Measured memory_bytes: 4008
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.IntStream;

public class Main {

    public static boolean found = false;

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

        int n = sc.nextInt();

        long ret = 1;
        for (int i = 0; i < n; i++) {
            ret = (ret * (i + 1));
            ret = ret % 1000000007;
        }
        System.out.println(ret);


    }

}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int n; cin >> n;
  vi a(n),b(n);
  rep(i,n){
    cin >> a[i];
    b[i] = a[i];
  }

  ll ansa = 0, ansb = 0;

  // 偶数番目を正に
  if(a[0] <= 0){
    ansa = 1 - a[0];
    a[0] = 1;
  }
  FOR(i,1,n){
    a[i] += a[i - 1];
    if(i % 2 == 0 and a[i] <= 0){
      ansa += 1 - a[i];
      a[i] = 1;
    }else if(i % 2 == 1 and a[i] >= 0){
      ansa += a[i] + 1;
      a[i] = -1;
    }
  }

  // 奇数番目を正に
  if(b[0] >= 0){
    ansb = b[0] + 1;
    b[0] = -1;
  }
  FOR(i,1,n){
    b[i] += b[i - 1];
    if(i % 2 == 1 and b[i] <= 0){
      ansb += 1 - b[i];
      b[i] = 1;
    }else if(i % 2 == 0 and b[i] >= 0){
      ansb += b[i] + 1;
      b[i] = -1;
    }
  }

  cout << min(ansa,ansb) << endl;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
    int H, W;
    cin >> H >> W;
    char r[500][500];
    char b[500][500];
    int M = min(H, W);
    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
            if(min(min(h-0, H-h-1),min(w-0, W-w-1))%2 == 0){
                if(h+1 == w && 2*h < M-1){
                    r[h][w] = '.';
                    b[h][w] = '#';
                }else{
                    r[h][w] = '#';
                    b[h][w] = '.';
                }
            }
            else {
                if(h+1 == w && 2*h < M-1){
                    r[h][w] = '#';
                    b[h][w] = '.';                    
                }else{
                    r[h][w] = '.';
                    b[h][w] = '#';
                }
            }
            //cout << r[h][w];
        }
    //cout << endl;
    }
    
    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
            char a;
            cin >> a;
            if(a == '#'){
                r[h][w] = '#';
                b[h][w] = '#';
            }
        }
    }
    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
            cout << r[h][w];
        }
        cout << endl;
    }
    cout << endl;
    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
            cout << b[h][w];
        }
        cout << endl;
    }
    
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>
#include <functional>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	int n;
	ll x;
	cin >> n >> x;
	
	vector<ll> b(n + 1), p(n + 1);
	b[0] = 1LL; 
	p[0] = 1LL;
	
	for(int i = 1; i <= n; ++i) {
		b[i] = b[i - 1] * 2LL + 3LL;
		p[i] = p[i - 1] * 2LL + 1LL;
	}
		
	function<ll(int, ll)> func = [&](int i, ll r) -> ll {
		if( i == 0 ) {
			if( r <= 0 ) return 0;
			else return 1;
		} else if( r <= 1LL + b[i - 1] ) {
			return func(i - 1, r - 1);
		} else {
			return p[i - 1] + 1LL + func(i - 1, r - 2LL - b[i - 1]);
		}			
	};
	
	cout << func(n, x) << endl;
	
	return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>

int main(){
    int a,s[3],i=0,count=0;
    scanf("%d",&a);

    for(i=0;i<3;i++){
        s[i]=a%10;
        a/=10;
    }


    if(s[0]==1) count++;
    if(s[1]==1) count++;
    if(s[2]==1) count++;

    printf("%d",count);


return 0;
}


Measured memory_bytes: 128
/// awoooooo

# include <bits/stdc++.h>
# define sz(x) (int)((x).size())

using namespace std;

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

const int N = (int)2e5 + 5;
const int inf = (int)1e9 + 7;

int n, m;
int a[301][301], cur[301], u[301], cnt[301];
set < pii > s;

int ok(int val){
  s.clear();
  for(int i = 1; i <= m; ++i){
    cnt[i] = 0;
  }
  for(int i = 1; i <= n; ++i){
    cnt[a[i][1]]++;
    cur[i] = 1;
  }
  for(int i = 1; i <= m; ++i){
    u[i] = 0;
    s.insert(make_pair(cnt[i], i));
  }
  while(true){
    if(s.rbegin() -> first <= val){
      break;
    }
    int p = s.rbegin() -> second;
    s.erase(--s.end());
    u[p] = 1;
    for(int i = 1; i <= n; ++i){
      int changed = 0;
      while(cur[i] <= m && u[a[i][cur[i]]]) ++cur[i], changed = 1;
      if(cur[i] > m){
        return 0;
      }
      if(changed){
        s.erase(make_pair(cnt[a[i][cur[i]]], a[i][cur[i]]));
        cnt[a[i][cur[i]]]++;
        s.insert(make_pair(cnt[a[i][cur[i]]], a[i][cur[i]]));
      }
    }
  }
  return 1;
}

int main(){
  scanf("%d %d", &n, &m);
  for(int i = 1; i <= n; ++i){
    for(int j = 1; j <= m; ++j){
      scanf("%d", a[i] + j);
    }
  }
  int ans = n;
  for(int i = 10; i >= 0; --i){
    if(ans - (1 << i) >= 0 && ok(ans - (1 << i))){
      ans -= (1 << i);
    }
  }
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 640
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3

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

# 最終エリアの上端:t(a=4),下端:b(a=3),右端:r(a=2),左端:l(a=1)
D = {'t': H, 'b': 0, 'r': W, 'l': 0}

for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:  # 左端
        D['l'] = max(D['l'], x)
    elif a == 2:  # 右端
        D['r'] = min(D['r'], x)
    elif a == 3:  # 下端
        D['b'] = max(D['b'], y)
    elif a == 4:  # 上端
        D['t'] = min(D['t'], y)

print(str((D['t']-D['b'])*(D['r']-D['l']))
      ) if D['t'] > D['b'] and D['r'] > D['l'] else print('0')


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

int main() {
    int W, H, x, y;
    cin >> W >> H >> x >> y;
    double ans = (double)W * H / 2;
    cout << fixed << setprecision(15);
    cout << ans << " " << (x * 2 == W && y * 2 == H) << endl;
}

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


int main() {
    int n,m;
    ll k;
    vector<ll> a(200000),b(200000);
    int ans=0;
    cin >>n>>m>>k;
    rep(i,n)cin>>a[i];
    rep(i,m)cin>>b[i];
    vector<ll> sum_a(n+1);
    vector<ll> sum_b(m+1);
    sum_a[0]=0;
    sum_b[0]=0;
    int ia=0,ib=m;
    ll remain=0;
    rep(i,n)sum_a[i+1]+=sum_a[i]+a[i];
    rep(i,m)sum_b[i+1]+=sum_b[i]+b[i];
    for(;ia<n+1;++ia){
        if(sum_a[ia]>k)break;
        remain=k-sum_a[ia];
        for(;ib>=0;--ib){
            if(remain>=sum_b[ib])break;
        }
        ans=max(ans,ia+ib);
    }
    cout<<ans;
    return 0;
}

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

#define mod 1000000007
using namespace std;

long long dp[302][302][302],l,r,x,ans = 0;
bool a[302][302][302];

int main(){
	int i,j,k,n,m;
	cin >> n >> m;
	for(i=0;i<=n;i++){
		for(j=0;j<=n;j++){
			for(k=0;k<=n;k++){
				a[i][j][k] = true;
			}
		}
	}
	for(i=0;i<m;i++){
		cin >> l >> r >> x;
		for(j=0;j<r;j++){
			for(k=0;k<r;k++){
				if((j!=0 && j==k) || j<k){
					a[r][j][k] = false;
				}else if(x==1){
					if(j>=l || k>=l){
						a[r][j][k] = false;
					}
				}else if(x==2){
					if(!((j>=l)^(k>=l))){
						a[r][j][k] = false;
					}
				}else if(x==3){
					if(j<l || k<l){
						a[r][j][k] = false;
					}
				}
			}
		}
	}
	
	dp[0][0][0] = 1;
	for(i=0;i<=n;i++){
		for(j=0;j<=n;j++){
			for(k=0;k<=n;k++){
				if(!a[i][j][k]){
					dp[i][j][k] = 0;
				}
				if((i>j && j>k) || (j==0 && k==0)){
					(dp[i+1][j][k] += dp[i][j][k])%=mod;
					(dp[i+1][i][k] += dp[i][j][k])%=mod;
					(dp[i+1][i][j] += dp[i][j][k])%=mod;
				}
			}
		}
	}
	
	for(i=0;i<=n;i++){
		for(j=0;j<=n;j++){
			(ans += dp[n][i][j])%=mod;
		}
	}
	cout << ans << endl;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N, H, W;
  cin >> N >> H >> W;
  cout << (N-H+1) * (N-W+1) << endl;



  return 0;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
s = input()

ans_list = []
for i in range(len(s)):
    frag = False
    if s[i] == "a":
        if a > 0:
            a -= 1
            frag = True
        elif b > 0:
            b -= 1
            frag = True
    elif s[i] == "b":
        if b > 0:
            b -= 1
            frag = True
    if frag:
        ans_list.append("Yes")
    else:
        ans_list.append("No")

for i in range(len(s)):
    print(ans_list[i])


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

using namespace std;

int main()
{
    int a, b, t;
    scanf("%d %d %d",&a, &b, &t);
    int res = 0, i = 1;;
        t += 0.5;
        while((i * a) <= t){
            res += b;
            i = i + 1;
        };
    printf("%d\n", (res > 0 ? res : 0));
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;

#define REP(i, N) for (int i = 0; i < N; i++)
#define REP1(i, N) for (int i = 1; i < N; i++)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ANS(a) cout << a << endl;
#define SORT(V) sort(V.begin(), V.end())
#define RSORT(V) sort(V.rbegin(), V.rend())

#define DBG(V) for (auto v : V) cout << v << " "; cout << endl
#define INF ((ull)1e9+7)
int N, K;

vector<vector<ull>>C(4002, vector<ull>(4002));


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

  C[1][1] = 1;
  C[2][1] = 1;
  C[2][2] = 1;
  for (int i = 3; i <= K+N; ++i) {
    C[i][1] = 1;
    for (int j = 2; j < i; ++j) {
      C[i][j] = (C[i-1][j] + C[i-1][j-1]) % INF;
    }
    C[i][i] = 1;
  }

  REP1(i, K+1) {
    ull ans = C[K][i] * C[N-K+2][i+1] % INF;
    ANS(ans);
  }

  return 0;
}


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

#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
using ll = long long;
using namespace std;

int a[110];
int main(void)
{
    int N;
    cin >> N;
    for (int i = 0; i < N; ++i)
        cin >> a[i];

    int minV = 0;

    int cnt = 0;
    for (int i = 0; i < N; ++i)
    {
        if (a[i] == 1)
        {
            cnt++;
        }
        else
        {
            if (cnt != 0)
                minV = max(minV, cnt + 1);
            cnt = 0;
        }
    }
    minV = max(minV, cnt + 1);
    cout << minV << endl;
    return 0;
}


Measured memory_bytes: 3092
card = []
3.times { |i| card[i] = gets.chomp.split(" ").map(&:to_i)}
n = gets.to_i
selectedNums = []
n.times { |i| selectedNums[i] = gets.to_i}

# 行でそろう場合
card.each do |row|
    if (row & selectedNums).length == 3
        print 'Yes'
        exit
    end
end

# 列でそろう場合
card.transpose.each do |row|
    if (row & selectedNums).length == 3
        print 'Yes'
        exit
    end
end

# ななめでそろう場合
if ([card[0][0], card[1][1], card[2][2]] & selectedNums).length == 3 || ([card[0][2], card[1][1], card[2][0]] & selectedNums).length == 3
    print 'Yes'
    exit
end

print 'No'

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

#define rep_(v, f, l) for (int v = (f); v < (l); ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)

using namespace std;

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

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

int main()
{
    int n;
    while (n = in()){
        vector<pii> ds;
        rep(i, n){
            int p, d;
            p = in();
            d = in() + in();
            ds.push_back(make_pair(d, p));
        }
        sort(ds.begin(), ds.end());
        printf("%d %d\n", ds[n - 1].second, ds[n - 1].first);
    }
    return (0);
}

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

int main(void){
    long int n;
    cin >> n;
    string s = to_string(n);
    int min = s.size();
    for(long int a = 1;a * a <= n;a++){
        if(n % a != 0)continue;
        long int b = n/a;
        s = to_string(b);
        if(min > s.size())min = s.size();
    }
    cout << min << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    int n;
    string s,t;
    cin >> n >> s >> t;
    string ans="";
    rep(i,n){
        ans += s[i];
        ans += t[i];
    }
    cout << ans;
}

Measured memory_bytes: 3612
N=int(input())
S=input()
A=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
A=[i.upper() for i in A]
##print(A)
S=list(S)
for i, a in enumerate(S):
    S[i]=A.index(a)+N
    if S[i]>25:
        S[i]=S[i]-26
    S[i]=A[S[i]]

print("".join(S))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	vi a(n);
	int sum=0;
	for(int i=0;i<m;i++) for(int j=0;j<n;j++){
		char c;
		cin>>c;
		if(c=='W') a[j]++,sum++;
	}
	int mn=sum,id=-1;
	for(int i=0;i<n;i++){
		sum+=m-2*a[i];
		if(sum<mn){
			mn=sum;
			id=i;
		}
	}
	cout<<id+1<<' '<<id+2<<endl;
}


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};

int n, a[3010];
long long int ans;
int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a[i];
		ans += a[i] - 1;
	}

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

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		sc.close();
		if(A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
			System.out.println("Possible");
		}else {
			System.out.println("Impossible");
		}
	}
}

Measured memory_bytes: 21588