akhauriyash/Code-Regression huggingface dataset:
<?php
fscanf(STDIN, '%d', $N);
$info = array();
$subInfo = array();
for($i = 1; $i < $N; $i++) {
	fscanf(STDIN, "%d %d %d", $C, $S, $F);
	array_push($subInfo, $C);
	array_push($subInfo, $S);
	array_push($subInfo, $F);
	array_push($info, $subInfo);
	$subInfo = array();
}

$ans = array();
$bound = 0;
for($i = 1; $i < $N; $i++) {
	$midSum = 0;
	for($j = $bound; $j < ($N-1); $j++) {
		if ($j === $bound) {
			$midSum = $info[$j][0] + $info[$j][1];
		} else {
			if ($midSum > $info[$j][1]) {
				if ($info[$j][2] === 1) {
					$midSum+=$info[$j][0];
				} else if($midSum%$info[$j][2] === 0){
					$midSum += $info[$j][0];
				} else {
					$midSum = $midSum + ($info[$j][2] - $midSum%$info[$j][2]) + $info[$j][0];
				}
			} else if ($midSum === $info[$j][1]) {
				$midSum += $info[$j][0];
			} else {
				$midSum = $info[$j][1];
				$midSum += $info[$j][0];
			}
		}
	}
	array_push($ans, $midSum);
	$bound++;
}

array_push($ans, 0);
foreach ($ans as $num) {
	echo $num.PHP_EOL;
}

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

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



Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main()
{
  int N, D, X;
  int tabeta = 0;
  cin >> N >> D >> X;
  vector<int> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++)
  {
    tabeta += (D - 1) / A[i] + 1;
  }
  cout << tabeta + X << endl;
  return 0;
}

Measured memory_bytes: 256
n, c = map(int, input().split())
a = [[0 for _ in range(c)] for _ in range(10 ** 5 + 1)]
for _ in range(n):
    s, t, u = map(int, input().split())
    a[s][u - 1] += 1
    a[t][u - 1] -= 1
m = 0
x = 0
for b in a:
    x += b.count(1)
    if x > m:
        m = x
    x -= b.count(-1)
print(m)

Measured memory_bytes: 38260
h,w=map(int,input().split())
l=[list(input()) for i in range(h)]

mod=10**9+7

dp=[[0]*w for i in range(h)]
dp[0][0]=1

for i in range(h):
 for j in range(w):
  if i==j==0:
   continue
  if l[i][j]=='#':
   dp[i][j]==0
   continue

  if i-1>=0 and l[i-1][j]=='.':
   dp[i][j]+=dp[i-1][j]
  if j-1>=0 and l[i][j-1]=='.':
   dp[i][j]+=dp[i][j-1]

  dp[i][j]%=mod

print(dp[-1][-1])

Measured memory_bytes: 51504
import java.util.*;
 
class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    int zIndex = Integer.MIN_VALUE;
    int aIndex = Integer.MAX_VALUE;
    for(int i=0; i<s.length(); i++){
      String S = String.valueOf(s.charAt(i));
      if(S.equals("A")){
        if(aIndex > i){
          aIndex = i;
        }
      } else if(S.equals("Z")){
        if(zIndex < i){
          zIndex = i;
        }
      }
    }
    System.out.println(zIndex-aIndex+1);

    sc.close();
  }
}


Measured memory_bytes: 36500
#include <stdio.h>
int main(){

	int a[101];
	int n;
	int max;
	int i;
	
	for(i=1;i<=100;i++) a[i]=0 ;
	max=0;
	while(scanf("%d\n",&n)!=EOF)a[n]++;
	for(i=1;i<=100;i++) if(a[i]>=max)max=a[i] ;
	for(i=1;i<=100;i++) if(a[i]==max)printf("%d\n",i) ;

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};

int main(){
    ll n,k; cin >> n >> k;
    vl a(n);
    vl v(200005,inf);
    ll kind = 0;
    rep(i,n){
        cin >> a[i];
        a[i]--;
        if(v[a[i]]==inf){
            v[a[i]] = 1;
            kind++;
        }
        else v[a[i]]++;
    }
    sort(all(v));
    ll ans = 0;
    rep(i,kind-k){
        ans += v[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,count=0;
    cin>>n;
    for(int i=0;i<=25;i++){
        for(int j=0;j<15;j++){
            if(i*4+j*7==n){
                count=1;
                break;
            }
        }
    }
    if(count==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

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

    int num[4];
    num[0] = n / 1000;
    num[1] = (n - (num[0] * 1000)) / 100;
    num[2] = (n - (num[0] * 1000 + num[1] * 100)) / 10;
    num[3] = n - num[0] * 1000 - num[1] * 100 - num[2] * 10;

    if((num[0] == num[1] && num[1] == num[2]) || (num[1] == num[2] && num[2] == num[3])){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n, m, x, i, c=0, b=0, j;
  scanf("%d %d %d", &n ,&m, &x);
  int a[m];
  for(i=0;i<m;i++){
    scanf("%d", &a[i]);
  }
  for(j=1;j<x;j++){
    for(i=0;i<m;i++){
      if(a[i]==j){
        c++;
      }
    }
  }
  for(j=x;j<n;j++){
    for(i=0;i<m;i++){
      if(a[i]==j){
        b++;
      }
    }
  }
  if(c>=b){
    printf("%d\n", b);
  }else{
    printf("%d\n", c);
  }
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <tuple>
#include <vector>
#include <sstream>
using namespace std;

int main() {
  int N, a[200009], M=0;
  cin >> N;
  long long step=0;
  for (int i=0; i<N; i++){
    cin >> a[i];
    M = max(M, a[i]);
    step += M-a[i];
  }
  cout << step << endl;
  return 0;
}

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

int main() {
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d;
  e = a + b ;
  f = c + d ;
  
  if ( e > f ){
    cout << "Left" <<endl;
  }
  else if ( e == f ){
    cout<<"Balanced"<<endl;
  }
  else   {
    cout<<"Right"<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<queue>

using namespace std;

int N;
int interval;

struct A
{
	string suit;
	int time;
};

int main()
{
	queue<A> Q;
	A a;
	int sum = 0;
	cin >> N >> interval;
	for (int i = 0; i < N; i++)
	{
		cin >> a.suit >> a.time;
		Q.push(a);
	}
	while (!Q.empty())
	{
		a = Q.front();
		Q.pop();
		if (a.time - interval <= 0)
		{
			sum = sum + a.time;
			
			cout << a.suit << ' '<<sum << endl;
			
		}
		else
		{
			a.time = a.time - interval;
			sum = sum + interval;
			Q.push(a);
		}
		
	}


	return 0;
}


Measured memory_bytes: 6288
from collections import deque
import copy
h,w = map(int,input().split())
maze = [["#"] * (w+2)]
for i in range(h):
    lu = list(input())
    l = ["#"] + lu + ["#"]
    maze.append(l)
maze.append(["#"] * (w+2))


def breadth_first_search(start,W,Wn):
    work_q = deque([])
    visited = set()
    work_q.append(start)
    visited.add(start)
    Wn[start[0]][start[1]] = 0
    max_dist = 0
    while work_q:
        here = work_q.popleft()
        move = [(here[0]+1,here[1]), (here[0],here[1]+1),
                (here[0]-1,here[1]),(here[0],here[1]-1)]
        for i in move:
            if W[i[0]][i[1]] == "." and i not in visited:
                work_q.append(i)
                visited.add(i)
                Wn[i[0]][i[1]] = Wn[here[0]][here[1]] + 1
                max_dist = max(max_dist, Wn[i[0]][i[1]])
    return Wn, max_dist


ans = 0
for i in range(h+2):
    for j in range(w+2):
        maze_num = copy.deepcopy(maze)
        if maze[i][j] == ".":
            start = (i,j)
            wn, wn_max = breadth_first_search(start,maze, maze_num)
            ans = max(ans, wn_max)
print(ans)


Measured memory_bytes: 3564
s = input()
k = int(input())

ans = '1'

if s.count('1') == len(s) or k == 1 and s[k-1] == '1':
    print(1)
else:
    for i in range(k):
        if s[i] != '1':
            ans = s[i]
            break
    print(ans)


Measured memory_bytes: 3060
#include<iostream>


using namespace std;

int main()
{
    long long n, *s, i;
    cin>>n;
    s = new long long [n+1];
    for(int i=0; i<n; i++) cin >> s[i];
    long long c =0;
    for( int i=0; i<n; i++)
        for(int j=i+1; j<n; j++)
    {
        c+=(s[i]*s[j]);
    }
    cout<<c<<endl;

    return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

int main() {
  int n; cin >> n;
  int a=n/1000, b=n/100%10, c=n/10%10, d= n % 10;
  if(a+b+c+d == 7) printf("%d+%d+%d+%d=7\n", a, b, c, d);
  else if(a+b+c-d == 7) printf("%d+%d+%d-%d=7\n", a, b, c, d);
  else if(a+b-c+d == 7) printf("%d+%d-%d+%d=7\n", a, b, c, d);
  else if(a-b+c+d == 7) printf("%d-%d+%d+%d=7\n", a, b, c, d);
  else if(a+b-c-d == 7) printf("%d+%d-%d-%d=7\n", a, b, c, d);
  else if(a-b+c-d == 7) printf("%d-%d+%d-%d=7\n", a, b, c, d);
  else if(a-b-c+d == 7) printf("%d-%d-%d+%d=7\n", a, b, c, d);
  else if(a-b-c-d == 7) printf("%d-%d-%d-%d=7\n", a, b, c, d);

  return 0;
}

Measured memory_bytes: 256
n = input()
a, b = map(int, raw_input().split())
l = map(int, raw_input().split())
lesa, bwab, gtb = 0, 0, 0
for i in l:
	if i <= a:
		lesa += 1
	elif a < i <= b:
		bwab += 1
	else:
		gtb += 1
print min(lesa, bwab, gtb)

Measured memory_bytes: 2568
#include <stdio.h>

int main(void)
{
int a , b;
scanf("%d %d",&a,&b);
if(a < b){
printf("a < b\n");
}
 else if(a > b){
printf("a > b\n");
}
else {
printf("a == b\n");
}
return 0;

}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int kx[] = {+1, +2, -1, -2, +1, +2, -1, -2};
const int ky[] = {+2, +1, +2, +1, -2, -1, -2, -1};
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
inline void fastIO(){
  ios_base::sync_with_stdio(0);cin.tie(0);
}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

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

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

int main(){
  fastIO();
  ll ans=0;
  int n,k;
  cin>>n>>k;
  vector<int>a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  for(int i=0;i<k;i++){
    ans+=a[i];
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll N,M,H,W,K,A,B;
string S;
//Write From this Line

int main()
{
	cout << setprecision(10);
	cin >> N >> M >> S;
	//goal から スタートに向かうことを考える
	reverse(S.begin(),S.end());
	vector<int> ans(0);
	int stand = 0;
	while(1){
		for(int i = M ; i >= 0 ; i--){
			if(i == 0){
				cout << -1 << endl;
				return 0 ;
			}
			if(N - stand <= M){//ゴール直前
				ans.push_back(N-stand);
				goto OUT;
			}
			else if(S[stand+i]=='0'){//0だったらそこに行けばいい。
				ans.push_back(i);
				stand += i;
				break;
			}
		}
	}
	OUT:
	reverse(ans.begin(),ans.end());
	for(auto x: ans){
		cout << x << " ";
	}
	cout << endl;


}


Measured memory_bytes: 1144
h, w = gets.chop.split.map(&:to_i)

table = []
h.times { table << gets.chop.split('') }

list = []
h.times do |i|
    list << i if !table[i].include?('#')
end
list.reverse.each do |i|
    table.delete_at(i)
end

list = []
w.times do |j|
    flag = true
    table.length.times do |i|
        flag = false if table[i][j] == '#'
    end
    list << j if flag
 end
list.reverse.each do |j|
    table.length.times do |i|
        table[i].delete_at(j)
    end
end

table.each do |t|
    puts t.join('')
end

Measured memory_bytes: 2556
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <set>
#include <bitset>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORR(i,a,b) for(ll i=a-1;i>=(ll)(b);i--)

#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)

#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

#define popcount __builtin_popcount

int main(void){
    int n, k;
    cin >> n >> k;
    ll a[n];
    ll ans = INF;
    ll i, j;
    memset(a, 0, sizeof(a));

    FOR(i, 0, n){
        cin >> a[i];
    }

    FOR(i, 0, pow(2, n)){
        //cout << i << ' ' << popcount(i) << ' ' << (popcount(i) != k) << endl;
        if (popcount(i) != k) continue;
        ll now = 0, cnt = 0;
        FOR(j, 0, n){
            if ((i >> j) & 1){
                if (a[j] <= now){
                    cnt += (now - a[j]) + 1;
                    //cout << now << ' ' << a[j] << ' '<< (now - a[j]) + 1 << endl;
                    now++;
                }
                now = max(now, a[j]);
            } else{
                now = max(now, a[j]);
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
//
// Created on 2019-02-09.
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }

#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

#define PB push_back
#define INF 1e9
const int MOD = 1e9+7;
#define EPS 1e-9

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;


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


    int n;
    string s;
    cin >> n >> s;

    ll ans = 1;

    map<char, int> m;

    REP(i,n){
        m[s[i]]++;
    }

    for (auto x : m){
        ans *= (x.second+1);
        ans %= MOD;
    }

    cout << --ans << endl;


    return 0;

}

Measured memory_bytes: 512
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;

int n,w,a,a1,a2,a3,amida[50],kind[6];

int main(){
    I(n);
    REP(i,n){
        a1 = 0;
        a2 = 1;
        a3 = 2;
        I(w);
        REP(j,w){
            I(a);
            if (a){
                swap(a2,a3);
            } else {
                swap(a1,a2);
            }
        }
        if (a1 == 0){
            amida[i] = a2 == 1 ? 0 : 1;
        } else if (a1 == 1){
            amida[i] = a2 == 0 ? 2 : 3;
        } else {
            amida[i] = a2 == 0 ? 4 : 5;
        }
    }
    REP(i,n) kind[ amida[i] ] ++;

    if (kind[0] || kind[1] >= 2 || kind[2] >= 2 || kind[5] >= 2 ||
        kind[3] >= 3 || kind[4] >= 3 || (kind[3] && kind[4]) ||
        ( (kind[3] + kind[4]) && (kind[0] + kind[1] + kind[5]) >= 2 ) ) {
            cout << "yes" << endl;
        } else{
            cout << "no" << endl;
        }
}



Measured memory_bytes: 3212
#include<bits/stdc++.h>
#define endl '\n'
#define mp make_pair
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
typedef long long int ll;
ll mod =1000000007;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,d,a,b;
    cin>>a>>b;
    if((a/2019)!=(b/2019)){ cout<<0; return 0; }
    ll ans=INT_MAX;
    ans*=20;
    for(ll i=a;i<b;i++){
        for(ll j=i+1;j<=b;j++){
            ll val=(i%2019)*(j%2019);
            ans=min((i*j)%2019,ans);
        }
    }
    cout<<ans%2019<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);

int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  vector<ll>h(n);
  rep(i,n) cin >> h[i];
  ll ok=1e9+1,ng=0;
  while(abs(ok-ng)>1){
    ll mid=(ok+ng)/2;
    ll sum=0;
    rep(i,n){
      if(h[i]-mid*b>0){
        sum+=(h[i]-mid*b+a-b-1)/(a-b);
      }
    }
    if(sum<=mid)ok=mid;
    else ng=mid;
  }
  cout << ok << endl;
  return 0;
}


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



int main(){
    int n;
    cin >> n;
    vector<ll> v;
    map<ll, int> mp;
    for (int i = 0; i < n; i++){
        int a;
        cin >> a;
        mp[a]++;
        if (mp[a] == 2 || mp[a] == 4) v.push_back(a);
    }
    
    if ((int)v.size() < 2) cout << 0 << endl;
    else{
        sort(v.begin(), v.end(), greater<int>());
        cout << v[0] * v[1] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 6652
use proconio::input;
fn main(){
    input!{
        n: usize,
        a: [usize; n - 1]
    }
    let mut ans = vec![0; n];
    for b in a {
        ans[b-1] += 1;
    }
    for i in 0 .. n {
        println!("{}", ans[i])
    }
}

Measured memory_bytes: 5560
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[5];
  for(int i=0;i<4;i++){
    cin>>a[i];
  }
  sort(a,a+4);
  if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9){
    cout<<"YES"<<endl;
  }
  else cout<<"NO"<<endl;
  return(0);
}


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

int main()
{
  int k;
  cin>>k;
  string s;
  cin>>s;
  if(s.size()<=k)
  {
    cout<<s<<endl;
  }
  else
  {
    for(int i=0;i<k;i++)
      cout<<s[i];
    cout<<"..."<<endl;
  }
}

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

struct work{
    int past;
    int until;

    bool operator<(const work& right)const{
        return until == right.until ? past < right.past : until < right.until;
    }
};

bool cmp(const work &A, const work &B){
    return A.until < B.until;
}

int main(){
    int A, B, N, i, asum = 0;

    cin >> N;
    vector<work> work_array(N);

    for(i = 0; i < N; i++){
        cin >> A >> B;
        work_array[i].past = A;
        work_array[i].until = B;
    }
    sort(work_array.begin(), work_array.end());
    
    for(i = 0; i < N; i++){
        asum += work_array[i].past;
        if(asum > work_array[i].until){
            cout << "No" << endl;
            break;
        }
    }
    if(i == N){
        cout << "Yes" << endl;
    }
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

long long powmod(long long a,long long b){
    long long c=1;
    while(b>0){
        if(b&1) c=a*c%mod;
        a=a*a%mod;
        b>>=1;
    }
    return c;
}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

const int MAXN=1005;
const int MAXV=MAXN*(MAXN-1)/2;

vll to(MAXV);

int main()
{
	ll n,k;
	map<ll,ll> m;
	cin >> n >> k;
	vll a(n);
	rep(i,n) cin >> a[i];
	ll cnt1=0;
	rep(i,n-1){
		ll tmp=0;
		for(ll j=i+1;j<n;j++){
			if(a[i]>a[j]) tmp++;
		}
		cnt1+=tmp;
	}
	cnt1*=k;
	ll cnt2=0;
	rep(i,n){
		ll tmp=0;
		rep(j,n){
			if(a[i]>a[j]) tmp++;
		}
		cnt2+=tmp;
	}
	cerr << cnt1 << " " << cnt2 << endl;
	cout << (cnt1+cnt2*((k*(k-1))/2%mod))%mod << endl;
	return 0;
}


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

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

typedef long long ll;

int main() {
    int n;cin>>n;
    ll a[n],b[n];
    rep(i,n)cin>>a[i];
    b[0]=a[0];
    rep(i,n-1)b[i+1]=b[i]+a[i+1];
    
    ll ans = 0;
    ll cc  = 1;
    ll cc0 = 0;
    sort(b, b+n);

    rep(i,n-1){
        if(b[i] == 0)++cc0;

        if(b[i+1] == b[i])++cc;
        if(b[i+1] != b[i]){
            ans += cc*(cc-1)/2;
            cc = 1;
        }
    }

    ans += cc*(cc-1)/2;    

    if(b[n-1]==0)++cc0;
    ans += cc0;

//    rep(i,n)rep(j,i)if(b[i]-b[j]==0)++ans;
//    rep(i,n)if(b[i]==0)++ans;

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

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(void){
    long long N;
    cin >> N;
    long long A[N];
    long long sum = 0;
    for(long long i = 0; i < N; i++){
        
        cin >> A[i];
        sum += A[i];    
            
    }
    
    long long left[N];
    long long right[N];
    long long accl = 0;
    for(long long i = 0; i < N; i++){
        
        accl += A[i];
        left[i] = accl;
        right[i] = sum - accl;
            
    }
    
    long long m =  LLONG_MAX ;
    
    for(long long i = 0; i < N; i++){
        
        m = min(m,abs(left[i]-right[i]));
    }
    
    cout << m << endl;
    
    
}


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

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-7
typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()
typedef pair<int, int> pii;

ll ans;

int main()
{
	ans = 1;
	ll n, k;
	cin >> n >> k;
	rep(i, n)
	{
		if (i == 0)
			ans *= k;
		else
			ans *= (k - 1);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  int n,a[100000],cnt=0,b[100000];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  for(int i=1;i<n;i++){
    if(a[i]==a[i-1]){
      b[cnt++]=a[i];
      a[i]=0;
      a[i-1]=0;
    }
  }
  if(cnt<2)cout<<0<<endl;
  else cout<<b[cnt-1]*b[cnt-2]<<endl;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 99999999999999999;



long long int N,M,res=0;

long long int a,b,c;

char ch[140];
int main()
{
    cout << fixed << setprecision(18);
   cin>>N;
   for(long long int i = 0; i <N ; i++){
       cin>>ch[i];
       if(ch[i]=='Y'){
           cout<<"Four"<<endl;
           return 0;
       }
   }
   
   cout<<"Three"<<endl;
   
    
}


Measured memory_bytes: 256
import math
N = int(input())
A = list(map(int, input().split()))
a_lst = [0 for i in range(9)]

for i in A:
    if 1 <= i <= 399:
        a_lst[0] += 1
    elif 400 <= i <= 799:
        a_lst[1] +=1
    elif 800 <= i <= 1199:
        a_lst[2] +=1
    elif 1200 <= i <= 1599:
        a_lst[3] +=1
    elif 1600 <= i <= 1999:
        a_lst[4] +=1
    elif 2000 <= i <= 2399:
        a_lst[5] +=1
    elif 2400 <= i <= 2799:
        a_lst[6] +=1
    elif 2800 <= i <= 3199:
        a_lst[7] +=1
    else:
        a_lst[8] +=1

mn = len([0 for i in a_lst[:-1] if i > 0])
mx = mn + a_lst[-1]
if mn == 0:
    mn = 1
print(mn, mx)


Measured memory_bytes: 3064
#include <iostream>
#define llint long long

using namespace std;

llint n, a, b;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> a >> b;
	if(a%2 == b%2){
		cout << (b-a)/2 << endl;
		return 0;
	}
	a--, b--;
	if(a > b) swap(a, b);
	llint ans = a+(b-a-1)/2+1;
	
	a = (n-1)-a, b = (n-1)-b;
	if(a > b) swap(a, b);
	ans = min(ans, a+(b-a-1)/2+1);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 764
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>


using namespace std;

typedef pair < int , int > pii;

typedef long long ll;
const int maxn = (int) 2e5 + 100;


int main(){
    int a, b;
    cin >> a >> b;
    if(a > b)
        swap(a, b);
    int ans = a;
    b -= a;
    if(b % 2 == 1){
        cout << "IMPOSSIBLE";
    }
    else{
        ans += (b / 2);
        cout << ans;
    }
}


Measured memory_bytes: 256
/*
完全二叉树
ALDS1_9_A:Complete Binary Tree




*/
#include <iostream>
using namespace std;
#define Max 10000


int p(int i) {
	return i / 2;
}
int l(int i) { return i * 2; }
int r(int i) { return i * 2 + 1; }

int main()
{
	int n, a[Max + 1];
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) {
		cout << "node " << i << ": key = " << a[i] << ", ";
		if (p(i) >= 1)cout << "parent key = " << a[p(i)] << ", ";
		if (l(i) <= n)cout << "left key = " << a[l(i)] << ", ";
		if (r(i) <= n)cout << "right key = " << a[r(i)] << ", ";
		cout << endl;
	}



	return 0;
}



Measured memory_bytes: 3096
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    int x,y;
    double z;
    x = a / b;
    y = a % b;
    z = 1.0* a / b;
    printf("%d %d %.6f",x,y,z);
}


Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate など
#include <stdexcept>
#include <cassert> // assert
using namespace std;

#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cerr << H << " ";
  debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// constexpr inline ll MOD = 1'000'000'007;

constexpr int MAX_N = 100'000 + 10;
mp::cpp_int res = 1;
mp::cpp_int base = 10;
mp::cpp_int bound = pow(base, 18);
array<mp::cpp_int, MAX_N> a;

int main()
{
  // 入出力
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  // http://tomeapp.jp/archives/2301
  // https://boostjp.github.io/tips/multiprec-int.html

  int n;
  cin >> n;
  REP(i, n)
  {
    cin >> a.at(i);
    if (a.at(i) == 0)
    {
      res = 0;
    }
  }
  REP(i, n)
  {
    res *= a.at(i);
    if (res > bound)
    {
      res = -1;
      break;
    }
  }

  cout << res << endl;

  return 0;
}



Measured memory_bytes: 6860
#include "bits/stdc++.h"
using namespace std;


// =========================== DEBUGGER =================================

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ((it == d.b) ? "" : ", ") << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define tag(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

// =====================================================================







#define ll long long
const ll int INF = 1e15;

int dp[3005][3005];
string s1, s2;


int kil(int idx1, int idx2)
{
  if(idx1 == s1.length() || idx2 == s2.length())
    return 0;
  if(dp[idx1][idx2] != -1)
    return dp[idx1][idx2];

  if(s1[idx1] == s2[idx2])
      dp[idx1][idx2] = max(dp[idx1][idx2], kil(idx1+1, idx2+1) + 1);
  else
  {
    dp[idx1][idx2] = max(dp[idx1][idx2], kil(idx1, idx2+1));
    dp[idx1][idx2] = max(dp[idx1][idx2], kil(idx1+1, idx2));
  }
  return dp[idx1][idx2];
}

int main()
{
  cin>>s1>>s2;
  string res;
  int ans;
  //memset(dp, -1, sizeof dp);
  
  for(int idx1=s1.length()-1;idx1>=0;idx1--)
    for(int idx2=s2.length()-1;idx2>=0;idx2--)
    {
      if(s1[idx1] == s2[idx2])
          dp[idx1][idx2] = max(dp[idx1][idx2], dp[idx1+1][idx2+1] + 1);
      else
      {
        dp[idx1][idx2] = max(dp[idx1][idx2], dp[idx1][idx2+1]);
        dp[idx1][idx2] = max(dp[idx1][idx2], dp[idx1+1][idx2]);
      }
    }
  
  
  int i=0, j=0;
  int n = s1.length();
  int m = s2.length();
  while(i!=n && j!=m){
       if (s1[i]==s2[j]){
         res+=s2[j];
        i+=1;
          j+=1;
    } else{
         if (dp[i][j]==dp[i+1][j]) i+=1;
        else if (dp[i][j]==dp[i][j+1]) j+=1;
        else{
             cout << "ERROR " <<endl; 
        }
      
    }
    
  }
  cout<<res<<endl;  

  return 0;
}


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

int main(){
	int a,b,c,k;
	cin >> a >> b >> c >> k;

	if(k <= a) cout << k << endl;
	else if(k <= a+b) cout << a << endl;
	else{
		int leave = k-a-b;
		cout << a-leave << endl;
	}
	return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;
import java.math.BigDecimal;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			double a=scan.nextInt();
			double b=scan.nextInt();
			double c=scan.nextInt();
			double d=scan.nextInt();
			double e=scan.nextInt();
			double f=scan.nextInt();
			BigDecimal x = new BigDecimal((c*e-b*f)/(a*e-b*d));
			BigDecimal y = new BigDecimal((f*a-c*d)/(a*e-d*b));
			BigDecimal bdx = x.setScale(3, BigDecimal.ROUND_HALF_UP);
			BigDecimal bdy = y.setScale(3, BigDecimal.ROUND_HALF_UP);
			System.out.println(bdx+" "+bdy);
		}
	}
}

Measured memory_bytes: 18196
#素数関連
def prime_numbers(x):
    if x < 2:
        return []
    prime_numbers = [i for i in range(x)]
    prime_numbers[1] = 0
    for prime_number in prime_numbers:
        if prime_number > math.sqrt(x):
            break
        if prime_number == 0:
            continue
        for composite_number in range(2 * prime_number, x, prime_number):
            prime_numbers[composite_number] = 0
    return [prime_number for prime_number in prime_numbers if prime_number != 0]
def is_prime(x):
    if x < 2:
        return False
    if x == 2 or x == 3 or x == 5:
        return True
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0:
        return False
    prime_number = 7
    difference = 4
    while prime_number <= math.sqrt(x):
        if x % prime_number == 0:
            return False
        prime_number += difference
        difference = 6 - difference
    return True
from collections import deque
n, d, a = map(int, input().split())
xh = [list(map(int, input().split())) for i in range(n)]
xh.sort()
queue = deque()
ans = 0
cur = 0
for i in range(n):
    x, h = xh[i]
    while queue != deque() and queue[0][0] < x:
        cur -= queue.popleft()[1]
    h -= cur
    if h > 0:
        cur += a * ((h - 1) // a + 1)
        ans += (h - 1) // a + 1
        queue.append([x + 2 * d, a * ((h - 1) // a + 1)])
print(ans)

Measured memory_bytes: 62152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int maxN = 2 * (int)1e5 + 100;
int prefA[maxN];
int prefB[maxN];
string s;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        prefA[i + 1] = prefA[i];
        prefB[i + 1] = prefB[i];
        if (s[i] == '.') prefA[i + 1]++;
        else prefB[i + 1]++;
    }
    int mn = (int)1e9;
    for (int cut = 0; cut <= s.size(); cut++) {
        int x = prefB[cut];
        int y = prefA[s.size()] - prefA[cut];
        mn = min(mn, x + y);
    }
    cout << mn;
    return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}

signed main(){
    int a,b;
    while(cin>>a>>b)cout<<gcd(a,b)<<" "<<lcm(a,b)<<endl;
}

Measured memory_bytes: 1156
import java.util.*;
import java.text.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        if (S.compareTo("2019/04/30") > 0) {
            System.out.println("TBD");
        } else {
            System.out.println("Heisei");
        }
        try {
            Date date1 = DateFormat.getDateInstance().parse(S);
        }
        catch (ParseException e) {
            e.printStackTrace();
        }
    }
}


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

	int a, b;
	cin >> a >> b;

	if (a < b){
		cout << "a < b" << endl;
	}
	else if (a > b){
		cout << "a > b" << endl;
	}
	else if (a = b){
		cout << "a == b" << endl;
	}


}


Measured memory_bytes: 3092
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue> //C++
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
#include <map> //C++
using namespace std; //C++
#define rep(i, a, n) for (i = (a); i < (n); i++)


//C++で提出



// string s="AAA";    s.size() =3    (sのサイズ) ...1
// vector <int> a;    配列a(サイズは0) ...2
// a.push_back(10);   配列のサイズが一つ増えて一番後ろに10を代入 ...2
// A.pop_back();   最後の要素が消去される
// sort(A.begin(),A.end());   配列Aの最初の要素から最後の要素(/.)より前までを小さい順に並び替えてa[0]から代入していく...3
// reverse(A.begin(),A.end());   配列Aの最初の要素から最後の要素(/.)までを逆の順にしてa[0]から代入していく
// s.substr(3,2)   配列s[3]から2個の文字を抜き出した文字列 (s[3]とs[4]) ...4
// strcmp(s1,s2)  文字列が等しければ0を出力　s1>s2なら1 s1<s2なら-1を出力　C言語用なので配列は、s1[100]にする...5




/*
const int MAX = 100;
int main() {
	int N, M;
	string s, t;
	map<string, int> m;
	m["apple"] = 10;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> s;
		m[s]++;
	}
	cin >> M;
	for (int i = 0; i < M; ++i) {
		cin >> t;
		m[t]--;
	}
	
	int max=0;

	for (map<string, int>::iterator i = m.begin(); i != m.end(); ++i) {
		if (max < (i->second)) max = i->second;
	}

	if (max < 0) cout << "0";
	else cout << max;

	return 0;
}

*/

int main() {
	
	string s, t,u;
	int a, b;

	cin >> s >> t >> a >> b >> u;

	if (u == s)a--;
	if (u == t)b--;

	cout << a << " " << b;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

/*int H,W;
vector<vector<int>> field;

void dfs(int h, int w){
   field[h][w] = 0;
   
   for(int dh = -1; dh <= 1; dh++){
      for(int dw = -1; dw <= 1; dw++){
         int nh = h + dh;
         int nw = w + dw;
      
         if(nh < 0 || nh >= H || nw < 0 || nw >= W)continue;
         if(field[nh][nw] == 0)continue;

         dfs(nh, nw);
      }
   }
}*/

int main(){
   ll n,k; cin >> n >> k;
   cout << (n + k - 3) / (k - 1) << endl;
} 

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

using namespace std;

#define Rep(i,a,b)  for (int i=(a);i<(b);i++)
#define rep(i,n)    for (int i=0;i<(n);i++)
#define all(x)      (x).begin(), (x).end()

#define ll long long

int main()
{
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> vx(n), vy(m);
	rep (i, n)
		cin >> vx[i];
	rep (i, m)
		cin >> vy[i];
	vx.push_back(x);
	vy.push_back(y);
	if (*max_element(all(vx)) < *min_element(all(vy)))
		cout << "No War" << endl;
	else
		cout << "War" << endl;

}



Measured memory_bytes: 256
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main (String args[]) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String[] sizes = br.readLine().split(" ");
        int r = Integer.parseInt(sizes[0]);
        int c = Integer.parseInt(sizes[1]);
        int suma = 0;
        int[][] total = new int[r+1][c+1];
        
        for(int i=0; i<r ; i++) {
            String[] s_row = br.readLine().split(" ",c);
            for(int j=0; j<c ; j++) {
                total[i][j] = Integer.parseInt(s_row[j]);
                total[i][c] += total[i][j];
                total[r][j] += total[i][j];
                total[r][c] += total[i][j];
            }
        }
        
        String last = "";
        for(int[] row : total) {
            char first = '0';
            for(int col: row) {
                if(first == '0') {
                    first = '1';
                    last += String.valueOf(col);
                } else {
                    last += " " + String.valueOf(col);
                }
            }
            last += "\n";
        }
        last = last.substring(0, last.length() - 1);
        System.out.println(last);
    }
}


Measured memory_bytes: 285192
def MI(): return map(int, input().split())
def II(): return int(input())
def IS(): return input()
def LI(): return list(map(int, input().split()))

a, b = map(str, input().split())
hei = [i * i for i in range(1,1000)]
print('Yes') if int(a+b) in hei else print('No')

Measured memory_bytes: 3060
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
As = []
memo = set()
for i in range(N):
    A = n()
    if A in memo:
        memo.remove(A)
    else:
        memo.add(A)

print(len(memo))



Measured memory_bytes: 11884
MOD = 10 ** 9 + 7

def kaijo(n):
    k = 1
    for i in range(1, n + 1):
        k = k * i % MOD
    return k

n, m = map(int, input().split())
if n == m:
    print((kaijo(n) ** 2 * 2) % MOD)
elif abs(n - m) > 1:
    print(0)
else:
    print((kaijo(n) * kaijo(m)) % MOD)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;
    ll ans=0,id;
    int N,M;
    ll A,B,C,W;
    int a[100010];
    bool f=false;
    ll sum=0;
    string S;

int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>M;
    REP(i,N)cin>>a[i];
    sort(a,a+N);
    REP(i,M){
        ans+=a[N-i-1];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    for (auto &x : a) cin >> x;
    sort(a.begin(), a.end());   
    ll ans = 1e18;
    for (int x = 0; x <= 1000; x++) {
        ll cur = 0;
        for (int i = 0; i < n; i++) {
            cur += (a[i] - x) * (a[i] - x);
        }
        ans = min(ans, cur);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256