akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n ; i++ )
#define For(i, a, b) for(int i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll mod = 1e9 + 7;

ll power_mod(ll a, ll power){
    ll value = 1;
    
    while(power != 0){
        if(power & 1) value = (value * a) % mod;
        a = (a * a) % mod;
        power = power >> 1;
     
    }

    return value % mod;
}

//https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae

ll combination(ll n, ll r){
    ll numerator = 1;
    ll denomenator = 1;

    rep(i, r){
        (numerator *= ll(n - i)) %= mod;
        (denomenator *= power_mod(ll(i + 1), ll(mod - 2))) %= mod;
    }
    
    return (numerator * denomenator) % mod;
}

int main(void){
    //int N, M, K;
    ll N, M, K;
    cin >> N >> M >> K;
    //scanf("%d %d %d", &N, &M, &K);
    ll cost_x = 0;
    ll cost_y = 0;
    ll comb = combination(ll(N * M - 2), ll(K - 2));

    For(d, 1, N){
        (cost_x += ll(d * (N - d)) % mod) %= mod;
    }

    For(d, 1, M){
        (cost_y += ll(d * (M - d)) % mod) %= mod;
    }

    (cost_x *= ll(M * M) % mod) %= mod;
    (cost_y *= ll(N * N) % mod) %= mod;
    ll cost = (cost_x + cost_y) % mod;

    cout << (cost * comb) % mod << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end())
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define _1 first
#define _2 second
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)

int main() {
  int h, w, n;
  cin >> h >> w >> n;
  chkmax(h, w);
  cout << (n + h - 1) / h;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a, b, wa, sa, seki,ans;

	scanf("%d%d", &a, &b);

	wa = a + b;
	sa = a - b;
	seki = a*b;

	ans = wa;
	if (ans < sa)
		ans = sa;

	if (ans < seki)
		ans = seki;

	printf("%d\n", ans);

	return 0;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

void build(const string& pattern, vector<int>& table){
  int M = pattern.size();
  table.assign(M+1, 0);
  for(int i=2,j=0;i<=M;){
	if(pattern[i-1] == pattern[j]){
	  table[i] = j+1;
	  ++i;
	  ++j;
	}
	else if(j > 0) j = table[j];
	else{
	  table[i] = 0;
	  ++i;
	}
  }
}

int kmp_search(const string& str, const string& pattern, const vector<int>& table){
  int N = SZ(str), M = SZ(pattern);
  int res = 0;
  for(int m=0,i=0;m+i<N;){
	if(str[m+i] == pattern[i]){
	  ++i;
	  if(i == M){
		cout << m << endl;
		++res;
		m += i - table[i];
		i = table[i];
	  }
	}
	else{
	  if(i > 0){
		m += i - table[i];
		i = table[i];
	  }
	  else
		++m;
	}
  }
  return res;
}

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

  string S, T;
  cin >> S >> T;
  VI tb;
  build(T, tb);
  kmp_search(S, T, tb);

  return 0;
}

Measured memory_bytes: 4572
#include <stdio.h>
int main() {
	int i, I, N;
	int x[11];
	scanf("%d", &N);
	for(I = 0; I < N; ++ I) {
		scanf("%d", &x[0]);
		for(i = 1; i < 11; ++ i) {
			x[i] = x[i - 1] * x[i - 1] / 100 % 10000;
		}
		printf("Case %d:\n", I + 1);
		for(i = 1; i < 11; ++ i) printf("%d\n", x[i]);
	}
	return 0;
}

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

int main() {
    int N, t, total = 0;
    cin >> N;
    t = N;
    while (N > 0) {
        total += N % 10;
        N = N /10;
    }
    cout << (t % total == 0 ? "Yes" : "No") << endl;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1e9 + 7

using namespace std;

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

int main(void)
{
    int x;
    cin >> x;
    cout << ((x == 3 || x == 5 || x == 7) ? "YES" : "NO") << endl;
    return 0;
}

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

int main(){
  int A;
  int B;
  cin >> A >> B;
  
  if(A>=13){
    cout << B <<endl;
  }else if((A>=6)&&(A<13)){
    cout << B / 2 <<endl;
  }else{
    cout << 0 <<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,K;
char c[1010000];
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>K;
	cin>>c;
	int l=0,r=n-1,tim=0,tag=0;
	while(tim+1<=K){
		tim++;
		if(tag&&c[l]=='A'||!tag&&c[l]=='B'){
			l++;tag^=1;
			c[++r]=tag?'B':'A';
		}
		else c[l]=tag?'A':'B';
		if(tim>2*n) break;
	}
	if(tim<=2*n){
		for(int i=l;i<=r;i++)
			if(!tag) cout<<c[i];
			else cout<<(c[i]=='A'?'B':'A');
		cout<<'\n';
	}
	else{
		if(K-tim&1&&(n==1||tag&&c[l+1]=='A'||!tag&&c[l+1]=='B')){
			cerr<<"!!";
			c[l]=c[l]=='A'?'B':'A';
		}
		for(int i=l;i<=r;i++)
			if(!tag) cout<<c[i];
			else cout<<(c[i]=='A'?'B':'A');
		cout<<'\n';
	}
	return 0;
}


Measured memory_bytes: 896
#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];

    map<int, int> count;
    for(int i = 0; i < N; i++) count[a[i]]++;

    int ans = 0;
    for(auto itr = count.begin(); itr != count.end(); itr++){
        if(itr->first < itr->second){
            ans += itr->second - itr->first;
        }else if(itr->first > itr->second){
            ans += itr->second;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))

#define rdi(i) ll i; scanf("%lld", &i)
#define rds(s) string s; cin >> s
#define rdc(c) char c; cin >> c

#define INF 10000000000
//#define MOD 1000000007
#define MOD 998244353

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

ll pw(ll a, ll n) {
    if (n <= 0) {
        return 1;
    } else if (n == 1) {
        return a;
    } else if (n % 2 == 0) {
        ll work = pw(a, n / 2);
        return work * work % MOD;
    } else {
        return pw(a, n - 1) * a % MOD;
    }
}

vector<ll> f;
vector<ll> ff;

ll combi(ll a, ll b) {
    if (b <= 0 || a - b <= 0) {
        return 1;
    } else {
        return (f[b] * f[a - b] % MOD) * ff[a] % MOD;
    }
}

int main()
{
    ll n, m, k;
    cin >> n >> m >> k;

    f.resize(n);
    ff.resize(n);
    f[0] = 1;
    ff[0] = 1;
    rrep(i, 1, n) {
        f[i] = pw(i, MOD - 2);
        f[i] = f[i] * f[i - 1] % MOD;
        ff[i] = i * ff[i - 1] % MOD;
    }

    vector<ll> p(n + 1);
    p[0] = m;
    rrepp(i, 1, n) {
        p[i] = (p[i - 1] * (m - 1)) % MOD;
    }

    ll result = 0;
    repp(i, k) {
        ll work = p[n - i - 1] * combi(n - 1, n - i - 1) % MOD;
        result = (result + work) % MOD;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 7448
/***
        ***Fresher***
    Md Mahfujur Rahman Khan
    Dept. of CSE
    CSE-28 Batch
    JU-48 Batch
    Jahangirnagar University

***/
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<numeric>
#include<utility>
using namespace std;
#define V_ vector
#define Q_ queue
#define S_ set
#define ST_ stack
#define M_ map
#define DQ_ deque
/***PAIR***/
#define pii pair<ll,ll>
#define pci pair<char,ll>
#define psi pair<string, ll>
#define pis pair<ll,string>
#define pic pair<ll, char>
/***MAP***/
#define mii map<ll,ll>
#define msi map<string, ll>
#define mis map<ll, string>
#define mib map<ll,bool>
#define msb map<string,bool>
#define mci map<char, ll>
/***VECTOR***/
#define vi vector<ll>
#define vs vector<string>
/***ITERASTORS***/
#define ivi vector<ll> :: iterator
#define ivs vector<string> :: iterator
#define imii map<ll,ll> :: iterator
#define imsi map<string,ll> :: iterator
#define imis map<ll, string> :: iterator
#define imib map<ll, bool> :: iterator
#define imsb map<string, bool> :: iterator
#define imci map<char, ll> :: iterator
/*** FAST ***/
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/***FUNCTIONS AND MACROS***/
#define F first
#define S second
#define M_P(x, y) make_pair(x, y)
#define PB(x) push_back(x)
#define PP(x) push(x)
#define RSZ(n) resize(n)
#define POB pop_back()
#define P_ pop()
#define CL_ clear()
#define LEN_ length()
#define SZ_ size()
#define CNT(x) count(x)
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define B_ begin()
#define E_ end()
#define F_ front()
#define t_ top()
#define IN_ insert
#define ER_  erase
#define GT(x) getline(cin , x)
#define NL_   "\n"
#define SP_ " "
#define R_0 return 0
#define R_ return

#define ul unsigned long long int
#define ll long long int
/***
//prime fact
#define most_prime_loop 10001
#define most_prime_number 20000010
#define prime_MAX_arr 20000010/2
ll PRIME[prime_MAX_arr];
void seive()
{
    PRIME[0] = 0;
    for(auto &x: PRIME )
        x = 1;
    for(ll i= 3; i <= most_prime_loop; i+=2)
    {
        for(ll j = i*i; j <= most_prime_number; j+=2*i)
            PRIME[j/2] = 0;
    }
}
***/
#define fr(i, n) for( ll i = 0; i < n; i++)
#define fe(x, n) for( ll i = x; i <= n; i++)
#define fa(x,a)    for(auto &x : a)

#define pi acos(-1)

#define SR(x) sqrt(x)
#define IC   (ll)

const ll  inf = 1000000000;
ll i=0, T=0, N=0, tc =0, t= 0;
ll n=0, k=0;

int main()
{
 ll a, b;
     cin >> a;
     cout << a *(a-1)/2;
    R_0;
}



Measured memory_bytes: 256
#include<stdio.h>
int MAX=100;
int INFTY=100000;
int WHITE=0;
int GRAY=1;
int BLACK=2;
int prim(void);
int n,i,M[100][100];

int main(){
  int e;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(int j=0;j<n;j++){
      scanf("%d",&e);
      if(e==-1)
	M[i][j]=INFTY;
      else M[i][j]=e;
    }
  }
  printf("%d\n",prim());
  return 0;
}

int prim(){
  int u,mincost;
  int d[MAX],p[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }

  d[0]=0;

  while(1){
    mincost=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(mincost>d[i]&&color[i]!=BLACK){
	u=i;
	mincost=d[i];
	}
    }
    
    if(u==-1) break;
    color[u]=BLACK;
    
    for(int v=0;v<n;v++){
      if(color[v]!=BLACK&&M[u][v]!=INFTY){
	if(d[v]>M[u][v]){
	  d[v]=M[u][v];
	  p[v]=u;
	  color[v]=GRAY;
	}
      }
    }
    
  }
  int sum=0;
  for(i=0;i<n;i++){
    if(p[i]!=-1) sum+=M[i][p[i]];
  }
  
  return sum;
}


Measured memory_bytes: 2056
x,y=map(int,input().split())
xx=y-2*x
flag=True
if(xx%2==0):
    xx//=2
    if(xx>=0 and xx<=x):
        ''
    else:
        flag=False
else:
    flag=False
if(flag):
    print('Yes')
else:
    print('No')
    

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

int main() {
    int a, b;
    cin >> a >> b;
    int sum = a + b;
    if(sum % 2 == 0){
        cout << sum / 2 << endl;
    } else { 
        cout << sum / 2 + 1 << endl;
    }
}


Measured memory_bytes: 256
import numpy
n, k = map(int, input().split())

s = input().strip()

first_is_L = s[0] == 'L'
last_is_R  = s[-1] == 'R'
cnt = s.count("RL")

X = cnt
Y = first_is_L + last_is_R


turn = min(k, cnt)
rest_X = cnt - min(k, cnt)
rest_k = k - turn


rest_Y = Y - min(rest_k, Y)

ans = len(s) - rest_X * 2 - rest_Y
print(min(ans, len(s)-1))


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

int main(){
    string s;
    cin >> s;
    string a;
    int b = 753;
    int ans = 10000000;
    for(int i = 0;i < s.size()-2;++i){
        a = s.substr(i,3);
        if(ans > abs(b - stoi(a))) {
            ans = abs(b - stoi(a));
            //cout << a << endl;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
char c;
cin >> c;
switch(c){
case 'a':
case 'i':
case 'u':
case 'e':
case 'o':
cout << "vowel" << endl;
break;
default:
cout << "consonant" << endl;
}
return 0;
}


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

int main(void)
{
	int x,y,z,a,b=0;
	char c[4];
	scanf("%d %d %d %d",&x,&y,&z,&a);
//	scanf("%d %d %d",&x,&y,&z);
//	scanf("%d %d",&x,&y);
//	scanf("%d",&x);
	if (abs(x-y) <= a && abs(y-z) <= a) b =1;
	if (abs(x-z) <= a) b = 1;
	if (b) printf("Yes");
	else printf("No");
	return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

bool is4(int n)
{
    int ls[4] = {4,6,9,11};
    
    for(int i = 0; i < 4; i++)
    {
        if(n==ls[i]) return true;
    }
    return false;
}

int main()
{
    int x,y;
    cin >> x >> y;
    if(x==2||y==2)
    {
        cout << "No"<<endl;
    }
    else if(is4(x) == is4(y))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No"<<endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll T = 1;
    while(T--)
    {
        ll N; cin>>N;
        ll one = (N + 999)/1000;
        ll two = N/1000;
        
        cout<<(1000 * one - N)<<endl;
    }
}

Measured memory_bytes: 3608
from bisect import bisect_left
import sys
sys.setrecursionlimit(1000000)


def dfs(j, parent):
    index = bisect_left(dp, a[j-1])
    old = dp[index]
    dp[index] = a[j-1]
    ans[j-1] = bisect_left(dp, INF)-1
    for child in to[j]:
        if child != parent:
            dfs(child, j)
    dp[index] = old

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))
    to = [[] for _ in range(n+1)]
    for _ in range(n-1):
        u, v = map(int, input().split())
        to[u].append(v)
        to[v].append(u)
    INF = 10**20
    dp = [INF]*(n+1)
    dp[0] = -INF
    ans = [None]*n
    dfs(1, -1)
    print("\n".join(list(map(str, ans))))

Measured memory_bytes: 360364
fun main(args: Array<String>) {
    var (a,b,c,k) = readLine()!!.split(" ").map { it.toInt() }
    var n = 0
    if (k-a <= 0) {
        println(k)
    } else {
        n += a
        k -= a
        if (k-b <= 0) {
            println(a)
        } else {
            k-=b
            println(n-k)
        }
    }
}

Measured memory_bytes: 36492
//
// Created by Myabu on 2020/01/22.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;


int main(void){
    string S;
    string T;
    cin>>S>>T;

    sort(S.begin(),S.end());
    sort(T.begin(), T.end(), std::greater<int>());

//
//    cout<<S<<endl;
//    cout<<T<<endl;
    if(S<T){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }


    return 0;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline

s = input()[:-1]
t = input()[:-1]

N = len(s) + 1
M = len(t) + 1


# dp[i][j] := s[i] t[j]までのLCS
dp = [[0]*M for _ in range(N)]


for i in range(1, N):
    for j in range(1, M):
        if s[i-1] == t[j-1]:
            dp[i][j] = dp[i-1][j-1] + 1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

"""
復元
もしdp[i][j] == dp[i][j-1]ならt[j-1]は使われていないことがわかる
もしdp[i][j] == dp[i-1][j]ならs[i-1]は使われていないことがわかる
それ以外の場合、s[i-1], t[j-1]が使われていることがわかる
"""

ans = ""
i = len(s)
j = len(t)

while i > 0 and j > 0:
    if dp[i][j] == dp[i-1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j-1]:
        j -= 1
    else:
        ans = s[i-1] + ans  # t[j-1] + ansでも同じ
        i -= 1
        j -= 1
print(ans)


Measured memory_bytes: 112092
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("in.txt");ofstream coutt("out.txt");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Use __builtin_popcountll for ll;
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

int f[200005];
int a[200005];
int ans[200005];

signed main(){
    FASTER;
    int n;cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    
    for(int i=n;i>=1;i--){
        int lo=0;
        for(int j=i*2;j<=n;j+=i){
            lo+=ans[j];
        }
        if(lo%2!=a[i]){
            ans[i]=1;
        }
    }
    cout<<accumulate(ans+1,ans+1+n,0LL)<<"\n";
    for(int i=1;i<=n;i++){
        if(ans[i])cout<<i<<" ";
    }
}

Measured memory_bytes: 6696
#include <bits/stdc++.h>
using namespace std;
#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 all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll x = 1000, y = 0;
    rep(i, n) {
        if (i == n - 1 || a[i] > a[i + 1]) {
            x += y * a[i];
            y = 0;
        } else if (a[i] < a[i + 1]) {
            y += x / a[i];
            x %= a[i];
        }
    }
    cout << x << endl;
}

Measured memory_bytes: 3620
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), ((a) + (n))
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MODNUM (static_cast<unsigned long long>(1e9 + 7))
#define MOD(x) ((x) % MODNUM)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const int INF = 2e9;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

template <typename T>
int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T>
T square(T x) {
	return x * x;
}

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

ll mod_pow(ll a, ll n) {
#ifndef MOD
	static_assert(false, "MOD() is not defined.");
#endif

	ll ret = 1;
	while(n != 0) {
		if(n % 2) {
			ret = MOD(ret * a);
		}
		a = MOD(a * a);
		n /= 2;
	}
	return ret;
}

int main() {
	ll n;
	scanf("%lld", &n);
	vector<ll> a(n);
	EACH(e, a) { scanf("%lld", &e); }

	ll result = 0;
	REP(i, 60) {
		ll one = 0;
		ll zero = 0;

		REP(j, n) {
			((a[j] & 1) ? one : zero) += 1;
			a[j] >>= 1;
		}

		result = MOD(result + MOD(MOD(one * zero) * mod_pow(2, i)));
	}

	printf("%lld\n", result);

	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#define BS 64

using namespace std;

int main(void) {
	long long N,K;
	cin >> N >> K;
	vector< bitset<BS> > bits(N);
	for (int i = 0; i < N; ++i) {
		long long temp;
		cin >> temp;
		bits[i] = bitset<BS>(temp);
	}

	int base = N/2 + (N%2); 
	long long res = 0;
	bitset<BS> now(0);
	for (int i = 0; i < BS; ++i) {
		int count = 0;
		for (int j = 0; j < N; ++j) {
			if (bits[j][BS-i-1]) {
				++count;
			}
		}
		if (now.set(BS-i-1).to_ullong() <= K) {
			if (count < base) {
				count = N - count;
			}
			else {
				now.reset(BS-i-1);
			}
		}
		else {
			now.reset(BS-i-1);
		}
		res += count * (1ll << BS-i-1);
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>

using namespace std;


int main()
{
	int n[11],count=0,m;
	while(scanf("%d",&m)!=EOF){
		
		if(m==0){
			count--;
			cout<<n[count]<<endl;		
		}
		else{
			n[count]=m;
			count++;
		}
	}

	return 0;
}

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

using ll = long long;

int main() {
    ll n, k;
    cin >> n >> k;
    map<ll, ll> m;
    for (ll i = 0; i < n; i++) {
        ll a, b;
        cin >> a >> b;
        m[a] += b;
    }

    ll cnt = 0;
    for (auto x : m) {
        // cout << x.first << ", " << x.second << endl;
        cnt += x.second;
        if (cnt >= k) {
            cout << x.first << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

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

  return 0;
}


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


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int n, m;
int cnt[N], flag[N];

int32_t main()
{
	IOS;
	int ans = 0;
	cin >> n >> m;
	for(int i = 1; i <= m; i++)
	{
		int x;
		string s;
		cin >> x >> s;
		if(s == "WA")
		{
			if(!flag[x])
				cnt[x]++;
		}
		else
			flag[x] = 1;
	}	
	int ans1 = 0;
	for(int i = 1; i <= n; i++)
	{
		if(flag[i])
		{
			ans1++;
			ans += cnt[i];
		}
	}
	cout << ans1 << " " << ans;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>

int main(){
unsigned int ans,N,H,W;
std::cin >> N>>H>>W;
for(int i =0 ; i<N;i++){
int tmp1,tmp2;
std::cin >> tmp1 >> tmp2;
if(tmp1 >= H&&tmp2 >= W){
ans++;
}
}
std::cout <<ans<<'\n';
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define ff first
#define ss second

template <class T>
void print(vector<T>& v){
    for(T x:v) cout<<x<<" ";
    cout<<"\n";
}
void inp(vector<int>& v, int n){
    for (int i=0; i<n; ++i) scanf("%d", &v[i]);
}


void sol(){
    int n, m;
    cin>>n>>m;
    int a, b, c, d, x, y;
    cin>>a>>b>>c>>d;
    a--, b--, c--, d--;
    vector<string> v(n);
    for (int i=0; i<n; ++i) cin>>v[i];
    queue<pair<int, int>> q1, q2;
    int res=0;
    vector<vector<int>> vis(n, vector<int>(m, 0));
    q1.push({a, b});
    vis[a][b]=1;
    pair<int, int> p;
    // q1.push({-1, -1});
    while (!q1.empty()){
        // q2=queue<pair<int, int>>;
        while (!q1.empty()){
            p=q1.front();
            q1.pop();
            q2.push(p);
            if (p.ff==c && p.ss==d){
                printf("%d\n", res);
                return;
            }
            if (p.ff>1 && vis[p.ff-1][p.ss]==0 && v[p.ff-1][p.ss]=='.'){
                vis[p.ff-1][p.ss]=1;
                q1.push({p.ff-1, p.ss});
            }
            if (p.ss>1 && vis[p.ff][p.ss-1]==0 && v[p.ff][p.ss-1]=='.'){
                vis[p.ff][p.ss-1]=1;
                q1.push({p.ff, p.ss-1});
            }
            if (p.ff<n-1 && vis[p.ff+1][p.ss]==0 && v[p.ff+1][p.ss]=='.'){
                vis[p.ff+1][p.ss]=1;
                q1.push({p.ff+1, p.ss});
            }
            if (p.ss<m-1 && vis[p.ff][p.ss+1]==0 && v[p.ff][p.ss+1]=='.'){
                vis[p.ff][p.ss+1]=1;
                q1.push({p.ff, p.ss+1});
            }
        }
        while (!q2.empty()){
            p=q2.front();
            q2.pop();
            for (int i=-2; i<3; ++i){
                for (int j=-2; j<3; ++j){
                    x=p.ff+i;
                    y=p.ss+j;
                    if (x>-1 && x<n && y>-1 && y<m && vis[x][y]==0 && v[x][y]=='.'){
                        vis[x][y]=1;
                        q1.push({x, y});
                    }       
                }
            }
        }
        res++;
    }
    printf("-1\n");
    return;
}

int main() {
    // int t;
    // cin>>t;
    // t++;
    // for (int i=1; i<t; ++i){
        // cout<<"Case #"<<i<<": ";
        sol();
    // }
    return 0;
}

Measured memory_bytes: 9636
from collections import deque

inputs = open(0).readlines()
n, k = map(int, inputs[0].split())
V = deque(map(int, inputs[1].split()))
def calc(ii, jj, kk):
    W = []
    for i in range(ii):
        W.append(V[i])
    for j in range(jj):
        W.append(V[-j-1])
    W.sort(reverse=True)
    for _ in range(kk):
        if W[-1] < 0:
            W.pop()
    return sum(W)

ans = 0
for i in range(min(n, k)+1):
    for j in range(min(n, k)+1-i):
        for k_ in range(min(i+j, k+1-i-j)):
            ans = max(ans, calc(i, j, k_))
print(ans)

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

int main(){
  int a, b, i;
  cin >> a >> b;
  string s;
  cin >> s;
  for(i = 0; i < a; i++){
    if(!('0' <= s[i] && s[i] <= '9')){
      cout << "No" << endl;
      return 0;
    }
  }
  if(s[a] != '-'){
    cout << "No" << endl;
    return 0;
  }
  for(i = a + 1; i <= a + b; i++){
    if(!('0' <= s[i] && s[i] <= '9')){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main(){
	int N; cin >> N;
	if(1 << (int)(log2(N + 0.1)) == N){puts("No"); return 0;}
	puts("Yes");
	for(int i = 1 ; i < 3 ; ++i){
		cout << i << ' ' << i + 1 << endl;
		cout << i + N << ' ' << i + N + 1 << endl;
	}
	cout << 3 << ' ' << N + 1 << endl;
	for(int i = 4 ; i < N ; i += 2){
		cout << i << ' ' << i + 1 << endl;
		cout << i + 1 << ' ' << N + 1 << endl;
		cout << N + 1 << ' ' << i + N << endl;
		cout << i + N << ' ' << i + N + 1 << endl;
	}
	if(!(N & 1)){
		int t = 1 << (int)(log2(N + 0.1));
		cout << N << ' ' << t + N << endl; cout << N - t + 1 << ' ' << 2 * N << endl;
	}
	return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int MAXNK = 5000 + 50;
int can[MAXNK][MAXNK];
int canr[MAXNK][MAXNK];

int main() {
	int N, K;
	VI a;
	a.PB(0);
	scanf("%d%d", &N, &K);
	for(int i = 0; i < N; i++) {
		int tin;
		scanf("%d", &tin);
		if(tin < K) a.PB(tin);
	}
	can[0][0] = 0;
	for(int i = 1; i < SZ(a); i++) {
		for(int j = 0; j < K; j++)
			if(can[i - 1][j] == j || (j - a[i] >= 0 && can[i - 1][j - a[i]] == j - a[i]))
				can[i][j] = j;
			else
				can[i][j] = can[i][j - 1];
	}
	canr[0][0] = 0;
	for(int i = 1; i < SZ(a); i++) {
		int id = SZ(a) - i;
		for(int j = a[id]; j < K; j++)
			if(canr[i - 1][j] == j || (j - a[id] >= 0 && canr[i - 1][j - a[id]] == j - a[id]))
				canr[i][j] = j;
			else
				canr[i][j] = canr[i][j - 1];
	}
	int ans = SZ(a) - 1;
	for(int i = 1; i < SZ(a); i++) {
		for(int j = K - 1; j >= 0; j--) {
			debug("(%d, %d)\n", i, j);
			if(can[i - 1][j] == j && canr[SZ(a) - i - 1][K - j - 1] + j >= K - a[i]) {
				debug("!\n");
				ans--;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 198912
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
using p = pair<int, int>;

int main()
{
  int n, m;
  cin >> n >> m;
  std::vector<int> a(n);

  int sum = 0;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    sum += a[i];
  }
  sort(a.rbegin(), a.rend());
  string ans = "Yes";
  if (a[m - 1] < (double)sum / (double)(4 * m))
  {
    ans = "No";
  }
  cout << ans << endl;
  return 0;
}


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

#define N_MAX 100000

using namespace std;

int main(){
    int N;
    int A[N_MAX];
    int n_unique = 0;
    int tmp_cnt = 1;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    sort(A, A+N);
    for(int i = 1; i < N; i++){
        if(A[i] == A[i-1]){
            tmp_cnt++;
        }else{
            if(tmp_cnt %2 == 1) n_unique++;
            tmp_cnt = 1;
        }
    }
    if(tmp_cnt %2 == 1) n_unique++;
    cout << n_unique << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

#define MAX_PRIME	(10000)


int prime[MAX_PRIME + 1];

void make_prime(void)
{
    int i;
    int j;
    int n;
    int c;
    
    for (i = 2; i * i <= MAX_PRIME; i++){
        if (prime[i] == 0){
            for (j = i * 2; j <= MAX_PRIME; j += i){
				prime[j] = 1;
            }
        }
    }
}
	

int main(void)
{
	int n;
	int count;
	int s;
	int i, j;

	make_prime();
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}

		count = 0;
		for (i = 2; i <= n; i++){
			if (prime[i] == 0){
				s = 0;
				for (j = i; j<= n; j++){
					if (prime[j] == 0){
						s += j;
//printf("[%d %d]", j, s);
						if (s == n){
							count++;
//printf("<-OK ");
						}
						else if (s > n){
//printf("<-NG ");
							break;
						}
					}
				}
			}
		}
		
		printf("%d\n", count);
	}
	return (0);
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
int f[300009];
main(){
    string s;
    cin >> s;
    int a = 0;
    long long ans  =0;
    for(int i = 0; i < s.size()-1; i++){
        if(s[i] == 'B' && s[i+1] =='C') ans+=a;
        if(s[i] =='B' && s[i+1] != 'C') a = 0;
        if(s[i] == 'C' && i && s[i-1] != 'B') a = 0;
        if(s[i] =='A') a++;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import sys

a,b,c = list(map(int, list(input().split())))
k = int(input())

for i in range(k):
    if not(c > b) or not(c > a):
        c *= 2
    elif not(b > a):
        b *= 2
    else:
        print('Yes')
        sys.exit()

if c > b and b > a:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 9176
/* author   : mpily :-()
title : Competing.cpp
time :Sun Mar 22 15:02:46 2020

*/
#include<bits/stdc++.h>
using namespace std;

int main(){
	int n;
	cin>>n;
	vector<long long>sn(n+1);
	vector<int>arr(n);
	for(int i = 0; i < n; ++i){
		cin>>arr[i];
		sn[arr[i]]++;
	}
	long long ans = 0;
	for(int i = 0; i <= n ;++i){
		long long temp = sn[i]*(sn[i]-1);
		temp/=2;
		ans+=temp;
	}
	for(int i = 0; i < n; ++i){
		long long tmp = ans;
		long long torem = sn[arr[i]]*(sn[arr[i]]-1);
		torem/=2;
		tmp-=torem;
		long long toadd = (sn[arr[i]]-1)*(sn[arr[i]]-2);
		toadd/=2;
		tmp+=toadd;
		cout<<tmp<<"\n";
	}
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e6 + 10, mod = 1e9 + 7;

ll pw(ll a, ll b) {
    ll r = 1;
    for( ; b ; b >>= 1, a = a * a % mod) {
        if(b & 1) {
            r = r * a % mod;
        }
    }
    return r;
}
ll fac[N], invfac[N];
void init(int n) {
    fac[0] = invfac[0] = 1;
    for(int i = 1 ; i <= n ; ++ i) {
        fac[i] = fac[i - 1] * i % mod;
    }
    invfac[n] = pw(fac[n], mod - 2);
    for(int i = n - 1 ; i ; -- i) {
        invfac[i] = invfac[i + 1] * (i + 1) % mod;
    }
}
ll C(int n, int m) {
    return n < m || m < 0 ? 0 : fac[n] * invfac[m] % mod * invfac[n - m] % mod;
}

int n, k;
ll f[2010][2010];
void upd(ll &x, ll y) {
    x = (x + y) % mod;
}

int main() {
    init(N - 1);
    scanf("%d%d", &n, &k);
    if(! -- k) {
        puts("1");
    } else {
        f[0][0] = 1;
        for(int i = 0 ; i <= n ; ++ i) {
            for(int j = i ; j <= n ; ++ j) {
                if(j) {
                    if(i - 1 >= 0) {
                        upd(f[i][j], f[i - 1][j]);
                    }
                    upd(f[i][j], f[i][j - 1] * C(i + (j - 1) * k + k - 1, k - 1) % mod);
                }
            }
        }
        printf("%lld\n", f[n][n] * fac[n] % mod);
    }
}


Measured memory_bytes: 109952
#include <stdio.h>

int main(void)
{
  int n, d;
  scanf("%d%d", &n, &d);
  int width = 1 + 2 * d;
  int count = 1;
  while(n > width) {
    n -= width;
    count++;
  }
  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#define FUP(i,x,y) for(int i=(x);i<=(y);i++)
#define FDW(i,x,y) for(int i=(x);i>=(y);i--)
#define MAXN 110
#define INF 0x7fffffff
#define MOD 1000000007
#define ll long long
#define db double
using namespace std;
int read(){
    int w=0,flg=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')flg=-1;ch=getchar();}
    while(ch<='9'&&ch>='0'){w=w*10-'0'+ch,ch=getchar();}
    return w*flg;
}
int max(int x,int y){return x>y?x:y;}
int min(int x,int y){return x<y?x:y;}
int abs(int x){return x<0?(-x):x;}
char s[MAXN];
int len,ans;
int main(){
	scanf("%s",s+1);
	len=strlen(s+1);
	FUP(i,1,len/2)
	{
		if(s[i]!=s[len-i+1])
		{
			ans++;
		}
	}
	printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
const int MAXN=1e5+5;
vector<int>g[MAXN];
int dist[2][MAXN],id;
void dfs(int idx,int par=-1){
	if(~par)dist[id][idx]=dist[id][par]+1;
	for(auto &to:g[idx])if(to!=par)dfs(to,idx);
}
int main(){
	cin>>n;
	for(int i=0;i<n-1;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}
	id=0;
	dfs(0);
	id=1;
	dfs(n-1);
	int ret=0;
	for(int i=0;i<n;i++){
		if(dist[0][i]<=dist[1][i])ret++;
	}
	if(2*ret>n)cout<<"Fennec";
	else cout<<"Snuke";
	return 0;
}

Measured memory_bytes: 11136
#!/usr/bin/env python3
import sys
from collections import Counter

def comb(n, k):
    if n <= 1:
        return 0
    ans = 1
    for i in range(1, k + 1):
        ans = (ans * (n + 1 - i) // i)
    return ans

def solve(N: int, A: "List[int]"):
    counter = dict(Counter(A))

    MAX = 0
    for _,value in counter.items():
        MAX += comb(value,2)

    for i in range(N):
        value = counter[A[i]]

        print(MAX-comb(value,2)+comb(value-1,2))



    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 37620
from sys import exit
s=input()
x,y=map(int,input().split())

def groupby(a):
    a2=[[a[0],1]]
    for i in range(1,len(a)):
        if a2[-1][0]==a[i]:
            a2[-1][1]+=1
        else:
            a2.append([a[i],1])
    return a2
s=groupby(s)
a,b=[],[]
turn=True
#初めまっすぐの場合
if s[0][0]=="F":
    x-=s[0][1]
    s.pop(0)
for i in s:
    if i[0]=="F":
        if turn:
            a.append(i[1])
        else:
            b.append(i[1])
    elif i[1]%2==1:
        turn=not turn
a.sort(reverse=True)
b.sort(reverse=True)
for i in a:
    x=abs(x)-abs(i)
if x!=0:
    print("No")
    exit()
for i in b:
    y=abs(y)-abs(i)
if y!=0:
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 41072
#include<stdio.h>
 
int main(void){
	int i;
	char a[3];

	for(i=0;i<3;i++){
	scanf("%c",&a[i]);
	}
 
 
	if(a[0] == a[2])printf("Yes\n");
	else printf("No\n");
	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main() {
	int n;
	int result = 0;

	scanf("%d", &n);

	int i_flag, j_flag, k_flag;
	for (int cor = 1; cor <= n; cor++)
	{
		result = 0;
		i_flag = 0, j_flag = 0, k_flag = 0;
		for (int i = 1; i_flag == 0; i++)
		{
			j_flag = 0;
			for (int j = 1; j_flag == 0; j++)
			{
				k_flag = 0;
				for (int k = 1; k_flag == 0; k++)
				{
					int cal = i * i + j * j + k * k + i * j + j * k + k * i;
					if (cal == cor) {
						result += 1;
					}
					else if (cal > cor) {
						k_flag = 1;
						if (k == 1) {
							j_flag = 1;
							if (j == 1) {
								i_flag = 1;
								printf("%d\n", result);
							}
						}
					}
				}
			}
		}
	}

	return 0;
}

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

#define ll long long int
#define endl "\n"
#define mod 1000000007


int main()
{

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	{
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	}
#endif
	ll x, cnt = 0, a = 100;
	cin >> x;
	while (a < x) {
		a = a + (a / 100);
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3648
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M, X[int(1e5 + 5)];
int Count[int(1e5 + 5)], Same[int(1e5 + 5)];

int main(){
  scanf("%d%d", &N, &M);
  for (int i = 0; i < N; i++) scanf("%d", X + i);
  sort(X, X + N);

  int cnt = 1;
  for (int i = 0; i < N; i++){
    if (X[i] == X[i + 1]){
      cnt++;
      continue;
    }
    Count[X[i] % M] += cnt;
    Same[X[i] % M] += cnt / 2;
    cnt = 1;
  }

  int ans = Count[0] / 2;
  if (M % 2 == 0) ans += Count[M / 2] / 2;

  for (int i = 1; i < (M + 1) / 2; i++){
    int now = min(Count[i], Count[M - i]);
    Count[i] -= now; Count[M - i] -= now;
    now += min(Same[i], Count[i] / 2);
    now += min(Same[M - i], Count[M - i] / 2);
    ans += now;
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 4916
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi

MOD = 998244353
INF = 10 ** 18
SIZE = 10 ** 6

g1, g2, inv = [1, 1], [1, 1], [0, 1]
for i in range(2, SIZE + 1):
    g1.append((g1[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    g2.append((g2[-1] * inv[-1]) % MOD)
    
def comb(n, r):
    if r < 0 or r > n:
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % MOD

N, M, K = map(int, input().split())

ans = 0
for k in range(K + 1):
    ans = (ans + M * pow(M - 1, N - k - 1, MOD) * comb(N - 1, k)) % MOD
print(ans)

Measured memory_bytes: 216592
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define FORq(i, m, n) for(int i = m;i <= n;i++)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define PRINTD(n) printf("%d\n",n)
#define DEBUG printf("%s\n","debug")
using namespace std;
//////////////////////////////////////////////////////
const int MAX = 1002;
const int p = 1000000007;
bool prime[MAX];
bool dic[MAX];

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
    map<int,int>f;
    int N;
    SCD(N);
    int a[MAX] = {};
    int i = 2;
    
    FORq(j,2,N){
        int n = j;
        
        while(i<=n){
            if (!IsPrime(i)){
                i++;
                continue;
            }
        
            if ((n%i) == 0){
                a[i] = (a[i] + 1) % p;
                n = n/i;
                continue;
            }else{
                i++;
                continue;
            }
        }
        i = 2;
    }
    
    long long ans = 1;
    
    REP(i,MAX){
        ans = (ans * ((1 + a[i]) % p)) % p;
    }
    
    PRINTD(ans);
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int a = sc.nextInt();
      	int b = sc.nextInt();
      	int c = sc.nextInt();
      	int d = sc.nextInt();
      	
      	String res = "No";
      	
      	if (a + b == c + d) {
      		res = "Balanced";
      	} else if (a + b > c + d) {
      		res = "Left";
      	} else {
      		res = "Right";
      	}
      	
        System.out.println(res);
		
	}
	
	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: 21076
#include<stdio.h>
#define m 100001

int main(void)
{
	int g[m];
	int num = 0;
	int h, n;
	scanf("%d", &h);
	scanf("%d", &n);

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

	for (int i = 0; i < n; i++)
	{
		num += g[i];
	}

	if (num >= h) printf("Yes");
	else
		printf("No");

	return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    ll x;
    ll a = 100;
    cin >> x;
    int ans = 0;
    while(a < x) {
        a += a * 0.01;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, k;
    cin >> a >> b >> k;

    rep(i, k) {
        if (i % 2 == 0) {
            if (a % 2 == 1) a--;
            b += a / 2;
            a /= 2;
        } else {
            if (b % 2 == 1) b--;
            a += b / 2;
            b /= 2;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}



Measured memory_bytes: 256