akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=1e5+5;
int a[N],dir[N],x[N],ans[N];
int32_t main(){
    int n,len,t;
    cin>>n>>len>>t;
    forn(i,n){
        cin>>a[i]>>dir[i];
        if(dir[i]==1)x[i]=(a[i]+t)%len;
        else x[i]=((a[i]-t)%len+len)%len;
    }
    int x0=x[0];
    sort(x,x+n);
    int f=0,s=0;
    forn(i,n){
        if(dir[s]==1&&dir[i]==2){
            int alt=t*2;
            if(a[s]<a[i])alt-=a[i]-a[s];
            else alt-=len-a[s]+a[i];
            if(alt<0)continue;
            int cnt=1+alt/len;
            f+=cnt%n;
        }
        if(dir[s]==2&&dir[i]==1){
            int alt=t*2;
            if(a[s]<a[i])alt-=a[s]-a[i]+len;
            else alt-=a[s]-a[i];
            if(alt<0)continue;
            int cnt=1+alt/len;
            dbg(s,i,cnt);
            f-=cnt%n;
        }
    }
    f=(f%n+n)%n;
    int g=lower_bound(x,x+n,x0)-x;
    if(g<n-1&&x[g+1]==x[g]&&dir[0]==1)g++;
    for(int i=0;i<n;++i,(++f)%=n,(++g)%=n)
        ans[f]=x[g];
    forn(i,n)cout<<ans[i]<<'\n';
    return 0;
}


Measured memory_bytes: 6708
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
int main() {
	int A, B;
	cin >> A >> B;
	if (B%A == 0)cout << A + B << endl;
	else cout << B - A << endl;

	return(0);
}

Measured memory_bytes: 256
N,M=map(int,input().split())

a=list(map(int,input().split()))
a=sorted(a)
a.append(0)
D=[]
for i in range(M):

    d=list(map(int,input().split()))

    D.append(d)

D.sort(key=lambda x:x[1])


k=0

for j in range(M):
    l=k
    for i in range(D[M-j-1][0]):
        q=max(M-j-1,0)
        if D[q][1] > a[k] and k!=N:
            a[k]=D[q][1]
            k=k+1
        else:
            k=k

        if l==k:
            break

    if l==k:
        break



print(sum(a)-a[N])

Measured memory_bytes: 32852
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)


long long M = 1000000007;
vector<vector<vector<double>>> dp;
int n,m;

double solve(int i, int k, int l){
    if(dp[i][k][l]!=-1)return dp[i][k][l];
    double res = 1.0;
    if(i>0)res += solve(i-1,k,l)*(double)i/(double)n;
    if(k>0)res += solve(i+1,k-1,l)*(double)k/(double)n;
    if(l>0)res += solve(i,k+1,l-1)*(double)l/(double)n;
    res *= (double)n/(double)(i+k+l);
    dp[i][k][l] = res;
    return res;
}

int main(int argc, char const *argv[]) {
    cin>>n;
    dp = vector<vector<vector<double>>>(n+1,vector<vector<double>>(n+1,vector<double>(n+1,-1)));
    dp[0][0][0] = 0.0;
    vector<int> a(3,0);
    for(int i=0;i<n;++i){
        int tmp;cin>>tmp;
        a[tmp-1]++;
    }
    cout<<setprecision(50)<<solve(a[0],a[1],a[2])<<endl;
    return 0;
}

Measured memory_bytes: 216960
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define MS1(I) memset(I, -1, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define per1(i, a, b) for(int i = a; i >= b; --i)
#define DRI(A) int A; scanf("%d", &A);
#define DRII(A, B) int A, B; scanf("%d %d", &A, &B);
#define DRIII(A, B, C) int A, B, C; scanf("%d %d %d", &A, &B, &C);
#define MP make_pair 
#define pb push_back
#define F first
#define S second
#define ALL(I) (I).begin(), (I).end()
typedef const void CV;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;	
const int INF = (int)1e9;
const int mod = (int)1e9+7;
const int MAX = (int)5e1+5;
char st[MAX][MAX];
int rr[] = {1, 0, -1, 0};
int cc[] = {0, 1, 0, -1};
int main(void){
	int n, m; scanf("%d %d", &n, &m);
	rep1(i, 1, n+1) scanf("%s", &st[i][1]);
	rep1(i, 1, n+1) rep1(j, 1, m+1){
		if(st[i][j] == '#'){
			bool flag = 0;
			rep(k, 4){
				int r = rr[k] + i;
				int c = cc[k] + j;
				if(st[r][c] == '#'){
					flag = 1; break;
				}
			}
			if(!flag){
				puts("No"); return 0;
			}
		}
	}
	puts("Yes");
	return 0;
}


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

int main() {
    int64_t N, K;
    cin >> N >> K;
    vector<int64_t> A(N);
    for (int64_t i = 0; i < N; i++) {
        cin >> A[i];
        A[i] %= K;
    }

    vector<int64_t> sum(N + 1, 0);
    for (int64_t i = 0; i < N; i++) {
        sum[i + 1] = (sum[i] + A[i]) % K;
    }

    for (int64_t i = 0; i <= N; i++) {
        (sum[i] += N * K - i) %= K;
    }

    int64_t ans = 0;
    //K区間だけを考える
    map<int64_t, int64_t> mp;
    for (int64_t i = 0; i < min(K - 1, N + 1); i++) {
        mp[sum[i]]++;
    }
    for (const auto& p : mp) {
        ans += p.second * (p.second - 1) / 2;
    }

    for (int64_t i = K - 1; i <= N; i++) {
        ans += mp[sum[i]];
        mp[sum[i - K + 1]]--;
        mp[sum[i]]++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 15872
h,w=map(int,input().split())
s=[input() for _ in range(h)]
dp=[[10**9]*w for _ in range(h)]
dp[0][0]=(s[0][0]=='#')+0
for i in range(h):
  for j in range(w):
    a=dp[i-1][j]
    b=dp[i][j-1] 
    if s[i-1][j] == "." and s[i][j] == "#":
      a+=1
    if s[i][j-1] == "." and s[i][j] == "#":
      b+=1
    dp[i][j]=min(a,b,dp[i][j])
print(dp[-1][-1])

Measured memory_bytes: 9288
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef pair<int,int> P;
//typedef pair<LL,LL> PL;

const int MOD=1000000007;
int INF=100100100;
int n,m;
string s;

int next(int x)
{
	int y=x; 
	for(int i=1;i<=min(m,x);i++)
	{
		if(s[x-i]=='0')y=x-i;
	}
	return y;
}
int main(){
	cin>>n>>m;
	cin>>s;
	
	int ima=n;
	vector<int> v;
	v.push_back(ima);
	while(ima>0)
	{
		int po=next(ima);
		if(po==ima)
		{
			cout<<-1<<"\n";
			return 0;
		}
		else
		{
			v.push_back(ima);
			ima=po;
		} 
	}
	v.push_back(0);
	sort(v.begin(),v.end());
	for(int i=0;i<v.size()-2;i++)
	{
		cout<<v[i+1]-v[i]<<" ";
		//cout<<v[i]<<" ";
	}
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a, b, c, d; cin >> a >> b >> c >> d;
    int yoko = c - a, tate = d - b;
    cout << c - tate << " " << d + yoko << " " << a - tate << " " << b + yoko << endl;
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << res << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)


int main() {
	int n;
	cin >> n;
	int save = 1;
	int res = 0;
	FOR(i, 1, n) {
		int a;
		cin >> a;
		if (save == a) {
			save++;
		}
		else {
			res++;
		}
	}
	if (res == n) {
		ps(-1);
	}
	else {
		pv(res)
	}
	return(0);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();

            if(str == "a" || str == "i" || str == "u" || str == "o" || str == "e")
            {
                Console.WriteLine("vowel");
            }
            else
            {
                Console.WriteLine("consonant");
            }
        }
    }
}


Measured memory_bytes: 11092
import collections
n = int(input())
ls = [int(input()) for i in range(n)]
ls.sort()
c = collections.Counter(ls)
d = list(c)
p = 0
for j in range(len(c)):
    if c[d[j]] % 2 ==0:
        continue
    else:
        p += 1
print(p)


Measured memory_bytes: 62152
#include <stdio.h>
 
int main(void)
{
 
  unsigned long a, b, r, x, tmp;
 
  scanf("%ld", &a);
  scanf("%ld", &b);
 
  x = a * b;
 
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  printf("%ld", x/b);
 
  return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll K, X;
  cin >> K >> X;
  for(ll i = max(-1000000LL, X-K+1); i <= min(X+K - 1, 1000000LL); i++){
    cout << i << " ";
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>

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

using namespace std;

typedef long long ll;

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

  string s; cin >> s;

  int ans = 0;
  int head = 0, tail = s.length()-1;

  while (true) {
    char s1 = s[head], s2 = s[tail];
    
    if ( s1 != 'x' && s2 != 'x' && s1 != s2 ){
      cout << -1 << endl;
      return 0;
    }

    if ( s1 == 'x' && s1 != s2 ) {
      ans++;
      head++;
    } else if ( s2 == 'x' && s1 != s2 ) {
      ans++;
      tail--;
    } else if ( s1 == s2 ) {
      head++;
      tail--;
    }
    if ( head >= tail ) { break; }
  }

  cout << ans << endl;

  return 0;
}

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

using namespace std;

typedef pair < int , int > pii;

priority_queue < int > pq;
priority_queue < pii > pq2;

int main(){
	int n,m,x,y;
	cin >> n >> m;
	for(int i=0; i<n; i++){
		cin >> x;
		pq.push(-x);
	}
	for(int i=0; i<m; i++){
		cin >> x >> y;
		pq2.push(make_pair(y,x));
	}
	while(!pq2.empty()){
		int cnt = pq2.top().second;
		int val = pq2.top().first;
		pq2.pop();
		while(-pq.top() < val && cnt > 0){
			pq.pop();
			pq.push(-val);
			cnt--;
		}
	}
	long long ans = 0;
	while(!pq.empty()){
		ans += -pq.top();
		pq.pop();
	}
	cout << ans << endl;
	return 0;
}

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

 ll MOD = 1000000007;

 int main() {
   int N, M;
   cin >> N >> M;
   vector<vector<int>> Graph(N, vector<int>(N, 0));
   vector<pair<int, int>> input(M);

   rep(i, 0, M) {
     cin >> input.at(i).first >> input.at(i).second;
     input.at(i).first--;
     input.at(i).second--;
     Graph.at(input.at(i).first).at(input.at(i).second)++;
     Graph.at(input.at(i).second).at(input.at(i).first)++;
   }

   vector<int> num;

   rep(i, 1, N) num.push_back(i);

   int cnt = 0;

   do {
     bool ok = true;
     if (!Graph.at(0).at(num.at(0))) ok = false;
     rep(i, 0, N - 2) {
       if (!Graph.at(num.at(i)).at(num.at(i + 1))) ok = false;
     }
     if (ok) cnt++;
   } while (next_permutation(num.begin(), num.end()));

   cout << cnt << endl;
 }


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;


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

    vector<int>l(q),r(q),L(n),R(n);

    rep(i,q)cin>>l[i]>>r[i];

    rep2(i,1,n-1){
        if(s[i-1]=='A'&&s[i]=='C')L[i]+=L[i-1]+1;
        else L[i]=L[i-1];
    }

    repr(i,n-2,0){
        if(s[i]=='A'&&s[i+1]=='C')R[i]+=R[i+1]+1;
        else R[i]=R[i+1];
    }

    int all=R[0];
    rep(i,q)cout<<all-R[r[i]-1]-L[l[i]-1]<<endl;

}


Measured memory_bytes: 2688
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  vector<int> v(3);
  cin>>v[0]>>v[1]>>v[2];
  sort(v.begin(),v.end());
  cout<<v[0]<<' '<<v[1]<<' '<<v[2]<<endl;
}
  


Measured memory_bytes: 3132
/* ex3_2
   tamayama */

#include<stdio.h>

int main(void){
    int N;
    int Pencil;
    scanf("%d",&N);
    Pencil = N;
    
    /*一の位の数をPencilから引いて、一の位を0にする。このときどんな数を引くかで区別*/
    if((Pencil-2)%10 == 0 || (Pencil-4)%10 == 0 || (Pencil-5)%10 == 0 || (Pencil-7)%10 == 0 || (Pencil-9)%10 == 0){
        printf("hon");
    }else if(Pencil%10 == 0 || (Pencil-1)%10 == 0 || (Pencil-6)%10 == 0 || (Pencil-8)%10 == 0){
        printf("pon");
    }else{
        printf("bon");
    }
    return 0;
}


Measured memory_bytes: 1732
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n=I()
dp=[0 for i in range(n+1)]
dp[0]=2
dp[1]=1
for i in range(n-1):
    dp[i+2]=dp[i+1]+dp[i]
print(dp[n])

Measured memory_bytes: 3444
#include <stdio.h>
#define N 10000

int linearSearch(int[],int[],int,int);

int main(){
  int n,i,a[N],b[N],key,x,q;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&b[i]);
  }

  x=linearSearch(a,b,n,q);

  if(x==0) printf("0\n");
  else printf("%d\n",x);

  return 0;
}

int linearSearch(int a[],int b[],int n,int q){
  int i,j,status=0;

  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(a[j]==b[i]){
	status++;
	break;
      }
    }
  }
  return status; 
}



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

typedef  long long ll;
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//
//
#define int long long

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}


 ll  a,b,c,s,t,i,j,k,x,y,z;
 ll A,B,C,S,T,X,Y,Z;
 ll count;
signed main(){
	int F[6];

	for(i=0;;i++){
		cin>>F[i];
		if(F[i]!=i+1){
			cout<<i+1;
			break;
		}
	}
 return 0;
}


Measured memory_bytes: 3516
#include <stdio.h>

int main(){
	int l[10],v1,v2;
	int p1,p2;
	int lon;
	int ans;
	int i,j,k;

	double dp1,dp2,dv1,dv2;
	while(EOF!=
		scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d"
			,&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9],&v1,&v2)){
		lon=0;
		for(i=0; i<10; i++){
			lon+=l[i];
		}
		lon*=1000;
		dp1=0;
		dp2=lon;
		dv1=v1/3.6;
		dv2=v2/3.6;

		while(dp1<dp2){
			dp1+=dv1;
			dp2-=dv2;
		}
		j=0;
		for(i=0; i<10; i++){
			j+=l[i]*1000;
			if(j>dp2)break;
		}
		printf("%d\n", i+1);
		//printf("%lf %lf %d\n ",dp1,dp2,j);
	}
	return 0;
}

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

int main(){
    int N = 10000;
    vector<int> vec(N);
    int tmp = 0;
    for (int i = 0; i <= N; i++) {
        int tmp_a;
        string tmp_ope;
        int tmp_b;
        cin >> tmp_a >> tmp_ope >> tmp_b;

        if (tmp_ope == "?"){
            tmp = i;
            break;
        }
        
        if (tmp_ope == "+") vec.at(i) =  tmp_a + tmp_b;
        if (tmp_ope == "-") vec.at(i) =  tmp_a - tmp_b;
        if (tmp_ope == "*") vec.at(i) =  tmp_a * tmp_b;
        if (tmp_ope == "/") vec.at(i) =  (double) tmp_a / (double)tmp_b;
    }
    for (int i = 0 ; i < tmp; i++) {
        cout << vec[i] << endl;
    }
    return 0;
}



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

int main() {
  int x,y;cin>>x>>y;
  int group[12] = {1,3,1,2,1,2,1,1,2,1,2,1};
  bool ans = group[x-1] == group[y-1];
  cout << (ans ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
	SpeedForce;
	int h1, h2, m1, m2;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	cur = (h2-h1+24) % 24;
	cur *= 60;
	cur += m2-m1;
	while(cur<0) cur+= 60;

	cout << max(0, cur-k) << '\n';

	return Accepted;
}

// B...a

Measured memory_bytes: 17732
#include <stdio.h>
#define MAX_N 10000

int main(void) {
	int num, q, com, x, y, i;
	int s[MAX_N];

	scanf("%d %d", &num, &q);

	for (i = 0; i < num; i++) {
		s[i] = i;
	}

	while (q--) {
		scanf("%d %d %d", &com, &x, &y);
		if (com) {
			if (s[x] == s[y])
				puts("1");
			else
				puts("0");
		} else {
			x = s[x];
			y = s[y];
			if (x != y) {
				for (i = 0; i < num; i++) {
					if (s[i] == y) {
						s[i] = x;
					}
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 624
#include <iostream>

using namespace std;

void printChessboard(const int row_number, const int width)
{
	int n = row_number % 2;
	for(int i = 0; i < width; i++){
		if(i % 2 == n){ cout << "#"; }
		else          { cout << "."; }
	}
	cout << endl;
}

int main()
{
	int h = 0, w = 0;
	while(true)
	{
		cin >> h >> w;
		if(h == 0 && w == 0){ break; }
		for(int y = 0; y < h; y++)
		{
			printChessboard(y, w);
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
const ll mod=1e9 +7;
#define vi vector<int>
#define pb emplace_back
ll poww(ll n,ll x)
{
    ll res=1;
    
    while(x>0)
    {
        if(x&1)
          res*=n;
        
        x=x>>1;
        n*=n;
    }
    return res;
}





int main() 
{
	   ios::sync_with_stdio(0);
	   cin.tie(0);
	   cout.tie(0);
       
       ll n;
       cin>>n;
       ll *a= new ll[n];
       for(int i=0;i<n;i++)
        cin>>a[i];
       
       ll *pref= new ll[n+1];
       pref[n+1]=0;
       for(int i=n-1;i>=0;i--)
       {
       	pref[i]=(pref[i+1] + a[i])%mod;
       } 
       ll sum=0;
       for(int i=0;i<n;i++)
         {
             sum+= (a[i]*pref[i+1])%mod;
         }
         cout<<sum%mod;
       
}

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

main() {
    while(1) {
        int h, w;
        cin >> h >> w;
        if(!h) return 0;
        vector<vector<int>> a(h, vector<int>(w));
        rep(i, h) rep(j, w) cin >> a[i][j];
        int ans = 0;
        rep(i, h) rep2(ii, i, h - 1) rep(j, w) rep2(jj, j, w - 1) {
            int d = 0;
            if(i + 1 >= ii or j + 1 >= jj) continue;
            rep2(iii, i + 1, ii - 1) {
                rep2(jjj, j + 1, jj - 1) { d = max(d, a[iii][jjj]); }
            }
            int D = INT_MAX;
            rep2(jjj, j, jj) D = min({D, a[i][jjj], a[ii][jjj]});
            rep2(iii, i, ii) D = min({a[iii][j], a[iii][jj], D});
            if(D <= d) continue;
            int now = 0;
            rep2(iii, i + 1, ii - 1) rep2(jjj, j + 1, jj - 1) now += D - a[iii][jjj];
            ans = max(ans, now);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3164
#include<stdio.h>
char p[101000], q[5][10]={"dream","dreamer","erase","eraser"};
int D[101000], L[5]={5,7,5,6};
int main(){
    int i, j, k;
    scanf("%s",p+1);
    D[0]=1;
    for(i=1;p[i];i++){
        for(j=0;j<4;j++){
            if(i < L[j])continue;
            for(k=0;k<L[j];k++){
                if(p[i-L[j]+k+1] != q[j][k])break;
            }
            if(k==L[j]){
                D[i] |= D[i-L[j]];
            }
        }
    }
    puts(D[i-1]?"YES":"NO");
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int a[333333];
int cnt[1111111];
int divi[1111111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		cnt[a[i]]++;
	}
	for(int i=1;i<=1000000;i++)
	{
		for(int j=i;j<=1000000;j+=i)
		{
			divi[j]+=cnt[i];
		}
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(divi[a[i]]==1) ans++;
	}
	cout<<ans<<'\n';
}


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

int w,h;
string grid[55],col[55];
bool vis[55][55];
int dy[] = {-1,0,1,0}, dx[] = {0,1,0,-1};

int count(char color){
  int res = 0;
  rep(i,h)rep(j,w)if(col[i][j]==color)res++;
  return res;
}

void rec(int y,int x,int color){
  if(vis[y][x])return;
  vis[y][x] = true;

  if(grid[y][x]=='.'){
    if(col[y][x] == '.' || col[y][x] == color)col[y][x] = color;
    else col[y][x] = 'G';
  }
    
  rep(d,4){
    int ny = y+dy[d], nx = x+dx[d];
    if(ny<0 || nx<0 || ny>=h || nx>=w)continue;
    if(grid[ny][nx]!='.')continue;
    rec(ny,nx,color);
  }
}

int main(){
  while(cin >> w >> h, w){
    rep(i,h){
      cin >> grid[i];
      col[i] = "";
      rep(j,w)col[i] += '.';
    }
    
    rep(i,h){
      rep(j,w){
	if(grid[i][j]!='.'){
	  memset(vis,0,sizeof(vis));
	  rec(i,j,grid[i][j]);
	}
      }
    }
   
    cout << count('B') << " " << count('W') << endl;
  }
}

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

const int INF = 1e8;

typedef vector<int> vi;
typedef vector<vi> vvi;

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

map<char, vvi> cost;

char m[71][71];
int w, h;

struct Data{
    char ft;
    int y, x;
};

void dfs(Data s){

    queue<Data> q;
    q.push(s);

    while(not q.empty()){
        // cout << endl;
        // rep(i,h){ rep(j,w){ cout << cost['R'][i][j] << ' ' ; } cout << endl; }
        // cout << endl;
        // rep(i,h){ rep(j,w){ cout << cost['L'][i][j] << ' ' ; } cout << endl; }
        // cout << endl;
        struct Data u = q.front(); q.pop();
        char nft = (u.ft == 'L' ? 'R' : 'L');
        rep(i,9){
            int ny = u.y + dy[i];
            int nx = u.x + dx[i] * (nft == 'R' ? 1 : -1);
            if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
            if(m[ny][nx] == 'X' || m[ny][nx] == 'S') continue;
            if(m[ny][nx] == 'T'){
                //show(cost[u.ft][u.y][u.x])
                cost[nft][ny][nx] = min(cost[nft][ny][nx], cost[u.ft][u.y][u.x]);
                continue;
            }
            if(cost[u.ft][u.y][u.x] + (m[ny][nx] - '0') < cost[nft][ny][nx]){
                cost[nft][ny][nx] = cost[u.ft][u.y][u.x] + (m[ny][nx] - '0');
                q.push(Data{nft,ny,nx});
            }
        }
    }
}

int main(){
    while(cin >> w >> h, w){
        cost['R'] = vvi(71, vi(71,INF));
        cost['L'] = vvi(71, vi(71,INF));

        rep(i,h) rep(j,w) cin >> m[i][j];

        rep(i,w) if(m[h - 1][i] == 'S'){
            cost['R'][h - 1][i] = 0;
            dfs(Data{'R', h - 1, i});
            cost['L'][h - 1][i] = 0;
            dfs(Data{'L', h - 1, i});
        }

        int mini = INF;
        rep(i,w){
            int tmp = INF;
            if(m[0][i] == 'T') tmp = min(cost['R'][0][i], cost['L'][0][i]);
            mini = min(mini, tmp);
        }
        cout << (mini == INF ? -1 : mini) << endl;
    }
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
const int mod =1e9+7;

int main() {
	// your code goes here
	
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,i,j,k;
	cin>>n;
	double p;
	vector<double>dp(n+1);
	dp[0]=1;
	for(i=1;i<=n;i++)
	{
	    cin>>p;
	    
	    for(j=i;j>=0;j--)
	    {
	        dp[j]= (p==0?0:(dp[j-1]*p)) + dp[j]*(1-p);
	    }
	    
	}
	p=0;
	for(i=n/2;i<=n;i++)
	{
	    if(i>(n-i))
	    p+=dp[i];
	}
	cout<<setprecision(100)<<p;
	
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#include<cmath>
#include <algorithm> 
#include <unordered_map>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long x, k, d;
	cin >> x >> k >> d;
	x = abs(x);
	long long diff = x % d;
	long long v = x / d;
	if (k <= v) {
		x = x - k * d;
		cout << x;
	}
	else {
		k = k - v;
		k = k % 2;
		if (k == 1) {
			cout << abs(x - (v + 1) * d);
		}
		else {
			cout << abs(x - v*d);
		}
	}
	return 0;
}

Measured memory_bytes: 3660
#include <stdio.h>

int main(void)
{

	int W;
	int H;
	int x;
	int y;
	int r;
	
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	
	if(W>=2*r && H>=2*r && x>=r && x+r<=W && y>=r && y+r<=H){
		puts ("Yes");
	}
	
	else{
		puts ("No");
	}

	return 0;
}

Measured memory_bytes: 584
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int v[] = new int[n];
        for (int i = 0; i < n; i++) {
            v[i] = sc.nextInt();
        }

        long ans = 0;
        // i : 取る個数
        for (int i = 1; i < k + 1; i++) {
            int get = i;
            if (get >= n) {
                get = n;
            }
            int have[] = new int[get];

            // 左からj個取る
            for (int j = 1; j <= get; j++) {
                int pos = 0;
                for (int m = 0; m < j; m++) {
                    have[pos] = v[m];
                    pos++;
                }
                for (int m = 0; m < get - j; m++) {
                    have[pos] = v[n - 1 - m];
                    pos++;
                }
                Arrays.sort(have);
                for (int m = 0; m < k - get; m++) {
                    if (m == get) {
                        break;
                    }
                    if (have[m] <= 0) {
                        have[m] = 0;
                    } else {
                        break;
                    }
                }
                long tmpans = 0;
                for (int m = 0; m < get; m++) {
                    tmpans += have[m];
                }
                if (ans < tmpans) {
                    ans = tmpans;
                }
            }

        }
        System.out.println(ans);

        sc.close();
    }
}

Measured memory_bytes: 25412
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,c=0;
	cin>>n;
	int a[n],b[n];
	for(i=0;i<n;i++)
		cin>>a[i];
		
	for(i=0;i<n;i++)
	{
		b[i]=a[i];
	}
	sort(b,b+n);
	for(i=0;i<n;i++)
	{
		if(a[i]!=b[i])
			c++;
	}
	if(c==2)
		cout<<"YES"<<endl;
	else if(c==0)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
}

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

//const int mod = 998244353;
const int mod = 1000000007;


struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

vector<pair<ll,int>> pfact(ll n){
    vector<pair<ll,int>> fs;
    for(ll i=2;i*i<=n;i++){
        int tmp = 0;
        while(n%i==0){
            n /= i;
            tmp++;
        }
        if(tmp>0) fs.push_back(make_pair(i,tmp));
    }
    if(n!=1) fs.push_back(make_pair(n,1));
    return fs;
}


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

  map<int,int> mp;
  for(int i=0;i<n;i++){
    vector<pair<ll,int>> vec = pfact(a[i]);
    for(pair<ll,int> p: vec){
      mp[p.first] = max(mp[p.first],p.second);
    }
  }

  mint lcm = 1;
  for(auto x: mp) for(int i=0;i<x.second;i++) lcm *= x.first;

  mint ans = 0;
  for(int x:a) ans += lcm/x;
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 3992
#include<stdio.h>

int main(void){
  int n,k;
  
  scanf("%d %d",&n,&k);
  
  int i,j,kazu,a[100]={0},b;
  
  for(i=0; i<k; i++){
    scanf("%d",&kazu);
    for(j=0; j<kazu; j++){
      scanf("%d",&b);
      a[b-1] ++;
    }
  }
  
  int nin=0;
  
  for(i=0; i<n; i++)
    if(a[i] == 0)
      nin ++;
  
  printf("%d",nin);
}

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

int N, K, H[200000];
int64_t ans;

int main() {
    cin >> N >> K;
    rep(i, N) cin >> H[i];

    sort(H, H + N);
    rep(i, N - K) {
        ans += H[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  	string s, t;	cin >> s >> t;
  	int sn, tn;	cin >> sn >> tn;

	string u;	cin >> u;
  	if(u == s) cout << --sn << " " << tn << endl;
  	else cout << sn << " " << --tn << endl;
}

Measured memory_bytes: 764
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot

#############
# Main Code #
#############

N, Y = getNM()

n10k = Y // 10000
ans = []
for i in range(n10k + 1):
    left5 = Y - (i * 10000)
    n5k = left5 // 5000
    for j in range(n5k + 1):
        left1 = left5 - (j * 5000)
        l = left1 // 1000
        if i + j + l == N:
            ans = [i, j, l]
if len(ans) == 0:
    print(-1, -1, -1)
else:
    print(*ans)

Measured memory_bytes: 62296
n = int(input())
dp = [float("Inf")]*(n+1)
dp[0] = 0
for i in range(n):
    for j in range(1,6):
        if i + j > n:
            break
        dp[i+j] = min(dp[i+j], dp[i] + j)
    for j in range(1,n//6+1):
        if i + 6**j > n:
            break
        dp[i+6**j] = min(dp[i+6**j], dp[i] + 1)
    for j in range(1,n//9+1):
        if i + 9**j > n:
            break
        dp[i+9**j] = min(dp[i+9**j], dp[i] + 1)
print(dp[-1])

Measured memory_bytes: 9616
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &P){
	in >> P.first >> P.second;
	return in;
}
template<class T1, class T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &P){
	out << "(" << P.first << ", " << P.second << ")";
	return out;
}
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}
template<class T>
istream &operator>>(istream &in, deque<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const deque<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}

int32_t main(){
	int a , b , c, d;
	cin>>a>>b>>c>>d;
	if(a < c){
		cout<<1 << endl;
	}
	else cout<<0 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  char a[]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n'
,'o','p','q','r','s','t','u','v','w','x','y','z'};
  int b[26]={0};
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    for(int j=0;j<26;j++){
      if(s[i]==a[j]){
        b[j]++;
      }
    }
  }
  for(int i=0;i<26;i++){
    if(b[i]%2!=0){cout<<"No";
    return 0;}


  }
cout<<"Yes"<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i) = 0; (i) < (n); (i)++)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }


int main() {
    int n;
    cin >> n;
    cout << (n-1)/2 << endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 整数の入力
N = int(input())
# スペース区切りの整数の入力
# b, c = map(int, input().split())
# 文字列の入力
#s = input()
sList=[input() for i in range(N)]

m = 0;
a = 0;
r = 0;
c = 0;
h = 0;
for i in range(len(sList)):
  s = sList[i];
  if s[0] == 'M':
    m = m + 1;
  elif s[0] == 'A':
    a = a + 1;
  elif s[0] == 'R':
    r = r + 1;
  elif s[0] == 'C':
    c = c + 1;
  elif s[0] == 'H':
    h = h + 1;
  
# 出力
# MARCHの10通りの組み合わせを足す
result = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h + r * c * h + a * c * h;
print(result);


Measured memory_bytes: 9772
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <class T> using treap = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
    {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
    {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
    {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
template <class T, class S> ostream& operator<<(ostream& s, unordered_map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
    #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
    #define dump(...)
    #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(nullptr); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
    int n; cin >> n;
    vector<int> a(n), b(n), c(n - 1);
    REP (i, n) cin >> a[i], a[i]--;
    REP (i, n) cin >> b[i];
    REP (i, n - 1) cin >> c[i];
    int ans = 0;
    REP (i, n) ans += b[a[i]];
    REP (i, n - 1) {
        if (a[i] + 1 == a[i + 1]) ans += c[a[i]];
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
	var tmp = ReadIntArray();
	int n = tmp[0], m = tmp[1];

	int[] a = new int[m];
	int[] b = new int[m];
	for (int i = 0; i < m; i++)
	{
	    tmp = ReadIntArray();
	    a[i] = tmp[0];
	    int x = 0;
	    int[] c = ReadIntArray();
	    for (int j = 0; j < tmp[1]; j++)
	    {
		x += (1 << (c[j] - 1));
	    }
	    b[i] = x;
	    // WriteLine($"a[{i}] = {a[i]}, b[{i}] = {b[i]}");
	}

	long INF = 1000000000000;
	
	long[,] dp = new long[m+1,1<<n];
	for (int i = 0; i <= m; i++)
	    for (int j = 0; j < (1<<n); j++)
		dp[i,j] = INF;
	dp[0,0] = 0;

	for (int i = 1; i <= m; i++)
	{
	    int price = a[i-1];
	    int bm = b[i-1];
	    //WriteLine($"{i} {a[i-1]} {b[i-1]}");
	    for (int j = 0; j < (1<<n); j++)
	    {
		// かわなかった場合
		dp[i, j] = Math.Min(dp[i, j], dp[i-1, j]);
		//WriteLine($"dp[{i}, {j}] = {dp[i, j]}");
		// 買った場合
		dp[i, j | bm] = Math.Min(dp[i, j|bm], dp[i-1, j] + price);
		//WriteLine($"dp[{i}, {j|bm}] = {dp[i, j|bm]}");
	    }
	}

	long ans = dp[m, (1 << n) - 1]; 
	WriteLine(ans != INF ? ans : -1);
    }
    
}


Measured memory_bytes: 45152
#include <iostream>
#include <fstream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	int n; cin >> n;
	vector<ll> a(n);
	rep(i,n)cin>>a[i];

	ll left = 0,right = 0;
	ll sum = 0;
	ll ans=0;
	rep(i,n)
	{
		right=i;
		while ((sum^a[right])!=(sum+a[right]))
		{
			//cout<<(sum^a[right])<<':'<<sum+a[right]<<endl;
			//cout<<left<<':'<<right<<endl;
			sum-=a[left];
			left++;
			
		}
				
		sum+=a[right];
		ans+=right-left+1;
		//cout<<sum<<endl;
		//cout<<left<<':'<<right<<endl;
	}

	cout<<ans<<endl;

	return 0;
}

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

#define endl "\n"

typedef long long ll;
typedef pair <ll, ll> pii;
typedef long double ld;

const ll D = 200007;
const ll Inf = 1000000007;

int numberOfTownAfterMoves(vector<int> &towns, ll k)
{
	vector<int> howManySteps(towns.size(),-1); // [0, 1, 2, 3]
	int currentTown = 0; // 1
	int currentStep = 0; // 4
	int previousTown = 0; // 3
	while(howManySteps[currentTown] == -1 && currentStep < k )
	{
		howManySteps[currentTown] = currentStep++;
		previousTown = currentTown;
        currentTown = towns[currentTown];

	}
	if(currentStep != k)
	{
	int cycleLenght = howManySteps[previousTown]-howManySteps[currentTown]+1;
	// = 3 - 1 + 1 = 3
	k = (k-currentStep)%cycleLenght; // 5 % 3 = 2

	for(int i = 0; i < k; i++)
	{
		currentTown = towns[currentTown]; // 2 3
	}
	}
	return currentTown; // 3
}

int main()
{
    ll n,k;
    cin>>n>>k;
    vector<int> towns(n);
    for(int i = 0;i<n;i++)
    {
        cin>>towns[i];
        towns[i]--;
    }
    cout<<numberOfTownAfterMoves(towns, k)+1;

}
/*

6
aabbaa
*/


Measured memory_bytes: 4848
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    d, t, s = map(int, input().split())
    if d <= t * s:
        print("Yes")
    else:
        print("No")



if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9164
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pi pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(min(a,c)>0){
    c-=b;
    if(c<=0){
      cout<<"Yes"<<endl;
      break;
    }
    a-=d;
    if(a<=0) {
      cout<<"No"<<endl;
      break;
    }
  }

  return 0;
}


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

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

    if (a.at(int(a.size()) - 1) == b.at(0) && b.at(int(b.size()) - 1) == c.at(0))
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256