akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Foldable
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VMM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VM
import qualified Data.ByteString.Char8 as B
import Data.ByteString.Internal (accursedUnutterablePerformIO)
import qualified Data.Set as S
import System.IO.Unsafe
import Debug.Trace

unew :: VU.Unbox a => Int -> VM.IOVector a
unew !n = accursedUnutterablePerformIO $ VM.unsafeNew n

uread :: VU.Unbox a => Int -> VM.IOVector a -> a
uread !i !v = accursedUnutterablePerformIO $ VM.unsafeRead v i

uwrite :: VU.Unbox a => Int -> a -> VM.IOVector a -> VM.IOVector a
uwrite !i !a !v =
  accursedUnutterablePerformIO $ VM.unsafeWrite v i a >> return v

umodify :: VU.Unbox a => Int -> (a -> a) -> VM.IOVector a -> VM.IOVector a
umodify !i !f !v =
  accursedUnutterablePerformIO $ VM.unsafeModify v f i >> return v

uthaw :: VU.Unbox a => VU.Vector a -> VM.IOVector a
uthaw !v = accursedUnutterablePerformIO $ VU.unsafeThaw v

ufreeze :: VU.Unbox a => VM.IOVector a -> VU.Vector a
ufreeze !v = accursedUnutterablePerformIO $ VU.unsafeFreeze v

solve :: Int -> Int -> B.ByteString -> Bool
solve x y bs =
  foldl' go dpX rx VU.! toIndex x && foldl' go dpY ry VU.! toIndex y
 where
  go !prev !i = VU.fromList
    [ (if (k + i) < maxN then prev VU.! toIndex (k + i) else False)
        || (if (k - i) >= -maxN then prev VU.! toIndex (k - i) else False)
    | k <- [-maxN .. maxN]
    ]

  maxN = B.length bs
  dpX  = VU.fromList [ i == rx0 | i <- [-maxN .. maxN] ]
  dpY  = VU.fromList [ i == 0 | i <- [-maxN .. maxN] ]

  toIndex k = k + maxN

  (rx0, rx, ry) =
    let
      (bs0, bs1)     = B.span (== 'F') bs
      (rx, ry, _, _) = if B.length bs1 == 0
        then ([], [], B.empty, 0)
        else fix
          (\f (!rx, !ry, !bs, !parity) ->
            let (bs0, bs1) = B.span (== 'F') bs
                r          = B.length bs0
                next       = if B.length bs1 == 0 then id else f
                bs1'       = if B.length bs1 == 0 then B.empty else B.tail bs1
                cons       = if r > 0 then (r :) else id
            in  if parity == 0
                  then next $ (cons rx, ry, bs1', 1)
                  else next $ (rx, cons ry, bs1', 0)
          )
          ([], [], B.tail bs1, 1)
    in
      (B.length bs0, rx, ry)

main = do
  let readInt = fmap (second B.tail) . B.readInt

  bs     <- B.getLine
  (x, y) <-
    (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine
  putStrLn $ if solve x y bs then "Yes" else "No"


Measured memory_bytes: 5500
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

int main(){
    string s;
    cin >> s;
    if(s[1]=='B') cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3628
#!/usr/bin/env python

import sys
#from sympy import isprime

class bigint:
    primeset = set()
    def __init__(self,n,mod):
        if not mod in bigint.primeset:
            assert mod**2 < sys.maxsize, "modulo is too large"
            #assert isprime(mod), "modulo should be a prime number"
            bigint.primeset.add(mod)
        #
        self.n = n % mod
        self.mod = mod
        return
    #
    def __str__(self):
        return str(self.n)
    #
    def __add__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        return bigint(self.n+other.n,self.mod)
    #
    def __sub__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        return bigint(self.n-other.n,self.mod)
    #
    def __mul__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        return bigint(self.n*other.n,self.mod)
    #
    def __pow__(self,other):
        assert type(other)==int, "power should be integer"
        #
        if other<0: return self ** ( other % ( self.mod-1 ) )
        elif other==0: return 1
        elif other==1: return self
        elif other%2==0:
            tmp= self ** (other//2)
            return bigint( ( tmp.n**2 ) % self.mod,self.mod )
        else:
            tmp= self ** (other//2)
            return bigint( ( tmp.n**2 * self.n ) % self.mod,self.mod )
    #
    def __truediv__(self,other):
        assert self.mod==other.mod, "modulos of the two not match"
        return self * ( other ** (other.mod-2) )
#
#::::::::::::::::::::::::::::::::::::::::::::::::::
mod= 10**9 + 7

def combination(n,m):
    global mod
    assert type(n)==type(m)==int, "type error"
    #
    mm= min(m,n-m)
    if mm==0: return bigint(1,mod)
    elif mm>0:
        a = bigint(n,mod)
        b = bigint(1,mod)
        for i in range(1,mm):
            a = a * bigint(n-i,mod)
            b = b * bigint(i+1,mod)
        return a / b
    #
    raise ValueError
#
n,m,k = [ int(x) for x in sys.stdin.readline().split() ]
#
# const.
nn= n * n
mm= m * m
cc= combination(n*m-2,k-2)

# initialize
score=bigint(0,mod)

# scan over horizontal direction
for i in range(1,n):
    score= score + bigint(i * mm * (n-i),mod) * cc

# scan over vertical direction
for i in range(1,m):
    score= score + bigint(i * nn * (m-i),mod) * cc
#
print( score )


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

public class Main {

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

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            out.println(b % a == 0 ? a + b : b - a);

        }


    }


    static class InputReader implements AutoCloseable {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

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

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

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

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

        public void close() {
        }

    }
}

Measured memory_bytes: 22996
a = input()

d=int(a)%10
c=(int(a)%100)//10
b=(int(a)%1000)//100
aa=int(a)//1000

if aa==b:
    print("Bad")
elif b==c:
    print("Bad")
elif c==d:
    print("Bad")
else:
    print("Good")

Measured memory_bytes: 3060
def solve(string):
    h, w, *s = string.split()
    h = int(h)
    w = int(w)
    for i in range(h):
        for j in range(w):
            if s[i][j] == ".":
                continue
            check = False
            if i > 0:
                check |= s[i][j] == s[i - 1][j]
            if i < h - 1:
                check |= s[i][j] == s[i + 1][j]
            if j > 0:
                check |= s[i][j] == s[i][j - 1]
            if j < w - 1:
                check |= s[i][j] == s[i][j + 1]
            if not check:
                return "No"
    return "Yes"


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n)])))


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

const int maxn = 303;
int num[maxn], n, cnt[4];
double tot;

double mem[maxn][maxn][maxn];

double dp(int a, int b, int c) {
  if (a == 0 && b == 0 && c == 0) return 0;
  if (mem[a][b][c] > 0.0)
    return mem[a][b][c];
  double res = 0.0;
  
  double one = (double)c, two = (double)b, three = (double)a; 
  double zero = double(n-a-b-c);
  if (c > 0)
    res += (one * (dp(a, b, c - 1) + 1.0));
  if (b > 0)
    res += (two * (dp(a, b - 1, c + 1) + 1.0));
  if (a > 0)
    res += (three * (dp(a - 1, b + 1, c) + 1.0));
  res += (zero);
  res /= tot;
  double p = 1.0 - (zero / tot);
  res /= p;
  return mem[a][b][c] = res;
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> num[i];
    cnt[num[i]] += 1;
  }
  tot = 1.0 * (double)n;
  mem[0][0][0] = 0.0;
  double res = dp(cnt[3], cnt[2], cnt[1]);
  printf("%.9lf\n", res);
}


Measured memory_bytes: 217344
#include <math.h>
#include <stdio.h>
int n, sqrtN;
long long ans, d;
char buf[8], out[20];
k;
i;
s;
X;
int main() {
    s = read(0, buf, 8);
    for(;;) {
        k = buf[i++];
        if(k < '0') break;
        n = n * 10 + k - '0';
    }
    const int sqrtN = sqrt(n);
    ans = -(long long)(sqrtN) * (sqrtN + 1) * (2 * sqrtN + 1) / 6;
    for(int i = 1; i <= sqrtN; ++i) {
        const int a = n / i;
        ans += ((long long)i * (i + a) * (a + 1 - i));
    }
    i = 20;
    do {
        out[--i] = ans % 10 + '0';
        ans /= 10;
    } while(ans);
    write(1, out + i, 20 - i);
}


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquest;
typedef priority_queue<string,vector<string>,greater<string>> rpriquest;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;

int main(){
  int n;ll x;cin >> n >> x;
  ll ans;
  rep(i,n){
    ll y;cin >> y;
    if(i==0)ans=abs(y-x);
    else ans=__gcd(ans,abs(y-x));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <cctype>
#include <stack>
 
using namespace std;

int main()
{
	long long res=0;
	stack<long long> sta;

	string s;
	while(cin>>s){
//		cout<<s<<endl;
		if(s[0]<'0'){
			long long a,b;
			a=sta.top(); sta.pop();
			b=sta.top(); sta.pop();
			if(s[0]=='+') sta.push(a+b);
			else if(s[0]=='-') sta.push(b-a);
			else if(s[0]=='*') sta.push(a*b);
			else sta.push(b/a);
		}else{
			sta.push(atol(s.c_str()));
		}
	}

	cout<<sta.top()<<endl;

	return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>
#include <math.h>
#include <string.h>
int main (void){
        int N,K;
        char S[100];
          scanf("%d",&N);
          scanf("%d",&K);
          scanf("%s",S);
          if (S[K-1]=='A') {
            S[K-1]='a';
          }
          if (S[K-1]=='B') {
            S[K-1]='b';
          }
          if (S[K-1]=='C') {
            S[K-1]='c';
          }
        printf("%s\n",S);
        return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < (int) n; i++)
#define forin(i, a, b) for(int i = a; i < (int) b; i++) 
#define rofin(i, a, b) for(int i = a; i > b; i--)
#define v vector
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define debug(i) cout << #i << ": " << i << endl
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
int N;

int main() {
    crap;
    cin >> N;
    vi dp(N+1, INT_MAX);
    vi h(N);
    
    forn(i,N) cin >> h[i];
    dp[1] = 0;

    forin(i, 1, N+1) {
        if(i+1<=N) dp[i+1] = min(dp[i+1],dp[i]+abs(h[i]-h[i-1]));
        if(i+2<=N) dp[i+2] = min(dp[i+2],dp[i]+abs(h[i+1]-h[i-1]));
    }
    cout << dp[N] << endl;

}

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

int main() {
  int N, M, A, B = 1e9+7;
  cin >> N >> M;

  vector<int> vec(N + 1, -1);
  vec.at(0) = 1;
  vec.at(1) = 1;

  for (int i = 0; i < M; i++) {
    cin >> A;
    vec.at(A) = 0;
  }

  for (int i = 2; i < N + 1; i++) {
    if (vec.at(i) != 0) vec.at(i) = (vec.at(i - 2) + vec.at(i - 1)) % B;
  }

  cout << vec.at(N) << endl;
}

Measured memory_bytes: 640
n, k, s = map(int, input().split())

A = [0] * n

if s == 10 ** 9:
	for i in range(k):
		A[i] = 10 ** 9
	for i in range(k, n):
		A[i] = 1

else:
	for i in range(k):
		A[i] = s
	for i in range(k, n):
		A[i] = s + 1

print(*A)

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

string s;

int main() {
	cin >> s;
	
	int i, cnt = 0;
	for (i = 0; i < 3; i++) {
		if (s[i] == 'o') cnt++;
	}
	cout << 700 + 100 * cnt << endl;
	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<deque>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1000000;
const int mod = 1000000007;
const int INF = 1 << 30;
#define rep(i,n) for(ll i=(ll)0;i<(ll)n;++i)
#define ALL(x) x.begin(),x.end()
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define fix(n) fixed<<setprecision(n)
#define itr vector<ll>::iterator
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
string YN(bool b) { return(b ? "YES" : "NO"); }
string yn(bool b) { return(b ? "Yes" : "No"); }
string s;
char mn='z';
ll k,mnp;
vector<string>ss;
int main() {
	cin >> s >> k;
	rep(i, s.size()) {
		if (s[i] < mn)mn = s[i];
	}
	rep(i, s.size()) {
		if (s[i] == mn) {
			rep(j, 5)
			{if (i + j >= s.size())break;
			ss.push_back(s.substr(i,j+1));
			}
		}
	}
	sort(ALL(ss));
	int ct = 0;
	rep(i, ss.size()) {
		if (i == 0 || ss[i - 1] != ss[i])++ct;
	}
	char cc;
	while (ct < k) {
		cc = mn; ct = 0; mn = 'z';
		rep(i, s.size()) {
			if (s[i] < mn&&s[i]>cc)mn = s[i];
		}
		rep(i, s.size()) {
			if (s[i] == mn) {
				rep(j, 5)
				{
					if (i + j >= s.size())break;
					ss.push_back(s.substr(i, j + 1));
				}
			}
		}
		sort(ALL(ss));
		rep(i, ss.size())if (i == 0 || ss[i - 1] != ss[i])++ct;
	}
	ct = 0;
	rep(i, ss.size()) {
		if (i == 0 || ss[i - 1] != ss[i])++ct;
		if (ct == k) { cout << ss[i] << endl; break; }
	}
	return 0;
}

Measured memory_bytes: 1660
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>
#include<random>
#include<set>
 
#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
#define Sort(X) sort(X.begin(), X.end())
#define RSort(X, T) sort(X.begin(), X.end(), greater<T>())
//#define MOD 998244353
#define MAX 100000
 
typedef long long int ll;
typedef unsigned long long int ull;
 
using namespace std;
 
template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }

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

	ll N;
	string S;
	cin >> N >> S;

	rep(i, S.size()) {
		S[i] += N;
		if (S[i] > 'Z') {
			S[i] -= ('Z' - 'A') + 1;
		}
	}

	cout << S << endl;
	

	return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(){

  char next;
  string S_A, S_B, S_C;
  vector<char> A, B, C;

  cin >> S_A >> S_B >> S_C;

  for(int i = S_A.size()-1; 0 <= i ; i--) A.push_back(S_A[i]);
  for(int i = S_B.size()-1; 0 <= i ; i--) B.push_back(S_B[i]);
  for(int i = S_C.size()-1; 0 <= i ; i--) C.push_back(S_C[i]);

  next = A[S_A.size()-1];
  A.pop_back();

  while(1){
    if(next == 'a'){
      if(A.empty()){
        cout << "A" << endl;
        break;
      }
      next = A[A.size()-1];
      A.pop_back();

    }else if(next == 'b'){
      if(B.empty()){
        cout << "B" << endl;
        break;
      }
      next = B[B.size()-1];
      B.pop_back();

    }else if(next == 'c'){
      if(C.empty()){
        cout << "C" << endl;
        break;
      }
      next = C[C.size()-1];
      C.pop_back();

    }

  }

  return 0;

}


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

using namespace std;

#define ll long long
#define mod 1000000007

const ll INF = 1e11;

struct item{
    int wt;
    int val;
};

void solve(){

    int n, w; cin >> n >> w;
    item arr[n];
    for(int i = 0; i < n; ++i){
        cin >> arr[i].wt >> arr[i].val;
    }
    vector<ll> dp((int)1e5+5, INF);
    dp[0] = 0;
    for(int i = 0; i < n; ++i){
        for(int j = (int)1e5+1; j-arr[i].val >= 0; --j){
            if(dp[j-arr[i].val] != INF){
                dp[j] = min(dp[j], dp[j-arr[i].val] + arr[i].wt);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < dp.size(); ++i)
        if(dp[i] <= w) ans = i;

    cout << ans << endl;
    
    return;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
	return 0;
}

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

int main(){
    string s;
    cin>>s;
    vector<int> dp(2);
    if(s[0]=='0') dp[0]=0,dp[1]=1;
    else dp[1]=0,dp[0]=1;
    for(int i=1;i<s.size();i++){
        vector<int> tmp(2,s.size());
        if(s[i]=='0'){
            tmp[0]=dp[1];
            tmp[1]=dp[0]+1;
        }
        else{
            tmp[1]=dp[0];
            tmp[0]=dp[1]+1;
        }
        dp=tmp;
    }
    cout<<min(dp[0],dp[1])<<endl;
    

    return 0;
}

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

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    for (int i = 0; i < M; i++) cin >> B[i];
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int sum = 0;
        for (int j = 0; j < M; j++) {
            int Aij;
            cin >> Aij;
            sum += Aij * B[j];
        }
        sum += C;
        if (sum > 0) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  string s;
  in(s);
  out(s[0]);
  out(s.size() - 2);
  out(s[s.size() - 1]);
  memi;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static int dp[][];
  public static int func(int[][] a,int i,int turn)
  {
    if(i==a.length)
    return 0;
    if(dp[i][turn]!=-1)
    return dp[i][turn];
    if(turn==0)
    {
      dp[i][turn]=Math.max(a[i][1]+func(a,i+1,1),
              a[i][2]+func(a,i+1,2));
    }
    else if(turn==1)
    {
      dp[i][turn]=Math.max(a[i][0]+func(a,i+1,0),
              a[i][2]+func(a,i+1,2));
    }
    else
    {
      dp[i][turn]=Math.max(a[i][0]+func(a,i+1,0),
              a[i][1]+func(a,i+1,1));
    }
    return dp[i][turn];
  }
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int a[][]=new int[n][3];
    dp=new int[n+1][3];
    for(int i=0;i<n;i++)
    {
      a[i][0]=sc.nextInt();
      a[i][1]=sc.nextInt();
      a[i][2]=sc.nextInt();
    }
    int max=0;
    for(int i=0;i<=2;i++)
    {
      for(int k=0;k<=n;k++)
      {
        for(int j=0;j<3;j++)
        dp[k][j]=-1;
      }
      max=Math.max(max,func(a,0,i));
    }
    System.out.println(max);
  }
}
    

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

class sorting{
public:
  bool operator()(const pair<int,int>& left,const pair<int,int>& right)const{
    return left.first < right.first;
  }
};

int main(){
  int n;
  while(cin >> n,n){
    vector<pair<int,int> > dat;
    int m,s,id;
    for(int i=0;i<n;i++){
      int total = 0;
      cin >> id;
      for(int j=0;j<4;j++){
	cin >> m >> s;
	total += m*60 + s;
      }
      dat.push_back(make_pair(total,id));
    }
    sort(dat.begin(),dat.end(),sorting());
    cout << dat[0].second << endl << dat[1].second << endl << dat[n-2].second << endl;
  }
}

Measured memory_bytes: 1304
import java.util.Arrays;
import java.util.Scanner;

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

    void solve(Scanner sc) {
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] hs = new int[n];
        for (int i = 0; i < n; i++) {
            hs[i] = sc.nextInt();
        }

        int[] dp = new int[n + 1];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0] = dp[1] = 0;
        dp[2] = Math.abs(hs[1] - hs[0]);
        for (int i = 3; i <= n; i++) {
            for (int j = 1; j <= Math.min(k, i - 1); j++) {
                dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(hs[i - 1] - hs[i - j - 1]));
            }
        }

        System.out.println(dp[n]);
    }
}


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

using namespace std;
using ll = long long int;
#define long ll

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

    ll n;
    cin >> n;
    ll r = 0;
    while(n--) {
        ll x;
        cin >> x;
        while(x%2==0) x /= 2, r++;
    }
    cout << r << endl;
}


Measured memory_bytes: 256
def limited_insertion(N: int, B: list) -> list:
    op = []
    for i in range(N-1, -1, -1):
        for j in range(i, -1, -1):
            b = B[j]
            if i+1 < b:
                # invalid number
                return []
            if j+1 == b:
                # remove b[j]
                B = B[:j] + B[j+1:]
                op.append(b)
                break
        else:
            # not found
            return []
    return reversed(op)


if __name__ == "__main__":
    N = int(input())
    B = [int(s) for s in input().split()]

    ans = limited_insertion(N, B)
    if ans:
        for a in ans:
            print(a)
    else:
        print(-1)


Measured memory_bytes: 3188
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

X = [A, B, C, D, E]
Y = [[x, 10-x%10] for x in X]
acc = 0
for y in Y:
    if y[1] == 10:
        acc += y[0]
    else:
        acc += y[0] + y[1]
Z = [10-a%10 for a in X if (10-a%10) < 10]
if Z:
    acc -= max(Z)
print(acc)


Measured memory_bytes: 3064
#include <cstdio>

int main()
{
  char s[6];
  scanf("%s", s);
  for (char *p = s; *p; ++p)
  {
    if (*p == 'A' && *(p + 1) == 'C')
    {
      puts("Yes");
      return 0;
    }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 128
// date: June 11 2020
// author: Tibbarnit

#include <bits/stdc++.h>

using namespace std;

#define X first
#define Y second
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
ll n;
map<int,int> m;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    ll res=0;
    int limit=ceil(sqrt(n));
    for (int i=2;i<=limit;++i)
    {
        if (n%i!=0) continue;
        ll times=0;
        while (n%i==0)
            ++times,n/=i;
        int temp=ceil(((double)sqrt(times*8+1)-1)/2+0.1)-1;
        res+=temp;
    }
    if (n>1) ++res;
    cout<<res;
    return 0;
}


Measured memory_bytes: 3708
#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++)
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 (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    string ans;
    if((B - A) % 2 == 0){
        ans = "Alice";
    }
    else{
        ans = "Borys";
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAX=200000,MQ=28;
int a[MAX],b[MAX],fin,n;
int mask=0;
bool cmp(int &x,int &y){
    return (x&mask)<(y&mask);
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    for(int i=0;i<n;i++) scanf("%d",&b[i]);
    if(n%2) for(int i=0;i<n;i++) fin^=a[i],fin^=b[i];
    for(int i=0;i<=MQ;i++){
        int val=0;
        mask^=(1<<i);
        sort(a,a+n,cmp);
        sort(b,b+n,cmp);
        for(int j=0,k=n;j<n;j++){
            for(;(b[k-1]&mask)+(a[j]&mask)>mask&&k>=1;k--);
            val+=n-k;
        }
        if(val%2) fin^=mask+1;
        //printf("%d %d\n",mask+1,val);
    }
    printf("%d\n",fin);
}


Measured memory_bytes: 1792
<?php
$n =trim(fgets(STDIN));
$a = explode(" ", trim(fgets(STDIN)));
$idx = $n;
$down = true;

for ($i = 1; $i <= $n; $i++) {
    $ans[] = $a[$idx - 1];
    if ($idx > 3 && $down) {
        $idx = $idx - 2;
    } elseif ($down) {
        $down = false;
        if ($idx == 3) {
            $next = 2;
        } else {
            $next = 3;
        }
        $idx = 1;
    } elseif (isset($next)) {
        $idx = $next;
        unset($next);
    } else {
        $idx = $idx + 2;
    }
}

echo implode(" ", $ans);

Measured memory_bytes: 33392
//09-3 連鎖
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<math.h>
#include<time.h>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<set>
#include<stack>
#include<queue>
#include<cstdlib>
#include<algorithm>
#include<random>
#include<cassert>
using namespace std;
#include<boost/multiprecision/cpp_int.hpp>
namespace boost_multiprecision = boost::multiprecision;
#define LL long long
#define CINT boost_multiprecision::cpp_int
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)

int N;
vector<int> c;

int top(int a){
    int re = a;
    while(c[re] == c[a]){
        re--;
        if(re <= -1) return 0;
    }
    return re+1;
}

int bottom(int a){
    int re = a;
    while(c[re] == c[a]){
        re++;
        if(re >= N) return N-1;
    }
    return re-1;
}

int del(int x, int y){//x番目からy番目を消した時
    if(x==0 && y==N-1) return 0;
    int t = top(x-1);
    int b = bottom(y+1);
    if(x-1 < 0){
        if(b-y >= 4) return del(0,b);
    }
    else if(y+1 > N-1){
        if(x-t >= 4) return del(t,N-1);
    }
    else if(c[x-1] == c[y+1]){
        if(b-y + x-t >= 4) return del(t,b);
    }
    return N-(y-x+1);
}

int main(){
    ROOP(){
        cin >> N;
        if(N == 0) break;
        c.clear();
        for(int i=0; i<N; i++){
            int tmp;
            cin >> tmp;
            c.push_back(tmp);
        }

        int answer = N;
        if(c[0]!=c[1] && bottom(1)>=3) answer = min(answer,del(0,bottom(1)));
        if(c[N-1]!=c[N-2] && top(N-2)<=N-4) answer = min(answer,del(top(N-2),N-1));
        for(int i=1; i+1<N; i++){
            int t = top(i-1);
            int b = bottom(i+1);
            if(c[i-1]==c[i+1]){
                if(b - t + 1 >= 4){
                    answer = min(answer,del(t,b));
                }
            }
            else{
                if(i - t + 1 >= 4){
                    answer = min(answer,del(t,i));
                }
                if(b - i + 1 >= 4){
                    answer = min(answer,del(i,b));
                }
            }
        }
        cout << answer << endl;
    }
    return 0;
}


Measured memory_bytes: 3184
/*input
8 5 22
100 3 7 5 3 1
164 4 5 2 7 8
334 7 2 7 2 9
234 4 7 2 8 2
541 5 4 3 3 6
235 4 8 6 9 7
394 3 6 1 6 2
872 8 4 3 7 2
*/
#include<bits/stdc++.h>
using namespace std;

#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test int t;cin>>t;while(t--)
#define X first
#define Y second
#define pb push_back
#define all(s) s.begin(),s.end()

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

const int MOD = 1e9+7;

int ans;
void find(vector<int> &curr, int x, int idx, vector<int> &c, vector<vector<int>> &arr,int cost){
    int n = arr.size();
    int m = arr[0].size();
    
    bool flag = true;
    for(int i=0;i<m;i++){
        if(curr[i]<x){
            flag = false;
            break;
        }
    }
    if(flag){
        ans = min(ans,cost);
        return;
    }
    if(idx==n) return;
    find(curr,x,idx+1,c,arr,cost);
    for(int i=0;i<m;i++){
        curr[i] += arr[idx][i];
    }
    find(curr,x,idx+1,c,arr,cost+c[idx]);
    for(int i=0;i<m;i++){
        curr[i] -= arr[idx][i];
    }

}

void solve(){
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> arr(n,vector<int>(m));
    for(int i=0;i<n;i++){
        cin >> c[i];
        for(int j=0;j<m;j++){
            cin >> arr[i][j];
        }
    }
    vector<int> curr(m,0);
    ans = INT_MAX;
    find(curr,x,0,c,arr,0);
    if(ans==INT_MAX)
        ans = -1;
    cout << ans;
}

int main(){
    FIN;   
    // test
    solve();
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)


ll capasity[5];
ll numpeople = 0;
ll minutes = 0;

int main() {
    cin >> numpeople;
    REP(i,5) cin >> capasity[i];

    bool complete = true;
    ll min = pow(10,15);

    REP(i,5)
    {
        if (min > capasity[i]) 
           min = capasity[i]; 
    }
    
    if (min >= numpeople) 
        minutes = 5;
    else if(numpeople % min == 0)
        minutes = 5 + (numpeople / min) - 1 ;
    else
        minutes = 5 + (numpeople / min);


    printf("%lld", minutes);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
    private static void p(Object x) {
        System.out.println(x);
    }

    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int count = 0;
        for (int x = 0; x <= k; x++) {
            for (int y = 0; y <= k; y++) {
                int z = s - x - y;
                if (z >= 0 && z <= k) {
                    count++;
                }
            }
        }
        p(count);
    }
}


Measured memory_bytes: 21844
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
use std::cmp::{max, min};
fn main() {
    input! { n, mut wsv: [(usize, usize, usize); n] };
    let max_ws = wsv.iter().map(|&(w, s, _v)| w + s).max().unwrap();
    wsv.sort_by_key(|&(w, s, _v)| w + s);
    let mut dp = vec![0; max_ws + 1];
    for &(w, s, v) in &wsv {
        for j in (0..min(max_ws - w, s) + 1).rev() {
            dp[j + w] = max(dp[j + w], dp[j] + v);
        }
    }
    println!("{}", dp.iter().max().unwrap());
}


Measured memory_bytes: 4352
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int numberArray [] = new int [n];
        int count = 0;
        
        for(int i = 0; i < n; i++){
            numberArray[i] = sc.nextInt();
        }
        //バブルソート
        
        for(int i = 0; i < n - 1; i++){
            for(int j = n - 1; j >= i + 1; j--){
                if(numberArray[j - 1] > numberArray[j]){
                    count++;
                    int tmp = numberArray[j];
                    numberArray[j] = numberArray[j - 1];
                    numberArray[j - 1] = tmp;
                    
                }
            }
        }
        StringBuilder stringBuilder = new StringBuilder();
        for(int i = 0; i < n; i++){
            if(i != 0){
                stringBuilder.append(" ");
            }
                stringBuilder.append(numberArray[i]);
        }
        stringBuilder.append("\n").append(count);
        System.out.println(new String(stringBuilder));
    }
}


Measured memory_bytes: 26408
#include <iostream>

//calc G.C.D(m >= n)
int calcGcd(int m, int n);
//calc L.C.M
inline int calcLcm(int m, int n, int gcd);

int main(){
	int a, b;
	
	while(std::cin >> a >> b){
		int gcd, lcm;
		
		if(a > b) gcd = calcGcd(a, b);
		else gcd = calcGcd(b, a);
		lcm = calcLcm(a, b, gcd);
		
		std::cout << gcd << " " << lcm << std::endl;
	}
	
	return 0;
}

int calcGcd(int m, int n){
	return n == 0 ? m : calcGcd(n, m%n);
}

inline int calcLcm(int m, int n, int gcd){
	return m / gcd * n;
}

Measured memory_bytes: 1160
a, b, c = sorted(list(map(int, input().split())))
count = 0
if (b - a) % 2 == 1:
    count += 1
    a += 1
    c += 1
a += c - b
count += c - b
b = c
count += (b - a) / 2
a += (b - a) / 2
print(int(count))


Measured memory_bytes: 3060
import sys
X = int(input())
P = [2]
if X == 2:
    print(2)

    sys.exit()
for i in range(3, 10**6):
    for l in range(len(P)):
        if i % P[l] == 0:
            break
        elif l == len(P)-1 and i >= X:
            print(i)
            sys.exit()
        elif l == len(P)-1:
            P.append(i)


Measured memory_bytes: 43132
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    ll d;
    cin>>d;
    if(d==22){
        cout<<"Christmas Eve Eve Eve"<<endl;
    }
    if(d==23){
        cout<<"Christmas Eve Eve"<<endl;
    }
    if(d==24){
        cout<<"Christmas Eve"<<endl;
    }
    if(d==25){
        cout<<"Christmas"<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)

C = Array.new(N + 1, 0)
counterA = A.tally
counterA.default = 0
cnt = 0
1.upto(N) do |num|
  c = counterA[num]
  cnt += c
  C[num] += cnt
end

D = Array.new(N + 1, 0)
counterB = B.tally
counterB.default = 0
cnt = 0
max_d = 0
1.upto(N) do |num|
  c = counterB[num]
  if N < counterA[num] + c
    puts "No"
    exit
  end

  cnt += c
  D[num] += cnt
  diff = C[num] - D[num - 1]
  max_d = diff if max_d < diff
end

puts 'Yes'
puts B.rotate(-max_d).join(' ')


Measured memory_bytes: 60924
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
const int M = 2e5 + 10;
int a[M] , vis[M] , cnt[M];
int main() {
    int n , m;
    scanf("%d%d" , &n , &m);
    int ans = n;
    for(int i = 1 ; i <= n ; i++) {
        scanf("%d" , &a[i]);
        cnt[a[i]]++;
        int pos = a[i] - cnt[a[i]];
        if(pos >= 0) {
            if(!vis[pos]) ans--;
            vis[pos]++;
        }
    }
    while(m--) {
        int x , y;
        scanf("%d%d" , &x , &y);
        int pos = a[x] - cnt[a[x]];
        if(pos >= 0) {
            vis[pos]--;
            if(!vis[pos]) ans++;
        }
        cnt[a[x]]--;
        a[x] = y;
        cnt[a[x]]++;
        pos = a[x] - cnt[a[x]];
        if(pos >= 0) {
            if(!vis[pos]) ans--;
            vis[pos]++;
        }
        printf("%d\n" , ans);
    }
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    long x;
    cin >> n >> x;
    vector<long> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    long c = 0;
    for (int i = 1; i < n; ++i) {
        long s = a[i-1] + a[i];
        if (s > x) {
            c += min(s - x, a[i]);
            a[i] -= min(s - x, a[i]);
            c += a[i] + a[i-1] - x;
            a[i-1] -= a[i] + a[i-1] - x;
        }
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(((C-1)/B+1)>((A-1)/D+1)){
    cout << "No" <<endl;
  }else{
    cout << "Yes" <<endl;
  }

}



Measured memory_bytes: 3604
#!/usr/bin/ruby
n,k=gets.split.map(&:to_i)
s=gets.chomp.chars
f=false
i=0
while i<n&&k>0
	if (s[i]=='A')^f
		s[i]=f ? 'A' : 'B'
	else
		f^=true
		s[n+i]=f ? 'B' : 'A'
		i+=1
	end
	k-=1
end
if 0<k
	if n%2>0
		print (s[i]=='A')^f^(k%2>0) ? 'A' : 'B'
	end
	puts 'BA'*(n/2)
else
	puts s[i,n].map{|c|(c=='A')^f ? 'A' : 'B'}*''
end

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

public class Main {

	void solve() {
		out.println(in.nextToken().startsWith("YAKI") ? "Yes" : "No");
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
				}
			}
			return st.nextToken();
		}

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

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

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

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


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;

ll fact(ll x){ll a=1;while(x>0){a*=x;a=a%1000000007;x--;}return a;}

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

	ll n, m;
	cin >> n >> m;

	if(abs(n-m) > 1){
		// cout << "not" << endl;
		cout << 0 << endl;
		return 0;
	}

	if(n == m){
		// cout << fact(n) << ' ' << fact(m) << endl;
		ll ans = 2*fact(n)*fact(m);
		cout << ans % 1000000007 << endl;
	}else{
		ll ans = fact(n)*fact(m);
		cout << ans % 1000000007 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    string s;
    cin >> s;
    map<char, int> mp;
    rep(i, 0, (int)s.size()) mp[s[i]]++;
    if (mp.size() == 4) cout << "Yes" << endl;
    else if (mp['N'] && mp['S'] && !mp['W'] && !mp['E']) cout << "Yes" << endl;
    else if (!mp['N'] && !mp['S'] && mp['W'] && mp['E']) cout << "Yes" << endl;
    else cout << "No" << endl; 
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int total_a=0, total_b=0, a, b;
    for(int i=1; i<=4; i++){
        scanf("%d", &a);
        total_a += a;
    }
    for(int i=1; i<=4; i++){
        scanf("%d", &b);
        total_b += b;
    }
    if(total_a >= total_b) printf("%d\n", total_a);
    else printf("%d\n", total_b);
    return 0;
    
}



Measured memory_bytes: 2732
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

int main() {
  int sum=0,i,name,count;
  string s;
  map<int,int> a,b;
  map<int,int>::iterator it,it2;
  
  while(1) {
    getline(cin, s);
    if(s=="") break;
    i=0;
    name=0;
    while(1) {
      if(s[i]==',') break;
      name*=10;
      name+=(int)s[i]-48;
      i++;
    }
    it=a.find(name);
    if(it==a.end()){
      a.insert(make_pair(name,1));
    } else {
      count=it->second;
      a.erase(it);
      a.insert(make_pair(name,count+1));
    }
  }
  while(scanf("%d%*c%*d",&name)==1) {
    it=b.find(name);
    if(it==b.end()){
      b.insert(make_pair(name,1));
    } else {
      count=it->second;
      b.erase(it);
      b.insert(make_pair(name,count+1));
    }
  }

  for(it=b.begin(); it!=b.end(); it++) {
    it2=a.find(it->first);
    if(it2!=a.end()) cout << it->first << " " << it->second+it2->second << endl;
  }
  return 0;
}


Measured memory_bytes: 1236
import java.util.*;

public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String line1 = sc.nextLine();
      String line2 = sc.nextLine();
      String[] line3 = line1.split(" ",0);
      String[] line4 = line2.split(" ",0);
      int H = Integer.parseInt(line3[0]);
      int W = Integer.parseInt(line3[1]);
      int h = Integer.parseInt(line4[0]);
      int w = Integer.parseInt(line4[1]);
      System.out.println((H-h)*(W-w));
    }
}

Measured memory_bytes: 22740
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include<climits>
using namespace std;
string s1, s2;
int main()
{
	s1 = "CODEFESTIVAL2016";
	cin>>s2;
	int ans = 0;
	for(int i = 0; i < s2.size(); i++)
        if(s1[i] != s2[i]) ans++;
    cout<<ans;
	return 0;
}


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

const ll INF = 1LL << 60;

ll N;
string S;
int main() {
    cin >> N >> S;
    vector<ll> R(N + 1), G(N + 1), B(N + 1);
    R[0] = 0;
    G[0] = 0;
    B[0] = 0;
    
    rep(i, S.size()) {
        if (S[i] == 'R') {
            R[i + 1] = R[i] + 1;
            G[i + 1] = G[i]; 
            B[i + 1] = B[i];
        } else if (S[i] == 'G') {
            R[i + 1] = R[i];
            G[i + 1] = G[i] + 1;
            B[i + 1] = B[i];
        } else {
            R[i + 1] = R[i];
            G[i + 1] = G[i];
            B[i + 1] = B[i] + 1;
        }
    }

    // rep(i, N + 1) {
    //     cout << R[i] << " ";
    // }
    ll ans = 0;
    for (int i = 1; i <= N - 1; i++) {
        if (S[i] == 'R') {
            // 左 G, 右 B
            ll tmp1 = (G[i] - G[0]) * (B[N] - B[i]);

            // 左 B, 右 G 
            ll tmp2 = (B[i] - B[0]) * (G[N] - G[i]);
            ans += tmp1;
            ans += tmp2;
            
        } else if (S[i] == 'G') {
            // 左 R 右 B
            ll tmp1 = (R[i] - R[0]) * (B[N] - B[i]);

            // 左 B, 右 R 
            ll tmp2 = (B[i] - B[0]) * (R[N] - R[i]);
            // cout << tmp1 << " " << tmp2 << endl;

            ans += tmp1;
            ans += tmp2;
        } else {
            // 左 R 右 G 
            // 左 G 右 R 
            ll tmp1 = (R[i] - R[0]) * (G[N] - G[i]);
            ll tmp2 = (G[i] - G[0]) * (R[N] - R[i]);

            ans += tmp1;
            ans += tmp2;
        }
    }

    ll c;
    // 距離 
    rep(k, N) {
        // 始点
        // cout << k << endl;
        // 中点
        for (int j = 1; j <= N - 1; j++) {
            if (j - k - 1 < 0) continue;
            if (j + k + 1 >= N) continue; 

            if (S[j] != S[j - k - 1] && S[j] != S[j + k + 1] &&
                S[j - k - 1] != S[j + k + 1]) {
                // cout << j - k - 1 << " " << j << " " << j + k + 1 << endl;
                ans--;
                // c++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3736
def is_ok(arg):
    return not Alist[arg] <= t
    

def bisect(ok, ng):
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

Alist = [0]
for i in range(N):
    Alist.append(Alist[i] + A[i])

ans = 0
for i in range(N+1):
    if Alist[i] <= K:
        ans = i
    else:
        break

b = 0
for i in range(M):
    b += B[i]
    t = K - b

    if t >= 0:
        res = bisect(N + 1, -1)
        ans = max(ans, i + res)

    else:
        break

print(ans)

Measured memory_bytes: 40432