akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		if (H == W) {
			System.out.print("Yes");
		} else {
			System.out.print("No");
		}
	}
}

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


//#define int long long 

const int N = 101;

int a[N], b[N];

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i];
		if(i >= 3 && a[i] == b[i] && a[i - 1] == b[i - 1] && a[i - 2] == b[i - 2]) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 3648
//Moh_K_Imar .......
//26/08/2020  ... 3,33.
//Ya Rab....
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
int main(){
    ll a;
    cin>>a;
    string s;
    cin>>s;
    if(a<3200)cout<<"red"<<endl;
    else cout<<s<<endl;

    return 0;
}



Measured memory_bytes: 3600
// D - Grid Coloring
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	int H,W,N; cin>>H>>W>>N;
	vi AA(H*W);
	int j = 0;
	rp(c, 1, N+1){
		int n; cin>>n;
		rp(i, 0, n) AA[j++] = c;
	}
	vvi V(H, vi(W));
	rp(i, 0, H*W){
		int h = i/W, w = i%W;
		if(h%2) w = W - 1 - w;
		V[h][w] = AA[i];
	}
	rp(i, 0, H) rp(j, 0, W) printf("%d%c", V[i][j], j+1==W? '\n':' ');
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
long long N;
cin >> N;
vector<int> num(N);
for(int i = 0; i < N; i++){
cin >> num.at(i);
}
sort(num.begin(), num.end());
long long mi = num.at(0);
long long ma = num.at(N-1);



long long su = 0;
for(int i = 0; i < N; i++){
su += num.at(i);
}

cout << mi << " " << ma << " " << su << endl;
}


Measured memory_bytes: 3168
#include <stdio.h>

int main(){
    int a[3],count=0,tmp[100],i,j;
    for (i=0; i<3; i++) scanf("%d",&a[i]);
    for (i=0; i<100; i++) tmp[i]=i+1;
    for (i=0; i<3; i++) {
        for (j=0; j<100; j++) {
            if (tmp[j]==a[i]) {
                tmp[j]=-1;
                count++;
            }
        }
    }
    printf("%d\n",count);
}

Measured memory_bytes: 128
{-# OPTION_GHC -O2 #-}

import Data.List (transpose, sort)

main = do

    [n, h] <- take 2 . map read . words <$> getLine
    sords <- sequence $ replicate n (map read . words <$> getLine) :: IO [[Int]]

    let [atks, thrs] = transpose sords
        maxDps = maximum atks
        needThrowSords = takeWhile (maxDps <) . reverse . sort  $ thrs
        attackCount
            | h <= sum needThrowSords = (+1) . length . takeWhile (h >) . scanl1 (+) $ needThrowSords
            | otherwise               = 1 + length needThrowSords + div (h - 1 - sum needThrowSords) maxDps
        in
            print attackCount

Measured memory_bytes: 183676
import java.io.BufferedInputStream;
import java.io.IOException;
import java.util.Scanner;

/**
 * Created by Harry on 5/10/20.
 */
public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(new BufferedInputStream(System.in));
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        int k = scanner.nextInt();
        int res = Math.min(a, k) * 1;
        k-=a;
        if(k>0){
            k-=b;
        }
        if(k>0){
            res += Math.min(c, k)*-1;
        }
        System.out.print(res);
    }
}


Measured memory_bytes: 35728
(let* ((w (concatenate 'list (read-line)))
       (lst (remove-duplicates
              (loop for i in w
                    collect (cons i (count i w)))
              :test #'equal)))

  (defun judge (l)
    (if (not (consp l))
      "Yes"
      (if (oddp (cdar l))
        "No"
        (judge (cdr l)))))


  (format t "~A~%" (judge lst)))



Measured memory_bytes: 24488
S = input()

def flip_num(goal):
    return sum([0 if S[i] == goal[i] else 1 for i in range(len(S))])

def stripe(zero_first):
    if (zero_first):
        return ['0' if i % 2 == 0 else '1' for i in range(len(S))]
    else:
        return ['0' if i % 2 == 1 else '1' for i in range(len(S))]

print(min(flip_num(stripe(True)), flip_num(stripe(False))))

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

int main() {

	string s; cin >> s;
	int a_index = 0;
	int z_index = s.size() - 1;
	while (true) {
		if (s[a_index] == 'A') {
			break;
		}
		a_index++;
	}
	while (true) {
		if (s[z_index] == 'Z') {
			break;
		}
		z_index--;
	}
		
	cout << z_index - a_index + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*; 
import java.util.*;
import java.util.regex.*;
/*
	  br = new BufferedReader(new FileReader("input.txt"));
	  pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
	  br = new BufferedReader(new InputStreamReader(System.in));
	  pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
 */

public class Main {
	private static BufferedReader br;
	private static StringTokenizer st;
	private static PrintWriter pw;

	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		//int qq = 1;
		int qq = Integer.MAX_VALUE;
		//int qq = readInt();
		for(int casenum = 1; casenum <= qq; casenum++)	{
			int n = readInt();
			int[] t = new int[n];
			int[] x = new int[n];
			int[] y = new int[n];
			for(int i = 0; i < n; i++) {
				t[i] = readInt();
				x[i] = readInt();
				y[i] = readInt();
			}
			boolean good = true;
			int lx = 0;
			int ly = 0;
			int lt = 0;
			for(int i = 0; i < n; i++) {
				if(t[i] % 2 != (Math.abs(x[i]) + Math.abs(y[i])) % 2) {
					good = false;
				}
				if(t[i] - lt < Math.abs(lx - x[i]) + Math.abs(ly - y[i])) {
					good = false;
				}
				lx = x[i];
				ly = y[i];
				lt = t[i];
			}
			pw.println(good ? "Yes" : "No");
		}
		exitImmediately();
	}

	private static void exitImmediately() {
		pw.close();
		System.exit(0);
	}

	private static long readLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	private static double readDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	private static int readInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	private static String nextLine() throws IOException  {
		if(!br.ready()) {
			exitImmediately();
		}
		st = null;
		return br.readLine();
	}

	private static String nextToken() throws IOException  {
		while(st == null || !st.hasMoreTokens())  {
			if(!br.ready()) {
				exitImmediately();
			}
			st = new StringTokenizer(br.readLine().trim());
		}
		return st.nextToken();
	}
}

Measured memory_bytes: 46060
#include<bits/stdc++.h>
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N;
int X;
int Y;
LL fact[214514];
LL rev[214514];
vector<int> W[214514];

LL mypow(LL base, LL exp) {
  if (exp == 0) return 1;
  LL res = mypow(base*base%MOD, exp/2);
  if (exp%2) res = res*base % MOD;
  return res;
}

const int INF = 0x3fffffff;
int mw[214514];
int imos[214514];
int rimos[214514];

int main() {
  fact[0] = 1;
  rev[0] = 1;
  reps(i, 1, 214514) {
    fact[i] = fact[i-1]*i % MOD;
    rev[i] = rev[i-1] * mypow(i, MOD-2) % MOD;
  }

  scanf("%d%d%d", &N, &X, &Y);
  rep(i, N) {
    int c, w;
    scanf("%d%d", &c, &w);
    --c;
    W[c].eb(w);
  }
  fill(mw, mw+N, INF);
  fill(imos, imos+N, INF);
  fill(rimos, rimos+N, INF);

  rep(i, N) {
    if (W[i].empty()) continue;
    sort(all(W[i]));
    mw[i] = W[i].front();
    imos[i] = rimos[i] = mw[i];
  }

  reps(i, 1, N) {
    imos[i] = min(imos[i-1], mw[i]); 
  }

  rrep(i, N-1) {
    rimos[i] = min(rimos[i+1], mw[i]); 
  }

  LL ans = 1;
  rep(i, N) {
    if (W[i].empty()) continue;
    sort(all(W[i]));

    int m = INF;
    if (i > 0) MN(m, imos[i-1]);
    if (i < N-1) MN(m, rimos[i+1]);

    int lim = max(X-W[i].front(), Y-m);
    while (W[i].size() > 1 && W[i].back() > lim) {
      W[i].pop_back();
    }
  }

  int accum = 0;
  rep(i, N) {
    int num = W[i].size();
    if (num == 0) continue;
    if (imos[N-1] + W[i].front() <= Y) {
      accum += num;
      ans = ans * rev[num] % MOD;
    } 
  }
  ans = ans * fact[accum] % MOD;
  printf("%lld\n", ans);
}


Measured memory_bytes: 15360
#include <iostream>
#include <cstdio>
#include <cstring>
#include <utility>

using namespace std;

pair<int, int> max(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.first == b.first ? a.second < b.second : a.first > b.first) {
        return a;
    } else {
        return b;
    }
}

#define MAX_W 1001

int main() {
    int W;
    int case_n = 1;
    while (cin >> W, W != 0) {
        int N; cin >> N;
        pair<int, int> dp[N][W+1];
        for (int i = 0; i < N; i++) 
            for (int j = 0; j <= W; j++) 
                dp[i][j] = pair<int, int>(0, 0); // 価値、 重さ
        int value[N];
        int weight[N];
        for (int i = 0; i < N; i++) {
            scanf("%d,%d", value+i, weight+i);
        }

        for (int j = weight[0]; j <= W; j++) {
            dp[0][j] = make_pair(value[0], weight[0]);
        }
        for (int i = 1; i < N; i++) {
            for (int j = 0; j <= W; j++) {
                if (j < weight[i]) {
                    dp[i][j] = dp[i-1][j];
                } else {
                    dp[i][j] = max(dp[i-1][j], 
                            make_pair(dp[i-1][j-weight[i]].first + value[i], 
                                      dp[i-1][j-weight[i]].second + weight[i]));
                }
            }
        }

        cout << "Case " << case_n << ":" << endl;
        cout << dp[N-1][W].first << endl;
        cout << dp[N-1][W].second << endl;
        case_n++;
    }
    return 0;
}
            

Measured memory_bytes: 9076
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,M,p,x,sum=0;
cin>>N;
vector<int>a(N);
for(int i=0;i<N;i++){
    cin>>a[i];
}
cin>>M;
for(int i=0;i<M;i++){
    cin>>p>>x;
    for(int j=0;j<N;j++){
    if(j+1==p){
        sum+=x;
        continue;
    }
    sum+=a[j];
    }
    cout<<sum<<endl;
    sum=0;
}

return 0;
}


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	string s;
	cin>>s;
	if(s[2] == s[3] && s[4] == s[5]){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
};

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int a,b,c;
  cin >> a>>b>>c;
  
  cout << (a+b)*c/2 << endl;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int x;

void solve(){
    cin >> x;
    ll ans=0;
    ans+=1000*(x/500);
    x-=500*(x/500);
    ans+=5*(x/5);
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>

int parent[100005];
int length[100005];
void init(){
  for (int i=0; i<100005; i++){
    parent[i] = -1;
    length[i] = 1;
  }
  return;
}
int getroot(int a){
  int temp = a;
  while(parent[temp]!=-1){
    temp = parent[temp];
  }
  return temp;
}

bool samegroup(int a, int b){
  if (getroot(a)==getroot(b)){
    return true;
  } else {
    return false;
  }
}

void combine(int a, int b){
  if (samegroup(a, b)){
    //printf("samwgourp!\n");
    return;
  }
  //printf("combine claled\n");
  int aroot = getroot(a);
  int broot = getroot(b);
  //  printf("root of %d = %d\n",a,aroot);
  //printf("root of %d = %d\n",b,broot);
  if (length[aroot]>length[broot]){
    parent[broot] = aroot;
    length[aroot]+=length[broot];
  } else {
    parent[aroot] = broot;
    length[broot] += length[aroot];
    //    if (length[aroot]==length[broot]){
    //      length[broot]++;
    //    }
  }
  return;
}

int count(int a){
  int aroot = getroot(a);
  //printf("root of %d = %d\n",a,aroot);
  return length[aroot];
}


int main(){
  init();
  int N, M, K;
  scanf("%d", &N);
  scanf("%d", &M);
  scanf("%d", &K);
  //printf("nmk end\n");
  std::vector<int > A(M), B(M);
  std::vector<int > C(K), D(K);
  std::vector<int > like[100005];
  for (int i=0; i<M; i++){
    scanf("%d", &A[i]);
    scanf("%d", &B[i]);
    A[i]--;
    B[i]--;
    like[A[i]].push_back(B[i]);
    like[B[i]].push_back(A[i]);
    combine(A[i], B[i]);
  }
  //printf("m end\n");
  std::vector<int > dislike[100005];
  //printf("step1\n");
  for (int i=0; i<K; i++){
    scanf("%d", &C[i]);
    scanf("%d", &D[i]);
    //printf("i=%d\n",i);
    C[i]--;
    D[i]--;
    dislike[C[i]].push_back(D[i]);
    dislike[D[i]].push_back(C[i]);
  }
  //  printf("step2\n");
  for (int i=0; i<N; i++){
    //printf("====== i=%d ====== \n",i);
    int groupnum = count(i);
    //printf("groupnum=%d\n",groupnum);
    int dislikecount = 0;
    for (int j=0; j<dislike[i].size(); j++){
      if (samegroup(i, dislike[i][j])){
        dislikecount++;
      }
    }
    //printf("dislikecount=%d\n",dislikecount);
    int likecount = 0;
    for (int j=0; j<like[i].size(); j++){
      if (samegroup(i, like[i][j])){
        likecount++;
      }
    }
    //printf("likecount=%d\n",likecount);
    printf("%d\n",groupnum-1-dislikecount-likecount);
  }
  return 0;
}


Measured memory_bytes: 14200
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int cnt[4]={0};

    REP(i,3){
        int a,b; cin>>a>>b; 
        a--; b--;
        cnt[a]++; cnt[b]++;
    }
    REP(i,4){
        if(cnt[i]>=3){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
 
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int count = 1;
        //int x = stdIn.nextInt();
        int a[] = new int[n];
        //String s = stdIn.next();
        //String t = stdIn.next();
        //char c[] = s.toCharArray();
        //int sum = 0;
        //boolean flag = true;
        a[0] = stdIn.nextInt();
        for(int i = 1; i < n; i++){
            int num = stdIn.nextInt();
            
            if(num != a[count - 1]){
                a[count++] = num;
            }
        }
        
        
        //int q = stdIn.nextInt();
        
        for(int i = 0; i < count - 1; i++){
            System.out.print(a[i] + " ");
        }
        System.out.println(a[count - 1]);

        //System.out.println();
        //System.out.print();

        stdIn.close();
    }
}





Measured memory_bytes: 73300
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX/2+2],R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right){
  int i,j,k;
  int n1=mid-left;
  int n2=right-mid;
  for(i=0;i<n1;i++) L[i]=A[left+i];
  for(i=0;i<n2;i++) R[i]=A[mid+i];
  L[n1].value=R[n2].value=SENTINEL;
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value){
      A[k]=L[i++];
    } else {
      A[k]=R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[],int n, int p, int r){
  int i,j;
  struct Card t,x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}

void quickSort(struct Card A[],int n, int p, int r){
  int q;
  if(p<r){
    q=partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main(){
  int n,i,v;
  struct Card A[MAX],B[MAX];
  char S[10];
  int stable=1;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %d",S,&v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++){
    if(A[i].suit!=B[i].suit) stable=0;
  }
  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);
  }
  return 0;
}
    



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

struct StPoint
{
  StPoint() :
    m_nTime(0), m_nXcrd(0), m_nYcrd(0)
  { }

  int m_nTime;
  int m_nXcrd;
  int m_nYcrd;
};

void fnInput(vector<StPoint>& rvoPoint)
{
  StPoint oPoint;
  int nSize;
  cin >> nSize;

  rvoPoint.resize(nSize + 1, oPoint);
  for (int i = 0; i < nSize; i++)
    cin >> rvoPoint[i + 1].m_nTime >> rvoPoint[i + 1].m_nXcrd >> rvoPoint[i + 1].m_nYcrd;
}

int fnTravel(const vector<StPoint>& cnrvoPoint)
{
  for (int i = 0; i < cnrvoPoint.size() - 1; i++)
  {
    int nTime = cnrvoPoint[i + 1].m_nTime - cnrvoPoint[i].m_nTime;
    int nDist = abs(cnrvoPoint[i + 1].m_nXcrd - cnrvoPoint[i].m_nXcrd)
              + abs(cnrvoPoint[i + 1].m_nYcrd - cnrvoPoint[i].m_nYcrd);

    if (nTime < nDist)           return 0;
    if (nTime % 2 != nDist % 2)  return 0;
  }
  return 1;
}

int main()
{
  vector<StPoint> voPoint;

  fnInput(voPoint);
  if (fnTravel(voPoint))  cout << "Yes" << endl;
  else                    cout << "No"  << endl;

  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <sstream>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{   
    i64 n,m;
    cin >> n >> m;
    cout << abs(n-2)*abs(m-2) << endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range, std.algorithm;

void main() {
	auto _n = readln;
	string[] n = [];
	foreach (string l; lines(stdin)) n ~= l.chomp;
	foreach (s; ["S", "H", "C", "D"])
		foreach (i; 1..14) {
			auto t = "%s %d".format(s, i);
			if (!n.canFind(t)) t.writeln;
		}
}

Measured memory_bytes: 2488
input = gets.chomp
words = %w(dream dreamer erase eraser)

until input.empty?
  flg = false
  words.each do |word|
    if input[-word.size, word.size] == word
      input = input[0..-word.size - 1]
      flg = true
      break
    end
  end

  unless flg
    break
  end
end

puts input.empty? ? 'YES' : 'NO'


Measured memory_bytes: 60492
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;


int main(){
  int n;
  cin >> n;
  if (n <= 999) cout << "ABC\n";
  else cout << "ABD\n";
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>
#include <cassert>

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

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int N, W; cin>>N>>W;
    vector<ll> w(N), v(N);
    vector<vector<ll>> dp(N+10, vector<ll>(100010, (ll)1e15));
    for (int i = 0; i < N; i++) {
        cin>>w[i]>>v[i];
    }

    dp[0][0]=0LL;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= 100000; j++) {
            dp[i+1][j]=min(dp[i+1][j], dp[i][j]);
            if(j+v[i]<=100000)dp[i+1][j+v[i]]=min(dp[i+1][j+v[i]], dp[i][j]+w[i]);
        }
    }

    ll res = 0LL;
    for (ll i = 0; i <= 100000; i++) {
        if(dp[N][i]<=W)res=max(res, i);
    }

    cout<<res<<endl;

    return 0;
}

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

//.define
// #define FILE_IN_OUT
#define RET(_x)                       return cout << (_x) << '\n', 0;
#define all(_obj)                     (_obj).begin(), (_obj).end()
#define loop(_n)                      for (int i = 0; i < (_n); ++i)
#define CeilDiv(_dividend, _divider)  (((_dividend) - 1LL + (_divider)) / (_divider))
#define sz(_obj)                      static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)                     std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)                     {}
#endif
#define endl "\n"
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
constexpr int MAXN = 200000;

vector<int> gr[MAXN];

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n;
    cin >> n;
    loop(n - 1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        gr[a].push_back(b);
        gr[b].push_back(a);
    }
    ll ans = 0;
    auto Sum = [](int x) {
        return 1LL * x * (x + 1) / 2;
    };
    loop(n) {
        ans += Sum(i + 1);
    }
    loop(n) {
        for (int j : gr[i]) {
            if (j > i) {
                ans -= 1LL * (i + 1) * (n - j);
            }
        }
    }
    cout << ans << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

Measured memory_bytes: 15040
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
base = 0
for i in c.values():
    base += i*(i-1)//2

ans = []
for ai in a:
    k = c[ai]
    tmp = base - k*(k-1)//2 + (k-1)*(k-2)//2
    ans.append(tmp)

print(*ans, sep="\n")


Measured memory_bytes: 104140
import sys
import numpy as np
from scipy.ndimage.morphology import distance_transform_cdt
INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())
sys.setrecursionlimit(10 ** 9)


def main():
    H, W = MAP()
    A = [INPUT() for _ in range(H)]
    A = np.array([[(Ai[j] != "#") for j in range(W)] for Ai in A])
    print(distance_transform_cdt(A, metric="taxicab").max())


if __name__ == '__main__':
    main()

Measured memory_bytes: 31840
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
#include<utility>
using namespace std;
using ll = long long;

int main(){
  int n;
  cin >> n;
  cout << int((n+1)/2);
  return 0;
}

Measured memory_bytes: 256
fun main(args:Array<String>):Unit {
    repeat(readLine()!!.toInt()){
        val len = readLine()!!.trim().toInt()
        val ea = readLine()!!.trim().split(' ').map(String::toInt).toIntArray()
        val memo = Array(len){Array(len){-1}}
        println(search(ea, memo))
    }
}

fun search(ea:IntArray, memo:Array<Array<Int>>, last:Int = ea.size - 1, prev:Int = 0):Int {
    if (memo[last][prev] >= 0) return memo[last][prev]
    memo[last][prev] = when(last){
        0 -> if (prev == 0) ea.first() else 0
        1 -> when {
            ea.first() >= prev -> ea[1]
            else -> 0
        }
        else -> when{
            ea[last - 1] > prev -> {
                val res = search(ea, memo,last - 2, 0)
                ea[last] + res
            }
            ea[last - 1] == prev -> {
                val res = search(ea, memo,last - 2, 1)
                if (res > 0)
                    ea[last] + res - 1
                else
                    ea[last]
            }
            else -> {
                val res = search(ea, memo, last - 2, prev - ea[last - 1] + 1)
                when {
                    res > 0 -> ea[last] + res - 1
                    search(ea, memo, last - 2, prev - ea[last - 1]) > 0 -> ea[last]
                    else -> 0
                }
            }
        }
    }
    return memo[last][prev]
}
/*

F 最後を最大にする並び
->最後から一つ前が0ならばG-2
->最後から一つ前が0でなければF-2

Fp := 最後から一つ前がp以上で、最後が最大のもの
最後から一つ前l
-> p+1以上ならF-20
-> F-2p-l
 */


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

class Dice {
    public:
        int a, b, c, d, z, f;
        Dice(int a, int b, int c, int d, int z, int f) {
            this->a = a;
            this->b = b;
            this->c = c;
            this->d = d;
            this->z = z;
            this->f = f;
        }

        void s() {
            int tmp = this->b;
            this->b = this->a;
            this->a = this->z;
            this->z = this->f;
            this->f = tmp;
        }

        void e() {
            int tmp = this->c;
            this->c = this->a;
            this->a = this->d;
            this->d = this->f;
            this->f = tmp;
        }

        void zAxis() {
            int tmp = this->b;
            this->b = this->c;
            this->c = this->z;
            this->z = this->d;
            this->d = tmp;
        }

        bool tf(int top, int front) {
            bool tp = this->a == top;
            bool ft = this->b == front;
            while (!(tp && ft)) {
                if (tp && !ft) {
                    while (!ft) {
                        this->zAxis();
                        ft = this->b == front;
                        if (ft) break;
                    }
                }
                else if (!tp && ft) {
                    while (!tp) {
                        this->e();
                        tp = this->a == top;
                        if (tp) break;
                    }

                }
                else {
                    this->s();
                    tp = this->a == top;
                    ft = this->b == front;
                }
            }
            return (tp && ft);
        }

        void printTop() {
            cout << this->a << endl;
        }
        void printFront() {
            cout << this->b << endl;
        }
        void printRight() {
            cout << this->c << endl;
        }
};


int main () {
        int a[6], b[6];
        for (int i=0; i<6; i++) cin >> a[i];
        Dice dd1(a[0], a[1], a[2], a[3], a[4], a[5]);
        for (int i=0; i<6; i++) cin >> b[i];
        Dice dd2(b[0], b[1], b[2], b[3], b[4], b[5]);

        bool check = dd2.tf(dd1.a, dd1.b);
        bool rightCheck = dd1.c == dd2.c;
        if (check && rightCheck) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --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; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

struct mint {
    long long x;
    mint(long long x=0):x(x % MOD + (0 <= x ? 0 : MOD)) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint& a) { if ((x += a.x) >= MOD) x -= MOD; return *this; }
    mint& operator-=(const mint& a) { if ((x -= a.x) < 0) x += MOD; return *this; }
    mint& operator*=(const mint& a) { (x *= a.x) %= MOD; return *this; }
    mint operator+(const mint& a) const { return mint(x) += a; }
    mint operator-(const mint& a) const { return mint(x) -= a; }
    mint operator*(const mint& a) const { return mint(x) *= a; }

    // for prime mod
    mint inv() const {
        long long a = x, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        return mint(u);
    }
    mint& operator/=(const mint& a) { return *this *= a.inv(); }
    mint operator/(const mint& a) const { return mint(x) /= a; }
};
istream& operator>>(istream& is, const mint& a){ return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a){ return os << a.x; }

template<typename T>
void dsp(vector<vector<T>> &A) {
    for (auto &i : A) {
        for (auto &j : i) cout << j << " ";
        cout << endl;
    }
}

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

    vector<int> a(N);
    for (int &i: a) cin >> i;

    vector<vector<mint>> dp(N+1, vector<mint>(K+1));
    vector<vector<mint>> sum(N+1, vector<mint>(K+2));
    dp[0][0] = 1;
    rep(i, K+1) sum[0][i+1] = sum[0][i] + dp[0][i];

    rep(i, N) {
        for (int j = 0; j <= K; ++j) {
            int k = max(0, j - a[i]);
            dp[i+1][j] += sum[i][j+1] - sum[i][k];
            sum[i+1][j+1] += sum[i+1][j] + dp[i+1][j];
        }
    }

    cout << dp[N][K] << endl;
}

Measured memory_bytes: 159088
#include <iostream>
#include <cmath>
#include <utility>

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
#define mp make_pair
#define x first
#define y second

int arr[200003];

int main () {
	int n;
	cin>>n;
	for(int i=2;i<=n;i++){
		int a;
		cin>>a;
		arr[a]++;
	}
	for(int i=1;i<=n;i++){
		cout<<arr[i]<<endl;
	}



return 0;
}



Measured memory_bytes: 4376
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

#define LL long long
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1

const int maxn = 2e5 + 7;
const int INF = 0x3f3f3f3f;

struct node {
    int pos,val;
}a[maxn];

bool cmp(node aa,node bb) {
    return aa.pos < bb.pos;
}

LL q[maxn];

int main() {
    int n,d,x;
    scanf("%d%d%d",&n,&d,&x);
    for(int i = 1 ; i <= n ; i++) {
        scanf("%d%d",&a[i].pos,&a[i].val);
    }
    d <<= 1;
    sort(a+1,a+n+1,cmp);
    LL ans = 0;
    for(int i = 1 ; i <= n ; i++) {
        q[i] += q[i-1];
        a[i].val -= q[i] * x;
        if(a[i].val <= 0) continue;
        LL temp = (a[i].val + x - 1) / x;
        ans += temp;
//        cout << "i = " << i << " ans = " << ans << endl;
        q[i] += temp;
        int l = i , r = n;
        int res = 0;
        while(l <= r) {
            int mid = (l + r) >> 1;
//            cout << "l = " << l << " r = " << r << " " << a[mid].pos << " " << a[i].pos + d << endl;
            if(a[mid].pos <= a[i].pos + d) {
                res = mid;
                l = mid + 1;
            } else {
                r = mid - 1;
            }
        }
//        cout << "res = " << res << endl;
        q[res+1] -= temp;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 3328
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        Float[] b = new Float[a];
        float sum = 0;
        for (int i = 0; i < a; i++){
            b[i] = sc.nextFloat();
        }
        for (int i = 0; i < a; i++){
            sum = sum + (1/b[i]);
        }
        System.out.print(1/sum);
    }
}


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

const int INF = 1e9;

int main() {
  int N,X;
  cin>>N>>X;
  set<int> s;
  int max_d=0;
  for(int i=0;i<N;i++){
    int xi;
    cin>>xi;
    max_d=max(max_d,abs(xi-X));
    s.insert(abs(xi-X));
  }
  vector<int> divisor;
  for(int i=1;i*i<max_d;i++) {
    if(max_d%i == 0) {
      divisor.push_back(i);
      if(i*i!=max_d) {
        divisor.push_back(max_d/i);
      }
    }
  }
  sort(divisor.begin(),divisor.end());
  reverse(divisor.begin(),divisor.end());
  for(int d:divisor){
    bool flag=true;
    for(int si:s){
      if(si%d!=0){
        flag=false;
        break;
      }
    }
    if(flag){
      cout<<d<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

typedef long long ll;

int main() {
    ll n;
    scanf("%lld", &n);
    vector<double> p(n + 1);
    vector< vector<double> > dp(n + 1, vector<double>(n + 1, 0));
    dp.front().front() = 1;
    for (ll i = 1; i <= n; ++i) scanf("%lf", p.begin() + i);
    for (ll i = 1; i <= n; ++i) for (ll j = 0; j <= n; ++j) {
        dp.at(i).at(j) = dp.at(i - 1).at(j) * (1 - p.at(i));
        if (j > 0) dp.at(i).at(j) += dp.at(i - 1).at(j - 1) * p.at(i);
    }
    printf("%.15lf\n", accumulate(dp.back().begin() + (n / 2 + 1), dp.back().end(), 0.0));
    return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const int MAX=1000005;
const int MOD=1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    COMinit();
    int x,y;
    cin>>x>>y;
    if ((x+y)%3!=0 || (2*x-y)%3!=0){
        cout<<0<<endl;
        return 0;
    }
    cout<<COM((x+y)/3,(2*x-y)/3)<<endl;

}

Measured memory_bytes: 23680
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int INF=1e9;
int n, a[3];
int l[9];
int v[1<<8], ct[1<<8];
int ans;
void dfs(int i, int k, int s){
    if(i==3){
        ans=min(ans, s);
        return;
    }
    int r=(1<<n)-1-k;
    if(r==0) return;
    for(int j=r; j>0; j=(j-1)&r){
        s+=abs(v[j]-a[i]); s+=ct[j];
        dfs(i+1, k^j, s);
        s-=abs(v[j]-a[i]); s-=ct[j];
    }
}
int main()
{
    cin>>n>>a[0]>>a[1]>>a[2];
    for(int i=0; i<n; i++) cin>>l[i];
    ans=INF;
    for(int i=1; i<(1<<n); i++){
        ct[i]=-10;
        for(int j=0; j<n; j++){
            if(i&(1<<j)) v[i]+=l[j], ct[i]+=10;
        }
    }
    dfs(0, 0, 0);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	static final int M = 1000000;

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		int[] a = new int[n];
		
		for (int i = 0; i < n; i++) {
			a[i] = scanner.nextInt();
		}
		
		int[] check = new int[M + 1];
		
		for (int i = 0; i < n; i++) {
			if (check[a[i]] != 0) {
				check[a[i]] = 2;
				continue;
			}
			
			for (int j = a[i]; j <= M; j += a[i]) {
				check[j]++;
			}
			
		}
		
		int count = 0;
		
		for (int x: a) {
			if (check[x] == 1) {
				count++;
			}
		}
		
		System.out.println(count);

	}

}


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


int main(void){
long long int a,b,c,d;

cin >> a >> b >> c;

d = c - a - b;
if(d > 0 && d * d > 4 * a * b)
{
cout << "Yes" << endl;
} 
else
{
cout << "No" << 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();
    int b = sc.nextInt();
    
    int max = a * b;

    if(max < a - b){
      max = a-b;
    }

    if(max < a + b){
      max = a+b;
    }
    System.out.println(max);
  }
}

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

int main(void){
  int i,l;
  char str[105],*p,s[105];
  long K;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  strcpy(s,p);
  l=strlen(s);
  fgets(str,sizeof(str),stdin);
  K=atol(str);
  
  for(i=0;i<l;i++){
    if(s[i]!='1'){
      printf("%c\n",s[i]);
      return 0;
    }
    if(i>=K-1){
      printf("%c\n",s[i]);
      return 0;
    }
  }
  
  return 0;
}


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

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

    vector<int> x(4);
    rep(i,4) x[i] = s[i] - '0';

    for (int i = 0; i < (1 << 4); i++) {
        int total = x[0];
        string ans;
        ans += (char)('0' + x[0]);
        for (int j = 0; j < 3; j++) {
            if (i & (1 << j)) {
                total += x[j+1];
                ans += '+';
                ans += (char) ('0' + x[j+1]);
            } else {
                total -= x[j+1];
                ans += '-';
                ans += (char) ('0' + x[j+1]);
            }
        }
        if (total == 7) {
            cout << ans << "=7" << endl;
            return 0;
        }
    }
}

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

using namespace std;

typedef long long ll;
int main() {
    ll n, a, b;
    cin >>n >> a >> b;
    ll r = (a + b);
    ll t = (n / r);
    ll w = (n % r);
    ll d = (t*a) + min(a,w);
    cout << d << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
dic = defaultdict(int)

n = int(input())
s = [input() for i in range(n)]

ans = 0
for j in range(len(s)):
    mozi = sorted(s[j])
    mozi_s = "".join(mozi)
    ans += dic[mozi_s]
    dic[mozi_s] += 1
    
print(ans)

Measured memory_bytes: 25332
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI 3.14159265358979


const lli MAX = 1000000;
const lli MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

 
signed main(){
 
	lli x,y;
	cin>>x>>y;

	if( (2*y-x)%3 != 0 || (2*y-x) < 0){
		cout<<0<<endl;
		return 0;
	}
	if( (2*x-y)%3 != 0 || (2*x-y)<0){
		cout<<0<<endl;
		return 0;
	}

	lli a = (2*y-x)/3;
	lli b = (2*x-y)/3;
	//if(DEBUG)cout<<"a="<<a<<" b="<<b<<endl;

	COMinit();

	cout<<COM(a+b,a)<<endl;

	return 0;
}

Measured memory_bytes: 23680
#include<iostream>
#include<set>
using namespace std;
int main()
{
  int n,k;
  int qq=0;
  multiset<int> pris;
  cin>>n>>k;
  for(int i=0;i<n;i++)
  {
	int p;
    cin>>p;
    pris.insert(p);
  }
  multiset<int>::iterator ptr=pris.begin();
  while(k>0)
  {
	qq+=*ptr;
    ptr++;
    k--;
  }
  cout<<qq;
  return 0;
}
    

Measured memory_bytes: 3644
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	int len = vv.size();
	for (int i = 0; i < len; ++i) {
		s << vv[i] << endl;
	}
	return s;
}

int main(){
    string s;
    cin >> s;
    //cout << s.length();
    bool a=true;
    rep(i,s.length()){
        rep(j,s.length()){
            if(s[i] == s[j] && i != j) a = false;
        }
    }
    if(a == true) cout << "yes";
    else cout << "no";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
typedef long long ll;
int n;
ll inv[maxn],sum[maxn],a[maxn];
ll fpow(ll a,ll b) {
	ll r = 1;
	while (b) {
		if (b & 1) r = r * a % mod;
		b >>= 1;
		a = a * a % mod;
	}
	return r;
}
int main() {
	inv[0] = 1;
	for (int i = 1; i <= maxn - 10; i++)
		inv[i] = inv[i - 1] * i % mod;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++)
		scanf("%lld",&a[i]);
	for (int i = 1; i <= n; i++)
		sum[i] = (sum[i - 1] + a[i]) % mod;
	ll ans = 0;
	for (int t = 1; t <= n - 2; t++) {
		ans = (ans + inv[n - 1] * fpow(t,mod - 2) % mod * fpow(t + 1,mod - 2) % mod * 
				((sum[n - 1] - sum[t] - sum[n - 1 - t] + 2 * mod) % mod) % mod) % mod;
	}
	for (int i = 1; i <= n - 1; i++) {
		ans = (ans + (a[n] - a[i]) * inv[n - 1] % mod * fpow(n - i,mod - 2) % mod) % mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <stdio.h>

int main() {
	int n, k;
	//1 = n , k <= 100
	std::cin >> n >> k;
	if (k == 0) {
		std::cout << "YES";
		return 0;
	}
	if ((n == k && n != 1) || n < k) {
		std::cout << "NO";
		return 0;
	}
	
	if (n % 2 == 0) {
		if (n / 2 >= k) {
			std::cout << "YES";
			return 0;
		}
		else {
			std::cout << "NO";
			return 0;
		}
	}
	else {
		if ((n + 1) / 2 >= k) {
			std::cout << "YES";
			return 0;
		}
		else {
			std::cout << "NO";
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if (int(i*1.08) == n) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)

func main() {
	defer writer.Flush()
	var A, B int
	fmt.Fscanf(reader, "%d %d\n", &A, &B)
	if A > 8 || B > 8 || A+B > 16 {
		fmt.Fprintf(writer, "%s\n", ":(")
		return
	}
	fmt.Fprintf(writer, "%s\n", "Yay!")
}


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

int n;

int main(){
  cin >> n;
  vector<long long> a(n);
  vector<long long> asum(n);
  
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  asum[0] = a[0];
  for(int i = 1; i < n; i++){
    asum[i] = asum[i-1] + a[i];
  }
  
  long long ans = 1LL << 60;
  int lc = 1, rc = 3;
  for(int i = 2; i < n - 1; i++){
    
    if(rc <= i) rc = i + 1;
    long long ll = asum[lc-1];
    long long lr = asum[i-1] - asum[lc-1];
    long long ld = abs(ll-lr);
    while(lc < i-1){
      long long nll = asum[lc];
      long long nlr = asum[i-1] - asum[lc];
      long long nld = abs(nll-nlr);
      if(nld < ld) {
        lc++;
        ll = nll; lr = nlr; ld = nld;
      }else{
        break;
      }
    }
    
    long long rl = asum[rc-1] - asum[i-1];
    long long rr = asum[n-1] - asum[rc-1];
    long long rd = abs(rl-rr);
    while(rc < n-1){
      long long nrl = asum[rc] - asum[i-1];
      long long nrr = asum[n-1] - asum[rc];
      long long nrd = abs(nrl-nrr);
      if(nrd < rd) {
        rc++;
        rl = nrl; rr = nrr; rd = nrd;
      }else{
        break;
      }
    }
    vector<long long> comp(4);
    comp[0] = ll; comp[1] = lr; comp[2] = rl; comp[3] = rr;
    sort(comp.begin(), comp.end());
    ans = min(ans, comp[3] - comp[0]);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
 
    int n;
    cin >> n;
    vector<long long> a;
    for (int i = 0; i < n; i++) {
        long long b;
        cin >> b;
        if (b == 0) {
            cout << 0 << "\n";
            return 0;
        }
        a.push_back(b);
    }
 
    long long r = 1;
    for (auto x : a) {
        if (r <= 1000000000000000000 / x) {
            r *= x;
        }
        else {
            cout << -1 << "\n";
            return 0;
        }
    }
    cout << r << "\n";
}

Measured memory_bytes: 4272
package main

import "fmt"

func main() {
	var s []byte
	fmt.Scan(&s)

	max := 0
	for i := 0; i < len(s);i++ {
		cnt := 0
		for j :=i; j < len(s); j++ {
			if s[j] == 'A' ||
				s[j] == 'C' ||
				s[j] == 'G' ||
				s[j] == 'T'  {
				cnt++
				continue

			}
			break
		}
		if max < cnt {
			max = cnt
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 1768