akhauriyash/Code-Regression huggingface dataset:
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	x := getNextInt(scanner)
	y := getNextInt(scanner)
	if (x+y)%3 != 0 || x > 2*y || y > x*2 {
		fmt.Println(0)
		return
	}

	c := (x + y) / 3
	cm := CombinationMod{}
	cm.init(c)

	fmt.Fprintln(writer, cm.calc(c, x-c))
	writer.Flush()
}

// CombinationMod ...
type CombinationMod struct {
	n, mod   int64
	fac, inv []int64
}

func (cm *CombinationMod) init(n int) {
	cm.n = int64(n)
	cm.fac = make([]int64, n+1)
	cm.inv = make([]int64, n+1)
	cm.fac[0] = 1
	cm.inv[0] = 1
	cm.mod = int64(1e9 + 7)
	var i int64
	for i = 1; i < cm.n+1; i++ {
		cm.fac[i] = (cm.fac[i-1] * i) % cm.mod
		cm.inv[i] = cm.calcInv(cm.fac[i])
	}
}

func (cm *CombinationMod) calcInv(n int64) int64 {
	if n == 1 {
		return 1
	}
	var a, b, x, y int64
	a = cm.mod
	b = n
	x = 1
	y = -a / b

	stack := [][]int64{
		[]int64{
			x, y,
		},
	}
	for a%b > 0 {
		a, b = b, a%b
		x = 1
		y = -a / b
		stack = append(stack, []int64{
			x, y,
		})
	}

	for i := len(stack) - 2; i > 0; i-- {
		stack[i-1][0] *= stack[i][1]
		stack[i-1][1] *= stack[i][1]
		stack[i-1][1] += stack[i][0]
	}

	ans := stack[0][1] % cm.mod
	if ans < 0 {
		ans += cm.mod
	}

	return ans
}

func (cm *CombinationMod) calc(n, m int) int64 {
	ans := (cm.fac[n] * ((cm.inv[m] * cm.inv[n-m]) % cm.mod)) % cm.mod
	return ans
}


Measured memory_bytes: 24092
#include <iostream>
#include <stack>
#include <algorithm>
using namespace std;
int main(){
  int a,b;
  while(cin >> a >> b , a+b){
    b = b-a;
    int a1 = b/1000;
    int b1 = (b%1000)/500;
    int c1 = ((b%1000)%500)/100;
    cout << c1 << ' ' << b1 << ' ' << a1 << endl; 
  }
  return 0;
}

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



int main() {

int hantei=1;
string S, T;
cin >> S >> T;
for (int i = 0; i < S.size(); i++) {
    if(S.at(i)!=T.at(i)){
        hantei=0;
    }
}
if(hantei==1){
    cout << "Yes" << endl;
}
else{
    cout << "No" << endl;
}
}

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

char S[1000010];

int main()
{
    scanf("%s",S);

    int N = strlen(S);
    for(int i = 0; i < N - 1; i++)
    {
        if(S[i] == 'A' && S[i + 1] == 'C')
        {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int t[n],i,m,s=0;
	for(i=0;i<n;i++)
	{
		cin>>t[i];
		s=s+t[i];
	}
	cin>>m;
	int p[m],x[m],a[m];
	for(i=0;i<m;i++)
	{
		cin>>p[i]>>x[i];
		a[i]=s+(x[i]-t[p[i]-1]);
	}
	for(i=0;i<m;i++)
	{
		cout<<a[i]<<endl;
	}
	
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, k, s=1;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        if (s*2 < s+k) s *= 2;
        else s += k;
    }
    cout << s << endl;
}

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

int main() {
    int n,ans=0;
    cin >> n;
    for (int i = 1;i <= n; i++) {
        if (i % 2 == 0)continue;
        int m = 0;
        for (int j = 1;j <= i;j++) {
            if (i % j == 0) m++;
        }
        if (m == 8) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def get_x(arr):
  pass


def main():
  input()
  X = list(map(int,input().split()))
  ans = 10 ** 8
  for i in range(min(X), max(X)+1):
    nums = [(x-i)**2 for x in X]  
    if sum(nums) < ans:
      ans = sum(nums)
  print(ans)

    
if __name__ == "__main__":
  main()

Measured memory_bytes: 2940
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  vs vec;
  cin >> n >> m;
  rep(i,0,n){
    cin >> s;
    vec.pb(s);
  }
  sort(all(vec));
  rep(i,0,vec.sz){
    cout << vec[i];
  }
  puts("");
  return 0;
}

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

void dfs(int node, int &p, vector<int> &seq, vector<int> &stk, vector<int> &ctr, vector<vector<int> > &adj){
    if(seq[p] < 0){
        int n = stk.size();
        int curr = stk[n-1];
        int prev = stk[n-1 +seq[p]];
        adj[curr].push_back(prev);
        adj[prev].push_back(curr);
        ctr[prev]--;
        p++;
        return;
    }
    int n = adj.size();
    adj.emplace_back();
    ctr.push_back(seq[p]);
    stk.push_back(n);
    p++;
    if(node!=-1){
        adj[n].push_back(node);
        adj[node].push_back(n);
    }
    while(ctr[n] > 0){
        dfs(n, p, seq, stk, ctr, adj);
        ctr[n]--;
    }
    stk.pop_back();
}

int main(){
    int rep=0;
    cin >> rep;
    for(int r=0; r<rep; r++){
        vector<int> a;
        while(1){
            int d;
            cin >> d;
            if(d == 0) break;
            if(d > 0) d--;
            a.push_back(d);
        }
        vector<int> ctr, stk;
        vector<vector<int> > adj;
        int p=0;
        dfs(-1, p, a, stk, ctr, adj);
        for(int i=0; i<(int)adj.size(); i++){
            cout << i+1;
            sort(adj[i].begin(), adj[i].end());
            for(int j=0; j<(int)adj[i].size(); j++){
                cout << " " << adj[i][j]+1;
            }
            cout << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3140
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
ll dp[200001], last[200001];
int main(void) {
	int n;
	cin >> n;
	vector<int> c(n + 1);
	rep(i, 1, n + 1)cin >> c[i];
	dp[0] = 1;
	rep(i, 1, n + 1) {
		dp[i] = dp[i - 1];
		if (last[c[i]] && last[c[i]] != i - 1) {
			dp[i] += dp[last[c[i]]];
			dp[i] %= mod;
		}
		last[c[i]] = i;
	}
	printf("%lld\n", dp[n]);
	return 0;
}


Measured memory_bytes: 4096
n = int(input())
s = []
for i in range(n):
    S = int(input())
    s.append(S)
s.sort()
count = [j for j in s if j%10 ==0]
No10 = [i for i in s if i%10 !=0]
if len(No10) ==0:
    print(0)
else:
    if (sum(count) + sum(No10)) %10 !=0:
        print(sum(count) + sum(No10))
        exit()
    for i in range(n):
        if (sum(count) + sum(No10)-No10[i]) %10 !=0:
            print(sum(count) + sum(No10)-No10[i])
            break
        else:
            pass

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<queue>
#include<vector>
using namespace std;

void big(void){
  cout<<"GREATER"<<endl;
}
void small(void){
  cout<<"LESS"<<endl;
}
int main(){
  string a,b;
  char ans[50];
  cin>>a;
  cin>>b;
  if(a.size()>b.size()){
    big();
  }else if(a.size()<b.size()){
    small();
  }else{
    int i=0;
    while(i<a.size()){
      if(a[i]>b[i]){
	big();
	break;
      }
      if(a[i]<b[i]){
	small();
	break;
      }
      
      if(i>=a.size()-1)cout<<"EQUAL"<<endl;
      i++;
    }
    
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define re register
#define ull usigned ll
using namespace std;
inline int read(){
	int s=0,t=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')s=(s<<1)+(s<<3)+(ch^48),ch=getchar();
	return s*t;
}
int n,m,tot,f[2],a[105];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	n=read(),m=read(),f[0]=1,f[1]=m;
	for(int i=1;i<=m;i++){
		a[i]=read();
		if(!(a[i]&1))continue;
		f[tot++]=i;
		if(tot>2)return printf("Impossible"),0;
	}swap(a[1],a[f[0]]),swap(a[m],a[f[1]]);
	for(int i=1;i<=m;i++)printf("%d ",a[i]);printf("\n");
	if(m==1&&a[1]==1)return printf("1\n1"),0;
	if(m==1)return printf("2\n%d 1",a[1]-1),0;
	printf("%d\n",a[m]>1?m:m-1);
	printf("%d ",a[1]+1);
	for(int i=2;i<m;i++)printf("%d ",a[i]);
	if(a[m]>1)printf("%d",a[m]-1);
	return 0;
}

Measured memory_bytes: 3744
/***************************************************
 * Problem Name : A.cpp
 * Problem Link :
 * OJ           :
 * Verdict      : Trying
 * Date         : 2020-01-12
 * Problem Type :
 * Author Name  : Saikat Sharma
 * University   : CSE, MBSTU
 ***************************************************/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <deque>
#include <stack>
#include <bitset>
#include <cassert>
#include <map>
#include <set>
#include <cassert>
#include <iomanip>
#include <random>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;

#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define __FileRead freopen ("input.txt", "r", stdin)
#define __FileWrite freopen ("output.txt", "w", stdout)
#define SET(a,v) memset(a,v,sizeof(a))
#define SZ(v) (int)v.size()
#define pii pair<int,int>
#define pil pair <int, ll>
#define pli pair <ll, int>
#define pll pair <ll, ll>
#define debug cout <<"######\n"
#define debug1(x) cout <<"### " << x << " ###\n"
#define debug2(x,y) cout <<"# " << x <<" : "<< y <<" #\n"
#define nl cout << "\n";
#define sp cout << " ";
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pf(n) scanf("%d", n)
#define pfl(n) scanf("%lld", n)
#define all(v) v.begin(), v.end()
#define rall(v) v.begin(), v.end()
#define srt(v) sort(v.begin(), v.end())
#define r_srt(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define Sqr(x) ((x)*(x))
#define Mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define pb push_back
#define mk make_pair
#define MAX 100005
#define INF 1000000009
#define MOD 1000000007

template<class T>
using min_heap = priority_queue<T, std::vector<T>, std::greater<T>>;
template<typename T>
using ordered_set  = tree<T, null_type, less<T>, rb_tree_tag,
      tree_order_statistics_node_update>;

template <typename T> string toString ( T Number ) {
    stringstream ss;
    ss << Number;
    return ss.str();
}
template<typename T> int toInt (T str) {
    stringstream ss;
    ss << str;
    int num;
    ss >> num;
    return num;
}
ll lcm (ll a, ll b) {
    return a * b / __gcd (a, b);
}
/************************************ Code Start Here ******************************************************/
int main () {
    //~ __FastIO;
    //~ cout << setprecision (10);
    //~ cout << fixed;
    char ch;
    cin >> ch;

    if (ch == 'z') cout << 'a' << "\n";
    else {
        ch++;
        cout << ch << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <random>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

struct MyStruct {
	int a, b;
};

bool comp(const MyStruct& s, const MyStruct& t) {
	if (s.a != t.a)
		return s.a > t.a; //降順
	return s.b > t.b;
}

int main() {
	long long n, m;
	cin >> n >> m;

	long long ans, left;

	if (m >= n * 2) {
		ans = n;
		left = m - 2 * n;
		ans += left / 4;
	}
	else {
		ans = m/2;
	}

	ANS(ans);
	

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n, s, c = 0, l, r, i;
    long long ans = 0;
    vector <int> x, y;
    vector <long long> p;
    
    scanf("%d %d", &n, &s);
    
    for (i = 0; i < n; i++) {
        int a, b;
        
        scanf("%d %d", &a, &b);
        
        x.push_back(a);
        p.push_back(b);
    }
    
    for (i = 0; i < n; i++) {
        if (x[i] < s) c++;
    }
    
    x.insert(x.begin() + c, s);
    p.insert(p.begin() + c, 0);
    
    n++;
    
    l = 0;
    r = n - 1;
    
    while (1) {
        if (c == l) {
            for (i = r; i >= l; i--) y.push_back(x[i]);
            break;
        } else if (c == r) {
            for (i = l; i <= r; i++) y.push_back(x[i]);
            break;
        } else if (p[l] >= p[r]) {
            y.push_back(x[r]);
            p[l] += p[r];
            r--;
        } else {
            y.push_back(x[l]);
            p[r] += p[l];
            l++;
        }
    }
    
    for (i = 0; i + 1 < y.size(); i++) ans += abs(y[i + 1] - y[i]);
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 2288
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n>>a;
  k=n-1;
  rep(i,a-k, a+k+1) cout<<i<<" ";
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
  // cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

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

namespace AtCoder_abc121_a
{
    class Program
    {
        public static int Solve(int[] N , int[] M)
        {
            int[] atai = new int[2];
            for (int i = 0; i <= 1; i++)
            {
                atai[i] = N[i] - M[i];
            }
            int sum = atai[0] * atai[1];

            return sum;
        }

        static void Main(string[] args)
        {
            string[] n = Console.ReadLine().Split(' ');
            int[] hen = n.Select(int.Parse).ToArray();
            int a = int.Parse(n[0]);
            int b = int.Parse(n[1]);

            string[] m = Console.ReadLine().Split(' ');
            int[] hen2 = m.Select(int.Parse).ToArray();
            int c = int.Parse(n[0]);
            int d = int.Parse(n[1]);


            Console.WriteLine(Solve(hen,hen2));
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[2] = {0, 1};
ll dy[2] = {1, 0};

int main(void){
    ll n, k;
    cin >> n >> k;
    ll INF = 1e+9+7;
    vector<ll> sa(n+1, 0);
    vector<ll> sb(n+1, 0);
    sb[0] = n;
    for(ll i = 1; i <= n; i++){
        sa[i] = sa[i-1]+i;
        sb[i] = sb[i-1]+(n-i);
    }
    ll ans = 0;
    for(ll i = 0; i <= n; i++){
        if(i>=k-1){
            ans+=(sb[i]-sa[i]+1);
            ans%=INF;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6328
<?php

$p = [];
fscanf(STDIN, "%d", $n);
$p = explode(" ", trim(fgets(STDIN)));

$cnt = 0;

for ($i=1; $i <$n-1 ; $i++) {
  if (($p[$i-1]<$p[$i]&&$p[$i]<$p[$i+1]) || ($p[$i-1]>$p[$i]&&$p[$i]>$p[$i+1]) ) {
    $cnt ++;
  }
}
echo $cnt;

Measured memory_bytes: 4728
#include <iostream>
#include <complex>
#include <cmath>

using namespace std;

int main(){
  int n;
  cin >> n;
  while(n--){
    complex<double> c1,c2;
    double r1,r2,dist;
    cin >> c1.real() >> c1.imag() >> r1 >> c2.real() >> c2.imag() >> r2;
    dist = abs(c1-c2);
    if(dist>r1+r2){
      cout << 0 << endl;
    }else if(dist>=abs(r1-r2)){
      cout << 1 << endl;
    }else if(r1>r2){
      cout << 2 << endl;
    }else{
      cout << -2 << endl;
    }
  }
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (int i = (a); i < (b); i++)
#define rrrep(i, a, b) for (int i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl

ll n, cnt, ans, a, b, c, d, tmp, tmpp, m, h, w, x, y, sum, pos, k;
ld doua;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
bool fl;
struct edge
{
    int to, cost;
};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin >> n;
    rep(i, n)
    {
        cin >> a;
        if (a % 2 == 1)
            cnt++;
    }
    if (cnt % 2 == 1)
        Cout("NO");
    else
        Cout("YES");
    return 0;
}


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

Measured memory_bytes: 600
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
using namespace std;

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

typedef long long ll;
typedef unsigned long long int ulli;

const ll INF = ll(1e18) + 1;

typedef struct {
	ll cost;
	ll damage;
}magic;

unsigned long long int a(ulli n, ulli b) {
	if (b <= 1) {
		return n;
	}
	else {
		return a(n * 2, b - 1);
	}
}

ll mina(ll a, ll b) {
	return (a > b) ? b : a;
}

void Main()
{
	ll n, m; cin >> n >> m;
	if (n == m) cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main() {
	Main();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  lint n; cin >> n;
  vector<lint> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }

  lint l; cin >> l;
  lint q; cin >> q;
  vector<lint> a(q);
  vector<lint> b(q);
  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    if (a[i] > b[i]) {
      swap(a[i], b[i]);
    }
  }


  vector<vector<lint>> dp(32, vector<lint> (n)); // 2^i 日でどこまでいけるか

  // 1 にちでどこまでいけるかの前処理
  for (int i = 0; i < n; i++) {
    lint ok = i;
    lint ng = n;
    while (ng - ok > 1) {
      lint mid = (ok + ng) / 2;
      (x[mid] - x[i] <= l ? ok : ng) = mid;
    }



    dp[0][i] = ok;
  }

  for (int i = 1; i < 32; i++) {
    for (int j = 0; j < n; j++) {
      // cerr << dp[i - 1][j] << " ";
      dp[i][j] = dp[i - 1][dp[i - 1][j]];
    }
    // cerr << endl;
  }

  vector<lint> po(32);
  po[0] = 1;
  for (int i = 1; i < 32; i++) {
    po[i] = po[i - 1] * 2;
  }
  

  // クエリ処理
  for (int i = 0; i < q; i++) {
    // cerr << i << " th query " << endl;
    // a[i] -> b[i] へ行く
    lint cur = a[i];
    lint ans = 0;
    
    // b[i] 以上にならない最大の日数
    /*
    while (cur < b[i]) {
      lint ok = 0;
      lint ng = 32;
      while (ng - ok > 1) {
        lint mid = (ok + ng) / 2;
        (dp[mid][cur] < b[i] ? ok : ng) = mid;
      }
  
      cur = dp[ok][cur];
      // cerr << ok << " " << cur << endl;
      ans += po[ok];
    } 
    */

    /*
     * 下ってどっちだろ
    大きい方から試して、それを適用して条件を満たさないのなら適用しない
    満たすのなら（2 べきの大小関係とか回数に対して単調なことなどから）適用していい
    みたいな感じで*/

    for (int j = 31; j >= 0; j--) {
      if (dp[j][cur] < b[i]) {
        cur = dp[j][cur];
        ans += po[j];
      }
    }

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


Measured memory_bytes: 28416
n = int(input())
s = input()
if n % 2 != 0:
    print('No')
else:
    count = 0
    for i in range(n//2):
        if s[i] == s[n//2+i]:
            count += 1
    if count == n // 2:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 2940
#define rep(i,n) for (int i=0;i<(n);i++)
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<string>
using namespace std;

int main(){
	string s1,s2,s3;
	cin >> s1 >> s2 >> s3;
	string s;
	s +=s1[0];
	s +=s2[0];
	s +=s3[0];

	rep(i,3) s[i] = toupper(s[i]);
	//transform(s.begin(),s.end(),s.begin(),toupper);
	cout << s << endl;

	return 0;
}

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

int main() {
	long n,k,max=0,sum=0;
	cin>>n>>k;
	long a[n];
	
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	
	sort(a,a+n);
	
	if(k<n){
		for(int b=1;b<=k;b++)
		sum-=a[n-b];
	}
	else if(k>=n)
	sum=0;
	
	cout<<sum;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
const int N=3e5+5,MAX=3e7,MOD=1e9+7;
 
using namespace std;
 
 
int n;
int main()
{
   	
 
 
    	cin>>n;

    	cout<<pow(n,3)<<endl;	
}

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

int main()
{
  int n;
  cin >> n;
  int a[n];
  int b[n];
  rep(i,n){
    cin >> a[i];
  }
  rep(i,n){
    cin >> b[i];
  }
  int ans = 0, tmp = 0;
  rep(i,n){
    if(a[i] > b[i]){
      ans += a[i];
      tmp += b[i];
    }
  }
  cout << ans - tmp << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
    int n,m;cin>>n>>m;
    vector<bool> gotAC(n+1,false);
    map<int,int> mp;
    int ACs=0;
    int pena=0;
    rep(i,0,m){
        int p;cin>>p;
        string s;cin>>s;
        if(s=="WA")++mp[p];
        if(s=="AC" && !gotAC[p]){
            pena+=mp[p];
            ++ACs;
            gotAC[p]=true;
        }
    }
    cout<<ACs<<" "<<pena<<endl;
}


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

#define fastIO                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

using namespace std;

typedef long long ll;
typedef long double ld;

int main()
{
    fastIO;
    ld D, T, S;
    cin >> D >> T >> S;
    cout << (((D / S) <= T)?"Yes":"No");
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
const int MID=8000, SZ=MID*2+1;
bool check(vector<int> len){
  bitset<SZ> dp;
  dp[MID] = 1;
  for (int l : len){
    dp = (dp<<l)|(dp>>l);
  }
  return dp[MID];
}
int main(){
  bool frst=true;
  int cur=0, i, li=0, x, y;
  string s;
  vector<int> len[2];
  cin >> s;
  s += 'T';
  rd(x);
  rd(y);
  for(i=0;i<s.size();i++){
    if (s[i] == 'F'){
      cur++;
    }
    else{
      if (frst){
        x -= cur;
        frst = false;
      }
      else{
        len[li].push_back(cur);
      }
      cur = 0;
      li ^= 1;
    }
  }
  len[0].push_back(abs(x));
  len[1].push_back(abs(y));
  bool ans = check(len[0]) && check(len[1]);
  wt_L(ans?"Yes":"No");
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20170910-1

// --- original code ---
// const int MID = 8000;
// const int SZ = MID*2+1;
// bool check(vector<int> len) {
//   bitset<SZ> dp;
//   dp[MID] = 1;
//   for (int l : len) {
//     dp = (dp<<l)|(dp>>l);
//   }
//   return dp[MID];
// }
// {
//   string s;
//   cin >> s;
//   s += 'T';
//   int x, y;
//   rd(x, y);
//   vector<int> len[2];
//   int li = 0, cur = 0;
//   bool frst = true;
//   rep(i,s.size()) {
//     if (s[i] == 'F') {
//       cur++;
//     } else {
//       if (frst) {
//         x -= cur;
//         frst = false;
//       } else {
//         len[li].push_back(cur);
//       }
//       cur = 0;
//       li ^= 1;
//     }
//   }
//   len[0].push_back(abs(x));
//   len[1].push_back(abs(y));
//   inplace_L bool ans = check(len[0]) && check(len[1]);
//   wt(ans?"Yes":"No");
// }

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

const int inf = 1e8;

void fin(){ 
  cout << "No" << endl;
  exit(0);
}

signed main(void){ 
  
  int n; cin >> n;
  vector<string> s(n);
  vector<pair<int,int>> Plus,Minus;
  
  for(int i = 0; i < n; i++){ 
    
    cin >> s[i];
    
    int num = 0;
    
    int Min = inf;
    
    for(int j = 0; j < (int)s[i].size(); j++){ 
     if( s[i][j] == '('){ 
       num++;
     }
      else{ 
       num--;
      }
      
      Min = min(Min,num);
    }
    
    if( num >= 0 ){ //最後が0以上
      Plus.push_back({Min,num});
    }
    else{
      Minus.push_back({Min,num});
    }
  }
  
  int alt = 0;
  
  sort(Plus.rbegin(),Plus.rend());
  //最下点が高いところほど、最終的な値が高いところほど先につなげていきたい
  
  
  
  
  
  for(int i = 0;  i< (int)Plus.size(); i++){ 
    
    auto p = Plus[i];
    
    if( alt+p.first < 0 ){ 
      fin();
    }
    else{
      alt += p.second;
    }
  }
  
  for(int i = 0; i < (int)Minus.size(); i++){ 
    
    Minus[i] = {Minus[i].first-Minus[i].second,-Minus[i].second};
    
  }
  
  sort(Minus.rbegin(),Minus.rend());
  
  int alt2 = 0;
  
  for(int i = 0; i < (int)Minus.size(); i++){ 
    
    auto p = Minus[i];
    
    if( alt2 + p.first < 0 ){ 
      fin();
    }
    else{
      alt2 += p.second;
    }
  }
  
  if(false){
    cout << alt << " " << alt2 << endl;
  }
  
  if( alt != alt2 ){ fin();}
  else{
    cout << "Yes" << endl;
  }
  
  return 0;
}
  

Measured memory_bytes: 50600
#include <iostream>

using namespace std;

int main(){
    long N;
    long A[5];
    cin >> N;
    for(int i = 0; i < 5; i++){
        cin >> A[i];
    }
    long ans = 0;
    for(int i = 0; i < 5; i++){
        long tmp;
        if(N%A[i] == 0) tmp = N/A[i];
        else tmp = N/A[i]+1;
        ans = max(ans, tmp);
    }
    cout << ans+4 << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n+2];
        a[0] = 0;
        for (int i = 1; i <= n; i++) {
            a[i] = sc.nextInt();
        }
        a[n+1] = Integer.MAX_VALUE;
        
        int b[] = a.clone();
        Arrays.sort(a);
        
        int mid = a[n/2 + 1];
        for (int i = 1; i <= n; i++) {
            if (b[i] >= a[n/2 + 1]) {
                System.out.println(a[n/2] + " ");
                
            } else {
                System.out.println(a[n/2 + 1] + " ");
            }
        }
    }
}


Measured memory_bytes: 94308
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#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 << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long ;
int main(){
	ll n , m , q ;
	cin >> n >> m >> q ;
	vector<ll> s(n) , t(m);
	for(ll i=0;i<n;i++){
		cin >> s[i] ;
	}
	for(ll i=0;i<m;i++){
		cin >> t[i] ;
	}
	while(q--){
		ll x ;
		cin >> x ;
		ll index = lower_bound(s.begin(),s.end(),x) - s.begin() ;
		vector<ll> first,second ;
		if ( index == n ) first.push_back(s[index-1]) ;
		else if ( index == 0 ) first.push_back(s[index]) ;
		else {
			first.push_back(s[index]) ;
			first.push_back(s[index-1]) ;
		}
		index = lower_bound(t.begin(),t.end(),x) - t.begin() ;
		if ( index == m ) second.push_back(t[index-1]) ;
		else if ( index == 0 ) second.push_back(t[index]) ;
		else {
			second.push_back(t[index]) ;
			second.push_back(t[index-1]) ;
		}
        sort(first.begin(),first.end());
        sort(second.begin(),second.end());
		debug() << imie(first) ;
		debug() << imie(second) ;
		ll ans = 1e18 ;
		for(ll i=0;i<(ll)first.size();i++){
            for(ll j=0;j<(ll)second.size();j++){
                if ( first[i] >= x && second[j] >= x ) ans = min(ans,max(first[i],second[j])-x);
                else if ( first[i] <= x && second[j] <= x ) ans = min(ans,x-min(first[i],second[j]));
                else{
                    if ( abs(first[i]-x) <= abs(second[j]-x) ){
                        ll ff = abs(first[i]-x) ;
                        ll ss = abs(second[j]-x) ;
                        ans = min(ans,2*ff+ss) ;
                    }
                    else{
                        ll ff = abs(first[i]-x) ;
                        ll ss = abs(second[j]-x) ;
                        ans = min(ans,2*ss+ff) ;
                    }
                }
            }
		}
		cout << ans << endl;
	}
    return 0 ;
}


Measured memory_bytes: 2944
/*
    https://atcoder.jp/contests/abc124/tasks/abc124_c
    C - Coloring Colorfully
*/
#include <bits/stdc++.h>
using namespace std;

void make_tile(int length, string &even, string &odd) {
    for (int i = 0; i < length; i++) {
        if (i % 2 == 0) {
            even += '0';
            odd += '1';
        } else {
            even += '1';
            odd += '0';
        }
    }
}

void solve(string s) {
    int length = (int)s.size();
    string even = "", odd = "";
    make_tile(length, even, odd);

    int sum_even = 0, sum_odd = 0;
    for (size_t i = 0; i < s.size(); i++) {
        if (s[i] != even[i]) {
            sum_even++;
        }
        if (s[i] != odd[i]) {
            sum_odd++;
        }
    }
    cout << min(sum_even, sum_odd) << endl;
}

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

    string s;
    cin >> s;
    solve(s);
}

Measured memory_bytes: 720
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

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

using namespace std;
using ll = long long int;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


int main()
{
	long long int a, b, k;
	cin >> a >> b >> k;
	if (a >= k){
		cout << a - k << " " << b << endl;
		return 0;
	}
	k = k - a;
	if (b >= k){
		cout << 0 << " " << b - k << endl;
		return 0;
	}
	cout << 0 << " " << 0 << endl;

	return 0;
}

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

struct Card
{
  char pic;
  int num;
};

int partition(Card a[], int p, int r)
{
  int x = a[r].num;
  int i = p - 1;
  for (int j = p; j < r; j++)
    if (a[j].num <= x)
    {
      i++;
      swap(a[i], a[j]);
    }
  swap(a[i + 1], a[r]);
  return i + 1;
}

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

void merge(Card a[], int left, int mid, int right)
{
  int n1 = mid - left;
  int n2 = right - mid;
  Card l[n1 + 1], r[n2 + 1];
  for (int i = 0; i < n1; i++)
    l[i] = a[left + i];
  for (int i = 0; i < n2; i++)
    r[i] = a[mid + i];
  l[n1] = {'J', 1000000001};
  r[n2] = {'J', 1000000001};

  int i = 0, j = 0;
  for (int k = left; k < right; k++)
    if (l[i].num <= r[j].num)
    {
      a[k] = l[i];
      i++;
    }
    else
    {
      a[k] = r[j];
      j++;
    }
}

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

int main()
{
  int n, x;
  char p;
  scanf("%d\n", &n);

  Card a[n], ms[n];
  for (int i = 0; i < n; i++)
  {
    scanf("%c%d\n", &p, &x);
    a[i] = {p, x};
    ms[i] = {p, x};
  }

  quickSort(a, 0, n - 1);
  mergeSort(ms, 0, n);

  bool isStable = true;
  for (int i = 0; i < n; i++)
    if (a[i].num != ms[i].num || a[i].pic != ms[i].pic)
    {
      printf("Not stable\n");
      isStable = false;
      break;
    }

  if (isStable)
    printf("Stable\n");

  for (int i = 0; i < n; i++)
    printf("%c %d\n", a[i].pic, a[i].num);

  return 0;
}

Measured memory_bytes: 4928
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)


int main(){
    ll n,k;
    cin >> n >> k;
    k--;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<vector<int> > b(200001);
    rep(i,n){
        b[a[i]].push_back(i);
    }
    vector<pair<int,int> > p(n);
    rep(j,200001){
        rep(i,b[j].size()){
            if(i==b[j].size()-1){
            
                p[b[j][i]] = MP(b[j][0],1);
            }else{
                p[b[j][i]] = MP(b[j][i+1],0);
            }
        }
    }
    ll c = 0;
    int id = -1;
    while(1){
        if(id==0)break;
        if(id==-1)id = 0;
        pair<int,int> s = p[id];
        id = s.first;
        c += s.second;
        if(id==n-1){
            id = 0;
            c++;
        }else{
            id++;
        }
    }
    //cerr << c << endl;
    k %= c;
    c = 0;
    id = -1;
    while(1){
        if(id==-1)id = 0;
        pair<int,int> s = p[id];
        if(c + s.second > k){
            break;
        }
        //cerr << id << " " << c << endl;
        id = s.first;
        c += s.second;
        if(id==n-1){
            if(c+1 > k){
                id = n;
                break;
            }
            id = 0;
            c++;
        }else{
            id++;
        }
    }
    //cerr << id << endl;
    if(id==n){
        return 0;
    }
    set<int> stt;
    stack<int> st;
    for(int i = id;i<n;i++){
        if(stt.count(a[i])){
            while(1){
                int k = st.top();
                st.pop();
                if(k!=a[i]){
                    stt.erase(k);
                }else{
                    break;
                }
            }
            stt.erase(a[i]);
        }else{
            stt.insert(a[i]);
            st.push(a[i]);
        }
    }
    vector<int> res;
    while(!st.empty()){
        int k = st.top();
        st.pop();
        res.push_back(k);
    }
    reverse(res.begin(),res.end());
    for(auto x:res){
        cout << x << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 25848
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    h, w = map(int, input().split())
    ss = [input() for _ in range(h)]

    matl = [[0 for _ in range(w)] for _ in range(h)]
    matr = [[0 for _ in range(w)] for _ in range(h)]
    matu = [[0 for _ in range(w)] for _ in range(h)]
    matd = [[0 for _ in range(w)] for _ in range(h)]

    for j in range(h):
        for i in range(w):
            if ss[j][i] == '#':
                matd[j][i] = 0
            elif j == 0:
                matd[j][i] = 1
            else:
                matd[j][i] = matd[j - 1][i] + 1

            if ss[h - j - 1][i] == '#':
                matu[h - j - 1][i] = 0
            elif h - j == h:
                matu[h - j - 1][i] = 1
            else:
                matu[h - j - 1][i] = matu[h - j][i] + 1

            if ss[j][i] == '#':
                matr[j][i] = 0
            elif i == 0:
                matr[j][i] = 1
            else:
                matr[j][i] = matr[j][i - 1] + 1

            if ss[j][w - i - 1] == '#':
                matl[j][w - i - 1] = 0
            elif w - i == w:
                matl[j][w - i - 1] = 1
            else:
                matl[j][w - i - 1] = matl[j][w - i] + 1

    maxv = 0
    for j in range(h):
        for i in range(w):
            tmp = matu[j][i] + matd[j][i] + matr[j][i] + matl[j][i]
            if tmp > maxv:
                maxv = tmp
    print(maxv - 3)

if __name__ == '__main__':
    main()


Measured memory_bytes: 182792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<numeric>

typedef long long LL;

using namespace std;

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

int main(void) {
	int n;
	cin >> n;
	vector<LL>dp(n + 1);
	dp[0] = 2;
	dp[1] = 1;
	for (int i = 1; i < n; i++) {
		dp[i + 1] = dp[i] + dp[i - 1];
	}
	cout << dp[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 ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
// cin.eof() 入力個数の問題

int main() {
int n;
cin >> n;
ll a[n];
rep(i,n) cin >> a[i];
int b=0;
for(int i=1;i<n;i++){
  b=b^a[i];
  
}
cout<<b<<endl;
for(int i=1;i<n;i++){
  b=b^a[i-1];
  b=b^a[i];
  cout<<b<<endl;
}

  return 0;
}


Measured memory_bytes: 5096
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  
  string S;
  cin>>S;
  int sum=0;
  
  for(int i=0;i<S.size();i++){
    if(A==i&&S.at(i)=='-'){
      sum++;
    }
else if(i!=A&&S.at(i)<='9'&&S.at(i)>='0'){
  sum++;
}
   }
   
   if(sum==A+B+1){
     cout<<"Yes"<<endl;
   }
else {
  cout<<"No"<<endl;
}
        }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
 
typedef long long ll;
typedef pair<int, int> ii;
 
int main(){

	int n;
	cin >> n;
	ll ans = 1;
	REP(i, 2, n+1){
		ans *= (ll)i;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3068
#include<stdio.h>
#include<algorithm>
#define M 2000000000

using namespace std;
int main(void)
{
	int n,i,j,s,a[5000],b[5000],m;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&a[i]);
	m=M;
	for(i=0;i<=a[0];i++){
		for(j=0;j<n;j++) b[j]=a[j];
		b[0]-=i; s=i;
		for(j=0;j<n-1;j++){
			if(b[j]>0){
				b[j+1]-=b[j];
				s+=b[j]*2;
				b[j]=0;
			}
		}
		if(b[n-1]>0) s+=b[n-1];
		m=min(m,s);
	}
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 2784
N = int(input())
states = []
for n in range(N):
  t, x, y = map(int, input().split())
  states.append((t, x, y))

current = (0, 0, 0)
for next_ in states:
  diff_time = next_[0] - current[0]
  diff_dist = abs(next_[1] - current[1]) + abs(next_[2] - current[2])
  if diff_dist > diff_time:
    print("No")
    break
  elif diff_time % 2 == diff_dist % 2:
    current = next_
  else:
    print("No")
    break

if current == states[-1]:
	print("Yes")

Measured memory_bytes: 88572
#include<iostream>
using namespace std;
#include<vector>
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
typedef long long ll;
int main(){
  ll N, ans=0;
  vector<ll> a,b;
  cin >> N;
  rep(i,0,N+1){
    ll temp;
    cin >> temp;
    a.pb(temp);
  }
  rep(i,0,N){
    ll temp;
    cin >> temp;
    b.pb(temp);
  }
  
  if(a[N] > 0 || a[N-1]>0){
    ll res, room=0;
    res = a[N] - b[N-1];
    if(res < 0){
      room = -res;
      //a[N] = 0;
    }
    else{
      a[N] -= b[N-1];
      ans += b[N-1];
      room = -99999;
    }
    if(room > a[N-1]){
      ans += a[N-1]+a[N];
      a[N-1] = 0;
    }
    else if(room != -99999){//room < a[i+1]
      ans += b[N-1];
      a[N-1] -= room;
    }
    //cout << ans << endl;
  }

  
  rep(i,0,N-1){
    ll res, room=0;
    //cout << ans << endl;
    if(a[i] > 0 || a[i+1]>0){
      res = a[i] - b[i];
      //cout << res << endl;
      if(res < 0){
	room = -res;
	//a[i] = 0;
      }else{
	a[i] -= b[i];
	ans += b[i];
	continue;
      }

      if(room > a[i+1]){
	ans += a[i]+a[i+1];
	a[i+1] = 0;
      }
      else{//room < a[i+1]
	ans += b[i];
	a[i+1] -= room;
      }			  
    }
    //cout << ans << endl;
  }
  cout <<ans<< endl;
}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
#include <unistd.h>
#include <random>
#include <numeric>

using namespace std;
typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end())
#define DOUBLECHANGE(count) cout << setprecision(count)
#define REV(vec) reverse(vec.begin(),vec.end())
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
      cin.tie(0);
      ios::sync_with_stdio(false);
      int N;
      cin >> N;
      vector<pair<int,int>> task (N);
      for(int i = 0;i < N;i++){
          cin >> task[i].second >> task[i].first;
      }
      SORT(task);
      long long int time = 0;
      for(int i = 0;i < N;i++){
          time += task[i].second;
          if(time > task[i].first){
              cout << "No" << endl;
              return 0;
          }
      }
      cout << "Yes" << endl;
      return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define maxn 100010
#define inf 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long LL;
vector<int> v;
int a[maxn], pre[maxn], succ[maxn], b[maxn];
bool flag[maxn];
int main() {
    int n;
    scanf("%d", &n);
    int tot = 0;
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
    }
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
        if (a[i] == i && !flag[i]) {
            if (a[i+1] == a[i+1]) {
                ++cnt;
                flag[i+1] = true;
            }
            else ++cnt;
        }
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 768