akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

int main(void)
{
    int k;
    int a[5];
    
    rep(i, 5)
    {
        cin >> a[i];
    }
    cin >>k;

    
    if(a[4] - a[0] <= k) cout << "Yay!" << endl;
    else cout << ":(" << endl;


    
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		System.out.println(a%2==0 ? (a/2)*(a/2) : (a/2)*(a+1)/2);
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((ll)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
typedef long long ll;
ll INF = 1e18;
using namespace std;

int main(){
  string S;
  cin >> S;

  ll l = 0;
  ll r = 0;
  vector<ll> ans(sz(S));
  rep(i,sz(S)){
    if(i==sz(S))continue;
    char s = S[i];
    char n = S[i+1];
    if(s=='R')r += 1;
    if(s=='L')l += 1;
    
    if((s=='R') and (n=='L')){
      ll j = i+1;
      while(S[j]=='L'){
        l += 1;
        ++j;
      }
      
      if(r%2 == l%2){
        ans[i] = (l+r)/2;
        ans[i+1] = ans[i];
      }
      else if((r%2==0) and (l%2!=0)){
        ans[i] = (r+l)/2;
        ans[i+1] = (r+l)/2 + 1;
      }
      else{
        ans[i] = (r+l)/2 + 1;
        ans[i+1] = (r+l)/2;
      }
      
      i = j-1;
      l = 0;
      r = 0;
    }
  }

  rep(i,sz(S)){
    cout << ans[i] << " ";
  }
  
  cout << endl;


  return 0;
}


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

int main() {

	int N;
  cin >> N;
	vector<string> S(N);
	for (int i = 0; i < N; i++) {
		cin >> S.at(i);
	}
	int a = 0;
	int b = 0;
	int c = 0;
	int d = 0;
	for (int i = 0; i < N; i++) {
		if (S.at(i) == "AC") {
			a++;
		}
		else if (S.at(i) == "WA") {
			b++;
		}
		else if (S.at(i) == "TLE") {
			c++;
		}
		else {
			d++;
		}
	}
	cout << "AC x " << a << endl;
	cout << "WA x " << b << endl;
	cout << "TLE x " << c << endl;
	cout << "RE x " << d << endl;
}


Measured memory_bytes: 6424
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int scoreA = 0;
		for (int i = 0; i < 4; i++){
			scoreA += sc.nextInt();
		}
		int scoreB = 0;
		for (int i = 0; i < 4; i++){
			scoreB += sc.nextInt();
		}
		if (scoreA >= scoreB){
			System.out.println(scoreA);
		}
		else {
			System.out.println(scoreB);
		}
	}

}



Measured memory_bytes: 26168
n,m = map(int,input().split())
ab = [0] * n
ans = 0
for i in range(n):
    a,b = map(int,input().split())
    ab[i]= (a,b)
ab.sort()

for i in range(n):
    if m > ab[i][1]:
        m -= ab[i][1]
        ans += ab[i][0] * ab[i][1]
    else:
        ans += ab[i][0] * m
        break

print(ans)

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

int main(){
  int n,m,a,d,tmp;
  int b[30][10];
  string s;
  bool flag;

  while(1){
    cin >> n;
    if(!n)break;

    cin >> m;
    cin >> a;
    cin >> d;

    for(int i=0;i<d;i++){
      cin >> s;
      for(int j=0;j<n-1;j++)b[i][j] = s[j]-'0';
    }

    tmp = m;
    for(int i=0;i<d;i++){
      if(tmp<n && b[i][tmp-1])tmp++;
      else if(tmp>1 && b[i][tmp-2])tmp--;
    }
    if(tmp == a)cout << 0 << endl;
    else{
      flag = false;
      for(int i=0;i<d;i++){
	for(int j=0;j<n-1;j++){
	  if( !b[i][j] && (!j || !b[i][j-1]) && (j==n-2 || !b[i][j+1]) ){
	    b[i][j] = 1;
	    
	    tmp = m;
	    for(int k=0;k<d;k++){
	      if(tmp<n && b[k][tmp-1])tmp++;
	      else if(tmp>1 && b[k][tmp-2])tmp--;
	    }

	    if(tmp == a){
	      flag = true;
	      cout << i+1 << " " << j+1 << endl;
	    }

	    b[i][j] = 0;
	  }
	  if(flag)break;
	}
	if(flag)break;
      }

      if(!flag) cout << 1 << endl;
    }
  }
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef unsigned int uint;

char S[2020][2020];
int P[2020][2020];
int Q[2020][2020];
int R[2020][2020];
int n, m, q;

int get(int T[][2020], int x1, int y1, int x2, int y2){
	return T[x2][y2] - T[x1-1][y2] - T[x2][y1-1] + T[x1-1][y1-1];
}

void solve(){
	scanf("%d%d%d", &n, &m, &q);
	for(int i=1;i<=n;i++) scanf("%s", S[i]+1);
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) {
		P[i][j] = P[i-1][j] + P[i][j-1] - P[i-1][j-1] + (S[i][j] - '0');
		Q[i][j] = Q[i-1][j] + Q[i][j-1] - Q[i-1][j-1] + (S[i][j] - '0') * (i?(S[i-1][j] - '0'):0);
		R[i][j] = R[i-1][j] + R[i][j-1] - R[i-1][j-1] + (S[i][j] - '0') * (j?(S[i][j-1] - '0'):0);
	}
	rep(u, q){
		int x1, y1, x2, y2; scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
		int ans = get(P, x1, y1, x2, y2);
		ans -= get(Q, x1+1, y1, x2, y2);
		ans -= get(R, x1, y1+1, x2, y2);
		printf("%d\n", ans);
	}
}

int main(){
	int Tc = 1; //scanf("%d\n", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 53504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int main(){
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    int ans = 0;
    for(int i=0;i<=N;i++){
        if(i % R != 0) continue;
        for(int j=0;j<=N;j++){
            if(j % G != 0) continue;
            int rest = N - i - j;
            if(rest < 0) continue;
            if(rest % B != 0) continue;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
int main()
{
	LL n,p;
	scanf("%lld%lld",&n,&p);
	LL cnt = 0,s = 1;
	if (n == 1) {
		printf("%lld\n",p);
		return 0;
	}
	for (LL i = 2; i <= sqrt(p); i++){
		while (p % i == 0){
			cnt++;
			p /= i;
			if (cnt >= n){
				s *= i;
				cnt = 0;
			}
		}
		cnt = 0;
	}
	printf("%lld\n",s);
}

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

using namespace std;

const int N = 1e5 + 10;
const int Mod = 1e9 + 7;

typedef long long ll;

int mul(int a, int b) {
  return 1ll * a * b % Mod;
}

int n;
int f[1000010];
char s[1000010];
int cnt[N];

int main() {
	cin >> n;
	scanf("%s",s+1);
	for(int j=1;j<=n;j++){
		cnt[s[j]-'a']++;
	}
	int ans=1;
	for(int i=0;i<26;i++){
		ans=mul(ans,cnt[i]+1);
	}
	ans--;
	if(ans<0)
      ans+=Mod;
  cout << ans <<endl;
}

Measured memory_bytes: 384
def examA():
    a, b = LI()
    ans = (a+b+1)//2
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()


Measured memory_bytes: 3444
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = int(1e9);
typedef long long int ll;

/* -- template -- */

int main(){
    int N; cin >> N;
    int minv = INF;
    for(int i = 0;i <= N; ++i){
        int ans = 0;
        int t = i;
        while(t > 0){
            int a = 1;
            while(t - a >= 0){
                a *= 6;
            }
            a /= 6;
            t -= a;
            ++ans;
        }
        t = N - i;
        while(t > 0){
            int b = 1;
            while(t - b >= 0){
                b *= 9;
            }
            b /= 9;
            t -= b;
            ++ans;
        }
        minv = min(ans, minv);
    }
    cout << minv << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define neko 300010
#define f(i,a,b) for(register int i=(a);i<=(b);++i)
#define rf(i,a,b) for(register int i=(a);i>=(b);--i)
using namespace std;
int tp,n,lastn,m;
typedef long long arr[neko];
arr stk,cnt,ans;
typedef long long ll;
typedef pair<ll,ll> pi;
queue<pi>q;
int main()
{
	ll x;
	pi p;
	scanf("%d%d",&n,&m);
	stk[tp=1]=n;
	f(i,1,m)
	{
		scanf("%lld",&x);
		while(x<=stk[tp])--tp;
		stk[++tp]=x;
	}lastn=n,n=stk[1],m=tp;
	cnt[m]=1;
	rf(i,m,1)
	{
		if(cnt[i])q.push(pi(stk[i],cnt[i]));
		while(!q.empty())
		{
			p=q.front(),q.pop();
			if(p.fi<=n){ans[p.fi]+=p.se;continue;}
			x=lower_bound(stk+1,stk+m+1,p.fi)-stk-1;
			cnt[x]+=p.fi/stk[x]*p.se;
			if(p.fi%stk[x])q.push(pi(p.fi%stk[x],p.se));
		}
	}rf(i,n-1,1)ans[i]+=ans[i+1];
	f(i,1,lastn)printf("%lld\n",ans[i]);
}

Measured memory_bytes: 6656
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# static colors [gray, brown, green, water, blue, yellow, orange, red, free]
color_list = [0] * 9


def check_color(a):
    if a <= 399:
        return 0
    elif (a >= 400) & (a <=799):
        return 1
    elif (a >= 800) & (a <=1199):
        return 2
    elif (a >= 1200) & (a <=1599):
        return 3
    elif (a >= 1600) & (a <=1999):
        return 4
    elif (a >= 2000) & (a <=2399):
        return 5
    elif (a >= 2400) & (a <=2799):
        return 6
    elif (a >= 2800) & (a <=3199):
        return 7
    elif (a >= 3200):
        return 8

# input
N = int(input())
a_list = list(map(int, input().split()))

# do
ans = 0
for i in range(len(a_list)):
    n = check_color(a_list[i])
    if (color_list[n] == 0) & (n <= 7):
        ans += 1
    color_list[n] += 1

min = ans
if (min == 0):
    min = 1
max = ans + color_list[8]
print (str(min) + " " + str(max))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  int N; cin >> N;
  string S1,S2; cin >> S1 >> S2;
  int index=0;
  int ans=1;
  if(S1[0]==S1[1]) ans=6;
  else ans=3;
  while(index+1<SZ(S1)){
    if(S1[index]!=S1[index+1]){
      if(index+2<SZ(S1) && S1[index+1]==S1[index+2]){
        ans*=2;
        ans%=MOD;
        index++;
      }
      else{
        ans*=2;
        ans%=MOD;
        index++;
      }
    }
    else{
      if(index+2>=SZ(S1)) break;
      if(index+3<SZ(S1) && S1[index+2]==S1[index+3]){
        ans*=3;
        ans%=MOD;
        index+=2;
      }
      else{
        index+=2;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	A, B, N := nextInt(), nextInt(), nextInt()
	var ans, x int
	if N < B {
		x = N
	} else {
		x = B - 1
	}
	ans = (A * x) / B
	fmt.Println(ans)
}

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


Measured memory_bytes: 1792
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    
    long sum = 0;

    for(int i = 0 ; i < n ; ++i){
      long a = sc.nextInt();
      sum += a;
    }

    System.out.println(sum - n);
    
  }
}

Measured memory_bytes: 40552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int n = 205;

int N;

int col[n], d[n];
bool vis[n];
vector<int> G[n];

bool DFS(int v, bool c){
	vis[v] = true;
	col[v] = c;
	bool val = true;
	for(int u : G[v]){
		if(vis[u] && col[u] == c)
			return false;
		if(!vis[u])
			val &= DFS(u, !c);
	}
	return val;
}

int dist(int v){
	vis[v] = true;
	d[v] = 0;
	queue<int> Q;
	Q.push(v);
	while(!Q.empty()){
		int u = Q.front();
		Q.pop();
		for(int x : G[u]){
			if(!vis[x]){
				d[x] = d[u]+1;
				vis[x] = true;
				Q.push(x);
			}
		}
	}
	int mxD = 0;
	for(int i = 0; i < N; ++i){
		mxD = max(mxD, d[i]);
	}
	return mxD;
}

int main(){
	cin >> N;
	for(int i = 0; i < N; ++i){
		string s ;
		cin >> s;
		for(int j = 0; j < N; ++j){
			if(s[j] == '1')
				G[i].push_back(j);
		}
	}
	bool val = true;
	val = DFS(0, false);
	if(!val){
		cout << "-1\n";
		return 0;
	}
	int mx = 0;
	for(int i = 0; i < N; ++i){
		fill_n(vis, N, 0);
		fill_n(d, N, 0);
		int d = dist(i);
		//cerr << "d(" << i << "): " << d<<endl;
		mx = max(mx, d);
	}
	cout << mx + 1 << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;

int main(){

	int n;
	int a[11];
	int M = 0;
	int sum = 0;
	int ans;

	cin >> n;

	for (int i = 1; i <= n; i++) { cin >> a[i]; M = max(M, a[i]); sum += a[i]; }

	M = M / 2;

	ans = sum - M;

	cout << ans << endl;

}

Measured memory_bytes: 256
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e5 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll k;
    cin >> k;
    vector<ll> ans, v(9);
    iota(v.begin(), v.end(), 1);
    while (ans.size() < N)
    {
        vector<ll> f;
        for (ll e : v)
        {
            ans.push_back(e);
            if (e % 10)
                f.push_back(10 * e + e % 10 - 1);
            f.push_back(10 * e + e % 10);
            if (e % 10 < 9)
                f.push_back(10 * e + e % 10 + 1);
        }
        v = f;
    }
    cout << ans[k - 1];
}

Measured memory_bytes: 10100
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL;
  typedef pair<ll,char> PLC;
  typedef pair<char,ll> PCL;

int main(void){
  int N,K;cin >> N >> K;
  string S;cin >> S;
  int i;REP(i,N){
    if(i+1 == K) cout << (char)(S[i] - 'A' + 'a');
    else cout << S[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10 ;
constexpr int mod = 1e9 + 7 ;
int r1, r2, c1, c2 ;
void plusle (int &a, int b) {
    if (( a += b) >= mod ) a -= mod ;
}
void minun (int &a, int b) {
    if ((a -= b) < 0) a += mod ;
}
int add (int a, int b) {
    return (( a += b ) >= mod ) ? a - mod  : a;
}
int sub (int a, int b) {
    return (( a -= b) < 0) ? a + mod : a;
}
int mul(int a, int b) {
    return 1LL * a * b % mod;
}
int power(int a, int b) {
    int res = 1;
    for (; b > 0 ; b >>= 1 , a = mul(a, a))
        if (b & 1) res = mul(res, a);
    return res ;
}
const int Mx = 2e6 + 10;
int fac[Mx], invf[Mx] ;
void prefact () {
    fac[0] = 1 ;
    for (int i = 1 ; i < Mx ; i ++) {
        fac[i] = mul(fac[i - 1], i);
    }
    invf[Mx - 1] = power (fac[Mx - 1] ,  mod - 2 );
    for (int i = Mx - 2 ; i >= 0 ; i --) {
        invf[i] = mul(invf[i + 1], i + 1);
    }
}

int ncr (int N, int R) {
    if (R > N) return 0;
    if (R == 0 || R == N) return 1;
    return mul (fac[N], mul(invf[N - R], invf[R]));
}

/**
    find the number of ways to move from (0 , 0)
    to any of square (r , c ) -> r1 <= r <= r2 , c1 <= c <= c2
    Let's represent the number of ways again
    To move from (0 , 0 ) to any (r , c)
    RRRRR -> r chars and UUUUU -> c chars
    and the number of shuffle equal to (r + c)! / (r!) / (c!)
    or (r + c) choose r
    Then it's trivially ask you
    compute summation (r + c) choose (r) from r = r1 to r = r2 and c from c1 to c2
    This can be done easily in O(rc)
    Of course, we can do it better. ;)
    Let's iterate over r from r1 to r2
    summation (r + c) choose r from c1 to c2
    by Pascal's theorem
    (r , 0 ) + (r + 1 , 1 ) + (r + 2 , 2) ...
    (r + 1 , 0) + (r + 1, 1) ->
    (r + 2, 1) + (r + 2 ,  2) -> (r + 3, 2 ) + (r + 3, 3)
    .... (r + c + 1 , c)
*/
int main () {
    prefact () ;

    scanf("%d %d %d %d", &r1, &c1, &r2, &c2);
    auto sum = [&] (int r, int c) -> int{
            /// (r , 0) + (r + 1 , 1) , .... (r + c, c)
            return ncr(r + c + 1, c);
    };
    int ans = 0;
    for (int r = r1 ; r <= r2 ; ++ r) {
        plusle (ans, sub (sum(r , c2), sum (r, c1 - 1)));
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 15872
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(N) for (int i = 0; i < N; i++)

int count_char(string S, char c){
    int count = 0;
    int pos = S.find(c);

    while (pos != string::npos){
        count++;
        pos = S.find(c, pos + 1);
    }

    return count;
}

int main(){
    string S, T;
    cin >> S >> T;
    int i = 0;
    vector<int> S_char_counts('z'-'a' + 1);
    vector<int> T_char_counts('z'-'a' + 1);
    bool can_match = true;
    for (char c = 'a'; c <= 'z'; c++){
        S_char_counts[i] = count_char(S, c);
        T_char_counts[i] = count_char(T, c);
        i++;
    }
    sort(S_char_counts.begin(), S_char_counts.end());
    sort(T_char_counts.begin(), T_char_counts.end());
    for (i = 0; i < 'z' - 'a' + 1; i++){
        if (S_char_counts[i] == T_char_counts[i]){
            continue;
        }else{
            can_match = false;
            break;
        }
    }
    if (can_match == true) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 776
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll h, w;
	cin >> h >> w;
	ll ans = h * w;
	for(ll divh = 1; divh < h; ++divh){
		ll a = w * divh;
		{// vertical
			ll b = (h - divh) * (w / 2);
			ll c = h * w - a - b;
			ll cmp = max({a,b,c}) - min({a,b,c});
			chmin(ans, cmp);
		}
		{// horizonal
			ll b = ((h - divh) / 2) * w;
			ll c = h * w - a - b;
			ll cmp = max({a,b,c}) - min({a,b,c});
			chmin(ans, cmp);
		}
	}
	for(ll divw = 1; divw < w; ++divw){
		ll a = h * divw;
		{// horizonal
			ll b = (w - divw) * (h / 2);
			ll c = h * w - a - b;
			ll cmp = max({a,b,c}) - min({a,b,c});
			chmin(ans, cmp);
		}
		{// vertical
			ll b = ((w - divw) / 2) * h;
			ll c = h * w - a - b;
			ll cmp = max({a,b,c}) - min({a,b,c});
			chmin(ans, cmp);
		}
	}
	std::cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <list>
using namespace std;

int main() {
    int n;
    cin >> n;
    if (n % 2 == 0) cout << n << endl;
    else cout << 2 * n << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int N; cin >> N;
	cout << ((N-9)%10 == 0 || (N-90) >= 0?"Yes":"No") << endl;
	return 0;
}

Measured memory_bytes: 256
H, W, N = gets.split.map(&:to_i)
dir = [-2, -1, 0].repeated_permutation(2)
lt = {}
N.times do
  a, b = gets.split.map(&:to_i)
  dir.each do |x, y|
    r, c = a + x - 1, b + y - 1
    next if r < 0 || r >= H - 2 || c < 0 || c >= W - 2
    key = r * 10 ** 10 + c
    lt[key] = 0 unless lt[key]
    lt[key] += 1
  end
end
h = (1..9).map { |i| [i, 0] }.to_h
lt.each_value { |v| h[v] += 1 }
h[0] = (H - 2) * (W - 2) - lt.size
10.times { |i| puts h[i] }


Measured memory_bytes: 93308
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<>());
    if(s<t)printf("Yes");
    else printf("No");
    return 0;
    
}


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

int gcd(int a, int b){
    return b==0 ? a : gcd(b, a%b);
}

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

    int g = gcd(w,h);
    cout << w*h/g/g*c << endl;
    
    return 0;
}


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

int main(int argc, char* argv[]) {
  int H, W;
  int h, w;
  std::cin >> H >> W;
  std::cin >> h >> w;
  std::cout << H * W - h * W - w * H + h * w << std::endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())

def divisors(n):
    ret = set()

    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            ret.add(i)
            ret.add(n // i)
    return ret

div_lis = sorted(list(divisors(n)))

if len(div_lis) % 2 == 0:
    print(div_lis[(len(div_lis) - 1) // 2] + div_lis[(len(div_lis) + 1) // 2] - 2)
else:
    print(div_lis[len(div_lis) // 2] * 2 - 2)

Measured memory_bytes: 3828
# include <bits/stdc++.h>
typedef long long ll ;//ポインタ？とかいうテクニックだと思う．これでllを定義
int N ;
ll L [87];//Lを先に宣言してる
int main(){
scanf ("%d",&N);//Nは87までしかないからdouble型でおけ
L[0]=2LL,L[1]=1LL;//Lは桁数が多いからll型じゃないと桁数が足りなくなる
for ( int i =2; i <= N ; i ++) L[i] = L[i-2] + L[i-1];
printf ("%lld\n", L[N]); //printの時にも桁数必要だから，%lldのフォーマット指定子が必要（32ビットシステム？）
}

Measured memory_bytes: 256
a;long d[2<<17],*p,m=1e9+7;f(){*p+=p[1];d-p--&&f();*p=(*p-p++[a+1])%m;}main(){scanf("%*d%d",&a);p=d+a;for(*p=1;~scanf("%d",&a);)f();printf("%d",*d);}

Measured memory_bytes: 2560
import numpy as np
MOD = 10 ** 9 + 7

n=int(input()) #3
alst=list(map(int,input().split())) #[1,2,3]

# 累積和を求める

# 例
# [1,2,3,4,5,6]の時、累積和は、
# [0,0+1,0+1+2,0+1+2+3,0+1+2+3+4,0+1+2+3+4+5,0+1+2+3+4+5+6]

s=[0]
for i in range(len(alst)):
  s.append(s[i]+alst[i])

sum=0

for i in range(len(alst)-1):
  sum+=alst[i]*(s[len(s)-1]-s[i+1])

print(sum%MOD)

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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define ins insert
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)9e18);
const int ninf=((int)-9e18);
const int mod=1000000007;

using namespace std;

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    int n,k;
    cin>>n>>k;
    int c=0;

    while(n>0)
    {
        c++;
        n/=k;
    }

    cout<<c;


    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int X[200200];
int main()
{
  int N,K;
  cin>>N>>K;
  for(int i=0;i<N;i++)
    cin>>X[i];
  for(int i=K;i<N;i++)
    if(X[i]>X[i-K])
      puts("Yes");
    else	puts("No");
  return 0;
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<int> vi;
typedef vector<ll> vl;
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    int n,q;
    cin >> n >> q;
    string s;
    cin >> s;
    vi ac(n,0);
    rep(i,n){
        if(s[i]=='A'){
            if(i+1<n&&s[i+1]=='C') ac[i+1]=1;
        }
    }
    vi rui(n,0);
    rep(i,n){
        if(i==0) rui[i]=ac[i];
        else{
            rui[i]=rui[i-1]+ac[i];
        }
    }
    vi ans(q,0);
    rep(i,q){
        int l,r;
        cin >> l >> r;
        ans[i]=rui[r-1]-rui[l-1];
    }
    rep(i,q){
        cout << ans[i] <<endl;
    }
    return 0;
}


Measured memory_bytes: 2176
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define pii pair<int, int>
#define pll pair<long long, long long>
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int T; cin >> T;
    while (T--) {
        int Y,M,D; cin >> Y >> M >> D;
        int cnt = 0;
        while (Y < 1000) {
            D++;
            if (Y%3 != 0 && M%2 == 0) {
                if (D == 20) {
                    M++;
                    D = 1;
                }
            } else {
                if (D == 21) {
                    M++;
                    D = 1;
                }
            }
            if (M == 11) {
                Y++;
                M = 1;
            }
            cnt++;
        }
        cout << cnt << endl;
    }
}


Measured memory_bytes: 3132
#include <iostream>
#include <algorithm>
#include <stack>
#include <set>
using namespace std;

set<int> se[510],ko;
int main(){
	int N,M,ma,sa,hog;
	stack<int> st;
	set<int>::iterator it;
	while(1){
		cin>>N>>M;
		if(N==0&&M==0) break;
		for(int i=1;i<=N;i++){
			se[i].clear();
		}
		ko.clear();
		for(int i=0;i<M;i++){
			cin>>ma>>sa;
			se[ma].insert(sa);
			se[sa].insert(ma);
		}

		//?????????ko?????\??????????????§???st????????\??????
		for(it=se[1].begin();it!=se[1].end();it++){
			ko.insert(*it);
			st.push(*it);
		}

		//st??????????????????????????£??\
		while(!st.empty()){
			hog=st.top();
			st.pop();
			for(it=se[hog].begin();it!=se[hog].end();it++){
				if(*it!=1)ko.insert(*it);
			}
		}
		cout<<ko.size()<<endl;
	}
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, b, n) for (int i = (b); i < (n); i++)
using namespace std;
using ll = long long;
const ll M = 1000000007;

int main() {
	int n;
	ll cnt = 0;
	cin >> n;
	for (int a = 1; a <= n; a++)
		for (int b = 1; a*b <= n; b++)
			if (n - a * b > 0) cnt++;
	cout << cnt << endl;
}

Measured memory_bytes: 3632
m, k = map(int, input().split())

if m*k == 1:
    print(-1)
    exit()

if 1 << m <= k:
    print(-1)
    exit()

if k == 0:
    t = []
    for i in range(1 << m):
        for _ in range(2):
            t.append(i)
    print(*t)
    exit()

b = []
for i in range(1 << m):
    if i != k:
        b.append(i)

c = b[::-1]

a = b + [k] + c + [k]
print(*a)


Measured memory_bytes: 95100
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<climits>

#define MAX_V 101
#define INF 10000000

using namespace std;


struct edge{int to, cost; };
typedef pair<int, int> P;

int V,mincost[MAX_V];
vector<edge>G[MAX_V];

int Prim(void){
  priority_queue<P, vector<P>, greater<P> >que;
  fill(mincost, mincost+V, INF);
  vector<bool> visited(V);
  fill(visited.begin(),visited.end(),false);

  mincost[0]=0;
  que.push(P(0,0));
  
  while(!que.empty()){
    P p = que.top();
    que.pop();
    
    int v = p.second;
    if(visited[v])continue;
    visited[v]=true;

    for(int i=0; i < G[v].size(); i++){
      edge e = G[v][i];
      if(mincost[e.to] > e.cost && !visited[e.to]){
	mincost[e.to] = e.cost;
	que.push(P(mincost[e.to], e.to));
      }
    }
  }
  int res=0;
  for(int i=0;i<V;i++)res+=mincost[i];
 
  return res;
}



int main(void){
  int m,a,b,c;
  char ch1,ch2;
  edge e;

  while(cin >> V,V){
    for(int i=0;i<V;i++)G[i].clear();
    cin >> m;
    for(int i=0;i<m;i++){
      cin >> a >> ch1 >> b >> ch2 >> c;
      c=c/100-1;
      e.to=b,e.cost=c;
      G[a].push_back(e);
      e.to=a;
      G[b].push_back(e);
    }
      cout << Prim() << endl;
  }

  return 0;
}

Measured memory_bytes: 1340
/*

    author : s@if

*/

#include<bits/stdc++.h>
using namespace std;
#define NIL -1
#define fi first
#define sec second
#define MAX INT_MAX
#define INF 99999999
#define ll long long
#define PI acos(-1.0)
#define MOD 1000000007
#define PLL pair<ll,ll>
#define PII pair<int,int>
#define triplell pair<pair<ll,ll> , ll>
#define triple pair<pair<int,int> , int>
#define For(i,n) for(int i=0;i<(int)n;i++)
#define Forn(i,a,b) for(int i=(int)a;i<=(int)b;i++)
#define forba(i,a,b) for(int i=(int)b;i>=(int)a;i--)

int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};

const int MAXN = (int)1e5+9;

const int N = 100000;

int chekh(string s)
{
	string ss = "ATCG";
	
	for(int i=0;i<s.size();i++)
	{
		if(find(ss.begin(),ss.end(),s[i])==ss.end())
			return 0;
	}
	
	return 1;
}

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */
    
    int i,j,k,l,m,n,p,q,r,tc,t;
    string s;
    vector<string>v;
    
    cin>>s;
    
    l=s.size();
    
    for(i=0;i<l;i++)
    {
    	for(j=1;j<=l;j++)
    	{
    		string ss="";
    		
    		for(k=i;k<j;k++)
    		{
    			ss+=s[k];
			}
			
    		v.push_back(ss);
		}
	}
	
	int mx =0;
	for(i=0;i<v.size();i++)
	{
		if(chekh(v[i]))
			mx=max(mx,(int)v[i].size());
	}
	cout<<mx<<endl;
	
//	main();

    return 0;
}

Measured memory_bytes: 256
// AtCoderTemplate.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<cstdio>
#include<iomanip>
#include<cmath>

#include<algorithm>
#include<vector>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

struct student
{
	int no;
	int count;
};

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


	vector<student> students;
	rep(i, n)
	{
		student s;
		s.no = i + 1;
		cin >> s.count;

		students.push_back(s);
	}

	auto a = [](student s1, student s2) {return s1.count < s2.count; };
	sort(students.begin(), students.end(), a);

	for (student s : students)
	{
		cout << s.no << endl;
	}

	return 0;
}


Measured memory_bytes: 1780
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int a, b, x;
	cin >> a >> b >> x;
	if (a + b >= x&&a <= x) cout << "YES\n";
	else cout << "NO\n";
}

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

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            var split = Console.ReadLine().Split(' ');
            int N = Int32.Parse(split[0]);
            int M = Int32.Parse(split[1]);
            int[] output = new int[N + 1];
            for (int c = 0; c < M; c++)
            {
                split = Console.ReadLine().Split(' ');
                int a = Int32.Parse(split[0]);
                int b = Int32.Parse(split[1]);
                output[a]++;
                output[b]++;

            }
            for (int c = 1; c < N + 1; c++)
            {
                Console.WriteLine(output[c]);
            }
        }
    }
}


Measured memory_bytes: 13140
n,m = map(int,input().split())
l,r = 0,n
for i in range(m):
    a,b = map(int,input().split())
    if a>l:
        l=a
    if b<r:
        r=b
if l<=r:
    print(r-l+1)
else:
    print(0)

Measured memory_bytes: 3060
#include <iostream>

int main() {
    long long n;
    long long ans = 0;
    std::cin >> n;
    for (long long i=1; i<=n; ++i) {
        if (i % 3 != 0 && i % 5 != 0) ans += i;
    }
    std::cout << ans << std::endl;
    return 0;
}


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

int main(){

  int a=0;
  int n=0;

  cin>>a>>n;
  
  int A[n];
  int sum=0;
  rep(i,n){

    cin>>A[i];
    sum+=A[i];
  }
  
  if(sum>=a)cout<<"Yes";
  else cout<<"No";
  
  
  
}

Measured memory_bytes: 640
import java.util.Scanner;
class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in); 
      int a = input.nextInt();
      int b =input.nextInt();
      for(int i =0; i<b; i++){
        	int c = input.nextInt();
      		a = a-c;
      }
      if(a<0){
        System.out.println ("-1");
      }
      else{
        System.out.println(a);
      }
    }
}

Measured memory_bytes: 46184
#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline int rd(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-') f=0;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return f?x:-x;
}
struct Node{
	int a,b,c;
}t[100050]; 
bool cmp(Node a,Node b){
	return a.a-a.b<b.a-b.b;
}
int n,X,Y,Z;
ll tot=0,ans=0;
priority_queue<ll,vector<ll>,greater<ll> >q;
ll lef[100050];
int main(){
	X=rd(),Y=rd(),Z=rd();n=X+Y+Z;
	for(int i=1;i<=n;i++){
		t[i].a=rd(),t[i].b=rd(),t[i].c=rd();
		tot+=t[i].c;
	}sort(t+1,t+1+n,cmp);
	ll sum=0;
	for(int i=1;i<=Y;i++){
		sum+=t[i].b-t[i].c;
		q.push(t[i].b-t[i].c);
	}
	for(int i=Y+1;i<=n-X+1;i++){
		lef[i]=sum;sum+=t[i].b-t[i].c;
		q.push(t[i].b-t[i].c);
		sum-=q.top();q.pop();
	}
	while(!q.empty()) q.pop();sum=0;
	for(int i=n;i>n-X;i--){
		sum+=t[i].a-t[i].c;
		q.push(t[i].a-t[i].c);
	}
	for(int i=n-X;i>=Y;i--){
		ans=max(ans,tot+lef[i+1]+sum);
		sum+=t[i].a-t[i].c;
		q.push(t[i].a-t[i].c);
		sum-=q.top();q.pop();
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2680
<?php
$dx = array(-1, 0, 1, 0);
$dy = array(0, 1, 0, -1);

while (fscanf(STDIN, "%d", $N) && $N) {
  unset($pos);
  for ($i = 0; $i < 401; $i++) {
    for ($j = 0; $j < 401; $j++) {
      $table[$i][$j] = 0;
    }
  }
  $table[200][200] = 1;
  $pos[0] = array(200, 200);
  
  for ($i = 1; $i < $N; $i++) {
    fscanf(STDIN, "%d %d", $n, $d);
    $x = $pos[$n][0] + $dx[$d];
    $y = $pos[$n][1] + $dy[$d];
    $table[$y][$x] = 1;
    $pos[$i] = array($x, $y);
  }

  $minX = 401;
  $minY = 401;
  $maxX = 0;
  $maxY = 0;
  
  for ($i = 0; $i < 401; $i++) {
    for ($j = 0; $j < 401; $j++) {
      if ($table[$i][$j]) {
        $minX = min($minX, $j);
        $minY = min($minY, $i);
        $maxX = max($maxX, $j);
        $maxY = max($maxY, $i);
      }
    }
  }

  printf("%d %d\n", $maxX - $minX + 1, $maxY - $minY + 1);
}
 

Measured memory_bytes: 29856
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    string s;
    cin >> s;
    int result = 0;
    int count = 0;
    for (string::iterator it = s.begin(); it != s.end(); ++it) {
        if (*it == 'A' || *it == 'T' || *it == 'C' || *it == 'G') {
            ++count;
        } else {
            result = max(result, count);
            count = 0;
        }
    }
    result = max(result, count);
    cout << result << endl;
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
nOdd=len(l)%2==1
if nOdd:
    num=[x for x in range(n) if n%2==0]
else:
    num=[x for x in range(n) if n%2!=0]
dic={}
for i in num:
    dic[i]=0
for i in l:
    dic.setdefault(i,0)
    dic[i]+=1
for i,c in dic.items():
    if i==0 and nOdd:
        if c!=1:
            print(0)
            exit()
    elif i==0 and not(nOdd):
        print(0)
        exit()
    elif c!=2:
        print(0)
        exit()
    


print(pow(2,n//2) % 1000000007)

Measured memory_bytes: 14436
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;



int main(){
   int N; cin >> N;
   vector<string> s(N);
   rep(i,N) cin >> s[i];
   int M; cin >> M;
   vector<string> t(M);
   rep(i,M) cin >> t[i];

   int ans = 0;
   rep(i,N){
       int cnt = 0;
       repr(j,i,N){
           if(s[i] == s[j]) ++cnt;
       }
       rep(j,M){
           if(s[i] == t[j]) --cnt;
       }
       ans = max(ans,cnt);
   }
   cout << ans << endl;

}

Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Sequence as Sq

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,m] <- getIntList
    ab <- VU.replicateM m $ do
        [a,b] <- getIntList
        return (a-1,b-1)
    let edge = V.create $ do
                vec <- VM.replicate n []
                VU.forM_ ab $ \(a,b) -> do
                    VM.modify vec (a:) b
                    VM.modify vec (b:) a
                return vec
    let result = VU.create $ do
                vec <- VUM.replicate n (-2 :: Int)
                let go Sq.Empty = return ()
                    go ((par,this) Sq.:<| qs) = do
                        VUM.write vec this par
                        qs' <- filterM (fmap (== -2) . VUM.read vec) $ edge V.! this
                        forM_ qs' $ \q -> VUM.write vec q (-1)
                        go (foldl (Sq.|>) qs (zip [this,this..] qs'))
                go (Sq.singleton (0,0))
                return vec
    putStrLn "Yes"
    VU.mapM_ print . VU.map succ $ VU.tail result

Measured memory_bytes: 40940
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int a,b,c;
int cnt[10];

int main(void){
	scanf("%d%d%d",&a,&b,&c);
	cnt[a]++;
	cnt[b]++;
	cnt[c]++;
	bool flag=false;
	for(int i=0;i<10;i++){
		if(cnt[i]==2){
			flag=true;
		}
	}
	printf("%s\n",flag?"Yes":"No");
	return 0;
}


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



int main() {
  long long A,B,C,K;
  
  cin >> A >> B >> C >> K;
  if(K%2 == 0){
    if(abs(A-B) > pow(10,18)){
      cout << "Unfair" << endl;
    }else{
      cout << A-B << endl;
    }
  }else{
    if(abs(B-A) > pow(10,18)){
      cout << "Unfair" << endl;
    }else{
      cout << B-A << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
#include <cmath>
using namespace std;

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

    int mini = x - k + 1;
    int maxi = x + k - 1;

    if (mini < -1000000) {
        mini = -1000000;
    }
    if (maxi > 1000000) {
        maxi = 1000000;
    }

    for (int i = mini; i <= maxi; i++) {
        cout << i << " ";
    }
    cout << endl;
}


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

dp = [1000]

for i in range(1,n):
	maxdp = max(dp)
	kabu = max([ m%a[j] + (a[i]*(m // a[j]) ) for j, m in enumerate(dp) ] )
	dp.append( max( maxdp, kabu ) ) 
print(dp[-1])

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

// 約数の列挙
vector<int> divisor(int n) {
    vector<int> res;
    for (int i=1;i*i<=n;++i) {
        if (n%i == 0) {
            res.push_back(i);
            if (i != n/i) res.push_back(n/i);
        }
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    map<int, int> mp;
    rep(i, N) {
        cin >> A[i];
        mp[A[i]]++;
    }

    if (N == 1) {
        cout << 1 << endl;
        return 0;
    }

    // zero
    if (mp.size() == 1) {
        cout << 0 << endl;
        return 0;
    }

    sort(A.begin(), A.end());
    ll ans = 0;
    map<int, ll> cnt;

    for (auto tmp : mp) {
        if (tmp.second > 1) {
            // 同じ数が2つ以上あるとだめ
            cnt[tmp.first]++;
            continue;
        }

        auto v = divisor(tmp.first);

        // 約数が前のところにすでに存在していた
        bool ok = true;
        for (int u : v) {
            if (cnt[u] > 0) {
                ok = false;
                break;
            }
        }

        if (ok)ans++;
        cnt[tmp.first]++;
    }

    cout << ans << endl;

}


Measured memory_bytes: 52504
#include<stdio.h>
#include <stdlib.h>

#define LIM 100100 //上限

 
int main(void){
    int i;
    int n, depth[LIM];
    int dp[LIM] = {0};
    scanf("%d", &n);

    for (i = 0; i < n; i++){
        scanf("%d", &depth[i]);
    }
    
    dp[0] = 0;
    dp[1] = abs(depth[0] - depth[1]);

    for (i = 2; i < n; i++){
        if (abs(depth[i] - depth[i - 2]) + dp[i - 2]< abs(depth[i] - depth[i - 1]) + dp[i - 1]){
            dp[i] += abs(depth[i] - depth[i - 2]) + dp[i - 2];
        }
        else{
            dp[i] += abs(depth[i] - depth[i - 1]) + dp[i - 1];
        }
    }
    printf("%d\n", dp[n - 1]);
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long s; cin>>s;
	long long xb=sqrt(s),yc=sqrt(s);
	xb+=xb*xb<s; yc+=yc*yc<s;
  	long long xc=xb*yc-s,yb=1;
  	long long xa=0,ya=0;
  	cout<<xa<<" "<<ya<<" "<<xb<<" "<<yb<<" "<<xc<<" "<<yc;
}


Measured memory_bytes: 256
from copy import deepcopy
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

n = int(input())
h = readints()
for i in range(n-1):
    if h[i] < h[i+1]:
        h[i+1] = h[i+1]-1
# print(h)
for i in range(n-1):
    if not(h[i] <= h[i+1]):
        print('No')
        exit()
print('Yes')


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

int main()
{
	int a1,a2,a3;
	cin>>a1>>a2>>a3;
	
	int maxv,minv;
	maxv=max(max(a1,a2),max(a2,a3));
	minv=min(min(a1,a2),min(a2,a3));
	
	cout<<maxv-minv<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,n) for(int i = (a); i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int N, K; cin >> N >> K;
	int res = 0;
	rep(i,N) {
		int tmp; cin >> tmp;
		if (tmp >= K) res++;
	}
	cout << res << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
int main() {
    long long n,num;
    cin>>n;
    vector<long long>v;
    for(int i=0;i<n;i++){
        cin>>num;
        v.push_back(num);
    }
    long long mi = 1000000;
    int minus = 0;
    long long sum = 0;
    for(int i=0;i<v.size();i++){
        if(v[i]<0)minus++;
        mi = min(abs(v[i]),mi);
        sum += abs(v[i]);
    }
    if(minus % 2 == 1){
        sum -= 2 * mi;
        
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 1400