akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test1 cout << "test1" << endl;
#define test2 cout << "test2" << endl;
#define fixprecision(n) fixed; cout << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define rep(i, s, N) for(ll i{s}; i < N; i++)
using namespace std;
using ll = long long;
using iikae = ll&;
using ld = long double;
using P = pair<ll,ll>;

int main(){
  //kyopro;
  ll N, M;
  cin >> N >> M;
  vector<ll> A(N);
  for(auto&& a : A){
    cin >> a;
  }
  vector<P> kakikae(M);
  ll kakikaesize{};
  for(auto&& youso : kakikae){
    cin >> youso.second >> youso.first;
    kakikaesize += youso.second;
  }
  sort(A.begin(), A.end());
  sort(kakikae.begin(), kakikae.end(), greater<P>());
  for(auto && a : kakikae){
    //cout << a.first << sp << a.second << rt;
  }
  ll ranguresu{};
  ll ima{};
  rep(i, 0, min(N, kakikaesize)){
    //cout << ima << rt;
    if(A.at(i) >= kakikae.at(ima).first){
      
      //cout << kakikae.at(ima).first;
      break;
      }
    A.at(i) = kakikae.at(ima).first;
    ranguresu++;
    if(ranguresu >= kakikae.at(ima).second){
      ima++;
      ranguresu = 0;
    }
  }
  ll sum{};
  rep(i, 0, N){
    sum += A.at(i);
  }
  cout << sum << rt;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<stdlib.h>
int main(){
  long long k;
  int n,i,j,count;
  scanf("%d%lld",&n,&k);
  int a[n+2],num[n+2],order[n+2];
  for(i=1;i<=n;i++){
    scanf("%d",&a[i]);
    num[i]=0;
  }
  i=1;
  count=0;
  while(count<=n+3){
    if(num[i]==0){
      count+=1;
      num[i]++;
      order[count]=a[i];
      i=a[i];
    }
    else{
      order[0]=1;
      break;
    }
  }
  for(j=0;j<n;j++)
    if(order[j]==i){
      count-=j;
      break;
    }
  if(k-j>=0){
    k-=j;
    k=k%count;
    printf("%d\n",order[j+k]);
  }
  else
    printf("%d\n",order[k]);
  return 0;
}


Measured memory_bytes: 4060
#include <stdio.h>
#include <stdlib.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail,n;

void enqueue(P x){
int next=(tail+1)%LEN;
if(next==head) {exit(2);}
Q[tail]=x;
tail=next;
}

P dequeue(){
P val;
if(head==tail){exit(3);}
val=Q[head];
head=(head+1)%LEN;
return val;
}

int min(int x,int y){
  if(x>y) return y;
  else return x;
}
int main(){
  int sum = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head =1 ;
  tail =n+1;
while (head!=tail) {
  u=dequeue();
  c=min(q,u.t);
  u.t=u.t-c;
  sum=sum+c;
  if (u.t>0) {
    enqueue(u);
  }
  else{
    printf("%s %d\n",u.name,sum);
  }

}

  return 0;
}



Measured memory_bytes: 11872
#include <bits/stdc++.h>
#define ___                      \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define endl '\n'
#define pii pair<int, int>
#define MAX INT_MAX
#pragma GCC optimize("Ofast")
#define int long long
const int MOD = (1e9 + 7);
using namespace std;
#define vvi vector<vector<int>>
const int mod = 998244353;

signed main()
{
	___ 
	int n; cin>>n;
	int arr[n];
	int dp[n];
	for(int i=0;i<n;i++) cin>>arr[i],dp[i]=arr[i];
	sort(arr,arr+n);
	for(int i=0;i<n;i++){
		if(dp[i]==arr[n-1]) cout<<arr[n-2]<<endl;
		else cout<<arr[n-1]<<endl;
	}
}



Measured memory_bytes: 4736
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()

for i in range(101):
    for j in range(101):
        if 4 * i + 7 * j == n:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define ff first
#define ss second 
#define MP make _pair
#define PB push_back
#define ll long long
#define pri 1000000007
using namespace std;
void run(){
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++){cin>>a[i];}
	ll z=n%2;
	ll dp[n+1][n+1];
	for(ll i=0;i<n+1;i++){
		for(ll j=0;j<n+1;j++)dp[i][j]=0;
	}
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<=n-i;j++){
		  if(i%2==z)
		  dp[j][i]=max(dp[j+1][i-1]+a[j],dp[j][i-1]+a[i+j-1]);	
		  else 
		  dp[j][i]=min(dp[j+1][i-1]-a[j],dp[j][i-1]-a[i+j-1]);	
		}
		
	}

	cout<<dp[0][n];
}
int main() {
	run();
	// your code goes here
	return 0;
}

Measured memory_bytes: 70656
#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() {
    ll X, Y;
    cin >> X >> Y;

    ll a = Y / X;
    ll ans = logl(a)/logl(2);
    // ll ans =0;
    // while(X<Y){
    //     ans++;
    //     X*=2;
    // }

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

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

int main(){
    string s;cin>>s;
    string ss="";
    for(int i=s.length()-1;i>=0;i--){
        ss+=s[i];
        if(ss=="maerd") ss="";
        else if(ss=="remaerd") ss="";
        else if(ss=="esare") ss="";
        else if(ss=="resare") ss="";
    }
    if(ss=="") cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 512
N,M = map(int,input().split())
MOD = 10**9 + 7

fact = [1]
for i in range(1, N+M+1):
  fact.append((fact[-1] * i) % MOD)

x = fact[N] * fact[M]

if N == M:
  answer = 2 * x % MOD
elif abs(N-M) == 1:
  answer = x % MOD
else:
  answer = 0

print(answer)

Measured memory_bytes: 11028
def Con(V,E):
  C1,C2=set(),set()
  C1.add(1)
  C2.add(1)
  for e in E:
    if e[0]==1:
      C1.add(e[1])
    elif e[1]==1:
      C1.add(e[0])
  while len(C1)>len(C2):
    for c1 in V:
      if c1 in C1 and c1 not in C2:
        for e in E:
          if e[0]==c1:
            C1.add(e[1])
          elif e[1]==c1:
            C1.add(e[0])
        C2.add(c1)
  if len(C1)==len(V):
    return True
  else:
    return False
n,m=map(int,input().split())
V=[int(i) for i in range(1,n+1)]
E=[]
for i in range(m):
  s,g=map(int,input().split())
  E.append([s,g])
ans=0
for i in range(m):
  if Con(V,E[:i]+E[i+1:])==False:
    ans+=1
print(ans)

Measured memory_bytes: 3064
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

#define fori(n) for(ll i=0; i<(n); i++)
#define forn(i, n) for(ll i=0; i<(n); i++)
#define forn3(i, x, n) for(ll i=(x); i<(n); i++)

int main() {
cin.tie(nullptr);
std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<double> p(n);
    fori(n)
        cin>>p[i];

    vector<vector<double>> dp(n+1, vector<double>(n+1)); /* dp[i][j]= prop of having i heads after j tosses */

    dp[0][0]=1;

    for(int i=1; i<=n; i++) {
        dp[0][i]=dp[0][i-1]*(1-p[i-1]);
        //cout<<dp[0][i]<<"  |  ";
    }
    //cout<<endl;

    for(int i=1; i<=n; i++) {
        for(int j=1; j<=n; j++) {
            dp[i][j]=dp[i-1][j-1]*p[j-1] + dp[i][j-1]*(1-p[j-1]);
            //cout<<dp[i][j]<<"  |  ";
        }
        //cout<<endl;
    }

    double ans=0;
    for(int i=(n+2)/2; i<=n; i++)
        ans+=dp[i][n];

    cout<<setprecision(10)<<ans<<endl;
}



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

using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<pair<int, int>> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i).first;
    vec.at(i).second = i+1;
  }
  sort(vec.begin(), vec.end());
  for (int i = 0; i < n; i++) {
    cout << vec.at(i).second << '\n';
  }
  //cout << '\n';
	return 0;
}


Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
//#include<array>
#include<algorithm>
#include<queue>
#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
//#include<bitset>
//#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//配列,座標
/*array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
array<int, 4>dir_x2 = { 0,0,1,-1 };
array<int, 4>dir_y2 = { 1,-1,0,0 };
char alp[] = { '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' };*/

//Union Find
class UnionFind {
public:
	vector<int>data;
	UnionFind(int size) :data(size, -1) {};
	bool unionset(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x]) {
				swap(x, y);
			}
			data[x] += data[y];
			data[y] = x;
		}
		return x != y;
	}
	bool findset(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

//最大公約数,最小公倍数
/*LLI gcd(LLI x, LLI y) {
	LLI  r;
	if (x < y) {
		swap(x, y);
	}
	r = x % y;
	while (r != 0) {
		x = y;
		y = r;
		r = x % y;
	}
	return y;
}
LLI lcm(LLI x, LLI y) {
	return x / gcd(x, y) * y;
}*/

//組み合わせ
/*long nCr(int n, int r) {
	long ans = 1;
	for (int i = n; i > n - r; i--) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; i++) {
		ans = ans / i;
	}
	return ans;
}
long nHr(int n, int r) {
	n = n + r - 1;
	return nCr(n, r);
}*/

//素数判定
/*bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;

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

	// 素数である
	return true;
}*/

//桁数
/*LLI GetDigit(LLI num) {
	LLI digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}*/

//サンプル
/*const int n_max = 8;
array<array<bool, n_max>, n_max>graph;
int dfs(int v,int N,array<bool,n_max>visited) {
	int ret = 0;
	bool all_visited = true;
	for (int i = 0; i < N;i++) {
		if (visited[i] == false) {
			all_visited = false;
		}
	}
	if (all_visited) {
		return 1;
	}
	for (int i = 0; i < N;i++) {
		if (graph[v][i] == false) {
			continue;
		}
		if (visited[i] == true) {
			continue;
		}
		visited[i] = true;
		ret += dfs(i,N,visited);
		visited[i] = false;
	}
	return ret;
}*/

//サンプル
/*vector<vector<int>>sub;
int dfs(int id) {
	if (sub[id].size() == 0) {
		return 1;
	}
	int minP = (int)1e9;
	int maxP = 0;
	for (int i : sub[id]) {
		int P = dfs(i);
		minP = min(minP, P);
		maxP = max(maxP, P);
	}
	return minP + maxP + 1;
}*/

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl
//cout << "Yes" << endl;
//cout << "No" << endl;



int main(void) {
	LLI N,M,res = 0;
	cin >> N >> M;
	for (int i = 0; i < M;i++) {
		LLI a;
		cin >> a;
		res += a;
	}
	if (res > N) {
		cout << -1 << endl;
	}
	else {
		cout << N - res << endl;
	}
}

Measured memory_bytes: 3192
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#define INF 1e8
using namespace std;

#define MAX 100020
int main(void){
    
int x;
cin>>x;

vector<bool> vec(MAX+1,true);

for(int i=2; i*i<=MAX;i++){
    if(vec[i]==true){
        for(int j=i*i; j<=MAX;j+=i){
            vec[j]=false;
        }    
    }
    
}

vector<int> prim;
 for(int i=2; i<=MAX;i++){
     if(vec[i]==true)
        prim.push_back(i);
 }
 
 auto it= lower_bound(prim.begin(), prim.end(),x);
    cout<<*it;


}

Measured memory_bytes: 3300
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
vi adj[upperlimit];
int arr[upperlimit];
int order[upperlimit];
struct data
{
	int ind,val;
};
data segtree[upperlimit];
data merge(data a,data b){
	if(a.val<b.val) return a;
	else return b;
}
void build(int node,int i,int j){
	if(i==j){
		segtree[node].ind=i;segtree[node].val=adj[i].size();
		return;
	}
	int mid=(i+j)>>1;
	build(2*node,i,mid);build(2*node+1,mid+1,j);
	segtree[node]=merge(segtree[2*node],segtree[2*node+1]);
}
void update(int node,int i,int j,int ind,int val){
	if(i==j){
		segtree[node].val+=val;return;
	}
	int mid=(i+j)>>1;
	if(ind<=mid) update(2*node,i,mid,ind,val);
	else update(2*node+1,mid+1,j,ind,val);
	segtree[node]=merge(segtree[2*node],segtree[2*node+1]);
}
int main() {
	int n,a,b;
	sd(n);
	for(int i = 1; i < n; i++){
		sd(a);sd(b);
		adj[a].pb(b);adj[b].pb(a);
	}
	for(int i = 1; i <= n; i++) sd(arr[i]);
	sort(arr+1,arr+n+1);
	build(1,1,n);
	ll ans=0,calc;
	for(int i = 1; i <= n; i++){
		int k=segtree[1].ind;
		calc=segtree[1].val;calc*=arr[i];
		ans+=calc;
		for(int j = 0; j < adj[k].size(); j++) update(1,1,n,adj[k][j],-1);
		update(1,1,n,k,INF);
		order[k]=arr[i];
	}
	plldn(ans);
	for(int i = 1; i <= n; i++) pds(order[i]);
	return 0;
}

Measured memory_bytes: 29696
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
#define ff(i,n,m) for(int i=n;i<m;i++)
#define i64 int64_t
#define tos(x) to_string(x)


int main() {
	int n;
	cin >> n;
	vector<int> data(n);
	i64 sum = 0;
	ff(i, 0, n) {
		i64 a;
		cin >> a;
	    data.at(i)=a;
		sum += a;
	}
	i64 x = 0;
	i64 bsa = 999999999999999999;
	ff(i, 0, n - 1) {
		x += data.at(i);
		i64 sa = sum - 2 * x;
		if (sa < 0) {
			sa *= -1;
		}
		if (sa < bsa) {
			bsa = sa;
		}
		else {
			break;
		}
	}
	cout << bsa << endl;
	return 0;
}

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

int main() {
  int n,a,b,ans=0,sum;
  cin>>n>>a>>b;
  int i;
  for(i=1;i<=n;i++){
    sum=i/10000 + (i/1000)%10 + (i/100)%10 + (i/10)%10 + i%10;
    if(sum<=b && a<=sum)
      ans+=i;
  }
  cout<<ans;
}


Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

func init() {
	sc = bufio.NewScanner(os.Stdin)
	buffsize := 1000000
	buff := make([]byte, buffsize)
	sc.Buffer(buff, buffsize)
	sc.Split(bufio.ScanWords)
}

func loadint() (result int) {
	sc.Scan()
	result, _ = strconv.Atoi(sc.Text())
	return
}

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

func main() {
	k := loadstr()
	n := loadint()
	pos := 0
	ch := '1'
	for i, c := range k {
		if c != '1' {
			pos = i
			ch = c
			break
		}
	}
	if pos >= n {
		ch = '1'
	}
	fmt.Println(string(ch))
}


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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;

string s;

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

  cin >> s;
  int l = sz(s);
  if (s[0] == '0' || s[l-1] == '1') {
    cout << "-1\n";
    return 0;
  }
  rep(i,l/2){
    if (s[i] != s[l-2-i]) {
      cout << "-1\n";
      return 0;
    }
  }
  int bef = 1;
  rep(i,l-1) {
    cout << bef << " " << (i+2) << "\n";
    if (s[i] == '1') {
      bef = i+2;
    }
  }
  return 0;
}


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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))

void update(int64 *bit,int x,int64 v){
  int n=(int)bit[0];
  for(int i=x;i<=n;i+=i&-i) bit[i]=MAX(bit[i],v);
}

int64 max(int64 *bit,int x){
  int64 res=0;
  for(int i=x;i>0;i-=i&-i) res=MAX(res,bit[i]);
  return res;
}

void run(void){
  int n;
  scanf("%d",&n);
  int *h=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",h+i);
  int *a=(int *)calloc(n,sizeof(int));
  for(i=0;i<n;i++) scanf("%d",a+i);
  int64 *bit=(int64 *)calloc(n+1,sizeof(int64));
  bit[0]=n;
  for(i=0;i<n;i++){
    if(h[i]==1){
      update(bit,1,a[i]);
    } else {
      int64 p=max(bit,h[i]-1);
      update(bit,h[i],p+a[i]);
    }
  }
  printf("%lld\n",max(bit,n));
}

int main(void){
  run();
  return 0;
}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

int main()
{

    ll s,c;
    ll ans=0;
    cin >> s >> c;
    if(s >= c)
    {

        ans=c/2;
    }
    else
    {

        if(s*2 <= c)
        {

            ans+=s;
            c-=(s*2);
            ans+=c/4;
        }
        else
        {

            ans=c/2;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <cmath>
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> P;

#define rep(i, m) for(ll i=0;i<(m);i++)
#define rep1(i, m) for(ll i=1;i<=(m);i++)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int N, M;
vector<int> X;
vector<int> diff;

int main() {
cin >> N >> M;
   rep(i, M) {
      int Y;
      cin >> Y;
      X.push_back(Y);
   }
   sort(X.begin(), X.end());
   rep(i, M-1) {
      diff.push_back(X[i+1] - X[i]);
   }
   sort(diff.begin(), diff.end());
   ll sum = 0;
   rep(i, M-N) {
      sum += diff[i];
   }
   cout << sum << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  string s;
  cin >> s;
  int n=s.size();
  vector<ll> a(mx,0),b(mx,0),c(mx,0),d(mx,0);
  d[0]=1;
  
  rep(i,n){
    if(s[i]=='A'){
      d[i+1]=d[i]; 
      a[i+1]=(a[i]+d[i])%mod;
      b[i+1]=b[i];
      c[i+1]=c[i];
    }
    if(s[i]=='B'){
      d[i+1]=d[i];
      a[i+1]=a[i];
      b[i+1]=(a[i]+b[i])%mod;
      c[i+1]=c[i];
    }
    if(s[i]=='C'){
      d[i+1]=d[i];
      a[i+1]=a[i];
      b[i+1]=b[i];
      c[i+1]=(b[i]+c[i])%mod;
    }
    if(s[i]=='?'){
      d[i+1]=(d[i]*3)%mod;
      a[i+1]=(a[i]*3+d[i])%mod;;
      b[i+1]=(a[i]+b[i]*3)%mod;
      c[i+1]=(b[i]+c[i]*3)%mod;
    }
  }

  ll ans=c[n];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>

static const int N=100;

int min(int a,int b);

int main(void)
{

  int n;
  int p[N+1];
  int m[N+1][N+1];
  int i,j,k,l;

  scanf("%d",&n);

  for(i=1;i<=n;i++)
    {
      scanf("%d%d",&p[i-1],&p[i]);
    }

  for(i=1;i<=n;i++)
    {
      m[i][i]=0;
    }

  for(l=2;l<=n;l++)
    {
      for(i=1;i<=n-l+1;i++)
	{
	  j=i+l-1;
	  
	  m[i][j]=(1<<21);

	  for(k=i;k<=j-1;k++)
	    {
	      m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
	    }
	  
	}
      
    }

  printf("%d\n",m[1][n]);

  return 0;
}

int min(int a,int b)
{
  int min;
  
  return min=a<b ? a:b;
}




Measured memory_bytes: 2100
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:128777216")
  
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <sstream>
  
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
  
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <string.h>
  
#include <memory.h>
#include <cassert>
#include <time.h>
  
using namespace std;
  
#define forn(i,n) for (int i = 0; i < (int)(n); i++)
#define fornd(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define forab(i,a,b) for (int i = (int)(a); i <= (int)(b); i++)
#define forabd(i, b, a) for (int i = (int)(b); i >= (int)(a); i--)
#define forit(i, a) for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
  
#define _(a, val) memset (a, val, sizeof (a))
#define sz(a) (int)((a).size())
#define pb push_back
#define mp make_pair
#define all(v) (v).begin(), (v).end()
  
typedef long long lint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vii;
  
const lint LINF = 1000000000000000000LL;
const int INF = 1000000000;
const long double eps = 1e-9;
const long double PI = 3.1415926535897932384626433832795l;
  
#ifdef MY_DEBUG
#define dbgx( x ) { cerr << #x << " = " << x << endl; }
#define dbg( ... ) { fprintf(stderr, __VA_ARGS__); fflush(stderr); }
#else
#define dbgx( x ) {  } 
#define dbg( ... ) {  } 
#endif
  
void prepare(string s)
{
#ifdef MY_DEBUG
    freopen ("input.txt", "r", stdin);
    //freopen ("output.txt", "w", stdout);
#else
    if (s.length() != 0)
    {
        freopen ((s + ".in").c_str(), "r", stdin);
        freopen ((s + ".out").c_str(), "w", stdout);
    }
#endif
}

const int NMAX = 50;


int n, m, x;
int c[NMAX];
int a[NMAX][NMAX];


void read() {
  scanf("%d %d %d", &n, &m, &x);
  forn(i, n) {
    scanf("%d", &c[i]);
    forn(j, m) {
      scanf("%d", &a[i][j]);
    }
  }
}

void solve() {
  int ans = INF;
  forn(msk, 1 << n) {
    int cost = 0;
    int lev[NMAX] = {0};
    forn(i, NMAX) lev[i] = 0;
    forn(i, n) {
      if ((msk >> i) & 1) {
        cost += c[i];
        forn(j, m) {
          lev[j] += a[i][j];
        }
      }
    }
    
    bool ok = true;
    forn(i, m) {
      ok = ok && lev[i] >= x;
    }
    if (ok) {
      ans = min(ans, cost);
    }
  }
  printf("%d\n", ans == INF? -1 : ans);
}

int main() {
  prepare("");

  read();
  solve();
  return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int n;
        cin >> n;
        if (n == 0) return 0;
        vector<int> V(n);
        int ans = 1000001;
        for (int i=0;i<n;i++) cin >> V[i];
        for (int i=0;i<n-1;i++){
            for (int j=i+1;j<n;j++){
                ans = min(ans,abs(V[i]-V[j]));
            }
        }
      	cout << ans << endl; 
    }
}



Measured memory_bytes: 3016
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
    int n, a, b;
    cin >> n >> a >> b;
    //各位の和
    int sum, num, dig;
    //各桁の和がa以上b以下であるものの和
    int s = 0;
    for(int i=1;i<=n;i++){
        sum = 0;
        dig = 0;
        num = i;
        while(num > 0){
            dig = num % 10;
            sum = sum + dig;
            num = num / 10; 
        }
        if(a<=sum && sum<=b){
            s = s + i;
        }

    }
    cout << s << "\n";
    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL

int main() {
	ll		b,c,h,i,j,k,l,m,n,x,y;
	ll		ans = 0;
	string	s;
	cin >> n >> m;
	vector<pair<ll,ll>>	a(n);
	for(i=0;i<n;i++) cin >> a[i].first >> a[i].second;
	sort(a.begin(),a.end());

	i = 0;
	while(1) {
		if (a[i].second <= m) {
			m -= a[i].second;
			ans += a[i].first * a[i].second;
		} else {
			ans += a[i].first * m;
			break;
		}
		i++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4812
#include <iostream>
using namespace std;
int main(){
    string S,T;
    cin>>S>>T;
    int count=0;
    int n=S.length();
    for(int i=0;i<n;i++){
        if(S[i]!=T[i]){
            count++;
        }
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 3860
#define Bobyama
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


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

  int A, B;

  cin >> A >> B;

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

  return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int t = 0;
        int i = 0;
        while (t < x) {
            i++;
            t += i;
        }
        System.out.println(i);
    }
}

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

int main(){
  int a,b,c;
  string out;  
  cin >> a >> b >> c;
  if(a<=c and c<=b) out = "Yes";
  else if(b<=c and c<=a) out ="Yes";
  else out ="No";
  cout << out << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

void go()
{
    int n,sw=0,cnt=0;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        if(s[i] == 'R')
            cnt++;
    }
    for(int i=0;i<cnt;i++)
    {
        if(s[i]!='R')
            sw++;
    }
    cout<<sw;
}
int main()
{
    FIO;
//    int t;
//    cin>>t;
//    while(t--)
        go();
    return 0;
}


Measured memory_bytes: 3728
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

struct edge{int to, cost;};

int n, d[3010], m, k, s[3010];
vector<edge> g[3010];

void dijkstra() {
  priority_queue<PII, vector<PII>, greater<PII>> que;
  fill(d, d+n, INF);
  REP(i, k) {
    d[s[i]] = 0;
    que.push(PII{0, s[i]});
  }

  while(que.size()) {
    PII p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(edge e: g[v]) {
      if(d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(PII{d[e.to], e.to});
      }
    }
  }
}

int a[100010], b[100010], c[100010];
signed main(void)
{
  cin >> n >> m >> k;
  REP(i, m) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
    g[a[i]].PB({b[i], c[i]});
    g[b[i]].PB({a[i], c[i]});
  }
  REP(i, k) cin >> s[i], s[i]--;

  dijkstra();
  // REP(i, n) cout << d[i] << " "; cout << endl;

  int ret = 0;
  REP(i, m) chmax(ret, (d[a[i]]+d[b[i]]+c[i])/2+!!((d[a[i]]+d[b[i]]+c[i])%2));
  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 7212
#include <bits/stdc++.h>
using namespace std;
int main() {
	int ans = 0;
	int tmp;
	int n;
	cin >> n;
	vector<int>a(n);
	for(int i=0;i<n;i++)cin >> a[i];
	sort(a.begin(), a.end());
	
	cout << a[n-1] - a[0] << endl;
}



Measured memory_bytes: 256
<?php
// Your code here!
$inp = fgets(STDIN);
$n   = (int)$inp;
$inp = fgets(STDIN);

$t   = explode(" ", $inp);
$t   = array_map(function($a){return (int)$a;}, $t);

$ans = 1e20;
for($int = 0; $int <= 100; $int++)
{
    $score = 0;
    foreach($t as $x)
    {
        $score += pow(($int - $x),2);
    }
    $ans = min($score, $ans);
}
echo($ans);
?>


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

int main(){
    string s;
    cin >> s;

    if(s[5] == '0'){
        if(s[6] > '4'){
            cout << "TBD" << endl;
        }
        else if(s[6] == '4' && s[8] == '3' && s[9] == '1'){
            cout << "TBD" << endl;
        }
        else cout << "Heisei" << endl;
    }
    else cout << "TBD" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
typedef long long LL;
int main(){
		LL n,m;
		cin >> n;
		cout << (1 + n) * n / 2 << endl;
		return 0;
	}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func main() {
	list1 := getStdinIntArr()
	p := getStdinIntArr()
	X := list1[0]
	N := list1[1]

	sort.Ints(p)

	find := true
	index := 0
	for idx, val := range p {
		if val == X {
			find = false
			index = idx
			break
		}
	}
	if find {
		fmt.Printf("%d\n", X)
		return
	}

	prev := 0
	min1 := -math.MaxInt16
	min2 := math.MaxInt16

	prev = p[index]
	find = false
	for i := index - 1; i >= 0; i-- {
		if prev-1 != p[i] {
			min1 = prev - 1
			find = true
			break
		}
		prev = p[i]
	}
	if !find {
		min1 = p[0] - 1
	}

	prev = p[index]
	find = false
	for i := index + 1; i < N; i++ {
		if prev+1 != p[i] {
			min2 = prev + 1
			find = true
			break
		}
		prev = p[i]
	}
	if !find {
		min2 = p[N-1] + 1
	}

	if min1 == -math.MinInt16 {
		fmt.Printf("%d\n", min2)
		return
	}
	if min2 == math.MinInt16 {
		fmt.Printf("%d\n", min1)
		return
	}

	min1abs := X - min1
	min2abs := min2 - X
	if min1 < 0 {
		min1abs = -min1
	}
	if min2 < 0 {
		min2abs = -min2
	}

	if min1abs == min2abs {
		fmt.Printf("%d\n", min1)
	} else if min1abs < min2abs {
		fmt.Printf("%d\n", min1)
	} else {
		fmt.Printf("%d\n", min2)
	}
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func getStdinArr() []string {
	str := getStdin()
	list := strings.Split(str, " ")
	return list
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


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

using namespace std;

typedef long long int lli;
typedef vector <lli> vi;
typedef vector <vi> vvi;
typedef pair <lli, lli> pi;

int is_prime(lli num) {
  lli square = sqrt(num);
  lli maximum_div = 0;

  for (lli i = square; i >= 2; --i) {
    if (num % i == 0) {
      return i;
    }
  }

  return -1;
}

int main() {
  lli num;

  cin >> num;

  lli div = is_prime(num);
  if (div == -1) {
    cout << num - 1 << endl;
  } else {
    cout << (div + (num / div)) - 2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
while True:
    try:
        a,b,c,d,e,f = (int(i) for i in input().split())
        det=a*e-b*d
        x = (c*e-b*f)/det
        y = (a*f-c*d)/det
        if x==0:x=0
        if y==0:y=0
        print("{0:.3f} {1:.3f}".format(x,y))
    except EOFError:
        break

Measured memory_bytes: 7640
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005
#define x1 xdddddddddddddddddd
#define y1 ydddddddddddddddddd
#define int ll

int n,a[100005],b[100005],s;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }
    for(int i=1;i<=n;i++){
        cin >> b[i];
        if(b[i]<=a[i]) s+=a[i]-b[i];
        else s-=(b[i]-a[i])/2;
    }
    if(s<=0) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 384
s = input()
n = int(input())
query = [0]*n
rev = 0
for i in range(n):
    query[i] = list(map(str, input().split()))
    if query[i][0] == '1':
        rev = rev + 1

begin = []
end = []
pal = 0

for i in range(n):
    if int(query[i][0]) == 1:
        pal = (pal+1)%2
    else:
        if pal == 0:
            if int(query[i][1]) == 1:
                begin.append(query[i][2])
            else:
                end.append(query[i][2])
        else:
            if int(query[i][1]) == 1:
                end.append(query[i][2])
            else:
                begin.append(query[i][2])
#    print('--------'+str(i+1)+'th try-----')
#    print(begin)
#    print(end)
#    print('pal:'+str(pal))
#print(s)

if rev%2 == 1:
    print(''.join(end[::-1])+s[::-1]+''.join(begin))
else:
    print(''.join(begin[::-1])+s+''.join(end))

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

using namespace std;

int main() {
	int n;
	double a[11];
	string u[11];
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i] >> u[i];
	double res = 0;
	cout << fixed << setprecision(6);
	for (int i = 1; i <= n; ++i) {
		if (u[i][0] == 'B') res += a[i] * 380000;
		else res += a[i];
	}
	cout << res;
	return 0;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
items = [[0, 0]]
v_total = 0
for _ in range(N):
    w, v = map(int, input().split())
    items.append([w, v])
    v_total += v

dp = [[float("inf")] * (v_total + 1) for _ in range(N + 1)]

for i in range(N + 1):
    dp[i][0] = 0

ans = 0
for i in range(1, N + 1):
    for j in range(v_total + 1):
        if j - items[i][1] >= 0:
            dp[i][j] = min(dp[i - 1][j - items[i][1]] + items[i][0], dp[i - 1][j])
        else:
            dp[i][j] = dp[i - 1][j]

        if i == N and dp[i][j] <= W:
            ans = max(ans, j)

print(ans)

Measured memory_bytes: 379448
#include<bits/stdc++.h>
using namespace std;
int main(){
int x,n;
cin>>x>>n;
int a[n];
for(int i=0;i<n;i++){
    cin>>a[i];
}
int t=0;
int flag=0;
int j=1;
if(n==0){
    cout<<x;
    return 0;

}
int f=n+1;
int r=0;
while(f--){
        int z=x;
    for(int i=0;i<n;i++){
        if(z==a[i]){
                flag=1;

        }
    }
    if(flag==0){
            cout<<z;
    return 0;
    }
    flag=0;
   if(r%2==0){
   x=x-j;
   j++;
   }
   else{
    x=x+j;
   j++;
   }
   r++;

}
}


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define f           first
#define s          second
#define sz(x)       (int)x.size()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep0(a,n)  for(int i=0;i<n;i++)cin>>a[i]
#define si(x)       cin>>x
#define sii(x,y)    cin>>x>>y
#define siii(x,y,z) cin>>x>>y>>z
#define ahell   998244353
#define hell 1000000007
#define N1 100001
#define fl 1.0000000000
//#define mod 998244353
#define cntbit(a) __builtin_popcountll(a)
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

main()
{
  ios

//si(test);
int test=1,i,j,k,l;
int n,m;
//si(test);
//sieve();
while(test--)
{
  // sii(n,k);
 si(n);
 int t1=1,t2=1,t3=1;
 for(i=0;i<n;i++)
 {
    t1*=10;
    t2*=9;
    t3*=8;
    t1%=hell;
    t2%=hell;
    t3%=hell;
 }
 t1+=t3;
 t1%=hell;
 t2*=2;
 t2%=hell;
 t1=(t1-t2+hell)%hell;
 cout<<t1;

 }
}


Measured memory_bytes: 3648
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;

import org.omg.Messaging.SyncScopeHelper;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		new Main();
	}
	public Main(){
		new Test_100().doIt();
	}
	class Test_100{
		void doIt() {
			int index[] = new int[13];
			index[1] = index[3] = index[5] = index[7] = index[8] = index[10] = index [12] = 1;
			index[4] = index[6] = index[9] = index[11] = 2;
			index[2] = 3;
			int x = sc.nextInt();
			int y = sc.nextInt();
			if(index[x] == index[y])System.out.println("Yes");
			else System.out.println("No");
		}
	}
}


Measured memory_bytes: 21204
import sys
from collections import defaultdict
def input(): return sys.stdin.readline().strip()


def main():
    n = input()
    if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


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

using namespace std;

int main() {
	cin.sync_with_stdio(false);

	int x;
	cin >> x;
	if (x < 1200) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ARC" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
L = [list(map(int, input().split())) for _ in range(M)]

X = [set([i]) for i in range(1,N+1)]

par = list(range(N+1))
rank = [0] * (N+1)
size = [1] * (N+1)

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
        size[y] += size[x]
    else:
        par[y] = x
        size[x] += size[y]
        if rank[x] == rank[y]:
            rank[x] += 1
    return

C = [0]
for a, b in L[::-1]:
    xa = find(a)
    xb = find(b)
    if xa == xb:
        C.append(C[-1])
    else:
        C.append(C[-1] + size[xa] * size[xb])
        unite(xa, xb)

for c in C[:-1][::-1]:
    print(N*(N-1)//2-c)

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

#define endl '\n'
#define PB push_back
#define PF push_front
#define MP make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int INF = 1e9 + 7;
const ll LINF = 1e18 + 14;

int main(){
    ios_base::sync_with_stdio(false); //cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 1; i < n; i++){
        cin >> v[i];
    }
    int sum = v[1];

    for (int i = 2; i < n; i++){
        sum += min(v[i-1], v[i]);
    }
    cout << sum + v[n-1];
    return 0;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 1e3;
int n;
int b[N][N];
int b3[3][3] = {
  0,1,1,
  1,0,0,
  1,0,0
};
int b4[4][4] = {
  1,1,3,4,
  2,2,3,4,
  3,4,1,1,
  3,4,2,2
};
int b5[5][5] = {
  1,1,2,2,3,
  4,0,1,1,3,
  4,1,0,0,4,
  2,1,0,0,4,
  2,3,3,1,1
};
int b6[6][6] = {
  0,4,4,2,2,3,
  4,0,0,1,0,3,
  4,0,0,1,2,2,
  2,2,3,0,4,4,
  1,0,3,4,0,0,
  1,2,2,4,0,0
};
int b7[7][7] = {
  0,1,1,2,2,1,1,
  1,3,3,4,0,0,0,
  1,4,0,4,0,0,0,
  2,4,3,3,0,0,0,
  2,0,0,0,3,3,4,
  1,0,0,0,4,0,4,
  1,0,0,0,4,3,3
};
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  if(n<3){
    cout << -1 << endl;
    return 0;
  }
  int a = n;
  while(a>=8){
    FOR(i, 0, 4)FOR(j, 0, 4) b[a-i-1][a-j-1] = b4[i][j];
    a -= 4;
  }
  switch(a){
    case 3:
      FOR(i, 0, a)FOR(j, 0, a) b[i][j] = b3[i][j];
      break;
    case 4:
      FOR(i, 0, a)FOR(j, 0, a) b[i][j] = b4[i][j];
      break;
    case 5:
      FOR(i, 0, a)FOR(j, 0, a) b[i][j] = b5[i][j];
      break;
    case 6:
      FOR(i, 0, a)FOR(j, 0, a) b[i][j] = b6[i][j];
      break;
    case 7:
      FOR(i, 0, a)FOR(j, 0, a) b[i][j] = b7[i][j];
      break;
  }
  FOR(i, 0, n){
    FOR(j, 0, n) cout << (b[i][j] ? char(96+b[i][j]) : '.');
    cout << endl;
  }
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<bool> vb;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sq(x) ((x)*(x))
#define fo(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<n;i++)
#define Fo(i,n) for(int i=1;i<=n;i++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define deb(x) cout<<#x<<"="<<x<<"\n"
#define deb2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<"\n"
#define fi first
#define se second
const double pi = 3.14159265358979323846;
#define uni(c) (c).resize(unique(all(c))-(c).begin())
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
//pair <int, int> w[4] = {mp(-1, 0), mp(0, -1), mp(1, 0), mp(0, 1)};   // for matrix movement:
void cp()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
}
void solve()
{
	ll a, b, c, d; cin >> a >> b >> c >> d;
	ll temp1 = -1e12, temp2 = -1e12, temp3 = -1e12, temp4 = -1e12;
	temp1 = a * c;
	temp2 = a * d;
	temp3 = b * c;
	temp4 = b * d;
	cout << max({temp4, temp3, temp2, temp1});

}
int main()
{
	fast;
	//cp();
	ll t = 1;
	//cin >> t;
	while (t--)
		solve();


	return 0;
}

Measured memory_bytes: 3648
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
s = 0
prev = 0
for i in range(n):
  s += B[A[i]-1]
  if A[i] != 1 and (A[i]-1 == prev):
    s += C[A[i]-2]
  prev = A[i]
print(s)

Measured memory_bytes: 3064
#python3
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

odd = [a[i] for i in range(n) if i%2==0]
even = [a[i] for i in range(n) if i%2!=0]

cntOdd = Counter(odd).most_common(2)
cntEven = Counter(even).most_common(2)

 

if cntOdd[0][0] != cntEven[0][0]:
    print(n - cntOdd[0][1] - cntEven[0][1])
else:
    if len(cntEven) == 1 and len(cntEven):
        print(n//2)
    else:
        ans1 = n - cntOdd[1][1] - cntEven[0][1]
        ans2 = n - cntOdd[0][1] - cntEven[1][1]
        print(min(ans1, ans2))


    
    
    

Measured memory_bytes: 15972