akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>


#define SIZE 100000


int main(void){

	int i,j,n,a,b,ad,bd,amariA,amariB,sum[SIZE],temp;
	scanf("%d",&n);
	
	for(i=1;i<n;i++){
		 
		b = i;
		a = n - b;
		ad = 0;
		bd = 0;
	
		for(j=1;j<=5;j++){
			amariA = a%10;//(int)pow(10,j);
			amariB = b%10;//(int)pow(10,j);
			ad += amariA;
			//printf("%d\n",ad);
			bd += amariB;
			a -= amariA;//pow(10,j-1);
			a = a/10;
			b -= amariB;//pow(10,j-1);
			b = b/10;   
		}

		sum[i] = ad + bd;
		//printf("%d\n",sum[i]);
	}

	temp = 99999;
	for(i=1;i<n;i++){

		if(temp>=sum[i]){
			 temp = sum[i];
		//	printf("%d\n",temp);
		
		}
	}
	
	printf("%d",temp);

	return 0;
	
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int N = 100100;


int a[N];
long long rs = 0;
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<n;i++){
        if (a[i]&1){
            if (a[i+1]==0) continue;
            a[i]--;
            a[i+1]--;
            rs++;
        }
    }
    for(int i=1;i<=n;i++){
        rs+=a[i]/2;
    }
    cout<<rs;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222


struct UnionFind {
  vll rank, par, data;

  UnionFind(ll x = MAX) {
    rank.resize(x + 1, 0);
    par.resize(x + 1, 0);
    data.resize(x + 1, 1);
    rep(i, x + 1) par[i] = i;
  }

  ll root(ll x) {
    if (x != par[x]) par[x] = root(par[x]);
    return par[x];
  }

  ll size(ll x) {
    return data[root(x)];
  }

  void unite(ll a, ll b) {
    ll x = root(a);
    ll y = root(b);
    if (x == y) return;
    if (rank[x] > rank[y]) {
      par[y] = x;
      data[x] += data[y];
    }
    else {
      par[x] = y;
      data[y] += data[x];
      if (rank[x] == rank[y]) rank[y]++;
    }
  }

  bool same(ll a, ll b) {
    return root(a) == root(b);
  }
};



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

  

  cin >> n >> m;
  UnionFind uf(MAX);
  rep(i, m) {
    ll x, y, z;
    cin >> x >> y >> z;
    uf.unite(x, y);
  }
  MAP mp;
  FOR(i, 1, n + 1) {
    if (!mp[uf.root(i)]) {
      ans++;
      mp[uf.root(i)]++;
    }
  }
  cout << ans << endl;



  return 0;
}

Measured memory_bytes: 11776
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)

ans = A[0]

for i in range(2,len(A)):
    if i % 2 == 0:
        ans += A[i-1*(i//2)]
    else:
        ans += A[i-1*(i//2)-1]

print(ans)

Measured memory_bytes: 31604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

int main(){
    ll a;
    double b;
    cin >> a >> b;
    ll bb = (ll)(b*100+0.1);
    cout << a * bb/100 << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define va vector<long long int> a 
#define vb vector<long long int> b
const ll M=1e9+7;
const ll inf=1e18+5;
using namespace std;
ll t;
void fast(){cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);}
ll bs(ll arr[], ll l, ll r, ll x){ 
	ll mid=0;
    if (r >= l){
		if (arr[mid] == x) return mid; 
        if (arr[mid] > x) return bs(arr, l, mid - 1, x); 
        return bs(arr, mid + 1, r, x); 
    }
    return -1;
}
ll power(ll x,ul y,ll p){
	ll res = 1;
	x = x % p;
	if(x == 0) return 0;
	while (y > 0){
		if (y & 1) res = (res*x) % p;
		y = y>>1;
		x = (x*x) % p;
		}
	return res;
}


void solve(){
	ll n;
	cin>>n;
	ll m=n%10;
	if(m==2 || m==4 || m==5 || m==7 || m==9) cout<<"hon\n";
	else if(m==0 || m==1 || m==6 || m==8) cout<<"pon\n";
	else cout<<"bon\n";
 }
int main(){
	fast();
	solve();
	return 0;
}



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

#define NIL -1
#define INF 100000000
#define WHITE 1
#define GREY 2
#define BLACK 3
#define N_MAX 100

int G[N_MAX][N_MAX];
int V[N_MAX];
int V_value[N_MAX];

void init(){
    for(int i = 0; i < N_MAX; i++){
        V[i] = WHITE;
        V_value[i] = INF;
    }

    for(int i = 0; i < N_MAX; i++){
        for(int j = 0; j < N_MAX; j++){
            G[i][j] = NIL;
        }
    }
}

int main(void){
    init();
    int n;
    scanf("%d\n", &n);

    for(int i = 0; i < n; i++){
        int u, k;
        scanf("%d %d", &u, &k);
        for(int j = 0; j < k; j++){
            int v, c;
            scanf("%d %d", &v, &c);
            G[u][v] = c;
        }
    }

    V[0] = BLACK;
    V_value[0] = 0;
    int new_node = 0;
    
    while(1){
        for(int i = 0; i < n; i++){
            if(G[new_node][i] != NIL && V[i] == WHITE){
                V_value[i] = min(V_value[i], V_value[new_node] + G[new_node][i]);
            }
        }

        int min_index = NIL;
        int min_value = INF;
        for(int i = 0; i < n; i++){
            if(V[i] == WHITE && V_value[i] < min_value){
                min_value = V_value[i];
                min_index = i;
            }
        }
        if(min_index == NIL){
            break;
        }else{
            new_node = min_index;
            V[new_node] = BLACK;
            V_value[new_node] = min_value;
        }
    }
    
    for(int i = 0; i < n; i++){
        printf("%d %d\n", i, V_value[i]);
    }

    return 0;
}



Measured memory_bytes: 3236
def dfs(i, f):
    if i == n - 1:
        return eval(f)
    
    return dfs(i + 1, f + s[i + 1]) + \
           dfs(i + 1, f + "+" + s[i + 1])

s = input()
n = len(s)

print(dfs(0, s[0]))

Measured memory_bytes: 3060
A, B, K = STDIN.gets.chomp.split(' ').map{|s| s.to_i}

if A - K > 0
  a = A - K
  b = B
else
  a = 0
  b = (B - (K - A)) <= 0 ? 0 : (B-(K-A))
end

puts "#{a} #{b}"


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a <= b) {
			System.out.println(a);
		} else {
			System.out.println(a-1);
		}

	}
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

int S(int n)
{
    int res = 0;
    while(n > 0)
    {
        res += n % 10;
        n /= 10;
    }
    return res;
}

void solve()
{
    int n; cin >> n;
    if(n % S(n) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

    solve();

    return 0;
}

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

signed main() {
  int n,q;
  cin>>n>>q;
  int s,t,x;
  pair<int,pair<int,int>> k[n];
  for(int i=0;i<n;i++){
    cin>>s>>t>>x;
    k[i]=make_pair(s-x,make_pair(x,t-x));
  }  
  sort(k,k+n);
  priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> que;
  int d,p=0;
  for(int i=0;i<q;i++){
    cin>>d;
    while(p<n&&k[p].first<=d){
      que.push(k[p].second);
      p++;
    }
    while(!que.empty()&&que.top().second <=d)que.pop();
    if(que.empty())cout<<-1<<endl;
    else cout<<que.top().first<<endl;
  }
  


 


    return 0;
}


Measured memory_bytes: 9584
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr = input.trim().split("\n");
var s=arr[0].split("");

for(var i=0;i<s.length;i++){
for(var j=i+1;j<s.length;j++){
   if(s[i]==s[j]){
      s[i]="";
      s[j]="";
      break;
   }
}
}
var n=s.join("").length;
if(n==0 || n==1)console.log(0);
else if(n%2==0)console.log(n/2);
else console.log((n-1)/2);


Measured memory_bytes: 15388
//<--sbhmsh-->//

#include <bits/stdc++.h>
#include <iostream>
#define FASTIO std::ios::sync_with_stdio(false);
using namespace std;
#define lli long long int
#define endl '\n'
#define deb cout<<"sab_badhiya"<<endl;
// const long long INF = 1000 * 1000 * 1000 * 1ll * 1000 * 1000 * 1000;
const long INF = 1000 * 1000 * 1000;
const long long int mod = 1000000007;
vector<int>g[100005];
bool vis[100005];
int dp[100005]={0};
int dfs (int v, int len) {
  vis[v] = true;
  int w, m = len;
  for (int i = 0; i < g[v].size(); i++) {
    w = g[v][i];
    if (!vis[w]) {
      m = max(dfs(w, 0), m);
    }
    else {
      m = max(m, dp[w] + 1);
    }
  }
  dp[v] = m;
  return m + 1;
}
int main() {
  FASTIO
  int n, m, x, y;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    g[x].push_back(y);
  }
  memset(vis, false, sizeof(vis));
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      ans = max(ans, dfs(i, 0) - 1);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 8320
import sys
import numpy as np

DList = []
N, D = map(int,sys.stdin.readline().split())
for i in range(N):
  DList.append(list(map(int,sys.stdin.readline().split())))
DList = np.array(DList);

counter=0
for i in range(N):
  for j in range(N):
    if i < j:
      dis = np.linalg.norm(DList[i] - DList[j])
      if dis.is_integer():
        counter+=1
print(counter)


Measured memory_bytes: 14428
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s, t;
    cin >> s >> t;
    char cs[1000], ct[1000];
    for(int i=0; i<s.size(); i++){
        cs[i] = s[i];
    }
    for(int i=0; i<t.size(); i++){
        ct[i] = t[i];
    }
    sort(cs, cs+s.size());
    sort(ct, ct+t.size(), std::greater<>());
    string str1(cs, s.size());
    string str2(ct, t.size());
    if(str1<str2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def check(dt, dl):
    if dt < dl:
        return False
    left = dt - dl
    return left % 2 == 0

N = int(input())
t, x, y = 0, 0, 0
for n in range(N):
    ti, xi, yi = map(int, input().split())
    dt = ti - t
    dx = xi - x
    dy = yi - y

    if not check(dt, abs(dx) + abs(dy)):
        print('No')
        exit(0)

    t, x, y = ti, xi, yi
print('Yes')


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

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,k;
    cin>>n>>k;
    vector<ll> a(n);
    for(int i=0;i<n;++i) cin>>a[i];
    sort(a.rbegin(),a.rend());
    ll ans = 0;
    for(int i=k;i<n;++i)
    {
        ans+=a[i];
    }
    cout<<ans;
}


Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
  const int MAXP = 999983;
  vector<bool> is_prime(MAXP + 1, true);
  is_prime[0] = is_prime[1] = false;
  for(int i = 2; i * i <= MAXP; i++)if(is_prime[i]){
    for(int j = i * i; j <= MAXP; j += i){
      is_prime[j] = false;
    }
  }
  vector<int> acc(MAXP + 1, 0);
  for(int i = 1; i <= MAXP; i++){
    acc[i] = acc[i - 1] + (is_prime[i] ? 1 : 0);
  }
  int N;
  while(cin >> N && N != 0){
    int ans = 0;
    REP(i, N){
      int p, m; cin >> p >> m;
      int left = max(p - m, 1);
      int right = min(p + m, MAXP);
      int cnt = acc[right] - acc[left - 1];
      ans += cnt - 1;
    }
    if(ans < 0) ans = 0;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 5164
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}
int exp(int a, int b){
    LL res = 1;
    LL sum = a;
    while(b){
        if(b&1)res = (res * sum)%MOD;
        sum = (sum * sum) % MOD;
        b >>= 1;
    }
    return res;
}

int main(){
    string L;
    cin >> L;
    LL ans = 0;
    LL nc = 1;
    REP(i, L.size()){
        if(L[i]=='1'){
            ans = (ans + nc * exp(3, L.size() - i - 1)) % MOD;
            nc = (nc * 2) % MOD;
        }
    }
    ans = (ans + nc) %MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

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

        int n = sc.nextInt();
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        int ans = 0;

        for (int i = 0; i < n; i++) {
            //System.out.println("今のans:" + ans + "\n今のi:" + i);

            if (a.charAt(i) != b.charAt(i) && b.charAt(i) != c.charAt(i) && c.charAt(i) != a.charAt(i)) {
                ans += 2;
            } else if (a.charAt(i) == b.charAt(i) && b.charAt(i) == c.charAt(i) && c.charAt(i) == b.charAt(i)) {
                ans += 0;
            } else {
                ans += 1;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
int main() {
	double d; cin >> d;
	double out = 0;
	if (d >= 1)out = (double)(1 + (int)d);
	out = max(out, sqrt(2)*d);
	cout << fixed << setprecision(10) << out << endl;
	return 0;
}



Measured memory_bytes: 3268
thismonth = Hash.new( 0 )
lastmonth = Hash.new( 0 )

while line = $stdin.gets
	if line.chomp.size == 0 
		break
	end
	data = line.chomp.split(/,/).map{ |n| n.to_i }

	if thismonth[data[ 0 ]] == 0
		thismonth[data[ 0 ]] = 1
	else
		thismonth[data[ 0 ]] += 1
	end
end

while line = $stdin.gets
	data = line.chomp.split(/,/).map{ |n| n.to_i }
	if lastmonth[data[ 0 ]] == 0
		lastmonth[data[ 0 ]] = 1
	else
		lastmonth[data[ 0 ]] += 1
	end
end

thismonth.sort{ |(k1,v1),(k2,v2) | k1 <=> k2 }.each{|key,value|
	if lastmonth.key?( key )
		printf( "%d %d\n", key, value + lastmonth[ key ] )
	end
}


Measured memory_bytes: 6124
s = int(input())
array = []
array.append(s)
m = 1

def f(s):
    if s % 2 == 0:
        return s//2
    else:
        return 3*s + 1

while (f(s) in array) == False:
    array.append(f(s))
    s = f(s)
    m += 1

print(m+1)

Measured memory_bytes: 3188
#include<iostream>

using namespace std;

int data[6];
int next[6];
int sum;

void init(){
  data[0] = 4;
  data[1] = 1;
  data[2] = 3;
  data[3] = 6;
  data[4] = 2;
  data[5] = 5;
  sum = 1;
}

void copy(){
  for(int i = 0; i < 6; i++) next[i] = data[i];
}

void N(int num){
  for(int i = 0; i < num; i++){
    copy();
    data[1] = next[4];
    data[3] = next[5];
    data[4] = next[3];
    data[5] = next[1];
  }
}

void W(int num){
  for(int i = 0; i < num; i++){
    copy();
    data[0] = next[1];
    data[1] = next[2];
    data[2] = next[3];
    data[3] = next[0];
  }
}

void R(int num){
  for(int i = 0; i < num; i++){
    copy();
    data[0] = next[4];
    data[2] = next[5];
    data[4] = next[2];
    data[5] = next[0];
  }
}

void move(string in){
  if(in == "North") N(1);
  if(in == "South") N(3);
  if(in == "West") W(1);
  if(in == "East") W(3);
  if(in == "Right") R(1);
  if(in == "Left") R(3);
}

int main(){

  int in;
  while(cin >> in && in){
    init();
    for(int i = 0; i < in; i++){
      string str;
      cin >> str;
      move(str);
      sum += data[1];
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;
const ll INF = 100100100100100100;

ll H,W,N;
ll x,y;
vector<P> a,b,c,d;
vector<ll> q;
vector<ll> mem;
ll cnt[100100];
bool aaa[100100];
int main(){
  cin >> H >> W >> N;
  rep(i,N*2){
    cin >> y >> x;
    if(y == 0){
      a.push_back(make_pair(x,i/2));
    }
    else if(x == W){
      b.push_back(make_pair(y,i/2));
    }
    else if(y == H){
      c.push_back(make_pair(-x,i/2));
    }
    else if(x == 0){
      d.push_back(make_pair(-y,i/2));
    }
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  sort(d.begin(),d.end());
  rep(i,a.size()){
    cerr << a[i].second << " ";
    q.push_back(a[i].second);
  }
  cerr << endl;
  rep(i,b.size()){
    cerr << b[i].second << " ";
    q.push_back(b[i].second);
  }
  cerr << endl;
  rep(i,c.size()){
    cerr << c[i].second << " ";
    q.push_back(c[i].second);
  }
  cerr << endl;
  rep(i,d.size()){
    cerr << d[i].second << " ";
    q.push_back(d[i].second);
  }
  cerr << endl;
  rep(i,q.size()){
    cerr << q[i] << " ";
    cnt[q[i]]++;
  }
  cerr << endl;
  ll now_p = -1;
  rep(i,q.size()){
    ll tmp = q[i];
    if(cnt[tmp] == 1) continue;
    cerr << tmp << " ";
    if(now_p == -1){
      mem.push_back(tmp);
      now_p = 0;
      aaa[tmp] = true;
    }
    else{
      if(mem[now_p] == tmp){
        now_p--;
        mem.pop_back();
        aaa[tmp] = false;
      }
      else if(aaa[tmp]){
        cout << "NO" << endl;
        return 0;
      }
      else{
        now_p++;
        mem.push_back(tmp);
        aaa[tmp] = true;
      }
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 8112
//Copyright(c)2017 Mstdream
#include<bits/stdc++.h>
using namespace std;

inline void splay(int &v){
	v=0;char c=0;int p=1;
	while(c<'0' || c>'9'){if(c=='-')p=-1;c=getchar();}
	while(c>='0' && c<='9'){v=(v<<3)+(v<<1)+c-'0';c=getchar();}
	v*=p;
}
int n,p,f[5];
long long ans,a,b;
long long C[55][55];
int main(){
	cin>>n>>p;
	for(int i=1;i<=n;i++){
		int x;splay(x);
		f[x&1]++;
	}
	C[0][0]=1;
	for(int i=1;i<=50;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++){
			C[i][j]=C[i-1][j]+C[i-1][j-1];
		}
	}
	if(p==0){
		for(int i=0;i<=f[0];i++)a+=C[f[0]][i];
		for(int i=0;i<=f[1];i+=2)b+=C[f[1]][i];
		ans=a*b;
	}
	else{
		for(int i=0;i<=f[0];i++)a+=C[f[0]][i];
		for(int i=1;i<=f[1];i+=2)b+=C[f[1]][i];
		ans=a*b;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "3 4", "...#", ".#..", "...." ].parse.expand.solve == 3 );
	assert( [ "5 2", "..", "#.", "..", ".#", ".." ].parse.expand.solve == 0 );
	assert( [ "5 5", "..#..", ".....", "#...#", ".....", "..#.." ].parse.expand.solve == 24 );
	assert( [
		"20 20",
		"....................",
		"....................",
		"....................",
		"....................",
		"....................",
		"....................",
		"....................",
		"....................",
		"....................",
		"....................",
		"....................",
		"....................",
		"....................",
		"....................",
		"....................",
		"....................",
		"....................",
		"....................",
		"....................",
		"...................." ].parse.expand.solve == 345263555 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto hw = input.front.split.to!( long[] );
	auto ass = new string[]( hw[ 0 ] );
	foreach( ref as; ass )
	{
		input.popFront;
		as = input.front;
	}
	return tuple( ass );
}

auto solve( string[] ass )
{
	const MOD = 10L ^^ 9 + 7;
	auto dp = new long[][]( ass.length, ass[ 0 ].length );
	
	dp[ 0 ][ 0 ] = 1;
	for( auto y = 0L; y < ass.length; y++ )
	{
		for( auto x = 0L; x < ass[ y ].length; x++ )
		{
			if( y + 1 < ass.length && ass[ y + 1 ][ x ] == '.' )
			{
				dp[ y + 1 ][ x ] = dp[ y ][ x ];
			}
			if( x + 1 < ass[ y ].length && ass[ y ][ x + 1 ] == '.' )
			{
				dp[ y ][ x + 1 ] = ( dp[ y ][ x ] + dp[ y ][ x + 1 ] ) % MOD;
			}
		}
	}
	
	return dp[ $ - 1 ][ $ - 1 ];
}


Measured memory_bytes: 10748
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define MP make_pair
#define ull unsigned long long int
#define F first
#define S second
#define put insert
#define pb push_back
#define rsortV(arr) sort(arr.begin(),arr.end(),greater<int>())
#define sortV(arr) sort(arr.begin(),arr.end())
#define sortA(arr,n) sort(arr,arr+n)
#define rsortA(arr,n) sort(arr,arr+n,greater<int>())
#define arrInput(arr,n) for(int i=0;i<n;i++) cin>>arr[i];
#define rev(arr) reverse(arr.begin(), arr.end())
#define all(x) (x).begin(), (x).end()
ll MOD = 1e9+7;
int main() {
    fastio
    // int t;
    // cin>>t;
    // while(t--) {
    string s;
    cin>>s;
    if(s[s.size()-1] != 's')
        s += "s";
    else
        s += "es";
    cout<<s;
    // }
    return 0;
}


Measured memory_bytes: 3660
import java.util.HashSet;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		HashSet<Integer>set = new HashSet<Integer>();
		
		int n = sc.nextInt();
		
		for(int i = 0 ; i < n ;i++) {
			int a = sc.nextInt();
			set.add(a);
		}
		
		int s = set.size();
		if(s % 2 == 1) {
			System.out.println(s);
		}
		else {
			System.out.println(s-1);
		}
		
	}

}


Measured memory_bytes: 61716
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    N = input(int)
    P = input([int, N])
    min_, count = P[0], 1
    for p in P[1:]:
        if p < min_:
            count += 1
            min_ = p
    print(count)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


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

int main() {
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  ll diff = v - w;
  if (diff <= 0) {
    puts("NO");
    return 0;
  }

  if (abs(a - b) <= t * diff) {
    puts("YES");
    return 0;
  }

  puts("NO");
  return 0;
}


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

#if DEBUG && !ONLINE_JUDGE
  #include "header.h"
#else
  #define debug(args...)
#endif

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long lli;
typedef long double ld;

#define pb push_back
#define all(x) x.begin(),x.end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(auto i=(a);i<b;i++)

#define INF (int)1e9
#define EPS 1e-9
#define MOD 1000000007
void preprocess(void) {
  return;
}

vi aa[1001];

lli dp[1001][(1<<12)];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  preprocess();
  int n, m; cin>>n>>m;
  vi c(m);
  vi b(m);
  rep(i,0,m) {
    int a, bb; cin>>a>>bb;
    c[i] = a;
    rep(j,0,bb) {
      int x; cin>>x;
      x--;
      aa[i].pb(x);
    }
    sort(all(aa[i]));
    int f = 0;
    rep(j,0,bb) {
      f = f | (1<<aa[i][j]);
    }
    b[i] = f;
  }
  rep(i,0,m) {
    rep(j,0,(1<<12)) dp[i][j] = MOD;
  }
  debug(b);
  dp[0][0] = 0;
  dp[0][b[0]] = c[0];
  rep(i,0,m) dp[i][0] = 0;
  rep(i,1,m) {
    rep(mask,0,(1<<n)) {
      dp[i][mask | b[i]] = min(dp[i][mask|b[i]], dp[i-1][mask] + c[i]);
      dp[i][mask] = min(dp[i][mask], dp[i-1][mask]);
    }
  }
  if(dp[m-1][(1<<n)-1] == MOD) cout<<-1<<endl;
  else
  cout<<dp[m-1][(1<<n)-1]<<endl;

}



Measured memory_bytes: 32384
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int a, b;
    std::cin>>a>>b;

    std::cout<<((b - a) * (b - a + 1) / 2 - b)<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
const ll MOD = 998244353;

int N;
string s;
int nv[3];

ll gogo()
{
    for (int i = 0; i < 3; i++)
    {
        nv[i] = 0;
    }

    ll ans = 1;
    int chi = 0, clo = 0;
    for (int i = 0; i < N; i++)
    {
        int ctype = 0;
        if (s[i] == 'R') ctype = 1;
        else if (s[i] == 'G') ctype = 2;

        nv[ctype]++;
        if (nv[ctype] > chi)
        {
            chi = nv[ctype];
            continue;
        }
        int nlo = 1e9;
        for (int j = 0; j < 3; j++)
        {
            nlo = min (nlo, nv[j]);
        }
        if (nlo > clo)
        {
            clo = nlo;
            continue;
        }

        ans *= (chi - nv[ctype] + 1);
        ans %= MOD;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(0);
    
    cin >> N;
    cin >> s;
    N *= 3;

    ll fv = gogo();
    for (int i = 0; i * 2 < N - 1; i++)
        swap (s[i], s[N-1-i]);
    ll rv = gogo();

    ll vfac = 1;
    for (int i = 1; i <= N / 3; i++)
    {
        vfac = (vfac * i) % MOD;
    }

    ll ans = (((fv * rv) % MOD) * vfac) % MOD;
    cout << ans << "\n";
}

Measured memory_bytes: 720
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r,g;
  cin>>r>>g;
  cout<<g+(g-r)<<'\n';
  return(0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    for (int i = sqrt(N); i >= 1; i--) {
        if (N % i == 0) {
            cout << N / i + i - 2 << endl;
            return 0;
        }
    }
    return 0;
}

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

int main( void )
{
    int n,m;
    cin >> n >> m;
    
    int ans = (n - 1) * (m - 1);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
	int i,n;
	string s;
	cin >> n >> s;
	int a,b,ans,c[n],d,e;
	a = 0;
	b = 0;
	d = 0;
	e = 0;
	for(i=0;i<n;i++){
		c[i] = 0;
	}
	for(i=0;i<n;i++){
		if(s[i]=='E'){
			a += 1;
		}else{
			b += 1;
	}
	}
	
	for(i=0;i<n;i++){
		if(s[i]=='W'){
			c[i] = e + a - d ;
		}else{
			c[i] = e + a - d -1;
		}
		if(s[i]=='E'){
			d += 1;
		}else{
			e += 1;
		}
	}
	ans = n;
	for(i=0;i<n;i++){
		ans = min(c[i],ans);
	}
	cout << ans << endl;		
}

Measured memory_bytes: 1796
#include<stdio.h>

long factorial(int n)
{
    if(n==1)
        return 1;
    else
        return(n*factorial(n-1));
}

int main()
{
    int n;
    long f;


    while(scanf("%d",&n)==1)
    {
        if(n<=0)
            printf("no factorial\n");
        else

        {
            f=factorial(n);
            printf("%ld\n",f);
        }
    }
    return 0;

}

Measured memory_bytes: 1016
#include<iostream>
#include<cstdio>
#include<algorithm>
#define reg register
#define ios ios::sync_with_stdio(false)
using namespace std;
int main() 
{
	ios;string s;cin>>s;
	int l=s.length(),x=0,y=0,ans=0;
	for(reg int i=0;i<=l-1;i++)
	{
		if(x==y){x++;if(s[i]=='p')ans--;}
		else{y++;if(s[i]=='g')ans++;}
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 512
sa = list(input())[::-1]
sb = list(input())[::-1]
sc = list(input())[::-1]

# A からスタート
p = sa.pop()
while len(sa) > -1 and len(sb) > -1 and len(sc) > -1:
    if p == 'a':
        if len(sa) == 0:
            print('A')
            exit()
        p = sa.pop()
    elif p == 'b':
        if len(sb) == 0:
            print('B')
            exit()
        p = sb.pop()
    elif p == 'c':
        if len(sc) == 0:
            print('C')
            exit()
        p = sc.pop()

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

int main(){
    int n;
    int ans=0;
    cin >> n;
    vector<int>x(n);
    rep(i,n) cin >> x[i];
    sort(x.begin(),x.end());
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int ab=x[i]+x[j];
            int r=lower_bound(x.begin(),x.end(),ab)-x.begin();
            int l=j+1;
            ans +=max(0,r-l);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int k, n;
	std::cin >> k >> n;
	
	std::vector<int> v(n);
	for (auto&& e : v)
		std::cin >> e;

	v.push_back(k + v.front());

	int ans = 100000000;
	for (int i = 0; i < n; ++i)
		ans = std::min(ans, k - (v[i + 1] - v[i]));

	std::cout << ans << std::endl;
}


Measured memory_bytes: 1792
S = input()
N = len(S)

# isparin
for x, y in zip(S, S[::-1]):
    if x != y:
        print("No")
        exit()

L = S[: (N - 1) // 2]
R = S[-(N - 1) // 2:]


for x, y in zip(R, R[::-1]):
    if x != y:
        print("No")
        exit()
for x, y in zip(L, L[::-1]):
    if x != y:
        print("No")
        exit()
print("Yes")


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    int X[2];
    cin >> X[0] >> X[1];
    ll ans = 0;
    REP(i,2){
        ll x = X[i];
        if(x == 1)
            ans += 300000;
        else if(x == 2)
            ans += 200000;
        else if(x == 3)
            ans += 100000;
    }

    if(X[0] == 1 && X[1] == 1)
        ans += 400000;

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


Measured memory_bytes: 256
from collections import deque
k = int(input())
lunlun = deque([i for i in range(9, 0, -1)])
for i in range(k):
    x = lunlun.pop()
    if i == k - 1:
        print(x)
    next_lunlun = 10*x + (x % 10)
    if x % 10 != 0:
        lunlun.appendleft(next_lunlun - 1)
    lunlun.appendleft(next_lunlun)
    if x % 10 != 9:
        lunlun.appendleft(next_lunlun + 1)

Measured memory_bytes: 11976
#include <iostream>
using namespace std;
#define MXN 3005
long double dp[MXN][MXN], p[MXN];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int N; cin>>N;
	for(int i=1; i<=N; i++) cin>>p[i];

	dp[0][0] = 1.0;
	for(int i=1; i<=N; i++)
		for(int j=0; j<=i; j++)
		{
			if(!j) dp[i][j] = (1.0-p[i])*dp[i-1][j];
			else dp[i][j] = p[i]*dp[i-1][j-1]+(1.0-p[i])*dp[i-1][j];
		}

	long double ret = 0.0;
	for(int i=(N/2+1); i<=N; i++)
		ret+=dp[N][i];
	cout.precision(11);
	cout<< fixed << ret << '\n';

	return 0;
}

Measured memory_bytes: 139392
#include<iostream>
#include<cstdio>
#include<vector>
#include<numeric>

using namespace std;

constexpr int MX = 10000;

int group[MX];

int FindRoot(int x){
    return x == group[x] ? x : group[x] = FindRoot(group[x]);
}

void Unite(int x, int y){
    int g1 = FindRoot(x);
    int g2 = FindRoot(y);
    if(g1 == g2) return;
    
    group[g1] = g2;
}

int main(){
    int n, q;
    scanf("%d%d",&n,&q);
    
    for(int i=0; i<n; i++)group[i] = i;

    for(int i=0; i<q; i++){
        int c, x, y;
        scanf("%d%d%d",&c,&x,&y);

        if(c == 0){
            Unite(x, y);
        }else if (c == 1){
            int g1 = FindRoot(x);
            int g2 = FindRoot(y);
            int ret = (g1 == g2) ? 1 : 0;
            cout << ret << endl;
        }
    }
}


Measured memory_bytes: 3300
import java.awt.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.*;

public class Main {
    static Map<Long,Integer> map;
    public static void main(String[] args) throws Exception {
        FastReader sc = new FastReader();
        long n=sc.nextLong();
        map=new HashMap<>();
        f(n);
        long ans=0;
        for (Map.Entry<Long,Integer> e:map.entrySet()){
            int f=e.getValue();
            int c=0;
            boolean ok=true;
            while (f>0){
                c++;
                f-=c;
                if (f<0)ok=false;
            }
            ans+=c;
            if (!ok)ans--;
        }
        System.out.println(ans);

    }

    static void f(long a){
        for (long i=2;i*i<=a;i++){
            while (a%i==0){
                map.put(i,map.getOrDefault(i,0)+1);
                a/=i;
            }
        }
        if (a>1)map.put(a,map.getOrDefault(a,0)+1);
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 25724
#include <algorithm>
#include <chrono>
#include <iostream>
#include <random>
#include <vector>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, x, t;
  cin >> n >> x >> t;
  int cur = 0;
  int res = 0;
  while (cur < n) {
    cur += x;
    res += t;
  }

  cout << res;
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int k;
  cin >> k;
  bool result=false;
  rep(i,k){
    b=b*pow(2,i);
    c=c*pow(2,k-i);
    if(a<b&&b<c){
      result=true;
      cout <<"Yes" << endl;
      return 0;
    }
    b=b/pow(2,i);
    c=c/pow(2,k-i);
  }
  if(result==false){
    cout << "No" << endl;
  }
  
  
  
}



Measured memory_bytes: 4112
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define _USE_MATH_DEFINES
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const int MOD=1e9+7;
const double EPS=1e-9;

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


int main()
{
    int N; cin >> N;
    vb is_prime(N+1, true);

    is_prime[0] = is_prime[1] = false;
    for(int i = 1; i*i <= N; i++) {
        if(is_prime[i]) {
            for(int j = 2; i*j <= N; j++) {
                is_prime[i*j] = false;
            }
        }
    }

    vi ns(N+1);
    vi primes;
    rep(i,N+1) {
        ns[i] = i;
        if(is_prime[i])
            primes.pb(i);
    }
    vi cnt(primes.size(), 0);

    for(int i = 1; i <= N; i++) {
        int n = i;
        rep(j, primes.size()) {
            while(n % primes[j] == 0) {
                cnt[j]++;
                n /= primes[j];
            }
            if(n == 1)
                break;
        }
    }

    

    ll ans = 1;
    rep(i, primes.size())
        ans = ans * (cnt[i]+1) % MOD;

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


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){
  char S[1002];
  int x,y;
  
  y = scanf("%s",S);
  x = strlen(S);
  
  if(strcmp(&S[x-1],"s")==0){
    strcpy(&S[x],"e");
    strcpy(&S[x+1],"s");
  }
  else{
    strcpy(&S[x],"s");
  }
  
  printf("%s",S);
  return 0;
}

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


def value_evaluator(x:int)->bool:
    return x >= sum(a) / (4 * m)

flt_a = list(filter(value_evaluator, a))

if len(flt_a) >= m:
    print('Yes')
else:
    print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    long long n;
    cin>>n;
    double ab=100;
    int num=0;
    while(ab<n){
        ab=floor(ab*1.01);
    num++;
}
   cout<<num;
}


Measured memory_bytes: 3648
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#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 <ctime>
#include <cstring>
using namespace std;
int main(){
	int a[3];
	for(int i=0;i<3;i++)
	cin>>a[i];
	int ans=1e9+5;
	for(int i=0;i<3;i++)
	for(int j=0;j<3;j++){
		if(i==j)continue;
		int tmp=abs(a[j]-a[i]);
		for(int k=0;k<3;k++){
			if(i==k||j==k)continue;
			tmp+=abs(a[k]-a[j]);
			ans=min(tmp,ans);
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(){
  char s;cin>>s;
  if(s=='A')cout<<"T"<<endl;
  if(s=='T')cout<<"A"<<endl;
  if(s=='G')cout<<"C"<<endl;
  if(s=='C')cout<<"G"<<endl;
}

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

int top = 0;
int S[105];


int pop()
{
	top--;
	return S[top];
}

void push(int a)
{
	S[top++]=a;
}

int main()
{
	char s[10];
	int a, b,c;

	while (scanf("%s",s,10)!=EOF)
	{
		if (s[0] == '+')
		{
			b = pop();
			a = pop();
			c = a + b;
			push(c);
		}
		else if (s[0] == '-')
		{
			b = pop();
			a = pop();
			c = a - b;
			push(c);
		}
		else if (s[0] == '*')
		{
			b = pop();
			a = pop();
			c = a * b;
			push(c);
		}
		else
			push(atoi(s));
	}
	printf("%d\n",pop());
	return 0;
}


Measured memory_bytes: 2692
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,x,y;
    cin >> n >> x >> y;

    cout << min(x,y) << " ";
    cout << (n-x-y > 0 ? 0 : abs(n-x-y)) << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int n,h[200005],val[200005];
map<int,ll> cnt;
ll ans=0;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>n;
	for(int i=1; i<=n; i++)
		cin>>h[i],val[i]=i+h[i];
	for(int i=n; i>=1; i--) {
		ans+=cnt[val[i]];
		if(i-h[i]<=0) continue;
		cnt[i-h[i]]++;
	}
	cout<<ans;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "APPROVED" << '\n'; exit(0); }
inline void no() { cout << "DENIED" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  vi32 a(n);
  cin >> a;
  rep(i, n) {
    if (a[i] % 2 == 0) {
      if (a[i] % 3 == 0 || a[i] % 5 == 0) continue;
      no();
    }
  }
  yes();
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define INF 1e9

int W,H;
int t_situ[20][20];
int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};
int x_start, y_start, Count;

void move(int x_standard, int y_standard){
  if(t_situ[y_standard][x_standard] == 2 && x_standard >=0 && x_standard < W
      && y_standard >=0 && y_standard < H){
    t_situ[y_standard][x_standard] = 1;
    Count++;
    REP(k,4) move(x_standard+dx[k], y_standard+dy[k]);
  }/*else if(t_situ[y_standard][x_standard] == 1 )
      REP(k,4) move(x_standard+dx[k]+dy[k], y_standard+dx[k]+dy[k]);*/
}

void solve(int X, int Y){
  Count = 0;
  char t_type[Y][X];
  REP(i,20) REP(j,20) t_situ[i][j] = 0;
  //0:red, 1:black&gone, 2:black&not_gone

  REP(i,Y){
    REP(j,X){
      cin>>t_type[i][j];
      switch (t_type[i][j]) {
        case '@':
            t_situ[i][j] = 2;
            x_start = j;
            y_start = i;
            break;
        case '.':
            t_situ[i][j] = 2;
            break;
        case '#':
            t_situ[i][j] = 0;
      }
    }
  }

  move(x_start, y_start);

  cout<<Count<<endl;
  /*REP(i,20){
    REP(j,20){
      cout<<t_situ[i][j];
    }
    cout<<endl;
  }*/
}

int main(){

  while(1) {
    cin>>W>>H;
    if(W == 0 && H == 0) break;
    solve(W,H);
  }

  return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int n, k;
	cin >> n >> k;
	map<int,int> m;
	for(int i = 0; i < k; i++){
		int x;
		cin >> x;
		m[x] = 1;
	}
	for(int i = n; i <= 1e7; i++){
		int cur = i;
		int flag = 0;
		while(cur){
			int d = cur % 10;
			cur /= 10;
			if(m.count(d))
				flag = 1;
		}
		if(flag == 0){
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}



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

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  if (s1[s1.size() - 1] == s2[0] && s2[s2.size() - 1] == s3[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256