akhauriyash/Code-Regression huggingface dataset:
n = int(input())
f = []
p = []
for _ in range(n):
  f.append(list(map(int, input().split())))
for _ in range(n):
  p.append(list(map(int, input().split())))

def solve(out_list):
  ans = 0
  for fi, pi in zip(f, p):
    c = 0
    for o in out_list:
      if fi[o] == 1:
        c += 1
    ans += pi[c]
  return ans

ans = -float("inf")
for i in range(2 ** 10):
  out_list = []
  ## どの桁が1になっているかをチェックするために2進数の各桁をループ
  for j in range(10):
    ## i >> jで確認したい桁を一番右までずらして1と論理積をとって「選択」している要素を確認
    if (i >> j) & 1:
      out_list.append(j)
  if len(out_list) != 0:
    ans = max(ans, solve(out_list))
print(ans)


Measured memory_bytes: 68832
ans=[0]*4

for i in range(3):
    a,b=map(int,input().split())
    ans[a-1]+=1
    ans[b-1]+=1

f1=0
f2=0
for i in range(4):
    if ans[i]==1:
        f1+=1
    if ans[i]==2:
        f2+=1
if f1==2 and f2==2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
/*  -*- coding: utf-8 -*-
 *
 * 3109.cc: Canisar Cipher
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MOD = 1000000007;
const int D = 10;

/* typedef */

typedef long long ll;

/* global variables */

char s[MAX_N + 4];
int ts[D], ps[D];

/* subroutines */

/* main */

int main() {
  int m;
  scanf("%d%s", &m, s);

  int n = strlen(s);
  for (int i = n - 1, e = 1; i >= 0; i--) {
    int ci = s[i] - '0';
    ts[ci] = (ts[ci] + e) % MOD;
    e = (ll)e * 10 % MOD;
  }

  for (int i = 0; i < D; i++) ps[i] = i;

  do {
    if (n > 1 && ps[s[0] - '0'] == 0) continue;

    int sum = 0;
    for (int i = 0; i < D; i++)
      sum = (sum + (ll)ps[i] * ts[i] % MOD) % MOD;
    if (sum == m) {
      for (int i = 0; i < n; i++) putchar(ps[s[i] - '0'] + '0');
      putchar('\n');
      return 0;
    }
  } while (next_permutation(ps, ps + D));

  puts("-1");
  return 0;
}



Measured memory_bytes: 3252
#include<stdio.h>
#define N 100000

int main(){
  int n1,n2,i,j,c=0,left=0,right,mid;
  int in[N],serch[N];

  scanf("%d",&n1);

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

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

  right=n1;


  right=n1;
  for(i=0;i<n2;i++){
    left=0;
    right=n1;
   while(left<right){
    mid=(left+right)/2;
    if(in[mid]==serch[i]){
      c++;
      break;
    }
    else if (serch[i] < in[mid])right=mid;
    else left=mid+1;
  }
  }
  

  printf("%d\n",c);
  return 0;
}



Measured memory_bytes: 2288
n = int(input())
leaves = list(map(int, input().split()))

ans = 0
nodes_min = [0] * (n + 1)
nodes_max = [0] * (n + 1)
nodes_min[n] = leaves[n]
nodes_max[n] = leaves[n]

for depth in range(n, 0, -1):
    root_min = nodes_min[depth] // 2 + nodes_min[depth] % 2
    nodes_min[depth - 1] = leaves[depth - 1] + root_min
    root_max = nodes_max[depth]
    nodes_max[depth - 1] = leaves[depth - 1] + root_max
nodes = [0] * (n + 1)
nodes[0] = 1
for depth in range(n):
    roots = nodes[depth]-leaves[depth]
    nodes[depth + 1] = min(roots * 2, nodes_max[depth + 1])
for depth in range(n+1):
    if nodes[depth] < nodes_min[depth]:
        print(-1)
        break
else:
    print(sum(nodes))

Measured memory_bytes: 654648
# coding: utf-8
# Your code here!
x=input().split()



if(x[0]=="0"):
    print(1)
elif(x[1]=="0"):
    print(2)
elif(x[2]=="0"):
    print(3)
elif(x[3]=="0"):
    print(4)
elif(x[4]=="0"):
    print(5)


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
 
#ifdef WIN32
    #define lld "%I64d"
#else
    #define lld "%lld"
#endif
 
#define mp make_pair
#define pb push_back
#define put(x) { cout << #x << " = "; cout << (x) << endl; }
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef double db;
 
const int M = 1e6 + 15;
const int Q = 1e9 + 7;

 
vector<int> ans;
int used[M];
vector<int> g[M];

void dfs(int v) {
	used[v] = 1;
	ans.pb(v);
	for (auto u : g[v]) {
		if (!used[u]) {
			dfs(u);
			return;
		}	
	}
}
int main() {
    srand(time(NULL));
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(0);
 
	int n;
	int m;
	cin >> n >> m;
	int v1 = -1, v2 = -1;
	for (int i = 0; i < m; i++) {
		int ai, bi;
		cin >> ai >> bi;
		g[ai].pb(bi);
		g[bi].pb(ai);
		v1 = ai, v2= bi;
	}

	
	used[v1] = used[v2] = 1;
	dfs(v1);
	reverse(ans.begin(), ans.end());
	dfs(v2);
	cout << (int)ans.size() << endl;
	for (auto u : ans)
		cout << u << " ";
	

    return 0;
}   

Measured memory_bytes: 31608
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    int x,y,a,b,c;
    vector<long long> p;
    vector<long long> q;
    vector<long long> r;
    
    cin >> x >> y >> a >> b >> c;
    
    for (int i = 0;i < a;i++){
        long long n;
        cin >> n;
        p.push_back(n);
    }
    
    for (int i = 0;i < b;i++){
        long long n;
        cin >> n;
        q.push_back(n);
    }
    
    for (int i = 0;i < c;i++){
        long long n;
        cin >> n;
        r.push_back(n);
    }
    
    p.push_back(1000000001);
    q.push_back(1000000001);
    
    sort(p.begin(),p.end(),greater<long long>());
    sort(q.begin(),q.end(),greater<long long>());
    sort(r.begin(),r.end(),greater<long long>());
    
    int pback = x;
    int qback = y;
    int rtop = 0;
    
    while(1){
        if (rtop >= r.size()){
            break;
        }
        
        if (min(p[pback],q[qback]) >= r[rtop]){
            break;
        }
        else{
            if (p[pback] < q[qback]){
                p[pback] = r[rtop];
                rtop += 1;
                pback -= 1;
            }
            else if (p[pback] > q[qback]){
                q[qback] = r[rtop];
                rtop += 1;
                qback -= 1;
            }
            else {
                if (pback > qback){
                    p[pback] = r[rtop];
                    rtop += 1;
                    pback -= 1;
                }
                else {
                    q[qback] = r[rtop];
                    rtop += 1;
                    qback -= 1;
                }
            }
        }
    }
    
    long long ans = 0;
    for (int i = 1;i <= x;i++){
        ans += p[i];
    }
    for (int i = 1;i <= y;i++){
        ans += q[i];
    }
    
    cout << ans << endl;
}


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

int n;
int a[60];
int cnt;
int cntx;

int main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == -2) cnt++;
		if (a[i] == -1) cntx++;
	}
	
	if (cnt % 2 == 0) cntx = 0;
	else cntx = min(cntx, 1);
	if (cnt % 2 && cntx == 0) cnt--;
	
	vector<int> ans;
	for (i = 0; i < n; i++) {
		if (a[i] == 2) ans.push_back(i);
		if (a[i] == -2 && cnt > 0) {
			ans.push_back(i);
			cnt--;
		}
		if (a[i] == -1 && cntx) {
			ans.push_back(i);
			cntx--;
		}
	}
	
	cout << ans.size() << endl;
	for (i = 0; i < ans.size(); i++) {
		cout << ans[i] + 1 << endl;
	}
	return 0;
}


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

int main() {
    long long n;
    cin >> n;
    vector<long long> balls(n), nums(1000000);
    long long maxn = 0;
    for (int i=0; i<n; i++) {
        long long num; cin >> num;
        balls[i] = num;
        nums[num]++;
        maxn = max(maxn, num);
    }
    long long sum = 0;
    for (int i=0; i<=maxn; i++) {
        long long num = nums[i];
        if (num >= 2) sum += num*(num-1)/2;
    }
    for (int i=0; i<n; i++) {
        long long num = balls[i];
        if (nums[num] == 1) cout << sum << endl;
        else if (nums[num] == 2) {
            cout << sum - (nums[num]*(nums[num]-1)/2) << endl;
        }
        else {
            cout << sum - (nums[num]*(nums[num]-1)/2) + ((nums[num]-1)*(nums[num]-2)/2) << endl;
        }
    }
}

Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  string s; cin>>s;
  if( s[2]==s[3] && s[4]==s[5]) cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] B = new int[N - 1];
        for (int i = 0; i < N - 1; i++) {
            B[i] = sc.nextInt();
        }
        int[] A = new int[N];
        A[0] = B[0];
        A[N - 1] = B[N - 2];

        for (int i = 1; i <= N -2; i++) {
            A[i] = Math.min(B[i - 1], B[i]);
        }

        int ans = 0;
        for (int i = 0; i < N; i++) {
            ans += A[i];
        }
        System.out.print(ans);
    }

    // Main
    public static void main(String[] args) {
        new Main().solve();
    }
}

Measured memory_bytes: 23892
N = 0
N, A, B, C = [int(s) for s in input().split()]

bamboos = [int(input()) for _ in range(N)]


# def divide(l):
#     if len(l) == 0:
#         return []
#     if len(l) == 1:
#         return [
#             [[], [], []],  # 使わない
#             [[l[0]], [], []],  # A で使う
#             [[], [l[0]], []],  # B で使う
#             [[], [], [l[0]]],  # C で使う
#         ]

#     res = []
#     for a, b, c in divide(l[1:]):
#         # 使わない
#         res.append([a, b, c])
#         # A で使う
#         res.append([l[0:1] + a, b, c])
#         # B で使う
#         res.append([a, l[0:1] + b, c])
#         # C で使う
#         res.append([a, b, l[0:1] + c])

#     return res


# min_mp = -1
# for a, b, c in divide(bamboos):
#     al, ac = sum(a), len(a)
#     bl, bc = sum(b), len(b)
#     cl, cc = sum(c), len(c)
#     if al == 0 or bl == 0 or cl == 0:
#         continue

#     # 合成に使った魔力
#     composite = 10 * ((ac - 1) + (bc - 1) + (cc - 1))
#     # 総合魔力
#     mp = abs(al - A) + abs(bl - B) + abs(cl - C) + composite

#     if mp < min_mp or min_mp == -1:
#         min_mp = mp

# print(min_mp)

# ------------------------
# dfs を使うともっと短くかける
# ------------------------
def dfs(l, a, b, c):
    global A, B, C
    INF = 10**18
    if len(l) == 0:
        if min(a, b, c) > 0:
            return abs(a - A) + abs(b - B) + abs(c - C) - 30
        else:
            return INF

    ret0 = dfs(l[1:], a, b, c)  # l[0] を使わない
    retA = dfs(l[1:], a + l[0], b, c) + 10  # l[0] を A で使う
    retB = dfs(l[1:], a, b + l[0], c) + 10  # l[0] を B で使う
    retC = dfs(l[1:], a, b, c + l[0]) + 10  # l[0] を C で使う

    return min(ret0, retA, retB, retC)


print(dfs(bamboos, 0, 0, 0))


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

int main() {
    int n;
    cin>>n;
    map<int,int> A;
    rep(i,n){
        int a;
        cin>>a;
        A[a-1]++;
    }
    //書かれた数字はいらないので、枚数の情報のみ大きい順に取り出したい
    priority_queue<int,vector<int>,less<int>> que;
    for(auto m:A) que.push(m.second);
    int ans=0;
    while(!que.empty()){
        int v=que.top();
        if(v==1) break;//一番多い枚数が1ならおわり
        que.pop();
        while(v>=3){//a,a,aのように取り出せたら1回の操作で2枚削る
            ans++;
            v-=2;
        }
        if(v==2){//a,a,bのように取り出せば、a,bの大小にかかわらず操作後aが残る
            int w=que.top();
            que.pop();
            if(w>1) que.push(w-1);
            v--;
        }
        que.push(v);
    }
    cout<<que.size()<<endl;
    return 0;
}

Measured memory_bytes: 5628
X,Y,A,B,C=[int(i) for i in input().split(" ")]
red=[int(i) for i in input().split(" ")]
green=[int(i) for i in input().split(" ")]
white=[int(i) for i in input().split(" ")]

red=sorted(red,reverse=True)[:X]
green=sorted(green,reverse=True)[:Y]

color=[(r,'r') for r in red]+[(g,'g') for g in green]
color=sorted(color,key=lambda w:w[0],reverse=False)
white=sorted(white,reverse=True)

delicious=0


for c in color:
    if(c[1]=='r'):
        if X==0:
            continue
        X-=1
        if(len(white)>0 and c[0]<white[0]):
            delicious+=white[0]
            white.pop(0)
        else:
            delicious+=c[0]

    else:
        if Y==0:
            continue
        Y-=1
        if(len(white)>0 and c[0]<white[0]):
            delicious+=white[0]
            white.pop(0)
        else:
            delicious+=c[0]


print(delicious)


Measured memory_bytes: 33712
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define REP(i, n) for (LL i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (LL i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define int long long
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main() {
  int n, m,ans=0;
  cin >> n>>m;
  REP(i,m){
    int a=0;
    cin>>a;
    ans+=a;
  }
  ans=ans;
  if(ans>n){
  cout << "-1";
  }else{
  cout << n-ans;
  }
}

Measured memory_bytes: 3644
#include<iostream>
#include<math.h>
#include<iomanip>

using namespace std;

int main(){
	int n;
	double x1,y1,x2,y2,x3,y3,px,py,r;
	cin>>n;
	cout<<setprecision(3);
	cout<<fixed;
	while(n--){
		cin>>x1>>y1>>x2>>y2>>x3>>y3;
		px=-1.0/2*((x2*x2-x1*x1)*(y3-y1)-(x3*x3-x1*x1)*(y2-y1)+(y3-y1)*(y2-y1)*(y2-y3))/((x3-x1)*(y2-y1)-(x2-x1)*(y3-y1));
		if(y2-y1 != 0){
			py=-(x2-x1)/(y2-y1)*(px-(x1+x2)/2)+(y1+y2)/2;
		}else{
			py=-(x3-x1)/(y3-y1)*(px-(x1+x3)/2)+(y1+y3)/2;
		}
		r=sqrt((px-x1)*(px-x1)+(py-y1)*(py-y1));
		cout<<px<<' '<<py<<' '<<r<<endl;
	}
	return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define LIMIT 1000000007 //10^9+7
#define rep(i, n) for(int i=0; i<(int)n; i++)
/* 一括cin */
template<class H>
void CIN(H& h){cin>>h;}
template<class H, class... T>
void CIN(H &h, T&... t){cin>>h;CIN(t...);}
/* デバッグ */
namespace /* debug */{
  #define DEBUG(...) do{cout<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数
  #define ldebug(...) do{cout<<"["<<setw(3)<<__LINE__<<"] ";debug(__VA_ARGS__);}while(0) //行数
  #define lDEBUG(...) do{cout<<"["<<setw(3)<<__LINE__<<"] "<<#__VA_ARGS__<<" = ";debug(__VA_ARGS__);}while(0) //変数, 行数
  template<class T>void show(T&x){cout<<x<<" ";} //出力
  template<class T>void showendl(T&x){cout<<x<<endl;} //出力改行
  template<class P,class Q>void show(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<") ";} //pair出力
  template<class P,class Q>void showendl(pair<P,Q>&x){cout<<"("<<x.first<<", "<<x.second<<")"<<endl;} //pair出力改行
  template<class H>void debug(H&&h){showendl(h);} //引数1つ
  template<class H,class...Ts>void debug(H&&h,Ts&&...ts){show(h);debug(forward<Ts>(ts)...);} //可変引数
  template<class T>void debug(vector<T>&vt){int i=0;for(auto x:vt)++i!=vt.size()?show(x):showendl(x);} //vector出力
  template<class T>void debug(initializer_list<T>init){int i=0;for(auto x:init)++i!=init.size()?show(x):showendl(x);} //初期化子リスト出力
}
#define all(v) (v).begin(), (v).end()

int main(){
  int n;cin>>n;
  using restaurant = tuple<string,int,int>;
  vector<restaurant> R;
  rep(i,n){
    string s;int p;CIN(s,p);
    R.push_back(make_tuple(s,p,i+1));
  }
  sort(all(R), [](restaurant a, restaurant b){
    string s,t;int p,q;
    tie(s,p,ignore)=a;tie(t,q,ignore)=b;
    return s<t || (s==t&&p>q);
  });
  for(auto x: R){
    string s;
    int p,i;
    tie(s,p,i) = x;
    //DEBUG(s,p,i);
    debug(i);
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
	int a, b, c, d, e, na, nb, nc;
	while(cin >> a >> b >> c >> d >> e >> na >> nb >> nc, a){
		int ans = a * na + b * nb + c * nc;
 
		if(nc >= d){
			ans = min(ans, a * na + b * nb + e * nc);
		}
		else{
			ans = min(ans, a * na + b * nb + e * d);
 
			if(nb + nc >= d){
				int k = d - nc;
				ans = min(ans, a * na + b * (nb - k) + e * d);
			}
			else if(na + nb + nc >= d){
				int j = d - nb - nc;
				ans = min(ans, (na - j) * a + e * d);
			}
			else{
				ans = min(ans, e * d);
			}
		}
 
		cout << ans << endl;
	}
}

Measured memory_bytes: 1164
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	
	public static Scanner sc = new Scanner(System.in);
	
	void run() {
		int a, b, c;
		while (sc.hasNextInt()) {
			a = sc.nextInt();
			b = sc.nextInt();
			c = a + b;
			System.out.println(Integer.toString(c).length());
		}
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().run();
	}

}

Measured memory_bytes: 20412
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int w,h,n;
  cin >> w >> h >> n;
  int m[4];
  m[0]=0;
  m[1]=w;
  m[2]=0;
  m[3]=h;
  rep(i,n){
    int x,y,a;
    cin >> x >> y >> a;
    if(a==1){
      m[0]=max(m[0],x);
    }
    else if(a==2){
      m[1]=min(m[1],x);
    }
    else if(a==3){
      m[2]=max(m[2],y);
    }
    else if(a==4){
      m[3]=min(m[3],y);
    }
  }
  cout << max(0,m[1]-m[0])*max(0,m[3]-m[2]) << endl;
return 0;}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <map>
#include <iostream>
#include<math.h>
using namespace std;

int main() {
	int a[6];
	bool ans = true;
	for (int i = 0; i < 6; i++)cin >> a[i];
	for (int i = 0; i < 5; i++) {
		if (a[4] - a[i] > a[5]) ans = false;
	}
	if (ans)cout << "Yay!" << endl;
	else cout << ":("  << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
double N;
  cin >> N;
  vector<double> A(N);
  for(int a = 0;a < N;a++)cin >> A.at(a);
  double result = 0;
  for(int a = 0;a < N;a++)result += 1 / A.at(a);
  result = 1 / result;
  cout << result << endl;
}

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

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

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

  sort(a.begin(), a.end());

  int maxx = a[n - 1];
  int r = a[0];

  double t = maxx / 2.0;
  for (int i = 1; i < n; i++) {
    double dt = abs(t - r);
    double da = abs(t - a[i]);
    if (da < dt) {
      r = a[i];
    }
  }

  cout << maxx << " " << r << endl;

  return 0;
}

Measured memory_bytes: 640
n = int(input())
s1 = input()
s2 = input()
l = []
m = 1
mod = 10**9 + 7

after = False
for i in range(n):
	if i == n-1:
		if after:
			pass
		else:
			l.append(0)
	else:
		if after:
			after = False
			pass
		else:
			if s1[i] == s1[i+1]:
				l.append(1)
				after = True
			else:
				l.append(0)

for i, x in enumerate(l):
	if i == 0:
		if x == 0:
			m = 3
		else:
			m = 6 
	else:
		if x == 0 and l[i-1] == 0:
			m = m * 2
			m = m % mod
		elif x == 1 and l[i-1] == 0:
			m = m * 2
			m = m % mod
		elif x == 0 and l[i-1] == 1:
			pass
		else:
			m = m * 3
			m = m % mod

print(m)

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

typedef long long lint;
typedef unsigned long long ulint;
const int MOD=1000000007;

int count(int x,int p){
    if(x<p) return x;
    return x%p+count(x/p,p);
}

int main(){
    int N;
    cin >> N;
    int cnt1=N%3;
    N-=cnt1;
    int mn=N;
    for(int i=0;N-9*i>=0;i++){
        if((N-9*i)%6!=0) continue;
        int j=(N-9*i)/6;
        int c=count(i,9)+count(j,6);
        mn=min(mn,c);
    }

    cout << mn+cnt1 << endl;

    return 0;
}

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

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    auto F = new uint[](N);
    auto P = new long[][](N);
    foreach (i; 0 .. N)
    {
        auto tmp = aryread!uint();
        foreach (j; 0 .. 10)
            F[i] = F[i] | (tmp[j] << j);
    }
    foreach (i; 0 .. N)
        P[i] = aryread();
    long eval(uint state)
    {
        long ret;
        foreach (i; 0 .. N)
        {
            ret += P[i][popcnt(state & F[i])];
        }
        return ret;
    }

    long ans = long.min;
    foreach (uint s; 1 .. (1 << 10))
    {
        ans = ans.max(eval(s));
    }
    writeln(ans);
}


Measured memory_bytes: 380
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N, K;
  while (cin >> N >> K) {
    vector<ll> V(N);
    for (ll& x : V) cin >> x;
    ll res = 0;
    for (int l = 0; l <= K && l <= N; l++) {
      priority_queue<ll> minus;
      ll sum = 0, minusSum = 0;
      for (int i = 0; i < l; i++) {
        sum += V[i];
        if (V[i] < 0) {
          minus.push(V[i]);
          minusSum += V[i];
        }
      }
      for (int r = 0; l + r <= K && l + r <= N; r++) {
        int rem = K - l - r;
        if (r > 0) {
          sum += V[N - r];
          if (V[N - r] < 0) {
            minus.push(V[N - r]);
            minusSum += V[N - r];
          }
        }
        while (minus.size() > rem) {
          minusSum -= minus.top();
          minus.pop();
        }
        chmax(res, sum - minusSum);
      }
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
 
  if (S =="AAA") {
    cout << "No" << endl;
  }
  else if (S =="BBB") {
    cout << "No" << endl;
  }
  else {
  cout << "Yes" << endl;
  }
 
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var N = cin.ReadInt;
            var a = cin.ReadIntArray(N).OrderByDescending( value => value ).ToArray();
            
            //Array.Sort(a); Array.Reverse(a); // Array.Sortは昇順ソートを行います
            
            var alice = 0;
            var bob = 0;
            for (int i = 0; i < N; ++i)
            {
                if (i % 2 == 0) alice += a[i];
                else bob += a[i];
            }
            WriteLine(alice - bob);
            
            
        }
        
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
    
    public class Function
    {
        public int findSumOfDigits(int n) {
            int sum = 0;
            while (n > 0) { // n が 0 になるまで
            sum += n % 10;
            n /= 10;
                
            }
            return sum;
            
        }
    }
}

Measured memory_bytes: 13524
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

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

    ll N, M, K;
    cin >> N >> M >> K;
    vector<ll> A(N + 1, 0), B(M + 1, 0);
    rep(i, N) { cin >> A[i + 1]; }
    rep(i, M) { cin >> B[i + 1]; }

    rep(i, N) { A[i + 1] += A[i]; }

    rep(i, M) { B[i + 1] += B[i]; }

    ll ans = 0;
    rep(i, N + 1) {
        ll tmp = i;
        if (A[i] > K)
            break;
        else {
            ll nokori = K - A[i];
            tmp += upper_bound(all(B), nokori) - B.begin() - 1;
        }

        ans = max(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6280
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

typedef long long ll;
const int maxn=50+5;

ll v[maxn],C[maxn][maxn];

void init() {
	for(int i=0;i<=50;i++) {
		C[i][0]=1;
		for(int j=1;j<=i;j++) C[i][j]=C[i-1][j-1]+C[i-1][j];
	}
}

int main() {
	int N,A,B;
	scanf("%d%d%d",&N,&A,&B);
	for(int i=1;i<=N;i++) scanf("%lld",&v[i]);
	sort(v+1,v+N+1);
	ll sum=0;
	int need=0,cnt=0;
	for(int i=N;i>=N-A+1;i--) {
		sum+=v[i];
		if(v[i]==v[N-A+1]) ++need;
	}
	for(int i=1;i<=N;i++) if(v[i]==v[N-A+1]) ++cnt;
	init();
	ll ans=0;
	if(need==A) for(int i=A;i<=B;i++) ans+=C[cnt][i];
	else ans=C[cnt][need];
	printf("%.6lf\n%lld\n",1.*sum/A,ans);
	return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;

typedef long long LL;
typedef long double ldouble;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    string s;
    cin >> s;
    vector<int> v;
    for(int i = 0; i < s.size(); ++i) {
        if(i + 1 < s.size() && s[i] == 'B' && s[i + 1] == 'C') {
            v.pb(1);
            i++;

        } else {
            if(s[i] == 'A') {
                v.pb(2);

            } else {
                v.pb(0);

            }
        }
    }

    LL res = 0;
    int bcc = 0;
    for(int i = v.size() - 1; i >= 0; --i) {
        if(v[i] == 2) {
            res += bcc;

        } else if(v[i] == 1){
            ++bcc;

        } else {
            bcc = 0;

        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1680
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define db cout<<'h'<<'i'<<endl 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define PI 3.14159265
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;
    int k;string s;
    cin>>n>>k>>s;

    int c=0;
    s.insert(s.begin(),'X');
    s.pb('X');
    int ans=0;
    rep(i,1,n+1)
    {
        if(s[i]=='L' && s[i-1]=='L')ans++;
        else if(s[i]=='R'&& s[i+1]=='R')ans++;
    }
    rep(i,2,n+1)
    {
        if(s[i]!=s[i-1])c++;
    }
    j=c/2;
    ans+=2*min(k,j);
    k-=min(k,j);
    if(k>0 && c%2==1)ans++;
    cout<<ans;
    return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define MAX 1000000

int a[MAX];

int f(int n){
    if(n%2 == 0){
        return n/2;
    }
    else{
        return 3*n+1;
    }
}

int main(){
    int s;
    cin >> s;
    a[0] = s;
    for(int i=1;i<MAX;i++){
        a[i] = f(a[i-1]);
        for(int j=i-1;j>=0;j--){
            if(a[i] == a[j]){
                cout << i+1 << endl;
                return 0;
            }
        }
    }


}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <queue>
#include <map>

int main(){
  int N;
  scanf("%d", &N);
  std::vector<int> A(N+5);
  int max_value = 0;
  int max_value2 = 0;
  int max_index = 0;
  int max_index2 = 0;
  for (int i=0; i<N; i++){
    scanf("%d", &A[i]);
  }
  for (int i=0; i<N; i++){
    if (A[i]>max_value){
      max_index = i;
      max_value = A[i];
    }
  }
  for (int i=0; i<N; i++){
    if (i!=max_index && A[i]>max_value2){
      max_index2 = i;
      max_value2 = A[i];
    }
  }
  
  for (int i=0; i<N; i++){
    if (i!=max_index){
      printf("%d\n",max_value);
    } else {
      printf("%d\n", max_value2);
    }
  }
  return 0;
}

Measured memory_bytes: 2432
#include<cstdio>
#include<cmath>
long long wei(long long x){
    long long sum=0;
    while(x){
        x/=10;
        sum++;
    }
    return sum;
}
long long maxn(long long a,long long b){
    a=wei(a);
    b=wei(b);
    if(a>b)
        return a;
    else
        return b;
}
int main(){
    long long n;
    scanf("%lld",&n);
    long long m=sqrt(n);
    long long minn=10000000000;
    for(int i=1;i<=m;i++){
        if(n%i==0){
            int t=maxn(i,n/i);
            if(t<minn)
                minn=t;
        }
    }
    printf("%lld\n",minn);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int nam = in.nextInt();
		HashSet hs = new HashSet();
		long cnt = 0;
		
		for(int i = 0;i < nam;i++){
		     hs.add(in.next()); 
		}
      
      System.out.println(hs.size());
	}
}

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

int main() {
  long long n;
  cin>>n;
  vector<long long>h(n);
  for(long long i=0;i<n;i++){
    cin>>h.at(i);
  }
  long long A=0;
  vector<long long>ans(n);
  ans.at(n-1)=0;
  for(long long i=n-1;i>=0;i--){
    if(i<n-1&&h.at(i)>=h.at(i+1)){
      A++;
      ans.at(i)=A;
    }
    if(i<n-1&&h.at(i)<h.at(i+1)){
      A=0;
      ans.at(i)=A;
    }
  }
  sort(ans.begin(),ans.end());
  cout<<ans.at(n-1)<< endl;
}
  
    
    

Measured memory_bytes: 1792
#include<bits/stdc++.h>
typedef  long long int ll;
typedef long double ld;
#define pb  push_back
#define vll vector<ll>
#define mll map<ll,ll>
const double PI = 2*acos(0.0);
#define gcd(a,b)   __gcd((a),(b))
#define lcm(a,b)   ((a)/(__gcd((a),(b)))*(b))
#define INF         LLONG_MAX
#define ln  INT_MAX
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;
int main() {
ll n;
cin>>n;
ll a=0;

for(int i=0; i<n; i++){
    a=((a*10)+7)%n;
    if(a==0){cout<<i+1; return 0;}
}

cout<<-1;
return 0;
}


Measured memory_bytes: 3628
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        long gcd(long a, long b) {
            return b == 0 ? a : gcd(b, a % b);
        }

        long lcm(long[] p) {
            long g = gcd(p[0], p[1]);
            long l = (p[0] / g) * p[1];
            for (int i = 2; i < p.length; i++) {
                g = gcd(l, p[i]);
                l = l / g * p[i];
            }
            return l;
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            if (n == 1) {
                out.println(in.nextLong());
                return;
            }
            long[] t = new long[n];
            for (int i = 0; i < n; i++) {
                t[i] = in.nextLong();
            }
            out.println(lcm(t));
        }

    }

    static class InputReader {
        StringTokenizer st;
        BufferedReader br;

        public InputReader(InputStream is) {
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            this.br = br;
        }

        public String next() {
            if (st == null || !st.hasMoreTokens()) {
                String nextLine = null;
                try {
                    nextLine = br.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (nextLine == null)
                    return null;
                st = new StringTokenizer(nextLine);
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}
 

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

int main(){
  ll a,b,c;
  char dummy;
  cin >> a >> b >> dummy >> c ;
  ll ans = a*(b*100+c)/100;
  cout << ans << endl;
  return 0;
}

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

int main(){
string s; cin>>s;
sort(s.begin(),s.end());
if(s.at(0) == s.at(1) && s.at(1) != s.at(2) && s.at(2) == s.at(3) ) cout << "Yes" ; else cout<< "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.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>;
 
typedef long long int ll;
const ll N = 5e5+9;
const ll p = 31;
// const ll m = 1e9 + 7;
const ll inf= 1ll<<60;
const ll mod = 1e9+7;
#define x first
#define y second
#define pb push_back
#define mp make_pair
using pii = pair<ll, ll>;
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
#define BLOCK 708 // ~sqrt(N)
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")



int main()
{   
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif                           
    ll T= 1;
    // cin >> T;
    while(T--){
    	
    	ll a,b,c,k;cin>>a>>b>>c>>k;
    	ll ans = 0;
    	if(k<a){
    		ans+=k;
    		k-=k;
    		a-=k;
    	}
    	else{
    		ans+=a;
    		k-=a;
    	}
    	if(k<b){
    		k-=k;

    	}
    	else{
    		k-=b;
    	}
    	if(k<c){
    		ans-=k;
    		k-=k;

    	}
    	else{
    		ans-=c;
    		k-=c;
    	}
    	cout<<ans<<'\n';	
    }
}   

Measured memory_bytes: 3652
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array;

void main() {
    auto c = new int[][](3, 3);
    iota(3).each!(i => c[i] = readln.split.to!(int[]));

    bool ok = 1;

    auto d = new int[][](3, 2);

    foreach (i ; 0 .. 3) {
        foreach (j ; 0 .. 2) {
            d[i][j] = c[i][j+1] - c[i][j];
        }
    }

    if (!(d[0] == d[1] && d[1] == d[2])) {
        writeln("No");
        return;
    }

    foreach (j ; 0 .. 3) {
        foreach (i ; 0 .. 2) {
            d[j][i] = c[i+1][j] - c[i][j];
        }
    }

    if (d[0] == d[1] && d[1] == d[2]) {
        writeln("Yes");
    }
    else {
        writeln("No");
    }
}




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

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



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

struct Queue(T) {
    private {
        size_t cap, head, tail;
        T[] data;
    }

    this (size_t n) in {
        assert(n > 0, "The capacity of a queue must be a positive integer.");
    } body {
        cap = n + 1;
        data = new T[](cap);
    }

    void clear() {
        head = tail = 0;
    }

    bool empty() {
        return head == tail;
    }

    bool full() {
        return head == (tail + 1) % cap;
    }

    size_t length() {
        return head <= tail ? tail - head : cap - head + tail;
    }

    T front() in {
        assert(!empty, "The queue is empty.");
    } body {
        return data[head];
    }

    void removeFront() in {
        assert(!empty, "The queue is empty.");
    } body {
        (++head) %= cap;
    }

    alias popFront = removeFront;

    void insertBack(T x) in {
        assert(!full, "The queue is full.");
    } body {
        data[tail++] = x;
        tail %= cap;
    }

    alias insert = insertBack;

    T[] array() {
        return head <= tail ? data[head .. tail].dup : data[head .. $] ~ data[0 .. tail];
    }

    string toString() {
        import std.format : format;

        if (head <= tail) {
            return format("[%(%s, %)]", data[head .. tail]);
        }
        else {
            return format("[%(%s, %)", data[head .. $]) ~ format(", %(%s, %)]", data[0 .. tail]);
        }
    }
}

Measured memory_bytes: 380
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) {
        try {
            BufferedReader stdReader = 
                    new BufferedReader( new InputStreamReader(System.in));
            String sStr = stdReader.readLine();

            String[] inputStr = sStr.split(" ");
            int input1 = Integer.valueOf(inputStr[0]).intValue();
            int input2 = Integer.valueOf(inputStr[1]).intValue();

            if (input1 > input2) {
                System.out.println("a > b");
            } else if ( input1==input2) {
                System.out.println("a == b");
            } else {
                System.out.println("a < b");
            }

            stdReader.close();
        } catch (Exception e) {
            System.exit(-1);
        } 
    }
}

Measured memory_bytes: 24228
#include <algorithm>
#include <string>
int i;
#define rep2(i, a, b) for(i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
using namespace std;
// _________コーディングはここから！！___________
template <const int sz = 5 * 10000000, typename T = long long> struct IO {
    char reader[sz], writer[sz];
    char *now, *now2 = writer;
    IO() {
        reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
        now = reader;
    }
    inline T read() {
        while(*now && *now <= 32) now++;
        if(*now == '-') {
            now++;
            T res = 0;
            while('0' <= *now and *now <= '9') { res = res * 10 + *now++ - '0'; }
            return -res;
        } else {
            T res = 0;
            while('0' <= *now and *now <= '9') { res = res * 10 + *now++ - '0'; }
            return res;
        }
    }
    inline void write(T x, char margin = ' ') {
        if(x == 0) {
            putchar('0');
            putchar(margin);
            return;
        }
        if(x < 0) {
            putchar('-');
            x = -x;
        }
        while(x) {
            *now2 = '0' + x % 10;
            now2++;
            x /= 10;
        }
        do {
            now2--;
            putchar(*now2);
        } while(now2 != writer);
        putchar(margin);
    }
};
IO io;
inline int read() { return io.read(); }
inline void write(int x) { io.write(x); }
inline void write(int x, char c) { io.write(x, c); }
constexpr int N = 500003;
int c[N];
struct T {
    int l, r, idx;
    constexpr bool operator<(const T &rhs) const noexcept { return r < rhs.r; }
} q[N];
int ans[N], last[N], dat[N];

inline void dec(int k) {
    for(++k; k < N; k += k & -k) --dat[k];
}
inline int sum(int k) {
    int res = 0;
    for(++k; k > 0; k -= k & -k) res += dat[k];
    return res;
}
int n, Q, now = 1;

// 頑張れ！！
// #pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")
// 頑張れ！！

int main() {
    n = read(), Q = read();
    rep2(i, 1, n) c[i] = read();
    rep(i, Q) q[i].l = read(), q[i].r = read() + 1, q[i].idx = i;
    sort(q, q + Q);
    rep(i, Q) {
        for(; now < q[i].r; ++now) {
            if(last[c[now]]) dec(last[c[now]]);
            last[c[now]] = now;
        }
        ans[q[i].idx] = sum(q[i].r - 1) - sum(q[i].l - 1) + q[i].r - q[i].l;
    }
    rep(i, Q) write(ans[i], '\n');
}


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

int main(){
  vector<vector<int>> bingo(3, vector<int>(3));
  vector<vector<bool>> checked(3, vector<bool>(3));
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> bingo.at(i).at(j);
    }
  }
  int N,buf;
  cin >> N;
  for(int q=0; q<N; q++){
    cin >> buf;
    for(int i=0; i<3; i++){
      for(int j=0; j<3; j++){
        if(bingo.at(i).at(j)==buf){
          checked.at(i).at(j)= true;
        }
      }
    }
  }
  bool ans= false;
  for(int i=0; i<3; i++){
    if(checked.at(i).at(0) && checked.at(i).at(1) && checked.at(i).at(2)){
      ans= true;
    }
  }
  for(int j=0; j<3; j++){
    if(checked.at(0).at(j) && checked.at(1).at(j) && checked.at(2).at(j)){
      ans= true;
    }
  }
  if(checked.at(0).at(0) && checked.at(1).at(1) && checked.at(2).at(2)){
    ans= true;
  }
  if(checked.at(0).at(2) && checked.at(1).at(1) && checked.at(2).at(0)){
    ans= true;
  }

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

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

int top, S[1000];

void push(int x)
{
 //top????????????????????????????????????????????\
 	S[++top] = x;
}

int pop()
{
	top--;
	//top??????????????????????´??????????
	return S[top+1];
}

int main(){
	int a,b;
	top =0;
	char s[100];
	
	while(scanf("%s", s) != EOF){
		if(s[0] == '+'){
			a = pop();
			b = pop();
			push(a+b);
		}else if(s[0] == '-'){
			b = pop();
			a = pop();
			push(a -b);
		}else if(s[0] == '*'){
			a = pop();
			b = pop();
			push(a*b);
		}else{
			push(atoi(s));
		}
	}
	printf("%d\n", pop());
	return 0;
}

Measured memory_bytes: 548
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstdio>
#include <cstdlib>

using namespace std;

int main(int argc,char** argv) {
	int x,t;
	cin >> x >> t;
	cout << max(0,x-t);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int gcd = a[0];

		for (int i = 0; i < n; i++) {
			gcd = gcd(gcd, a[i]);
		}

		System.out.println(gcd);
		sc.close();
	}

	public static int gcd(int m, int n) {
		if (m < n)
			return gcd(n, m);
		if (n == 0)
			return m;
		return gcd(n, m % n);
	}

}


Measured memory_bytes: 49828
#include<iostream>
#include<map>
#define MAX_N 100005
using namespace std;
typedef long long ll;

ll boxes[MAX_N];

int main() {
    int N, M;
    map<int, int> mp;
    cin >> N >> M;
    boxes[0] = 0;
    mp[0] += 1;
    for (int i = 1; i <= N; i++) {
        cin >> boxes[i];
        boxes[i] += boxes[i - 1];
    }
    for (int i = 1; i <= N; i++) {
        boxes[i] %= M;
        mp[boxes[i]] += 1;
    }
    ll ans = 0;
    for (int i = 1; i <= N; i++) {
        ll count = mp[boxes[i]];
        ans += count * (count - 1) / 2;
        mp[boxes[i]] = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    Int K; cin >> K;
    Int F = 0, E = 0, S = 0, T = 0, I = 0, V = 0, A = 0;
    vector<Int> L(500), C(500);
    for (int i = 0; i < 500; i++) {
        F += 1;
        E += F;
        S += E;
        T += S;
        I += T;
        V += I;
        A += V;
        L[i] = A;
    }
    for (int i = L.size() - 1; i >= 0; i--) {
        C[i] = K / L[i];
        K %= L[i];
    }
    for (int i = 0; i < 500; i++) {
        cout << "FESTIVA";
        for (int j = 0; j < C[i]; j++) {
            cout << 'L';
        }
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 3632