akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
typedef struct{
    char c[20];
    int d;
}X;
int main()
{
    int a,b,i,e=0;
    scanf("%d %d",&a,&b);
    X x[200000];
    for(i=0;i<a;i++){
        scanf("%s %d",x[i].c,&x[i].d);
    }
    for(i=0;i<a;i++){
        x[i].d-=b;
        if(x[i].d<=0){
            e+=x[i].d+b;
            printf("%s %d\n",x[i].c,e);
        }
        else{
        x[a]=x[i];
        e+=b;
        a++;
        }
    }
    return 0;
}

Measured memory_bytes: 5044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, ans;
ll adj[400][400];
ll inp[400][400];
vector<pair<ll, pair<ll, ll> > > sor;
int main()
{
	scanf("%lld", &n);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			
			scanf("%lld", &inp[i][j]);
			if (i != j)
			{
				adj[i][j] = 999999999999999;
				sor.push_back(make_pair(inp[i][j], make_pair(i, j)));
			}
		}
	}
	sort(sor.begin(), sor.end());
	for (int i = 0; i < sor.size(); i++)
	{
		ll d = sor[i].first;
		ll x = sor[i].second.first;
		ll y = sor[i].second.second;
		if (adj[x][y] < d)
		{
			printf("-1\n");
			return 0;
		}
		else if (adj[x][y] > d)
		{
			adj[x][y] = d;
			adj[y][x] = d;
			ans+=d;
		//	printf("%d %d\n", x, y);
			for (int i = 0; i < n; i++)
			{
				for (int j = 0; j < n; j++)
				{
			//		printf("%d %d %lld\n", i, j, adj[i][x]);
					if (adj[i][j] > adj[i][x] + adj[y][j] + d)
					{

						adj[i][j] = adj[i][x] + adj[y][j] + d;
					}
					if (adj[i][j] > adj[i][y] + adj[x][j] + d)
					{

						adj[i][j] = adj[i][y] + adj[x][j] + d;
					}
				}
			}
		}
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 6388
#include<iostream>
#include<queue>
using namespace std;
int main()
{
	priority_queue<double,vector<double>,greater<double> > a;
	int n,m;
	while(cin>>n)
	{
		for(int i=0;i<n;i++)
		{
			cin>>m;
			a.push(m);
		}
		for(int i=1;i<n;i++)
		{
			int temp2;
			double temp1,temp3;
			temp1=a.top();
			a.pop();
			temp2=a.top();
			a.pop();
			temp3=(double)(temp1+temp2)/2.0;
			a.push(temp3);
		}
		cout<<a.top()<<endl;
		a.pop();
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    
    ll a,b,c;
    ll x[4];
    cin>>a>>b>>c;
    x[0]=abs(a-b);
    x[1]=abs(c-b);
    x[2]=abs(a-c);
    sort(x,x+3);
    cout<<x[0]+x[1]<<endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, a, b = LI()
    print(min(n * a, b))
    return

#B
def B():
    n, d = LI()
    x = LIR(n)
    a = list(itertools.combinations(range(n), 2))
    ans = 0
    for a1,a2 in a:
        b = 0
        for bi in range(d):
            b += (x[a1][bi] - x[a2][bi])** 2
        if float.is_integer(math.sqrt(b)):
            ans += 1
    print(ans)
    return

#C
def C():
    l, r = LI()
    ans = 2018
    if l // 2019 == r // 2019:
        for i in range(l, r + 1):
            for k in range(i+1, r + 1):
                ans = min(ans, (i * k) % 2019)
        print(ans)
    else:
        print(0)
    return

#D
def D():
    n = II()
    a = LI()
    a = a + [a[0]]
    ans = [0] * n
    x = 0
    for i in range(1, n, 2):
        x = x + a[i + 1] - a[i]
    ans[1] = a[0] - x
    ans[0] = ans[1] + 2 * x
    for i in range(2, n):
        ans[i] = (a[i - 1] - ans[i - 1] // 2) * 2
    print(" ".join(map(str, ans)))

    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


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

ll dp[301][301][301];
ll f(int one, int two, int three, int& n)
{
    if(one < 0 || two < 0 || three < 0)
        return 0;
    if(three == 0 && two == 0 && one == 0)
        return 0;

    if(dp[one][two][three]>0)
        return dp[one][two][three];

    int total_123= one + two + three;
    ll exp_val = n+one*f(one-1,two,three,n) + two*f(one+1,two-1,three,n) +
                    three*f(one,two+1,three-1,n);

    return dp[one][two][three] = exp_val/total_123;
}

int main(){
    int i,j,t,n,m,p,k,x;
    
        cin>>n;
        int one=0,two=0,three=0;

        for(int i=0;i<n;i++)
        {
            cin >> x;
            if(x == 1)one++;
            else if(x == 2)two++;
            else three++;
        }

        memset(dp, -1, sizeof dp);
        cout<<fixed<<setprecision(9)<<f(one,two,three,n);
    return 0;
}


Measured memory_bytes: 213376
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
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; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main(){
    ld a,b;
    cin>>a>>b;
    ld c=a*b;
    cout<<(ll)c;
   
}

Measured memory_bytes: 3732
#include<stdio.h>
#include<string.h>
#define LEN 100000

typedef struct pea{
  char name[10];
  int t;
}P;

P Q[LEN];
int head,tail;

void  enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}

P dequeue(){
  P x=Q[head];
  head=(head+1)%LEN;
  return x;
}

int min(int a,int b){ return a<b?a:b;}

int main(){
  int time=0,c;
  int i,q;
  P u;
  int n;
  scanf("%d%d",&n,&q);
  for(i=1;i<=n;i++){
    scanf("%s",Q[i].name);
    scanf("%d",&Q[i].t);
  }
  head=1;
  tail=n+1;

  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    time+=c;
    if(u.t>0)enqueue(u);
    else printf("%s %d\n",u.name,time);
  }
  return 0;
}
    



Measured memory_bytes: 3248
#include <cstdio>
#include <algorithm>
using namespace std;

bool make_code(int n, int m, int *b, int *p, int *a, int t)
{
    for (int i = 0; i < n; ++i)
        a[i] = -1;
    int s = 0;
    for (int i = 0; i < m; ++i) {
        int k = 0;
        for (int j = 0; j < p[i]; ++j) {
            for (; k < n && !(a[k] == -1 && b[k] == t); ++k) {}
            a[k] = s++;
        }
        t = !t;
    }
    for (int i = 0; i < n; ++i)
        if (a[i] == -1)
            return false;
    return true;
}

int bsort(int n, int *a)
{
    int ans = 0;
    for (int i = n; i >= 0; --i) {
        for (int j = 1; j < i; ++j) {
            if (a[j - 1] > a[j]) {
                swap(a[j - 1], a[j]);
                ++ans;
            }
        }
    }
    return ans;
}

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);

    int b[15];
    for (int i = 0; i < n; ++i)
        scanf("%d", &b[i]);

    int p[15];
    for (int i = 0; i < m; ++i)
        scanf("%d", &p[i]);

    int a[15];
    int ans = 1000000;
        //for (int i = 0; i < n; ++i) printf(" %2d", a[i]); puts("");
    if (make_code(n, m, b, p, a, 0)) {
        ans = min(ans, bsort(n, a));
    }
    if (make_code(n, m, b, p, a, 1)) {
        ans = min(ans, bsort(n, a));
    }
    printf("%d\n", ans);

    return 0;
}

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

int main() {
  int N;
  scanf("%d", &N);
  string S;
  cin >> S;
  int K;
  scanf("%d", &K);

  for (int i = 0; i < N; ++i){
    if(S[i]!=S[K-1]) S[i] = '*';
  }

  cout << S << endl;


}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	h := make([]int, N)
	dp := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&h[i])
		dp[i] = 9999999999999
	}

	dp[0] = 0
	for i := 1; i < N; i++ {
		dp[i] = min(dp[i], dp[i-1]+abs(h[i]-h[i-1]))
		if i > 1 {
			dp[i] = min(dp[i], dp[i-2]+abs(h[i]-h[i-2]))
		}
	}

	fmt.Println(dp[N-1])
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

struct Team{
  string name;
  int win,lose,draw;
  int score;
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  bool f = false;
  while(cin>>n&&n){
    if(f)
      cout << endl;
    vector<Team> v(n);
    rep(i,n){
      cin >> v[i].name >> v[i].win>>v[i].lose >>v[i].draw;
      v[i].score = v[i].win*3 + v[i].draw;
    }
    sort(all(v),[](const Team &a,const Team &b){return a.score>b.score;});
    rep(i,n){
      cout << v[i].name << "," << v[i].score<<endl;
    }
    f = true;
  }
  return 0;
}

Measured memory_bytes: 3096
import sys, os, math, bisect, itertools, collections, heapq, queue
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S = iss()
    NUM = [0] * (N+1)

    for n in range(N):
        NUM[n+1] += NUM[n]
        if S[n] == 'E':
            NUM[n+1] += 1

    ret = MAX
    for n in range(N+1):
        # n人目までのうち左(W)を向いている人数
        #   n - NUM[n]
        # n人目以降に右(E)を向いている人数
        #   NUM[-1] - NUM[n]
        ret = min(ret, n - NUM[n] + (NUM[-1] - NUM[n]))
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 27008
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
		}
		Arrays.sort(a);
		int count = 1;
		long b = a[n-1];
		long max = 0, nmax = 0;
		for(int i = n-2; i >= 0; i--) {
			if(a[i] == b) {
				count++;
				if(max == 0) {
					max = a[i];
				}else if(nmax == 0) {
					if(max != a[i] ||(count >= 4)) {
						nmax = a[i];
					}
				}
			}
			b = a[i];
		}
		System.out.println(max * nmax);
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

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

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

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

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

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


Measured memory_bytes: 45516
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//絶対値
long long int change_plus(long long int a) {
	if (a < 0) { return -a; }
	if (a >= 0) { return a; }
}
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

int main() {
	long long int n, m, k = 0;
	char str[15],str2[15],str3[15];
	scanf("%lld%lld",&n,&m);
	n = n + m;
	if (n/24==1) {
		n-=24;
		
	}
	printf("%lld",n);
}

Measured memory_bytes: 128
using Yorukatsu029.Questions;
using Yorukatsu029.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu029.Questions
{
    /// <summary>
    /// ABC091 C
    /// </summary>
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var nm = inputStream.ReadLongArray();
            var n = nm[0];
            var m = nm[1];

            if (n == 1 && m == 1)
            {
                yield return 1;
            }
            else if (n == 1)
            {
                yield return Math.Max(m - 2, 0);
            }
            else if (m == 1)
            {
                yield return Math.Max(n - 2, 0);
            }
            else
            {
                yield return (n - 2) * (m - 2);
            }
        }
    }
}


namespace Yorukatsu029
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu029.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu029.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include <iostream>
using namespace std;
 
int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    int min1 = A, min2 = C;
    if ( B < min1 ) min1 = B;
    if ( D < min2 ) min2 = D;
    cout << min1 + min2 << endl;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut a: [usize;n],
    }

    let mut count = vec![0; (n + 1) / 2];
    for item in &a {
        count[item / 2] += 1;
    }

    if a.len() % 2 == 1 {
        count[0] += 1;
    }

    for item in &count {
        if *item != 2 {
            println!("0");
            return;
        }
    }

    let mut ans: u64 = 1;
    for _ in 0..n / 2 {
        ans *= 2;
        ans %= 1000000007;
    }
    println!("{}", ans);
}


Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	int x,y;
	cin>>x>>y;
	int kame = 0;
	for(; kame <= x; ++kame){
		if(4*kame + 2*(x-kame) == y){
			cout<<"Yes"<<endl; return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// 出力は.xで！！！！

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};


int main(){
  int n,k; cin >> n >> k;
  if(k>=n) k=n-1;
  mint ans=1;
  combination c(n+1);
  for(int i=1; i<=k; i++){
    ans+=c(n-1,i)*c(n,i);
  }
  cout << ans.x << endl;
return 0;
}



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


def main():
    n = int(input())
    a = list(map(int, input().split()))
    ans = [0 for _ in range(n)]

    for index, ai in enumerate(a):
        if index % 2 == 0:
            ans[0] += ai
        else:
            ans[0] -= ai

    for i in range(n - 1):
        ans[i + 1] = 2 * a[i] - ans[i]

    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 84708
N,K,L = map(int, input().split())

road_parent = list(range(N))
road_rank = [0] * N
train_parent = list(range(N))
train_rank = [0] * N

def Find(parent, i):
	if parent[i] == i:
		return i
	else:
		parent[i] = Find(parent, parent[i])
		return parent[i]

def Union(parent, rank, i, j):
	i_root = Find(parent, i)
	j_root = Find(parent, j)
	if rank[i_root] > rank[j_root]:
		parent[j_root] = i_root
	elif rank[i_root] < rank[j_root]:
		parent[i_root] = j_root
	elif i_root != j_root:
		parent[j_root] = i_root
		rank[i_root] += 1

for cnt in range(K):
	i,j = map(int, input().split())
	Union(road_parent, road_rank, i-1, j-1)

for cnt in range(L):
	i,j = map(int, input().split())
	Union(train_parent, train_rank, i-1, j-1)

from collections import defaultdict

counter = defaultdict(int)
for i in range(N):
	counter[(Find(road_parent, i), Find(train_parent, i))] += 1

print(' '.join(str(counter[(Find(road_parent, i), Find(train_parent, i))]) for i in range(N)))

Measured memory_bytes: 63580
///RAIYAN_MAHIN
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    string s; cin >> s ; ll x = s.size();
    char X = 'x';
    for(ll i = 0; i < x; i++)
    {
        cout << X;
    }
}

Measured memory_bytes: 256
def main():
    N = int(input())
    d = [0] * 100
    
    for i in range(N+1):
        s = str(i)
        d[int(s[0])*10+int(s[-1])] += 1
    
    ans = 0
    for i in range(1,10):
        for j in range(1,10):
            ans += d[i*10+j] *d[j*10+i]

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9156
import java.util.*;

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

    for(int i=0; i<3; i++){
    if(n[i]=='1'){
        n[i]='9';
    }else{
        n[i]='1';
    }
}
    System.out.println(String.valueOf(n));    
      }
}

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

int main(){
  string s;
  char pre;
  int Index;
  vector<string> vec[10000];
  Index=0;
  cin >> s;
  for(int i=0;i<s.length();i++){
    if(i != 0 && s[i] == pre)++Index;
    if(s[i] == 'e'){
      vec[Index].push_back("egg");
      pre = 'e';
      i+=2;
    }
    else if(s[i] == 'c'){
      vec[Index].push_back("chicken");
      pre = 'c';
      i+=6;
    }
  }
  int size_max = 0;
  for(int i=0;i<=Index;i++){
    size_max = max(size_max,(int)(vec[i].size()));
  }
  for(int i=0;i<=Index;i++){
    if((int)(vec[i].size()) == size_max){
      cout << vec[i][(int)(vec[i].size())-1] << endl;
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 1492
import sys

s = list(input())
t = list(input())
s.sort()
t.sort()
t.reverse()

for i in range(min(len(s) , len(t))):
    if ord(s[i]) < ord(t[i]):
        print("Yes")
        sys.exit()
    elif ord(s[i]) > ord(t[i]):
        print("No")
        sys.exit()

print("Yes") if len(s) < len(t) else print("No")


Measured memory_bytes: 3064
#include <iostream>

typedef long long ll;

int main(){
   ll n;
   std::cin >> n;
   ll a;
   ll sum[n];
   for(ll i=0; i<n; ++i){
      std::cin >> a;
      if(i==0) sum[i] = a;
      else sum[i] = sum[i-1] + a;
   }

   ll count_plus = 0;
   ll count_minus = 0;
   bool plus = true;
   ll diff_plus = 0;
   ll diff_minus = 0;
   for(ll i=0; i<n; ++i){
      if(plus){
	 if(sum[i]+diff_plus<=0){
	    ll add = -(sum[i] + diff_plus) + 1;
	    count_plus += add;
	    diff_plus += add;
	 }
	 if(sum[i]+diff_minus>=0){
	    ll add = sum[i] + diff_minus + 1;
	    count_minus += add;
	    diff_minus -= add;
	 }
      }else{
	 if(sum[i]+diff_plus>=0){
	    ll add = sum[i] + diff_plus + 1;
	    count_plus += add;
	    diff_plus -= add;
	 }
	 if(sum[i]+diff_minus<=0){
	    ll add = -(sum[i] + diff_minus) + 1;
	    count_minus += add;
	    diff_minus += add;
	 }
      }
      plus = !plus;
   }

   ll ans = std::min(count_plus, count_minus);
   std::cout << ans << std::endl;
   return 0;
}


Measured memory_bytes: 1024
n, l = map(int, input().split())
x = [0] * n
sum = 0
for i in range(1, n+1):
    sum += i
for i in range(n):
    x[i] = l + i+1 -1
if x.count(0) == 1:
    print((l-1)*n+sum)
elif min(x) > 0:
    print((l-1)*n+sum-min(x))
elif max(x) < 0:
    print((l-1)*n+sum-max(x))

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

int main() {
    int N;
    cin >> N;
    vector<int> S(4, 0);
    rep(i, N) {
        string s;
        cin >> s;
        if(s == "AC")
            S[0]++;
        else if(s == "WA")
            S[1]++;
        else if(s == "TLE")
            S[2]++;
        else
            S[3]++;
    }
    cout << "AC x " << S[0] << endl;
    cout << "WA x " << S[1] << endl;
    cout << "TLE x " << S[2] << endl;
    cout << "RE x " << S[3] << endl;
}

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

int main(void){
    ll N, M, K;
    ll A[200005], B[200005];
    cin >> N >> M >> K;
    rep(i, N){cin >> A[i];}
    rep(i, M){cin >> B[i];}

    ll A_t[200005], B_t[200005];
    rep(i, N){
        A_t[i+1] = A_t[i] + A[i];
    }
    rep(i, M){
        B_t[i+1] = B_t[i] + B[i];
    }

    ll best = M;
    ll count;
    ll ans = 0;
    rep(i, N+1){
        for (int j = best; j >= 0; j--){
            if (B_t[j] <= K - A_t[i]){
                count = i + j;
                if (count > ans){ans = count;}
                best = j;
                break;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 9852
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=n-1;i > m;i--)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,N,M,odd=0,sum=0;
  cin >> N;
  rep(i,0,N){
    cin >> A;
    if(A%2==0)sum++;
    else odd++;
  }
  if(odd%2==1)Out("NO");
  else Out("YES");
}

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

using ld = long double;

int freq[30];
ld p2[30];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cout << fixed << setprecision(20);
	p2[0] = ld(1);
	for (int i = 1; i < 30; i++) {
		p2[i] = p2[i-1] / ld(2);
	}

	int N, K; cin >> N >> K;
	for (int x = 1; x <= N; x++) {
		int y = x;
		int cnt = 0;
		while (y < K) {
			y *= 2;
			cnt++;
		}
		freq[cnt]++;
	}

	ld ans = ld(0);
	for (int i = 0; i < 30; i++) {
		ans += freq[i] * p2[i];
	}
	ans /= ld(N);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};


int main()
{
  string s; cin >> s;
  int n = s.size();
  auto ctoi = [](char c)-> int{
		return (int)c - '0';
	      };

  vector<vector<mint>> dp(n+1, vector<mint>(2));
  dp[0][0].x = 1;
  rep(i,n) {
    if(ctoi(s[i]) == 0) {
      dp[i+1][0] += dp[i][0];
    }
    else {
      dp[i+1][0] += (mint)2*dp[i][0];
      dp[i+1][1] += dp[i][0];
    }
    dp[i+1][1] += (mint)3*dp[i][1];
  }

  mint res = dp[n][0] + dp[n][1];
  cout << res.x << "\n";
  
  return 0;
}


Measured memory_bytes: 5760
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef _DEBUG

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 100005
#define MAX_M 55
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////
int check(int s, vector <int> &A) {
	int now = s;
	int N = A.size();
	for (int i = 0; i < N; i++) {
		now = (A[i] << 1) - now;
		if (now < 0) return -1;
	}
	if (now != s) return 1;
	return 0;
}
void output(int s, vector <int> &A) {
	vector <int> res = { s };
	int now = s;
	int N = A.size();
	for (int i = 0; i < N; i++) {
		now = (A[i] << 1) - now;
		res.push_back(now);
	}
	for (int i = 0; i < N; i++) printf("%d%c", res[i], " \n"[i == N - 1]);
}
/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	// WF("output.txt");
	DF("err.txt");

	int N;
	scanf("%d", &N);
	vector <int> A(N);
	for (int i = 0; i < N; i++) scanf("%d", &A[i]);
	int64 x = 0LL;
	for (int i = 0; i < N; i += 2) x += A[i];
	for (int i = 1; i < N; i += 2) x -= A[i];
	vector <int64> res = { x };
	for (int i = 0; i < N; i++) {
		x = (A[i] << 1) - x;
		res.push_back(x);
	}
	for (int i = 0; i < N; i++) printf("%lld%c", res[i], " \n"[i == N - 1]);
	return 0;
}

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

void matrixCahainOrder(void);

#define infinity 1000000

int x, p[101], m[101][101];

/*MatrixChainOrder関数*/
void matrixChainOrder()
{
  int i, j, k, l, n, q;
  
  for(i = 1; i <= x; i++)
    m[i][i] = 0;
  
  for(l = 2; l <= x; l++){
    for(i = 1; i <= x - l + 1; i++){
      j = i + l - 1;
      m[i][j] = infinity;
      for(k = i; k <= j - 1; k++){
	q = m[i][k] + m[k + 1][j] + p[i] * p[k + 1] * p[j + 1];
	if(q < m[i][j])
	  m[i][j] = q; 
      }
    }
  }
  printf("%d\n", m[1][x]);
}

/*ここからがmain関数*/
int main(){
  
  int i, a;
  
  scanf("%d", &x);
  
  for(i = 1; i <= x; i++)
    scanf("%d %d",&p[i], &a);
 
  p[i] = a;

  matrixChainOrder();
  
  return 0;
}










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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int H, W;
int A[80][80], B[80][80], C[80][80];
bool dp[2][80][2*80*80];

void f(bool (&a)[80][2*80*80], int x1, bool (&b)[80][2*80*80], int x2, int c){
    for(int i=0;i<2*80*80;++i){
        unless(a[x1][i]){
            continue;
        }

        if(i + c < 2 * 80 * 80){
            b[x2][i+c] = true;
        }

        b[x2][std::abs(i-c)] = true;
    }
}

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

    std::cin >> H >> W;

    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            std::cin >> A[i][j];
        }
    }

    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            std::cin >> B[i][j];
        }
    }
    
    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            C[i][j] = std::abs(A[i][j] - B[i][j]);
        }
    }

    dp[0][0][C[0][0]] = true;

    bool (&pr)[80][2*80*80] = dp[0], (&nx)[80][2*80*80] = dp[1];

    for(int x=1;x<W;++x){
        f(pr, x - 1, pr, x, C[0][x]);
    }

    for(int y=1;y<H;++y){
        f(pr, 0, nx, 0, C[y][0]);

        for(int x=1;x<W;++x){
            f(pr, x, nx, x, C[y][x]);
            f(nx, x - 1, nx, x, C[y][x]);
        }

        std::swap(pr, nx);
        memset(nx, 0, sizeof(nx));
    }

    int res = -1;
    for(int i=0;i<=80;++i){
        if(pr[W-1][i]){
            res = i;
            break;
        }
    }

    std::cout << res << std::endl;
}



Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
int n,k,p[200010],ps[200010];
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        scanf("%d",p+i);
        p[i]++;
        if(i==0)ps[i]=p[i];
        else ps[i]=ps[i-1]+p[i];
    }
    //for(int i=0;i<n;i++)cout<<ps[i]<<endl;
    long double ans=ps[k-1];
    for(int i=0;i<n-k;i++){
        ans=max(ans,(long double)ps[i+k]-ps[i]);
    }
    printf("%.6Lf\n",ans/2.00000);
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int n,sum=0,b=1e9;
  cin >> n;
  int m = n;
  r(i,10){
    sum+=m/b;
    m=m-(m/b)*b;
    b/=10;
  }
  if(n%sum==0)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
n=gets.to_i
h=Hash.new(0)
d=gets.split.map(&:to_i)
d.each{|v|
  h[v]+=1
}
m=gets.to_i
t=gets.split.map(&:to_i)
ok=true
t.each{|v|
  h[v]-=1
  ok=false if h[v]<0
}
if ok then
  puts "YES"
else
  puts "NO"
end

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

int main(){
	char ch;
	cin>>ch;
	ll n=int(ch);
	if(n<97){	
	cout<<"A"<<endl;	
	}
	else{
	cout<<"a"<<endl;	
	}
	return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int mod = 1e9+7;

int main(){
    int n, m;
    cin >> n >> m;
    if (n < m) swap(n, m);
    if (n - m >= 2){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;
    for(int i = n; i > 0; i--){
        ans *= i;
        ans %= mod;
    }
    for(int i = m; i > 0; i--){
        ans *= i;
        ans %= mod;
    }

    if (n == m){
        ans *= 2;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

int n,arr[52],cnt=0;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    

    cin>>n;
    rep(i,1,n)
    {
        cin>>arr[i];
        if(arr[i]!=i)
            cnt++;
    }
    if(cnt>2)
        cout<<"NO";
    else
        cout<<"YES";
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		long sum = 0, cnt = 0;
		for(int i = 0 ; i < n ; i++) {
			sum += a[i];
			if(i % 2 == 0 && sum <= 0) {
				// 正に変える
				cnt += Math.abs(sum) + 1;
				sum = 1;
			} else if(i % 2 == 1 && sum >= 0) {
				// 負に変える
				cnt += sum + 1;
				sum = -1;
			}
		}
		long sum1 = 0, cnt1 = 0;
		for(int i = 0 ; i < n ; i++) {
			sum1 += a[i];
			if(i % 2 == 0 && sum1 >= 0) {
				// 負に変える
				cnt1 += sum1 + 1;
				sum1 = -1;
			} else if(i % 2 == 1 && sum1 <= 0) {
				// 正に変える
				cnt1 += Math.abs(sum1) + 1;
				sum1 = 1;
			}
		}
		System.out.println(Math.min(cnt, cnt1));
	}
}

Measured memory_bytes: 49876
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define fcout cout << fixed << setprecision(10)

int main(){
    int a,b;
    cin>>a>>b;
    cout<<(a-1)/(b-1)+((a-1)%(b-1)?1:0);
}

Measured memory_bytes: 256
n = int(input())
List = list(map(int, input().split()))
flag = True

for i in range(n):
    if List[i] % 2 == 0 and (List[i] % 3 == 0 or List[i] % 5 == 0):
        continue
    elif List[i] % 2 != 0:
        continue
    else:
        flag = False
        break
        
if flag:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3060
/*input
15
*/

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <math.h>
#include <iomanip>
#include <utility>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

ll MOD = 1000000007;
const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define inv(a)      powr((a), (MOD - 2))
#define all(c)      (c).begin(),(c).end()
#define rep(i,a,b)  for(ll i = (a); i < (b); i ++)
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template<typename T> void toInt(string s, T &a) { istringstream(s) >> a; }
ll gcd(ll a, ll b) { ll t; while(a) { t = a; a = b%a; b = t; } return b; }
ll sub(ll a, ll b) { a -= b; a = (a + MOD) % MOD; return a; }
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll add(ll a, ll b) { a += b; a %= MOD; return a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/*********************************START**********************************/
const int N = 100005;

int main()
{
  ifalse;
  int r;
  cin >> r;
  cout << (3 * r * r);
  return 0;
}

Measured memory_bytes: 256
// failed to generate code

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

int main(){
	int H, W;
	scanf("%d",&H);
	scanf("%d",&W);
	char a[H+1][W+1];
	int dp[H+1][W+1];
	for(int i = 1 ; i <= H ; i++){
		for(int j = 1 ; j <= W ; j++){
			cin >> a[i][j];
		}
	}

	for(int i = 0 ; i <= H ; i++){
		for(int j = 0 ; j <= W ; j++){
			if (i == 0 || j == 0) {
				dp[i][j] = 0;
			} else if (i == 1 && j == 1) {
				//scanf("%c",&a[i][j]);
				dp[i][j] = 1;
			} else {
				//scanf("%c",&a[i][j]);
				if (a[i][j] == '#') {
					dp[i][j] = 0;
				} else {
					dp[i][j] = (dp[i-1][j]+dp[i][j-1]) % 1000000007;
				}
			}

			//printf("(%d,%d):%d %c\n", i,j,dp[i][j], a[i][j]);
		}
	}
	printf("%d\n", dp[H][W]);
}


Measured memory_bytes: 5120
N,M,X = map(int,input().split())
ans = []
CAs = [[int(i) for i in input().split()] for j in range(N)]
for i in range(1<<N):
    rikai = [0 for k in range(M)]
    res = 0
    for j in range(N):
        if (i>>j) & 1:
            res += CAs[j][0]
            for s in range(1,M+1):
                rikai[s-1] += CAs[j][s]
    for j in rikai:
        if j<X:
            res = -1
    ans.append(res)

ans = set(ans)
ans.discard(-1)
if ans:
    print(min(ans))
else:
    print(-1)

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

#define ll long long

int main() {
  ll a, b, x;
  cin >> a >> b >> x;
  
  ll c;
  if (a == 0) {
    c = 0;
  } else {
    c = (a-1)/ x + 1;
  }
  ll d = b / x +1;
  
  cout << d - c << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;

int main(int argc, char *argv[])
{
    ll N, M;
    std::cin >> N >> M;

    ll ans = 0;
    if (2*N >= M) {
        ans = M/2;
    } else {
        ans = N;
        M -= 2*N;
        ans += M/4;
    }

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

Measured memory_bytes: 256
#%%
n = int(input())
a = list(map(int, input().split()))

s = sum(a)
tmp = 0
for i in range(n):
    tmp += a[i]
    s -= a[i]
    if tmp >= s:
        t = a[i]
        break

ans = min(abs(tmp-s), abs(tmp-s-a[i]*2))
print(ans)

Measured memory_bytes: 26396
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		String S = sc.next();
		sc.close();

		int max = 0;
		int tmp = 0;
		for(int i = 0; i < S.length(); i++) {
			if(S.charAt(i) == 'I') {
				tmp++;
			}else if(S.charAt(i) == 'D') {
				tmp--;
			}
			max = Math.max(max, tmp);
		}
		System.out.println(max);
	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <string>

using namespace std;

int main(){
    string s;
   while(1){
       cin >> s;

       int sum=0;
       for(int j=0; j< s.size();j++){
           sum += s[j] - '0';
       }
       if(!sum){break;}
       cout << sum << endl;
   }
   
   return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;
const int MOD = 1'000'000'007;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

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 k, t;
    cin >> k >> t;
    vector<int> a(t);
    for (int i = 0; i < t; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    if (k % 2 == 1)
    {
        if ((k + 1) / 2 >= a[0])
        {
            cout << 0 << endl;
            return 0;
        }
        else
        {
            cout << (a[0] - (k + 1) / 2) * 2 << endl;
            return 0;
        }
    }
    else
    {
        if (k / 2 >= a[0])
        {
            cout << 0 << endl;
            return 0;
        }
        else
        {
            cout << (a[0] - k / 2) * 2 - 1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3608