akhauriyash/Code-Regression huggingface dataset:
S=input()

goal=[]
ans=[0]*len(S)
for i in range(len(S)-1):
    if S[i:i+2]=='RL':
        goal.append(i)

for i in goal:
    cnt=0
    for l in range(i,-1,-1):
        if S[l]=='R':
            if cnt%2==0:
                ans[i]+=1
            else:
                ans[i+1]+=1
            cnt+=1
        else:
            break
    
    cnt=0
    for r in range(i+1,len(S)):
        if S[r]=='L':
            if cnt%2==0:
                ans[i+1]+=1
            else:
                ans[i]+=1
            cnt+=1
        else:
            break

print(*ans)

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pipipii = pair<ll, pair<int, pii>>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    while(true){
        int n;
        cin >> n;
        if(!n) return 0;
        vector<string> s(n);
        vector<int> a(n);
        for(int i = 0; i < n; ++i){
            cin >> s[i];
            for(int j = 0; j < s[i].size(); ++j){
                a[i] += s[i][j] == '.';
            }
            if(s[i][a[i]-1] == '.') s[i][a[i]-1] = '+';
        }
        for(int i = 0; i < n; ++i){
            for(int j = i+1; j < n; ++j){
                if(a[i] == a[j]){
                    for(int k = i+1; k < j; ++k){
                        s[k][a[i]-1] = '|';
                    }
                    break;
                }
                else if(a[i] > a[j]) break;
            }
        }
        for(int i = 0; i < n; ++i){
            for(int j = 0; j < s[i].size(); ++j){
                if(s[i][j] == '.') s[i][j] = ' ';
            }
        }
        for(int i = 0; i < n; ++i){
            cout << s[i] << "\n";
        }
    }
    return 0;
}


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

using ll = long long;
using P = pair<int, int>;

int main()
{
    char ch;
    ll sum = 0;
    while (cin >> ch)
    {
        // cout << ch << endl;
        sum += atoi(&ch);
    }
    // cout << sum << endl;
    if (sum % 9 == 0)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
using namespace std;

int main()
{
    int N;
    cin >> N;
    long long ans = 0;
    REP (i, N) {
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;
ll mod=1000000007;

int main() {
    int N;
    cin >> N;
    string s1, s2;
    cin >> s1 >> s2;
    ll ans=1;
    vector<char> tile;
    if(N==1) cout << 3 << endl;
    else{
        for(int i=0; i<N-1; i++){
            if(s1[i]==s1[i+1]){
                tile.push_back('-');
                i++;
                if(i==N-2) tile.push_back('1');
            }else{
                tile.push_back('1');
                if(i==N-2) tile.push_back('1');
            }
        }
        

        if(tile[0]=='1'){
            ans=3;
        }else{
            ans=6;
        }
        for(int i=1; i<tile.size(); i++){
            if(tile[i-1]=='-' && tile[i]=='1') continue;
            else if(tile[i-1]=='-' && tile[i]=='-'){
                ans*=3;
                ans%=mod;
            }else{
                ans*=2;
                ans%=mod;
            }
        }
        cout << ans%mod << endl;
    }
 
    return 0;
}


Measured memory_bytes: 256
S = str(input(''))
if S == 'SUN' :
     print (7)
elif S == 'MON' :
     print (6)
elif S == 'TUE' :
     print (5)   
elif S == 'WED' :
     print (4)
elif S == 'THU' :
     print (3)
elif S == 'FRI' :
     print (2)
else :
     print (1) 



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

minimum = []
maximum = []
for i in range(n):
    a, b = list(map(int, input().split()))

    minimum.append(a)
    maximum.append(b)

# 奇数の場合は？

minimum.sort()
maximum.sort()

if n % 2 == 1:
    print(maximum[(n+1)//2 - 1]- minimum[(n+1)//2 - 1] + 1)
else:
    upper = maximum[n//2-1] + maximum[n//2]
    lower = minimum[n//2-1] + minimum[n//2]
    print(upper - lower + 1)



Measured memory_bytes: 25580
#include<iostream>
#include<algorithm>
using namespace std;
 
 
int main(){
	int n;
	int a[100100];
	int b[100100];
	int sum = 0;
 
	cin>>n;
 
	for(int i=1; i <= n; i++) cin>>a[i];

	a[0] = a[n+1] = 0; 
 
	for(int i = 1; i <= n; i++){
		b[i] = abs(a[i-1] - a[i+1]) - abs(a[i] - a[i-1]) - abs(a[i+1] - a[i]);
		sum += abs(a[i-1] - a[i]);
	}

	sum += abs(a[n]);

	for(int i=1; i <= n;i++){
		cout<<sum + b[i]<<"\n";
	}
}


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

int main(){
    vector<int> vec(4); 
    for (int i = 0; i < 4; i++) {
        cin >> vec.at(i);
    }
    if(vec.at(3)<=vec.at(0) || vec.at(1)<=vec.at(2))
        cout << 0 << endl;
    else{
        sort(vec.begin(), vec.end());
        cout << abs(vec.at(1)-vec.at(2)) << endl;
    }
  return 0;
}

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

    int n;
    while(cin>>n,n){
        int b=0;
        for(int i=0;i<n/4;i++){
            int a;
            cin>>a;
            b+=a;
        }
        cout<<b<<endl;
    }

    return 0;
}

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

int main(){
    char a[3];
    cin>>a;
    for(int i=0;i<3;i++) {
        if (a[i] == '1') a[i] = '9';
        else a[i] = '1';
        cout<<a[i];
    }
    cout<<endl;
}

Measured memory_bytes: 256
#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++)

int main(){
    string S;
    cin >> S;
    int N = S.length();
    int X, Y;
    cin >> X >> Y;

    bool tate = false;
    vector<int> x;
    vector<int> y;
    int stock = 0;
    for(int i = 0; i < N; i++){
        char c = S[i];
        if(c == 'F') stock++;
        if(c == 'T' || i == N-1){
            if(tate) y.push_back(stock);
            else x.push_back(stock);
            tate = !tate;
            stock = 0;
        }
    }

    int xx = 0;
    int yy = 0;
    xx += x[0];
    x.erase(x.begin());
    sort(x.begin(), x.end(), greater<int>());
    sort(y.begin(), y.end(), greater<int>());

    for(int i = 0; i < x.size(); i++){
        int step = x[i];
        if(xx < X) xx += step;
        else xx -= step;
    }

    for(int i = 0; i < y.size(); i++){
        int step = y[i];
        if(yy < Y) yy += step;
        else yy -= step;
    }
    //printf("(%d, %d)\n", xx, yy);

    bool ans;
    if(X == xx && Y == yy) ans = true;
    else ans = false;

    if(ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static long print(long n){
        if(n<=1)
            return 1;
        else
            return(2*print(n/2)+1);
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long num = scan.nextLong();
        
        if(num <= 1){
            System.out.println(1);
        }else{
            System.out.println(print(num));
        }
    }

}
/*
input : 1000000000000  // 4 // 2
output : 1099511627775 // 7 // 3


Caracal is fighting with a monster.

The health of the monster is 
H
.

Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:

->If the monster's health is 1,it drops to 0
->If the monster's health X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of 
X/2(flore value).(r) denotes the greatest integer not exceeding r.)

Caracal wins when the healths of all existing monsters become 0 or below.

Find the minimum number of attacks Caracal needs to make before winning.

Constraints
1≤H≤10^12
All values in input are integers.
*/


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

#define ll long long
#define PB push_back
#define PII pair<int, int>
#define MP make_pair
#define all(x) x.begin(), x.end()
#define REP(x, y, z) for(int x = y; x <= z; x++)
#define REPP(x, y, z) for(int x = y; x >= z; x--)
#define F first
#define S second
#define MSET(x, y) memset(x, y, sizeof(x)) 
#define EB emplace_back
#define maxn


//structure

//declaration
ll lis[300005];
//functions

int main(void)
{
	#ifdef DBG
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
	#endif

	int n;
	scanf("%d\n", &n);


	ll mod = 1000000007;

	REP(i, 1, n)
		scanf("%lld", &lis[i]);

	ll ans = 0;
	ll odd, even;

	for(ll i = 0; i < 60; i++)
	{
		odd = even = 0;
		REP(j, 1, n)
		{	
			if(lis[j]&1LL<<i)
				odd++;
			else
				even++;
		}

		ans = (ans + (((odd*even)%mod)*((1LL<<i)%mod))%mod)%mod;
	}


	printf("%lld\n", (ll)(ans%mod));

	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int ans[100000];
int visit[100000];
int main(void){
	int N;
	cin >> N;
	vector<vector<int>> to(N),cost(N);
	for(int i=0;i<N-1;i++){
		int u,v,w;
		cin >> u >> v >> w;
		u--;
		v--;
		to[u].push_back(v);
		to[v].push_back(u);
		cost[u].push_back(w);
		cost[v].push_back(w);
	}
	ans[0]=0;
	visit[0]=1;
	queue<int> q;
	q.push(0);
	while(!q.empty()){
		int temp = q.front();
		q.pop();
		for(int i=0;i<to[temp].size();i++){
			int v = to[temp][i];
			if(visit[v]==1)continue;
			ans[v]= (ans[temp]+cost[temp][i])%2;
			visit[v]=1;
			q.push(v);
		}
	}
	for(int i=0;i<N;i++)cout << ans[i] << endl;
}

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

int main(void){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    
    if((x-r<0)||(x+r>W)||(y-r<0)||(y+r>H)){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a[5], k;
  for(int i=0; i<5; i++) cin >> a[i];
  cin >> k;
  for(int i=0; i<5; i++) {
    for(int j=i+1; j<5; j++) {
        if(abs(a[i]-a[j])>k) {
          cout << ":(" << endl;
          return 0;
        }
     }
 }
  cout << "Yay!" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
long long x, an;
int main()
{
	cin >> x;
	if (x % 11 <= 6) {
		if (x % 11 == 0) {
			cout << (x / 11) * 2;
		}
		else {
			cout << (x / 11) * 2 + 1;
		}
	}
	else {
		cout << (x / 11 + 1) * 2;
	}
}

Measured memory_bytes: 256
def solve(N):
    k = 0
    rng = 0
    for i in range(54):
        if cl[i] < N <= cl[i+1]:
            k = i + 2
            rng2 = cl[i]
            rng = cl[i+1] - cl[i]
    # print(k)
    posrng = (N-rng2)%(rng//9)
    perrng = (N-rng2)//(rng//9)+1
    if posrng == 0:
        posrng = rng//9
        perrng -= 1
    ans = [perrng]
    for i in range(k-1):
        if i == k-2:
            tmp = [0 if j == perrng else 1 for j in range(10)]
        else:
            tmp = [(cl[k-i-2]-cl[k-i-3])//9 if j == perrng else 2**(k-i-2) for j in range(10)]
        if posrng <= tmp[0]:
            ans.append(0)
            # posrng = posrng
        for j in range(1, 10):
            tmp[j] += tmp[j-1]
            if tmp[j-1] < posrng <=tmp[j]:
                ans.append(j)
                posrng -= tmp[j-1]
        if max(ans) != min(ans):
            break
    for i in range(k-len(ans), 0, -1):
        if posrng <= 2**(i-1):
            ans.append(min(ans))
        else:
            ans.append(max(ans))
            posrng -= 2**(i-1)
    print(''.join(map(str, ans)))

cl = [sum([9*2**j for j in range(i)])*9 for i in range(55)]
for i in range(1, 55):
    cl[i] += cl[i-1]
while True:
    N = int(input())
    if N == 0:
        break
    solve(N)


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

struct PartiallyPersistentArray {
	std::vector<std::vector<std::pair<int, int> > > data;
	int time = 0;
	PartiallyPersistentArray (int n) : data(n, {{0, 0}}) {}
	void go_time() { time++; }
	void assign(int i, int val) {
		if (data[i].size() && data[i].back().first == time) {
			data[i].back().second = val;
		} else data[i].push_back({time, val});
	}
	int get(int i, int time) {
		auto itr = std::upper_bound(data[i].begin(), data[i].end(), std::pair<int, int>{time, 1000000000});
		return std::prev(itr)->second;
	}
	void swap(int i, int j) {
		int tmp = get(i, time);
		assign(i, get(j, time));
		assign(j, tmp);
	}
};

int main() {
	int n = ri(), k = ri(), q = ri();
	PartiallyPersistentArray a(n), b(n);
	for (int i = 0; i < n; i++) a.assign(i, i), b.assign(i, i);
	for (int i = 0; i < k; i++) {
		a.go_time();
		b.go_time();
		int x = ri() - 1;
		int y = ri() - 1;
		b.swap(a.get(x, a.time), a.get(y, a.time));
		a.swap(x, y);
	}
	for (int i = 0; i < q; i++) {
		int type = ri();
		int l = ri() - 1;
		int r = ri();
		int x = ri() - 1;
		if (type == 1) {
			std::cout << b.get(a.get(x, r), l) + 1 << std::endl;
		} else {
			std::cout << b.get(a.get(x, l), r) + 1 << std::endl;
		}
	}
	return 0;
}



Measured memory_bytes: 18144
import java.util.*;
import java.io.*;

public class Main
{
  	int cnt, max = 0, at = 0, l;
  	char[] s;
  	String set = "ATGC";
  
    Main(Scanner in, PrintWriter out)
    {
      s = in.next().toCharArray();
      l = s.length;
      while (at < l)
      {
        cnt = 0;
        while (at < l && set.contains(s[at]+""))
        {
          at++;
          cnt++;
        }
        max = Math.max(max, cnt);
        at++;
      }
      out.print(max);
    }
	
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		new	Main(in, out);
		out.close();
	} 
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

struct UnionFind{
    // par[i] parent. if i == par[i] i is root
    vector<ll> par;
    // sizes[i] sizeof tree i if i is root
    vector<ll> sizes;

    UnionFind(ll n) : par(n), sizes(n, 1){
        // init: all node is root i
        rep(i, n) par[i] = i;
    }

    // find root of x
    ll find(ll x){
        if (x == par[x])
            return x;
        return par[x] = find(par[x]); // recursive, editing root
    }

    // merge x, y
    void unite(ll x, ll y){
        // root
        x = find(x);
        y = find(y);

        // do not merge if same tree
        if (x == y)
            return;

        // force size x > y
        if (sizes[x] < sizes[y])
            swap(x, y);

        // unite: x is parent of y
        par[y] = x;
        sizes[x] += sizes[y];
    }

    // x, y same root
    bool same(ll x, ll y){
        return find(x) == find(y);
    }

    // size of tree containing x
    ll size(ll x){
        return sizes[find(x)];
    }
};

vll a;
vll b;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, k, l;
    cin >> n >> k >> l;
    UnionFind uf1(n);
    UnionFind uf2(n);
    a.resize(n);
    b.resize(n);
    rep(i, k){
        ll p, q;
        cin >> p >> q;
        p--, q--;
        uf1.unite(p, q);
    }
    rep(i, l){
        ll r, s;
        cin >> r >> s;
        r--, s--;
        uf2.unite(r, s);
    }
    rep(i, n){
        a[i] = uf1.find(i);
        b[i] = uf2.find(i);
    }
    map<pll, ll> ans;
    rep(i, n){
        ans[make_pair(a[i], b[i])]++;
    }
    rep(i, n){
        cout << ans[make_pair(a[i], b[i])] << " \n"[i==n-1];
    }
    return 0;
}

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

using namespace std;

typedef unsigned long long ull;
#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

string b = "w kstnhmyr";
string c = "aiueo";

int main(){
    map<string, string> m;
    m["T"] = "a"; m["L"] = "i"; m["U"] = "u"; m["R"] = "e"; m["D"] = "o";
    string s, ans;
    cin >> s;
    for(int i=0; i< s.size(); i+=2){
        if(s[i] != '0' && s[i] != 1) ans+= b[stoi(s.substr(i, 1))] + m[s.substr(i+1, 1)];
        else if(s[i] == '0'){
            string t = s.substr(i, 2);
            if(t == "0T") ans += "wa";
            else if(t == "0U") ans += "nn";
            else ans += "wo";
        }
    }
    rep(i, ans.size()) if(ans[i] != ' ') cout << ans[i];
    cout << endl;
}

Measured memory_bytes: 1208
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int main(void) {
  int scan; // scanf result
  ll answer; // to output 
  ll a; // to input 
  ll b; // to input 
  ll c; // to input 
  ll k; // to input 

  scan = scanf("%lld", &a);
  scan = scanf("%lld", &b);
  scan = scanf("%lld", &c);
  scan = scanf("%lld", &k);
  
  if (a <= k) {
    if (a + b >= k) {
      answer = a;
    } else {
      answer = a - (k - (a + b));
    }
  } else {
    answer = k;
  }

  printf("%lld", answer);
  return (0);
}


Measured memory_bytes: 1700
import sys

while True:
    N = int(sys.stdin.readline().rstrip())
    if N == 0:
        break;
    max_value = 0
    prev_row = [0] * N
    for i in range(N):
        row = sys.stdin.readline().rstrip()
        curr_row = [0] * N
        for x,d in enumerate(row):
            if d == '.':
                if x == 0:
                    curr_row[x] = 1
                else:
                    curr_row[x] = min(prev_row[x-1], prev_row[x], curr_row[x-1]) + 1
        max_value = max(max(curr_row), max_value)
        prev_row = curr_row

    print(max_value)

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

long long n;//n人
/*
bool check(int i){
	if(n%i==0){
		return true;
	}else{
		return false;
	}
}
*/
int main(){
	scanf("%lld",&n);
	
	long long ri=int(sqrt(n));
	double ans=1;
	
	for(int i=1;i<=ri;i++){
		if(n%i==0)ans=i;
	}
	ans=n/ans;
	int ans2=0;
	while(ans>=1){
		ans=ans/10;
		ans2++;
	}
	printf("%d\n",ans2);
	/*
	while(le+1==ri){
	int cen=int((ri+le)/2);
		if(check(cen)){
			ri=cen;
		}else{
			le=cen;
		}
	}
	printf("%d",le);
	*/

}

Measured memory_bytes: 256
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;
public class Main {

	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		while (read()) {
			solve();
		}
	}
	
	static int a, b;
	static boolean read() {
		if (!sc.hasNextInt()) return false;
		a = sc.nextInt(); b = sc.nextInt();
		return true;
	}
	
	static void solve() {
		int sum = a + b, res = 0;
		while (sum > 0) {
			sum /= 10;
			res++;
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int n;
vector<pair<double,double>> p;
double f(double x,double y){
    double res=0.0;
    rep(i,n){
        double dx=x-p[i].fi;
        double dy=y-p[i].se;
        double dd=sqrt(dx*dx+dy*dy);
        chmax(res,dd);
    }
    return res;
}
double g(double x){
    double l=0,r=1000;
    int cnt=100;
    while(cnt--){
        double c1=(l*2+r)/3;
        double c2=(l+r*2)/3;
        if(f(x,c1)>f(x,c2)) l=c1;
        else r=c2;
    }
    return f(x,l);
}
int main(){
    cin>>n;
    p=vector<pair<double,double>>(n);
    rep(i,n) cin>>p[i].fi>>p[i].se;
    int cnt=100;
    double l=0,r=1000;
    while(cnt--){
        double c1=(l*2+r)/3;
        double c2=(l+r*2)/3;
        if(g(c1)>g(c2)) l=c1;
        else r=c2;
    }
    double ans=g(l);
    cout<<fixed<<setprecision(10);
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

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

    bool swaped = false;

    if (a > b){
        swaped = true;
        swap(a, b);
    }

    int n = 100;
    VVI ans(n, VI(n));

    a--;

    REP(i,24) REP(j,24){
        int x = 2 + 4 * i;
        int y = 2 + 4 * j;

        if (a > 0){
            FOR(xx,x-1,x+1) FOR(yy,y-1,y+1){
                if (xx != x || yy != y) ans[xx][yy] = 1;
            }
            a--;
        }else{
            ans[x][y] = 1;
        }

        b--;
        if (b == 0){
            i = 25;
            break;
        }
    }

    cout << "100 100" << endl;
    REP(i,n){
        REP(j,n) cout << ".#"[ans[i][j] ^ swaped];
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int n;
  
  scanf("%d",&n);
  
  if(n==22){
    printf("Christmas Eve Eve Eve\n");
  }else if(n==23){
    printf("Christmas Eve Eve\n");
  }else if(n==24){
    printf("Christmas Eve\n");
  }else if(n==25){
    printf("Christmas\n");
  }
  return 0;
}

Measured memory_bytes: 128
N, x = map(int, input().split())
a = sorted(map(int, input().split()))

result = 0
a_sum = 0
for i in range(N):
    if i == N - 1:
        result += a[i] == x
    elif x >= a[i]:
        x -= a[i]
        result += 1
    else:
        break
print(result)


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

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

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

  int q;
  cin >> q;

  vector<int> m(q);
  vector<string> answer(q);
  for (int i = 0; i < q; i++) {
    cin >> m[i];
    answer[i] = "no";
  }

  for(int bits = 1; bits < (1 << n); bits++) {

    vector<int> bit;

    for (int i = 0; i < n; i++) {
      if (bits >> i & 1) {
        bit.push_back(i);
      }
    }

    int sum = 0;

    for (int i = 0; i < bit.size(); i++) {
      sum += A[bit[i]];
    }

    for (int i = 0; i < q; i++) {
      if (m[i] == sum) {
        answer[i] = "yes";
      }
    }

  }

  for (int i = 0; i < q; i++) {
    cout << answer[i] << endl;
  }

  return 0;

}


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

int main() {
    const long long mod = 1e9+7;
    long long n, k;
    cin >> n >> k;
    long long sum = 0;
    for(long long i = k; i <= n+1; ++i) {
        long long minv = (i-1)*i / 2;
        long long maxv = (n-i+1+n)*i / 2;
        sum += maxv - minv + 1;
        sum %= mod;
    }
    cout << sum << endl;
    return 0;
}

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

#define ll long long
#define mx 100005

int main()
{
   int a,b;
   scanf("%d %d",&a,&b);

   int c=a+b,d=a-b,e=a*b;

   printf("%d\n",max({c,d,e}));


    return 0;
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

//===


const int INF = int(1e9 + 7);


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;
	vector<Vi> to(N);
	for (int i = 0; i < M; ++i) {
		int u, v;
		cin >> u >> v;
		--u, --v;
		to[u].push_back(v);
	}
	int S, T;
	cin >> S >> T;
	--S; --T;

	vector<array<int,3>> dist(N);
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 3; ++j) {
			dist[i][j] = INF;
		}
	}

	queue<Pii> q;
	q.emplace(S, 0);
	dist[S][0] = 0;
	while (!q.empty()) {
		int v = q.front().first;
		int l = q.front().second;
		q.pop();
		for (const auto& u : to[v]) {
			int nl = (l + 1) % 3;
			if (dist[u][nl] != INF) continue;
			dist[u][nl] = dist[v][l] + 1;
			q.emplace(u, nl);
		}
	}

	int ans = dist[T][0];
	if (ans == INF) ans = -1;
	else ans /= 3;
	cout << ans << endl;
}


Measured memory_bytes: 6912
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 998244353
 
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define MAX_N 4000010
#define MOD 998244353
#define int long long
int inv[MAX_N],fac[MAX_N],finv[MAX_N];

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

int comb(int a,int b)
{
    if(a < b){
        return 0;
    }
    return fac[a] * ((long long)finv[b] * finv[a-b] % MOD) % MOD;
}

signed main(){
    int n,m;
    cin >> n >> m;
    make();
    ll sm = comb(3*m+n-1,n-1);
    ll tmp = 0;
    for(int k = m+2;k<=3*m;k+=2){
        int p = (3*m-k)/2;
        //cerr << k << " " << p  << endl;
        tmp += comb(n,k) * comb(p+n-1,n-1)%mod;
        tmp %= mod;
        //cerr << tmp << endl;
    }
    for(int k=2*m+1;k<=3*m;k++){
        tmp += n*comb(3*m-k+n-2,n-2)%mod;
        tmp %= mod;
    }
    //cerr << sm << " " << tmp << endl;
    cout << (sm+mod-tmp)%mod << endl;

    return 0;
}

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


using namespace std;
double pi=3.14159265358979323846264338;
int sum;
int arr[200001];
vector<int>arr2[200001];
map<pair<int,int>,bool>ma;
void dfs(int a){
	//cout<<a<<" "<<sum<<endl;
	arr[a]++;
	sum++;
	//cout<<a<<" "<<arr2[a].size()<<endl;
	for(int b:arr2[a]){
		//cout<<a<<" "<<b<<" "<<arr[b]<<endl;
		if(arr[b])continue;
		dfs(b);
	}
}
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<200001;i++)arr[i]=0;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		if(a>b){
			int c=a;
			a=b;
			b=c;
		}
		if(ma.find(make_pair(a,b))==ma.end()){
			//arr[a]++;
			//arr[b]++;
			ma[make_pair(a,b)]=true;
			arr2[a].push_back(b);
			arr2[b].push_back(a);
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(arr[i]!=0)continue;
		sum=0;
		dfs(i);
		ans=max(ans,sum);
	}
		
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 34028
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

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

    bool flag= true;
    while(!(a<=0||c<=0)) {
        if(flag) {
            c -= b;
        } else {
            a -= d;            
        }
        flag = !flag;

    }

    print((a<=0) ? "No" : "Yes");
    return 0;
}


Measured memory_bytes: 3620
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        s: String,
    }

    let v = s
        .split('/')
        .into_iter()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<usize>>();
    if v[1] <= 4 {
        println!("Heisei");
    } else {
        println!("TBD");
    }
}


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

using namespace std;
const int N = 1e5 + 5;
int p[N] , w[N];
int n;
int f(int u){
    if(u == p[u])return u;
    return p[u] = f(p[u]);
}
void connect(int a , int b){
    a = f(a);
    b = f(b);
    if(a == b)return;
    if(w[a] < w[b])swap(a,b);
    w[a] += w[b];
    p[b] = a;
}

void init(){
    for(int i = 0 ; i < N ; i++)
        p[i] = i , w[i] = 1;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n;
    init();
    vector< pair<int,int> >vx,vy;
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        vx.push_back({x,i});
        vy.push_back({y,i});
    }
    sort(vx.begin(),vx.end());
    sort(vy.begin(),vy.end());
    vector<pair< int , pair<int,int> > >v;
    for(int i=1;i<vx.size();i++)
        v.push_back({vx[i].first-vx[i-1].first,{vx[i].second,vx[i-1].second}});

    for(int i=1;i<vy.size();i++)
        v.push_back({vy[i].first-vy[i-1].first,{vy[i].second,vy[i-1].second}});
    sort(v.begin(),v.end());
    long long ans=0;
    for(int i=0;i<v.size();i++)
    {
        int a=v[i].second.first,b=v[i].second.second;
        if(f(a)==f(b)) continue;
        connect(a,b);
        ans+=v[i].first;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 8040
from collections import Counter


def solve():
    N = int(input())
    D = Counter(map(int, input().split()))
    M = int(input())
    T = Counter(map(int, input().split()))
    for k, v in T.items():
        if D[k] < v:
            return 'NO'
    return 'YES'


print(solve())

Measured memory_bytes: 67680
il = [int(k) for k in input().split()]
B = [int(k) for k in input().split()]
N = il[0]
M = il[1]
C = il[2]
result = 0

for i in range(N):
    A = [int(k) for k in input().split()]
    tmp_list = [x * y for (x, y) in zip(A, B)]
    sum_tmp_list = sum(tmp_list)
    if sum_tmp_list + C > 0:
        result += 1

print(result)


Measured memory_bytes: 3064
package main

// 某DP, 再帰でやったらTLEになる原因がメモ化再帰しか浮かばないんだけどループでやるDPってやったことないので練習のため来ました

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

var n int
var k int
var h []int

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code ---*/
	n, k = nextInt(), nextInt()
	h = nextInts(n)
	dp := make([]int, n+10)
	INF := int(math.Pow(10, 9))
	for i := 0; i < len(dp); i++ {
		dp[i] = INF
	}
	dp[0] = 0
	for i := 1; i < n; i++ {
		// 現在のところから0を下回らない限り-1 ~ -kしたところとの差を集めて計算し最小値を更新していく
		ans := INF
		for j := 1; j <= k; j++ {
			if i >= j {
				ans = min(ans, dp[i-j]+int(math.Abs(float64(h[i]-h[i-j]))))
			} else {
				break
			}
		}
		dp[i] = ans
	}
	fmt.Fprintln(out, dp[n-1])
}

func min(a, b int) int {
	if a <= b {
		return a
	} else {
		return b
	}
}

func max(a, b int) int {
	if a <= b {
		return b
	} else {
		return a
	}
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}


Measured memory_bytes: 2816
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

class Vec2d {
private:
    double m_dx;
    double m_dy;
public:
    Vec2d(double m_dx, double m_dy) {
        this->m_dx = m_dx;
        this->m_dy = m_dy;
    }
    double length() {
        return sqrt(pow(m_dx, 2) + pow(m_dy, 2));
    }
    void normalize() {
        double size = this->length();
        m_dx = m_dx / size;
        m_dy = m_dy / size;
    }
    Vec2d operator +(const Vec2d& zVec) {
        double dX = this->m_dx + zVec.m_dx;
        double dY = this->m_dy + zVec.m_dy;
        return Vec2d(dX, dY);
    }
    Vec2d operator -(const Vec2d& zVec) {
        double dX = this->m_dx - zVec.m_dx;
        double dY = this->m_dy - zVec.m_dy;
        return Vec2d(dX, dY);
    }
    //dot product
    double operator *(const Vec2d& zVec) {
        return this->m_dx * zVec.m_dx + this->m_dy * zVec.m_dy;
    }
    //scalar multiplication
    Vec2d operator *(const double mul) {
        double dX = m_dx * mul;
        double dY = m_dy * mul;
        return Vec2d(dX, dY);
    }
    double getX() {
        return m_dx;
    }
    double getY() {
        return m_dy;
    }
};

int main()
{
    double dCx, dCy, dCr;
    cin >> dCx >> dCy >> dCr;
    Vec2d zCircle(dCx, dCy);
    int nSize;
    cin >> nSize;
    double dX1, dY1, dX2, dY2, dRoot, dDiscriminant, dI1x, dI1y, dI2x, dI2y;
    for (int i = 0; i < nSize; i++) {
        cin >> dX1 >> dY1 >> dX2 >> dY2;
        Vec2d zP(dX1, dY1);
        Vec2d zD = (Vec2d(dX2, dY2) - zP);
        zD.normalize();
        dRoot = -(zD*(zP - zCircle));
        //Problem constraint: The circle and line have at least one cross point
        dDiscriminant = sqrt(pow(dRoot, 2) - (zP - zCircle)*(zP - zCircle) + dCr*dCr);
        Vec2d zIntersect1 = zP + zD*(dRoot - dDiscriminant);
        Vec2d zIntersect2 = zP + zD*(dRoot + dDiscriminant);
        dI1x = zIntersect1.getX();
        dI1y = zIntersect1.getY();
        dI2x = zIntersect2.getX();
        dI2y = zIntersect2.getY();
        cout << fixed << setprecision(6);
        if (dI1x < dI2x || (dI1x == dI2x && dI1y <= dI2y)) {
            cout << dI1x << " " << dI1y << " " << dI2x << " " << dI2y << "\n";
        }
        else {
            cout << dI2x << " " << dI2y << " " << dI1x << " " << dI1y << "\n";
        }    
    }
    return 0;
}


Measured memory_bytes: 3268
#include<iostream>
using namespace std;
int main(){
	int a,ccount;
	ccount=0;
	cin>>a;
	for(int i=1;i<=a;i=i+2){
		int count=0;
		for(int j=1;j<=i;j++){
			if(i%j==0){
				count++;
			}
		}
		if(count==8){ccount++;}
	}
	cout<<ccount<<endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  char c;
  cin >> c;
  if (c=='a'||c=='i'||c=='u'||c=='e'||c=='o') {
    cout << "vowel\n";
  } else {
    cout << "consonant\n";
  }
}

Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<queue>

typedef long long ll;
using namespace std;
const int max_n = 3 * 1e5 + 1;
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)

ll N, M;
int main()
{
	IOS;
	cin >> N >> M;

	if (2 * N >= M)
	{
		cout << min(N, M / 2);
	}
	else
	{
		ll val = (M - 2 * N);
		cout <<min(N,M/2)+val/4;
	}
}

Measured memory_bytes: 256
// AtCoder Grand Contest 010
// C - Cleaning

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;


const int MAX_N = 100000;

int N;
vector<int> G[MAX_N];
ll a[MAX_N];

ll dfs(int v, int par = -1) {
    ll down, down_max, down_sum, p, p_max;

    if (G[v].size() == 1) {
        if (par == -1) {
            return (dfs(G[v][0], v) == a[v] ? 0 : -1);
        } else {
            return a[v];
        }
    }

    down_max = 0;
    down_sum = 0;
    for (int to : G[v]) {
        if (to == par) {
            continue;
        }
        down = dfs(to, v);
        if (down < 0) {
            return -1;
        }
        down_max = max(down_max, down);
        down_sum += down;
    }
    p = down_sum - a[v];
    p_max = min(down_sum - down_max, down_sum / 2);
    if (!(0 <= p && p <= p_max)) {
        return -1;
    }
    return 2 * a[v] - down_sum;
}

int main() {

    int x, y;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < N - 1; i++) {
        cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    cout << (dfs(0) == 0 ? "YES" : "NO") << endl;

    return 0;

}





Measured memory_bytes: 13184
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

int main(){
    int m, t, p, r;
    while(cin >> m >> t >> p >> r, m||t||p||r){
        vector< pair<pair<int,int>,int> > v(51);
        int miss_cnt[51][11] = {0};
        rep(i,51) v[i].first.second= INF;
        rep(i,51) v[i].second= i + 1;
        rep(i,r){
            int time, team, prob,jud;
            cin >> time >> team >> prob >> jud;
            team--; prob--;
            if(jud == 0){
                v[team].first.first++;
                v[team].first.second -= time + miss_cnt[team][prob] * 20;
            }else{
                miss_cnt[team][prob]++;
            }
        }
        sort(v.begin(), v.begin() + t, greater<pair<pair<int,int>,int>>());
        rep(i,t){
            if(i){
                if(v[i - 1].first.first == v[i].first.first && v[i - 1].first.second == v[i].first.second){
                    cout << '=';
                }else{
                    cout << ',';
                }
            }
            cout << v[i].second;
        }
        cout << endl;
    }
}

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

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

    int N;
    cin >> N;
    int ans = 0;
    rep(i,N){
        int a;
        cin >> a;
        ans += a - 1;
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100000];
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    int ans=1,prev=a[0],count=1;
    for(int i=1;i<n;i++){
        if(prev==a[i])count++;
        else{prev=a[i];count=1;}
        if(count%2)ans++;
        else ans--;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
 
 
        int i,j,t;
        String st;
    
        t = s.nextInt();
        for(i=0;i<t;i++){
            int[] num = new int[10];
            int[] g = new int[10],b =new int[10], r =new int[10];
            boolean ch=true;
            for(j=0;j<9;j++)num[j]=s.nextInt();
            for(j=0;j<9;j++){
 
                st = s.next();
                if(st.charAt(0)=='G')g[num[j]]++;
                else if(st.charAt(0)=='B')b[num[j]]++;
                else if(st.charAt(0)=='R')r[num[j]]++;
            }
            for(j=1;j<=9;j++){
                if(g[j]>=3)g[j]-=3;
                if(j<8&&g[j]==2&&g[j+1]>1&&g[j+2]>1){
                    g[j]-=2;
                    g[j+1]-=2;
                    g[j+2]-=2;
                }
                if(j<8&&g[j]==1&&g[j+1]>0&&g[j+2]>0){
                    g[j]--;
                    g[j+1]--;
                    g[j+2]--;
                }
                if(b[j]>=3)b[j]-=3;
                if(j<8&&b[j]==2&&b[j+1]>1&&b[j+2]>1){
                    b[j]-=2;
                    b[j+1]-=2;
                    b[j+2]-=2;
                }
                if(j<8&&b[j]==1&&b[j+1]>0&&b[j+2]>0){
                    b[j]--;
                    b[j+1]--;
                    b[j+2]--;
                }
                if(r[j]>=3)r[j]-=3;
                if(j<8&&g[j]==2&&r[j+1]>1&&r[j+2]>1){
                    r[j]-=2;
                    r[j+1]-=2;
                    r[j+2]-=2;
                }
                if(j<8&&r[j]==1&&r[j+1]>0&&r[j+2]>0){
                    r[j]--;
                    r[j+1]--;
                    r[j+2]--;
                }
                if(g[j]>0||b[j]>0||r[j]>0){
                    ch = false;
                    break;
                }   
            }
            if(ch==true)System.out.println(1);
            else System.out.println(0);
            for(j=0;j<=9;j++){
                g[j]=0;
                b[j]=0;
                r[j]=0;
                num[j]=0;
            }
            ch=true;
        }
 
    }
}



Measured memory_bytes: 29384
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,x;
    
    cin>>n>>x;
    
    int L[n];
    int sum=0;
    
    for(int i=0; i<n+2; i++){
        cin>>L[i];
        //cout << sum << endl;
        sum=sum+L[i];
        if(sum>x){
            cout<<i+1;
            break;
        }
    }
}


Measured memory_bytes: 256