akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

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

template <class T>
using vec = vector<T>;
template <class T>
using vec2 = vector<vec<T>>;
template <class T>
using vec3 = vector<vec2<T>>;

constexpr int INF = numeric_limits<int>::max();
constexpr ll INFL = numeric_limits<ll>::max();
//constexpr ll MOD = 1000000007; // 10^9+7
constexpr ll MOD = 998244353;

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

template <class T>
bool chmax(T &a, const T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

ll H, W, K;
vec2<int> C;

int popcount(int n)
{
    int cnt = 0;
    while (n > 0)
    {
        if (n % 2 == 1)
            cnt++;
        n /= 2;
    }
    return cnt;
}

int rec(int ycut)
{
    // cerr << "ycut = " << ycut << endl;
    int ret = 0;
    const int pop = popcount(ycut);
    const int N = pop + 1;
    vec<int> sum(N);
    rep(x, W)
    {
        // cout << "\tx = " << x << endl;
        /*
        cout << "\t\tsum = ";
        rep(i, N)
        {
            cout << sum[i] << ", ";
        }
        cout << endl;
        */
        vec<int> add(N);
        int push = 0;
        rep(y, H)
        {
            add[push] += C[y][x];
            if ((ycut & (1 << y)) >= 1)
            {
                push++;
            }
            assert(N >= push);
        }
        /*
        cout << "\t\tadd = ";
        rep(i, N)
        {
            cout << add[i] << ", ";
        }
        cout << endl;
        */

        bool able = true;
        rep(i, N)
        {
            if (add[i] > K)
            {
                return INF;
            }
            else if (add[i] + sum[i] > K)
            {
                able = false;
            }
        }
        // cout << "\t\table = " << able << endl;

        if (able)
        {
            rep(i, N)
            {
                sum[i] += add[i];
            }
        }
        else
        {
            rep(i, N)
            {
                sum[i] = add[i];
            }
            ret++;
        }
    }
    // cerr << "\t" << ret << "+" << pop << "=" << ret + pop << endl;
    return ret + pop;
}

int solve()
{
    int min = INF;
    rep(ycut, 2 << (H - 1))
    {
        chmin(min, rec(ycut));
    }
    return min;
}

int main()
{
    cin >> H >> W >> K;
    C.resize(H, vec<int>(W));
    rep(y, H)
    {
        string s;
        cin >> s;
        rep(x, W)
        {
            C[y][x] = (s[x] == '0' ? 0 : 1);
        }
    }
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 3664
// Aizu Vol-0 0097: Sum of Integers II
// 2017.9.1 bal4u@uu

#include <stdio.h>

long long p[10][101][902];

int main()
{
	int n, s;
	int i, j, k, min, max;
	long long ans;

	for (i = 0; i <= 100; i++) p[1][i][i] = 1;
	for (min = 0, max = 100, n = 1; n < 9; n++, min++, max+=100)
		for (i = 0; i <= 100; i++)
			for (j = min; j <= max; j++)
				for (k = 1; k + i <= 100; k++) p[n+1][i+k][j+i+k] += p[n][i][j];

	while (scanf("%d%d", &n, &s) && n) {
		if (s > 864) puts("0");
		else {
			for (ans = i = 0; i <= 100; i++) ans += p[n][i][s];
			printf("%lld\n", ans);
		}
	}
	return 0;
}

Measured memory_bytes: 6508
def B():
    S = input()
    helyx_str = 'ATGC'
    cnt = 0
    max_cnt = 0
    for a in S:
        h = helyx_str.find(a) 
        if h != -1:
            cnt += 1
            if max_cnt < cnt:
               max_cnt = cnt
        else:
            if max_cnt < cnt:
               max_cnt = cnt
            cnt = 0

    print(max_cnt)

if __name__ == '__main__':
    B()

Measured memory_bytes: 2940
n = int(input())
a_arr = list(map(int,input().split()))
b_arr = list(map(int,input().split()))
cnt = 0
for i in range(n):
    tmp = min(a_arr[i],b_arr[i])
    cnt += tmp
    a_arr[i] -= tmp
    cnt += min(b_arr[i]-tmp,a_arr[i+1])
    a_arr[i+1] -= min(b_arr[i]-tmp,a_arr[i+1])
print(cnt)

Measured memory_bytes: 18476
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main() {
	int i,n;
	double a,sum,squ,s;
	while (cin>>n) {
		if (n == 0)break;
		sum = 0; squ = 0;
		for (i = 0; i < n; i++) {
			cin >> a;
			squ += pow(a, 2);
			sum += a;
		}
		s = sqrt(squ / n - pow(sum / n, 2));
		cout << fixed << setprecision(6) << s << endl;
	}
	return 0;
}


Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const ll mod=(1e9)+7;
const int maxn=(1e5)+10;
int n,k;
ll a[maxn],ans;
ll ksm(ll x,ll y) {
	ll res=1;
	while (y) {
		if (y&1) res=res*x%mod;
		x=x*x%mod; y>>=1;
	} return res;
}
int main() {
	//freopen("1.txt","r",stdin);
	int cnt;
	read(n); read(k);
	for (int i=1;i<=k;i++) {
		cnt=0;
		for (int j=i;j<=k;j+=i) cnt++;
		a[i]=ksm(cnt,n);
	}
	for (int i=k;i>=1;i--) {
		for (int j=i*2;j<=k;j+=i) a[i]=(a[i]-a[j]+mod)%mod;
		ans=(ans+a[i]*i)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 4540
#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(){
    int x;
    cin >> x;
    if(x==3 or x==5 or x==7){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3592
while True:
    try:
        inp = map(str, raw_input().split())
        s = []
        for i in inp:
            if   i == "+": s.append( s.pop(-2) + s.pop(-1) )
            elif i == "-": s.append( s.pop(-2) - s.pop(-1) )
            elif i == "*": s.append( s.pop(-2) * s.pop(-1) )
            elif i == "/": s.append( s.pop(-2) / s.pop(-1) )
            else: s.append(float(i))
        print s[0]
    except:
        break

Measured memory_bytes: 4248
#include <iostream>
#include <string>
#include <stdio.h>
int main()
{
    std::string input;
    std::string output;
    std::cin >> input;
    int temp;
    while (1) {
        temp = getchar();
        if (temp == '\n') {
            break;
        }
        input += temp;
    }

    output = input;

    for (int i = 0; i < input.length(); i++) {
        if (97 <= input[i] && input[i] <= 122) {
            output[i] = input[i] - 32;
        } else if (65 <= input[i] && input[i] <= 90) {
            output[i] = input[i] + 32;
        } else {
            output[i] = input[i];
        }
    }
    std::cout << output;
    std::cout << std::endl;
}



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

using namespace std;

#define ll             long long 
#define mod            1000000007
#define FIO            ios_base::sync_with_stdio(false); cin.tie(NULL);
                  
void initial()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
}


int main() 	 	
{
	initial();
	FIO;

	long double r;
	cin>>r;

	long double circum = 2*3.14*r;

	cout<<fixed<<setprecision(20)<<circum<<endl;
}



Measured memory_bytes: 3800
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <queue>
#include <utility>
#include <tuple>
#include <climits>
using namespace std;
using Int = long long;

int main()
{
    int N, A; cin >> N >> A;
    cout << N * N - A << endl;
    return 0;
}

Measured memory_bytes: 256
/* 
 * Author: aps
 * Time: 2019-08-01 18:15:37
**/
#include<bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
 
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
const ll inf = 1e18;
const ll mod = 1e9+7;
 
inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x;}
inline ll sub(ll x, ll y) { x -= y; if (x < 0) x += mod; return x;}
inline ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod;}
inline ll power(ll a, ll b) {
    ll x = 1;
    while (b) {
        if (b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline ll inv(ll a) { return power(a, mod - 2);}

const int N = 1e5+5;

vi g[N];
ll cnt[N], ans[N], answer=1L;

ll n,k;

void dfs(int u, int par){
    ll val = 1LL;
    if(u == 1) val = 0LL;

    ans[u] = max(0LL,k - val - cnt[par]);

    cnt[u] = 1LL;
    if(u == 1) cnt[u] = 0LL;

    for(int v: g[u]){
        if(v != par){
            dfs(v,u);
            cnt[u] += 1LL;
        }
    }
}

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

    cin >> n >> k;
    for(int i=0;i<n-1;i++){
        int u,v; cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }

    cnt[0] = 0;
    dfs(1,0);

    answer = 1LL;

    for(int i=1;i<=n;i++) {
        answer = mul(answer,ans[i]);
    }

    cout << answer << endl;

    return 0;
}


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


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

    int a;
    string s;

    cin >> a >> s;

    if (a >= 3200){
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }


}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


class UnionFind:
    def __init__(self, size):
        self.table = [-1 for _ in range(size)]

    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False

    def subsetall(self):
        a = []
        for i in range(len(self.table)):
            if self.table[i] < 0:
                a.append((i, -self.table[i]))
        return a

def main():
    n,m = LI()
    p = LI_()
    a = [LI_() for _ in range(m)]
    uf = UnionFind(n)
    for x,y in a:
        uf.union(x,y)
    r = 0
    for i in range(n):
        if uf.find(i) == uf.find(p[i]):
            r += 1

    return r



print(main())


Measured memory_bytes: 28868
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<int, int> > vec;
    for (int i = 1; i <= m; i++) {
        int a, b;
        cin >> a >> b;
        vec.push_back(make_pair(b, a));
    }
    sort(vec.begin(), vec.end());
    int recent_broken_bridge = 0; //橋の左の頂点を持つ
    int ret = 0;
    for (int i = 0; i < vec.size(); i++) {
        if (vec[i].second <= recent_broken_bridge) {
            ;
        }
        else {
            ret++;
            recent_broken_bridge = vec[i].first - 1;
        }
    }
    cout << ret << endl;
    return 0;
}

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

int main()
{
  int n, m;
  int ans;
  int now;

  cin >> n >> m;
  now = ans = m;

  for(int i=0; i<n; i++) {
    int a, b;
    cin >> a >> b;
    now += (a - b);
    if( now < 0 ) {
      cout << '0' << endl;
      return 0;
    }
    else ans = max(ans, now);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1160
S = list(str(input()))
T = list(str(input()))

dic_s = dict()
dic_t = dict()

for ind, s in enumerate(S):
    if dic_s.get(s) is None:
        dic_s[s] = {ind}
    else:
        dic_s[s].add(ind)
for ind, t in enumerate(T):
    if dic_t.get(t) is None:
        dic_t[t] = {ind}
    else:
        dic_t[t].add(ind)

ans = 1
for s_key in dic_s:
    for t_key in dic_t:
        if dic_s[s_key] == dic_t[t_key]:
            break
    else:
        ans = 0
if ans:
    print("Yes")
else:
    print("No")

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


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	int N, K;
	cin >> N >> K;

	cout << !(N % K == 0) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b;
    char op;
    while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op=='+'){
        printf("%d\n",a+b);
    }else if(op=='-'){
        printf("%d\n",a-b);
    }else if(op=='*'){
        printf("%d\n",a*b);
    }else if(op=='/'){
        printf("%d\n",a/b);
    }else{
        break;
    }
    }
    return 0;
}

Measured memory_bytes: 600
fun main(args: Array<String>)
{
    val (l, r)  =readNInts()

    if (r - l + 1 > 2019)
    {
        println(0)
    }
    else
    {
        var ans = 10000L
        for (i in l until r) {
            for (k in i+1..r) {
                val rem = (i * k) % 2019
                ans = if (ans > rem) rem else ans
            }
        }

        println(ans)
    }
}


// Read an integer
// Usage: val a = readInt()
private fun readInt() = readLine()!!.toInt()

// Read N integers separated by " "
// Usage: val (a, b, c) = readNInts()
private fun readNInts() = readLine()!!.split(" ").map(String::toLong)

// Read a string
// Usage: val a = readString()
private fun readString() = readLine()!!


Measured memory_bytes: 37752
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
int n;
ll MOD,c[3005][3005],f[3005][3005],pw2[3005];
ll quick_pow(ll x,ll a)
{
	ll ans=1;
	while(a)
	{
		if(a&1)ans=ans*x%MOD;
		x=x*x%MOD;
		a>>=1;
	}
	return ans;
}
int main()
{
	scanf("%d%lld",&n,&MOD);
	c[0][0]=1;
	for(int i=0;i<=n;i++)
	for(int j=0;j<=i;j++)
	{
		if(c[i][j]>=MOD)c[i][j]-=MOD;
		c[i+1][j+1]+=c[i][j];
		c[i+1][j]+=c[i][j];
	}
	pw2[0]=1;
	for(int i=1;i<=n;i++)pw2[i]=pw2[i-1]*2%(MOD-1);
	f[0][0]=1;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			f[i+1][j+1]=(f[i+1][j+1]+f[i][j])%MOD;
			f[i+1][j]=(f[i+1][j]+f[i][j]*(j+1))%MOD;
		}
	}
	ll ans=0;
	for(int i=0;i<=n;i++)
	{
		ll s=0,pw=quick_pow(2,n-i),v=1;
		for(int j=0;j<=i;j++,v=v*pw%MOD)s=(s+v*f[i][j])%MOD;
		if(i&1)ans-=c[n][i]*quick_pow(2,pw2[n-i])%MOD*s%MOD;
		else ans+=c[n][i]*quick_pow(2,pw2[n-i])%MOD*s%MOD;
	}
	ans%=MOD;
	if(ans<0)ans+=MOD;
	printf("%lld\n",ans);
	return 0;
}

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

import static java.lang.Integer.parseInt;

/**
 * Alphametic
 */
public class Main {

	static int[][] nums;
	static boolean[] used;

	static int[][] layout = {
			{0, 2},
			{1, 1}, {1, 2},
			{2, 0}, {2, 1}, {2, 2},
			{3, 0}, {3, 1}, {3, 2},
	};

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		words = br.readLine().split(" ");

		nums = new int[4][3];
		used = new boolean[10];
		int count = 0;

		for (int i = 0; i < words.length; i++) {
			int n = parseInt(words[i]);
			if (n != -1) used[n] = true;
			else count++;
			nums[layout[i][0]][layout[i][1]] = n;
		}

		System.out.println(solve(count));
	}

	static int solve(int c) {

		if (c == 0) {
			if (check()) return 1;
			else return 0;
		}

		//
		int ret = 0;

		outer:
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 3; j++) {
				if (nums[i][j] == -1) {
					for (int k = 1; k <= 9; k++) {
						if (!used[k]) {
							nums[i][j] = k;
							used[k] = true;
							ret += solve(c - 1);
							nums[i][j] = -1;
							used[k] = false;
						}
					}
					break outer;
				}
			}
		}

		return ret;
	}

	static boolean check() {
		
		int[] a = new int[4];
		
		for (int i = 0; i < 4; i++) {
			a[i] = nums[i][0] * 100 + nums[i][1] * 10 + nums[i][2];
		}
		
		return a[0] + a[1] + a[2] == a[3];
	}
}

Measured memory_bytes: 37888
#include<bits/stdc++.h>
using namespace std;
int a[10005][2];
string s[10005];
int main(){
	int n;
	cin>>n;
	int sum_1=0,sum_2=0,sum_3=0; 
	long long cnt = 0;
	for(int i=0;i<n;i++){
		cin>>s[i];
		for(int j=0;j<s[i].length()-1;j++)
			if(s[i][j]=='A'&&s[i][j+1]=='B')
				cnt++;
		if(s[i][0]=='B'&&s[i][s[i].length()-1]=='A')
			sum_3++;
		else if(s[i][0]=='B')
			sum_1++;
		else if(s[i][s[i].length()-1]=='A')
			sum_2++;
	}
	if(sum_2==0){
		if(sum_1>=1){
			cout<<cnt+sum_3<<endl;
		}
		else if(sum_3>=1)
			cout<<cnt+sum_3-1<<endl;
		else 
			cout<<cnt<<endl;
	}
	else {
		cout<<cnt+sum_3+min(sum_1,sum_2)<<endl; 
	}
} 

Measured memory_bytes: 768
mod=10**9+7
N=int(input())

#  ACG
#  AGC
#  GAC
#
# A?GC
#  AG?C
#         A  T  G  C
#            G  G
#            G  T

A=0
C=1
G=2
T=3
dp = [[[[0 for i4 in range(4)] for i3 in range(4)] for i2 in range(4)] for i in range(N+10)]
dp[0][T][T][T] = 1

for i1 in range(1,N+1):
    for i2 in range(4):
        for i3 in range(4):
            for i4 in range(4):
                for i5 in range(4):
                    if i3==A and i4==C and i5==G: continue
                    if i3==A and i4==G and i5==C: continue
                    if i3==G and i4==A and i5==C: continue
                    if i2==A and i4==G and i5==C: continue
                    if i2==A and i3==G and i5==C: continue
                    dp[i1][i3][i4][i5] += dp[i1-1][i2][i3][i4]

ans=0
for i1 in range(4):
    for i2 in range(4):
        ans += sum(dp[N][i1][i2])

print(ans % mod)


Measured memory_bytes: 48624
#include <bits/stdc++.h>
using namespace std;
typedef long long in;
typedef pair<in,in> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (in)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(in i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

int main(){
    IOS;
    in ans = 0;
    string s;
    cin >> s;
    rep(i,0,1<<(sz(s)-1)){
        string r = "";
        r+=s[0];
        rep(j,1,sz(s)){
            if(i & (1<<j-1)){
                ans+=stoll(r);
                r = "";
            }
            r += s[j];
        }
        if(r != ""){
            ans+=stoll(r);
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using  namespace std;
#define ll long long
#define sc second
#define fr first
#define mp make_pair
const int N = 300000 + 10, MOD = 1e9 + 7;
const int OO = 1e9 + 5000;
int main() {
	int a, b;
	cin >> a >> b;
	cout << max({ a*b,a + b,a - b });

}

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

int main()
{
    int x, y;
    cin>>x>>y;

    if((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12))
        cout<<"Yes";
    else if((x == 4 || x == 6 || x == 9 || x == 11) && (y == 4 || y == 6 || y == 9 || y == 11))
        cout<<"Yes";
    else if(x == 2 && y == 2)
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

void main() {
    int N;
    scan(N);
    auto a = readln.split.to!(int[]).sort();
    auto b = readln.split.to!(int[]).sort();
    auto c = readln.split.to!(int[]).sort();

    long ans;
    int lw = 0, up = 0;

    foreach (bi ; b) {
        while (lw < N && a[lw] < bi) lw++;
        while (up < N && c[up] <= bi) up++;
        ans += 1L * lw * (N - up);
    }

    writeln(ans);
}









void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 11260
#include<stdio.h>
#include<stdlib.h>
 
int main(void) {
	int a, b;
 
	scanf("%d %d", &a, &b);
 
	switch ((a * b) % 2) {
	case 0:
		printf("Even\n");
		break;
	default:
		printf("Odd\n");
		break;
	}
 
	return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc084_d.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

unordered_map<int, int> sieve(int N) {
  vector<bool> e(N + 1, true);
  e[0] = false;
  e[1] = false;
  int sqrtN = ceil(sqrt(N)) + 1;
  rep(p, sqrtN) {
    if (!e[p]) continue;
    for (int i = pow(p, 2); i <= N; i += p) {
      e[i] = false;
    }
  }
  unordered_map<int, int> ret;
  rep(i, N + 1) {
    if (e[i]) ret.emplace(i, 1);
  }
  return ret;
}

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<int> l(N), r(N);
  rep(i, N) { cin >> l[i] >> r[i]; }

  int MAX = 1e5;
  unordered_map<int, int> primes = sieve(MAX);
  vector<int> c(MAX, 0);
  for (int i = 3; i <= MAX; i += 2) {
    c[i] = c[i - 2];
    if (primes[i] && primes[(i + 1) / 2]) c[i]++;
  }

  rep(i, N) { cout << c[r[i]] - c[l[i] - 2] << endl; }
}

Measured memory_bytes: 6432
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] student = new int[n+1];
        
        for(int i=1;i<=n;i++){
            int a= scanner.nextInt();
            student[a]=i;
            
        }
        
        for (int i=1;i<=n;i++){
            System.out.println(student[i]);
        }
        
    }
}

Measured memory_bytes: 66748
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define space putchar(' ')
#define enter putchar('\n')
#define mp make_pair
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {putchar('-');x = -x;}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
int64 A[100005],ans;

int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    read(N);
    for(int i = 1 ; i <= N ; ++i) read(A[i]);
    for(int i = 1 ; i <= N + 1; ++i) {
	ans += abs(A[i] - A[i - 1]);
    }
    for(int i = 1 ; i <= N ; ++i) {
	int64 tmp = ans;
	tmp -= abs(A[i] - A[i - 1]) + abs(A[i] - A[i + 1]);
	tmp += abs(A[i - 1] - A[i + 1]);
	out(tmp);enter;
    }
}


Measured memory_bytes: 2048
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
#include <algorithm>
//#include <vector> 

int main(int argc, char* argv[])
{
	long n;
    scanf("%ld", &n);

    long flag0=0, flag1=0;
    long x[1000] = {0};
    long y[1000] = {0};
	long i;
	for(i=0; i<n; i++) {
        scanf("%ld %ld", &(x[i]), &(y[i]));
        if(abs(x[i]+y[i])%2==0) {
            flag0=1;
        }
        else {
            flag1=1;
        }
	}
    if(flag0 && flag1) {
        printf("-1\n");
        return 0;
    }

    long d[32]={0};
    d[30] = d[31] = 1;
    for(i=29; i>=0; i--) {
        d[i] = d[i+1] * 2;
    }
    long m = (flag1)? 31: 32;

    printf("%d\n", m);
    for(i=0; i<m; i++) {
        printf("%d", d[i]);
        if(i<m-1) {
            printf(" ");
        }
    }
    printf("\n");

    for(i=0; i<n; i++) {
        long j;
        for(j=0; j<m; j++) {
            if( abs(x[i]) >= abs(y[i]) ) {
                if(x[i]>=0) {
                    printf("R");
                    x[i] -= d[j];
                }
                else{
                    printf("L");
                    x[i] += d[j];
                }
            }
            else {
                if(y[i]>0) {
                    printf("U");
                    y[i] -= d[j];
                }
                else{
                    printf("D");
                    y[i] += d[j];
                }
            }
        }
        printf("\n");
        //printf("%d %d\n", x[i], y[i]);
    }

    return 0;
}


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

int main() {
	ll n; cin >> n;
	vector<ll> a(n+1);
	a[0] = -1;
	for(ll i=1; i<=n; i++) cin >> a[i];

	vector<ll> b(n+1);
	b[0] = -1;
	for(ll i=n; i>=n/2+1; i--) b[i] = a[i];

	for(ll i=n/2; i>=1; i--) {
		int g = 2, t = 0;
		ll j = i;
		while(1) {
			ll h = j * g;
			if(h > n) break;
			if(b[h] == 1) t++;
			g++;
		}
		if(t % 2 == a[i]) b[i] = 0;
		else b[i] = 1;
	}

	ll count = 0;
	for(ll i = 1; i<=n; i++) {
		if(b[i] == 1) count++;
	}
	cout << count << endl;
	for(ll i = 1; i<=n; i++) {
		if(b[i] == 1) cout << i << endl;
	}
}

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

int N;
int ans=0;

void dfs(int x,int keta,int three,int five,int seven){
	if(three+five+seven==3 && x<=N)ans++;
	if(keta<9){
		dfs(x*10+3,keta+1,1,five,seven);
		dfs(x*10+5,keta+1,three,1,seven);
		dfs(x*10+7,keta+1,three,five,1);
	}
}

int main(){
	cin >> N;
	dfs(3,1,1,0,0);
	dfs(5,1,0,1,0);
	dfs(7,1,0,0,1);
	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

#ifdef _LOCAL
struct Tester {
    Tester() { freopen("sample.in", "r", stdin); }
    ~Tester() { fprintf(stderr, "\nTime: %d ms\n", int(1000.0 * clock() / CLOCKS_PER_SEC)); }
} _tester;
#endif

const int INF = 0x3F3F3F3F;
const LL INFLL = 0x3F3F3F3F3F3F3F3FLL;
const int N = 2550;

map<vector<int>, LL> mp;

int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        string s;
        cin >> s;
        vector<int> v(26);
        for (char ch : s) {
            v[ch - 'a']++;
        }
        mp[v]++;
    }
    LL ans = 0;
    for (auto val : mp) {
        ans += val.second * (val.second - 1) / 2;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 18944
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;

int main() {
//	cout << fixed << setprecision(15);
    int n, m;
    cin >> n >> m;
    vi h(n);
    rep(i, n) cin >> h[i];

    vvi g(n, vi(0));
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vpii p(n);
    rep(i, n) p[i] = make_pair(h[i], i);
    sort(p.begin(), p.end(), greater<pii>());
//    rep(i, n) cout << p[i].first << ' ' << p[i].second << endl;
    int ans = 0;
    vector<bool> visited(n, false);
    rep(i, n) {
        int pos = p[i].second;
        if(visited[pos]) continue;
        visited[pos] = true;
        bool ok = true;
        for(auto j: g[pos]) {
//            cout << "test" << pos << ' ' << j << endl;
//            cout << p[i].first << ' ' << p[j].first << endl;
            visited[j] = true;
            if(h[pos] <= h[j]) ok = false;
        }
//        cout << "ok" << pos << ' ' << ok << endl;
        if(ok) ans++;
    }
    cout << ans << endl;
}


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

// エラトステネスの櫛を使って、最小公約数の一覧を求める
vector<int> sieve_of_eratosthenes(int lim) {
  vector<int> d(lim+1);

  // d[i] = i で初期化する
  for (int i = 0; i <= lim; i++) {
    d.at(i) = i;
  }

  // 素数の場合は、そのままである
  // 素数ではない場合は、最小の公約数がセットされる
  // 例
  //    6 = 2 * 3 より d[6] = 2
  //   35 = 5 * 7 より d[35] = 5
  for (int i=2; i <= sqrt(lim); i++) {
    // 素数の場合、
    if (d.at(i) == i) {
      // i=2 の場合、2より大きい2の倍数について、最小の公約数である 2 をセットする
      // 例
      //   4 : j = i*2 --> j = 2*2 --> j = 4
      //   6 : j = j+i --> j = 4+2 --> j = 6
      //   8 : j = j+i --> j = 6+2 --> j = 8
      for (int j = i*2; j < lim; j=j+i) {
        d.at(j) = i;
      }
    }
  }
  return d;
}

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

  int lim = 1e6;

  // 最小公約数 (least common divisor)
  vector<int> lcd_list = sieve_of_eratosthenes(lim);

  // 入力を受け取り、素因数分解する
  vector<int> prime_factor_cnt(lim+1, 0);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    //
    // a=30 の場合
    //   lcd_list[30] = 2
    //   divisor_cnt[2] をインクリメント
    //   a = 30 / 2 = 15
    //
    //   lcd_list[15] = 3
    //   divisor_cnt[3] をインクリメント
    //   a = 15 / 3 = 5
    //
    //   lcd_list[5] = 5
    //   divisor_cnt[5] をインクリメント
    //   a = 5 / 5 = 1
    //
    // a=30 の場合、素因数である 2,3,5 を1回ずつカウントする
    set<int> s;
    while (a > 1) {
      int divisor = lcd_list.at(a);
      // 素因数はユニークに1度のみカウントする
      // 例えば a=24 は 2*2*2*3 であるが、2 を1回、3を1回カウントする
      if (divisor > 1 && !s.count(divisor)) {
        prime_factor_cnt.at(divisor)++;
        s.insert(divisor);
      }
      a = a / divisor;
    }
  }

  // 各素因数の登場回数が1回以下であれば、pairwise coprime
  bool is_pairwise = true;
  bool is_setwise = true;
  for (int i = 0; i <= lim; i++) {
    if (prime_factor_cnt.at(i) > 1) {
      is_pairwise = false;
    }
    if (prime_factor_cnt.at(i) == n) {
      is_setwise = false;
    }
  }

  if (is_pairwise) {
    cout << "pairwise coprime" << endl;
  } else if (is_setwise) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
  return 0;
}


Measured memory_bytes: 11080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> vec(n);
    rep(i,n){
        cin >> vec[i];
    }
    sort(all(vec));
    ll ans1 = vec[n - 1];
    ll ans2;
    vector<ll> v(n);
    rep(i,n){
        v[i] = abs(ans1 - vec[i] * 2);
    }
    ll min_ans = 1000000000;
    rep(i,n - 1){
        min_ans = min(min_ans, v[i]);
    }
    rep(i,n - 1){
        if (v[i] == min_ans) ans2 = vec[i];
    }
    cout << ans1 << " " << ans2 << endl;
}


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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	ll i, j, n, h, w, k;
	cin >> h >> w >> k;
	vector <vector <bool>> mat (h, vector <bool> (w));
	for (i = 0; i < h; ++i)
	{
		string s;
		cin >> s;
		for (j = 0; j < w; ++j)
			mat[i][j] = (s[j] == '.');
	}
	ll ans = 0;
	for (ll hi = 0; hi < 1 << h; ++hi)
		for (ll wj = 0; wj < 1 << w; ++wj)
		{
			ll cur_k = 0;
			for (i = 0; i < h; ++i)
				for (j = 0; j < w; ++j)
					if ((hi & 1<<i) && (wj & 1<<j) && !mat[i][j])
						++cur_k;
			if (cur_k == k) ++ans;
		}
	cout << ans << '\n';

	return 0;
}



Measured memory_bytes: 3660
#include<stdio.h>

int main(void)
{
	long n,i;
	long sum=0;

	scanf("%ld",&n);

	for(i=1;i<=n;i++){
		if(i%3!=0&&i%5!=0){
			sum+=i;
		}
	}

	printf("%ld\n",sum);

	return 0;
}


Measured memory_bytes: 1692
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>

using namespace std;

typedef long long ll;

int main() {
    ll X, Y;
    cin >> X >> Y;
    
    int ans = 1;
    while (true) {
        X *= 2;
        if (X <= Y)
            ++ans;
        else
            break;
    }
    
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int H, W;
int num;
char c[15][15];
char ans[40];
const int vecj[] = {1, 0, -1, 0}, veci[] = {0, -1, 0, 1};
const char dirc[] = {'R', 'U', 'L', 'D'};

bool dfs(int fi, int fj, int dir, int idx)
{
	int ni, nj, nd;
	if(idx == num) return true;
	
	for(int d = -1; d <= 1; d++){
		ni = fi, nj = fj, nd = (dir+d+4)%4;
		while(1){
			ni += veci[nd], nj += vecj[nd];
			if(ni < 0 || ni >= H || nj < 0 || nj >= W) break;
			if(c[ni][nj] == 'o'){
				c[ni][nj] = '.';
				ans[idx] = dirc[nd];
				if(dfs(ni, nj, nd, idx+1)) return true;;
				c[ni][nj] = 'o';
				break;
			}
		}
	}
	return false;
}

int main(void)
{
	int fi, fj, dir;
	num = 0;
	
	cin >> H >> W;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cin >> c[i][j];
			if(c[i][j] != 'o' && c[i][j] != '.') fi = i, fj = j;
			else if(c[i][j] == 'o') num++;
		}
	}
	
	switch(c[fi][fj]){
	case 'U':
		dir = 1;
		break;
	case 'D':
		dir = 3;
		break;
	case 'L':
		dir = 2;
		break;
	case 'R':
		dir = 0;
		break;
	}
	
	dfs(fi, fj, dir, 0);
	for(int i = 0; i < num; i++) cout << ans[i];
	cout << endl;
	
	return 0;
}

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



int main()
{
	string S;
	cin >> S;
	size_t size = S.length();
	switch (size)
	{
	case 2:
			cout << S << endl;
		break;
		case 3:
			reverse(S.begin(), S.end());
			cout << S << endl;
			break;

	}

    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int f[100001],p[100001],t[100001];
int fa(int a)
{
	if (f[a]!=a) f[a]=fa(f[a]);
	return f[a];
}
int main()
{
	int n,m,a,b,ans=0;
	scanf("%d %d",&n,&m);
	for (int i=1;i<=n;i++)
	{
		f[i]=i;
		scanf("%d",&p[i]);
	}
	while (m--)
	{
		scanf("%d %d",&a,&b);
		f[fa(a)]=fa(b);
	}
	for (int i=1;i<=n;i++) t[p[i]]=fa(i);
	for (int i=1;i<=n;i++) if (f[i]==t[i]) ans++;
	printf("%d",ans);
	return 0;
}

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

int main(void){
    int n;
    cin >> n;
    double sum = 0;
    rep(i,n){
        double a;
        cin >> a;
        sum += 1.0/a;
    }
    printf("%.10f\n", 1.0/sum);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<climits>
#include<string>
#include"math.h"
#include"string.h"

using namespace std;

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


Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
ll h = 0;
vector<ll> a(0);
void maxHeapify(ll i) {
	ll l = 2 * i + 1, r = 2 * i + 2, largest;
	if (l < h && a[l] > a[i]) largest = l;
	else largest = i;
	if (r < h && a[r] > a[largest]) largest = r;

	if (largest != i) {
		swap(a[i], a[largest]);
		maxHeapify(largest);
	}
}
void pushHeap() {
	ll p = h - 1;
	while (p && a[p] > a[(p - 1) / 2]) {
		swap(a[p], a[(p - 1) / 2]);
		p = (p - 1) / 2;
	}
}
int main() {
	while (1) {
		string s;
		cin >> s;
		if (s == "insert") {
			ll k;
			scanf("%lld", &k);
			h++;
			a.push_back(k);
			pushHeap();
		}
		else if (s == "extract") {
			cout << a[0] << endl;
			a[0] = a[a.size() - 1];
			a.pop_back();
			h--;
			maxHeapify(0);
		}
		else break;
	}
}


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

int isprime(int x){
  int i;
  if(x==2){
    return 1;
  }
  if(x<2 || x%2==0){
    return 0;
  }
  i=3;
  while(i<=sqrt(x)){
    if(x%i==0){
      return 0;
    }
    i=i+2;
  }
  return 1;
}


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

int main() {
    int N;
    cin >> N;
    while (N--) {
        string s;
        
        vector<string> v;
        
        v.push_back(".,!? ");
        v.push_back("abc");
        v.push_back("def");
        v.push_back("ghi");
        v.push_back("jkl");
        v.push_back("mno");
        v.push_back("pqrs");
        v.push_back("tuv");
        v.push_back("wxyz");
        
        while (cin >> s) {
            string p;
            char buf = 0;
            int c = 0;
            for (int i = 0; i < s.size(); i++) {
                if (s[i] == '0') {
                    if (buf > 0)
                        p += v[buf - '0' - 1][(c - 1) % v[buf - '0' - 1].size()];
                    buf = 0;
                    c = 0;
                } else {
                    buf = s[i];
                    c++;
                }
            }
            
            cout << p << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3012
import math
n=int(input())

a=[0 for i in range(n)]
b=[0 for j in range(n)]
a=input().split()

bsum=0
c=[]
for i in range(n):
    index=n-i-1
    m=math.floor(n/(index+1))
    sum=0
    for j in range(m-1):
        sum+=b[(index+1)*(j+2)-1]
    b[index]=abs(sum%2-int(a[index]))
    if b[index]==1:
        c.append(index+1)
    bsum+=b[index]

print(bsum)
print(' '.join(map(str, c)))


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

int main(){
    int A, B, C, N, M ,K;
    double sum = 0.0;
    int t = 0;
    string s, s1;
    cin >> N;

    vector<double> x(N);
    vector<string> u(N);
    for(int i = 0; i < N; i++){
        cin >> x.at(i) >> u.at(i);
    }

    for(int i = 0; i < N; i++){
        if(u.at(i).at(0) == 'J') sum += x.at(i);
        else sum += x.at(i)*380000.0;
    }

    cout << sum << endl;
//    vector<int> X();

//    for(int i = 0; i < ; i++){}
//    for(int j = 0; j < ; j++){}

//    cout <<  << endl;
}

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

int main()
{
  int n,k;
  cin>>n>>k;
  string s;
  cin>>s;
  if(s.at(k-1)=='A')
  {
    s.at(k-1)='a';
  }
  else if(s.at(k-1)=='B')
  {
    s.at(k-1)='b';
  }
  else
  {
    s.at(k-1)='c';
  }
  cout<<s<<endl;
}


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

#define Int long long int
#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n)cin >> a[i];
    sort(All(a));
    reverse(All(a));
    int res=0;
    REP(i,n){
        if(!(i%2))res+=a[i];
        else res-=a[i];
    }
    cout << res << endl;
}


Measured memory_bytes: 256
S = input()

cnt = 0

S = S.replace("BC", "X")
S = S.replace("B", " ")
S = S.replace("C", " ")

arr = S.split()

for elem in arr:
    i = 0

    for char in elem:
        if char == "A":
            i += 1
        else:
            cnt += i

print(cnt)


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

using ll=long long;
const ll INF=1e18l+5;

int main(){
    string s;
    cin>>s;
    ll k;
    cin>>k;
    k--;
    int n=s.size();
    vector<vector<ll>> dp(n,vector<ll>(n+1,1));
    vector<vector<ll>> dpl(n,vector<ll>(n+1,1));
    for(int i=0;i<n;i++) dpl[i][i]=0,dpl[i][i+1]=1;
    for(int span=2;span<=n;span++){
        for(int i=0;i+span<=n;i++){
            int j=i+span;
            if(s[i]==s[j-1]) dp[i][j]=dp[i+1][j-1],dpl[i][j]=dpl[i+1][j-1]+2;
            else{
                if(dpl[i+1][j]<dpl[i][j-1]){
                    dpl[i][j]=dpl[i+1][j]+2;
                    dp[i][j]=dp[i+1][j];
                }
                else if(dpl[i+1][j]>dpl[i][j-1]){
                    dpl[i][j]=dpl[i][j-1]+2;
                    dp[i][j]=dp[i][j-1];
                }
                else{
                    dpl[i][j]=dpl[i][j-1]+2;
                    dp[i][j]=min(dp[i][j-1]+dp[i+1][j],INF);
                }
            }
        }
    }
    int i=0,j=n;
    string fr,bk;
    while(j-i>1){
        if(s[i]==s[j-1]){
            fr+=s[i],i=i+1; 
            bk+=s[j-1],j=j-1; 
        }
        else{
            if(dpl[i+1][j]==dpl[i][j-1]){
                if(s[j-1]<s[i]){
                    if(k>=dp[i][j-1]){
                        k-=dp[i][j-1];
                        fr+=s[i],bk+=s[i],i++;
                    }
                    else{
                        fr+=s[j-1],bk+=s[j-1],j=j-1;
                    }
                }
                else{
                    if(k>=dp[i+1][j]){
                        k-=dp[i+1][j];
                        fr+=s[j-1],bk+=s[j-1],j--;
                    }
                    else{
                        fr+=s[i],bk+=s[i],i++;
                    }
                }
            }
            else{
                if(dpl[i+1][j]<dpl[i][j-1]){
                    fr+=s[i],bk+=s[i],i++;
                }   
                else{
                    fr+=s[j-1],bk+=s[j-1],j--;
                }
            }
        }
    }
    if(j-i)  fr+=s[i],i++;
    reverse(bk.begin(),bk.end());
    if(k){
        cout<<"NONE"<<endl;
    }
    else{
        cout<<fr<<bk<<endl;
    }

    return 0;
}


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

int main(){
  int a,n;
  cin >> a >> n;
  int s=0;
  for(int i;i<n;i++){
    int l;
    cin >> l;
    s+=l;
  }
  if(s>=a){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
  return 0;
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input<T:FromStr>() -> T {
  let mut line: String = String::new();
  io::stdin().read_line(&mut line);
  line.trim().parse().ok().unwrap()
}

fn main() {
  let a: i32 = input();
  let s: String = input();
  if a >= 3200 {
    println!("{}", s);
  } else {
    println!("red");
  }
}


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include<string>
#include<cmath>
#include<queue>
using namespace std;

int main()
{
    long long a, b, x;
    cin >> a >> b >> x;
    if(a!=0) cout << (b / x) - ((a - 1) / x) << endl;
    else cout << (b / x) + 1 << endl;
    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, a[55];
  int ans = 0;
  cin>>n;
  for(int i = 1;i <= n;i++) cin>>a[i];
  for(int i = 1;i < n;i++){
  	for(int j = i + 1;j <= n;j++) {
    	ans += a[i] * a[j];
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;


int main() {
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;

    int hap_r = 0, hap_l = 0;
    rep(i, s.size()-1) {
        if (s[i] == 'R' and s[i+1] == 'R') ++ hap_r;
        }
    for(int i=1; i<n; ++i) {
        if (s[i] == 'L' and s[i-1] == 'L') ++ hap_l;
    }
    
    int cnt_lr=0, cnt_rl=0;

    for(int i=0; i<n; ++i) {
        if (s.substr(i, 2) == "LR") cnt_lr++;
        else if (s.substr(i, 2) == "RL") cnt_rl++;
    }

    int hap_add = 0;
    hap_add = min(cnt_rl,k) + min(cnt_lr,k);

    cout << hap_l+hap_r+hap_add << endl;
}



Measured memory_bytes: 512