akhauriyash/Code-Regression huggingface dataset:
import java.io._
import java.util.StringTokenizer

import scala.reflect.ClassTag

object Main {
  def main(args: Array[String]): Unit = {
    try {
      val (in, out) =
        if (isOnlineJudge) {
          (
            new FastScanner(new InputStreamReader(System.in)),
            new PrintWriter(System.out)
          )
        } else {
          (
            new FastScanner(new FileReader(new File("src/resource/problem.in"))),
            new PrintWriter(new File("src/resource/problem.out"))
          )
        }
      new Abc154(in, out).solve()
      out.flush()
      out.close()
    } catch {
      case e: IOException => e.printStackTrace()
    }
  }

  private[this] val isOnlineJudge = true

  class FastScanner(val streamReader: InputStreamReader) {
    private[this] val reader = new BufferedReader(streamReader, 32768)
    private[this] var tokenizer: StringTokenizer = _

    @inline private[this] final def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = Integer.parseInt(next())

    def nextLong(): Long = java.lang.Long.parseLong(next())

    def nextChar(): Char = next().charAt(0)

    def ni(): Int = nextInt()

    def nl(): Long = nextLong()

    def nc(): Char = nextChar()

    def ns(): String = next()

    def ns(n: Int): Array[Char] = ns().toCharArray

    def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)

    def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
      val A1, A2 = Array.ofDim[Int](n)
      REP(n) { i =>
        A1(i) = ni() + offset
        A2(i) = ni() + offset
      }
      (A1, A2)
    }

    def nm(n: Int, m: Int): Array[Array[Int]] = {
      val A = Array.ofDim[Int](n, m)
      REP(n) { i =>
        REP(m) { j =>
          A(i)(j) = ni()
        }
      }
      A
    }

    def nal(n: Int): Array[Long] = map(n)(_ => nl())

    def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n)(_ => ns(m))
  }

  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while (i < N) {
      f(i);
      i += 1
    }
  }

  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while (i >= offset) {
      f(i);
      i -= 1
    }
  }

  def TO(from: Int, to: Int)(f: Int => Unit): Unit = {
    REP(to - from + 1, from)(f)
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]): Array[Long] = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}

class Abc154(fScanner: Main.FastScanner, out: java.io.PrintWriter) {

  import Main._
  import fScanner._

  def solve(): Unit = {
    val s = ni()
    val a = na(s)

    val b = a.distinct
    if(a.length == b.length) out.println("YES") else out.println("NO")
  }
}


Measured memory_bytes: 60536
K, N = map(int, input().split())
A = list(map(int, input().split()))

dist = [0] * (N)
for i in range(N):
    if i != N-1:
        dist[i] = A[i+1] - A[i]
    else:
        dist[i] = K-A[i] + A[0]

print(sum(dist) - max(dist))

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

using namespace std;

int main(void)
{
	long long n,x; cin>>n>>x;
	long long ans = n;
	long long a,b, c;
	a = n - x; b = x; c = a / b;
	while(a%b != 0){
		ans += b * c * 2;
		long long tmp = a;
		a = b; 
		b = tmp % a;
		c = a / b;
	}
	ans += b * (c * 2-1);
	cout<<ans<<endl;
	return 0;
}



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

 
int main()
{
	int A, B;
    char Aadr[6] = {};
    char Badr[6] = {};
    char S[11];
    int i;
  
 // 整数の入力
    scanf("%d %d", &A, &B);
    scanf("%s", S);
//printf("%d %d \n",A, B);
//printf("%s \n",S);
  
   for(i=0; i < A; i++){
     if((S[i] < '0') ||  ('0' + 10) < S[i]) 
     {
     printf("No\n" );
     return 0;
     }
   }
   if( '-' !=S[A]){
     printf("No\n" );
     return 0;
   }
   for(i=0; i < B; i++){
//     Badr[i] = S[i + A + 1];
     if((S[i + A + 1] < '0') ||  ('0' + 10) < S[i + A +1]) 
     {
     printf("No\n" );
     return 0;
     }
   }


    printf("Yes\n" );

   return 0;
}


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

#define ll long long
#define ld long double
#define mod 1000000007LL
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define endl '\n'
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define pb(x) push_back(x)
#define fo(i, a, n) for (i = (a); i < (n); i++)
#define foe(i, a, n) for (i = (a); i <= (n); i++)
// clang-format off
#define vin(a) for (ll i = 0; i < sz(a); i++) { cin >> a[i]; } 
#define vout(a) for (auto x : a) { cout << x << " "; }
#define sws                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0)
// clang-format on
#define pd(x) cout << x
#define sd(x) cin >> x
#define nl cout << endl
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define foreach(i, a)                                                          \
  for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
// int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
void solve() {
  ll m, n;
  ll i, j, k;
  cin >> n;
  vll a(n);
  vin(a);
  ll ans = 0;

  fo(i, 0, n) {
    fo(j, i + 1, n) {
      fo(k, j + 1, n) {
        if (a[i] == a[j] || a[j] == a[k] || a[i] == a[k])
          continue;

        if (a[i] + a[j] <= a[k])
          continue;
        if (a[i] + a[k] <= a[j])
          continue;
        if (a[j] + a[k] <= a[i])
          continue;

        ans++;
      }
    }
  }

  cout << ans << endl;
}

int main() {
  sws;
  solve();
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cctype>

using namespace std;

int main() {
	char ch;
	int counter[26] = {};

	while(cin >> ch) {
		if (isalpha(ch)) {
			if (isupper(ch)) ch = tolower(ch);
			counter[ch - 'a']++;
		}
	}

	for (int i = 0; i < 26; i++) {
		ch = 'a' + i;
		cout << ch << " : " << counter[i] << endl;
	}

	return 0;
}

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

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

ll n, m;

string a, b;

map <int, int> mapa;

int main() {
  cin >> n >> m;
  cin >> a >> b;
  ll g = n * m / __gcd(n, m);
  REP(i, n) mapa[i * g / n] = a[i];
  REP(i, m) if (mapa[i * g / m] != 0 && mapa[i * g / m] != b[i]) {puts("-1"); return 0;}
  cout << g << endl;
  return 0;
}

Measured memory_bytes: 8192
while 1:
    r,c=map(int,raw_input().split())
    if r==c==0:break
    osenbei=[map(int,raw_input().split()) for _ in xrange(r)]
    r_osenbei=[0]*c
    for i in xrange(c):
        st=""
        for j in xrange(r):
            st+=str(osenbei[j][i])
        r_osenbei[i]=int(st,2)
    ans=-1
    for i in xrange(1<<r):
        cnt=0
        for j in xrange(c):
            n=bin(i^r_osenbei[j]).count('1')
            cnt+=max(n,r-n)
        ans=max(ans,cnt)
    print(ans)

Measured memory_bytes: 7668
x = input().split(" ")
n = int(x[0])
k = int(x[1])
count = 0

for b in range(1, n+1):
    p = n//b
    r = n % b
    count += p*max(0, b-k)
    count += max(0, r-k+1)

if k == 0:
    count -= n
print(count)


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

int tree[100001];
int a[100001];
int as[100001];
int n,m;

void init(){
  for(int i = 0;i <= n;i++){
    tree[i] = i;
  }
}

int root(int i){
  if(tree[i] == i) return i;
  return tree[i] = root(tree[i]);
}

void unit(int x,int y){
  x = root(x);
  y = root(y);
  tree[max(x,y)] = min(x,y);
}

bool find(int x,int y){
  if(root(x) == root(y)) return true;
  return false;
}

int main(){
  cin >> n >> m;
  init();
  for(int i = 0;i < n;i++){
    cin >> a[i];
    as[a[i]] = i+1;
  }

  int x,y;
  for(int i = 0;i < m;i++){
    cin >> x >> y;
    unit(x,y);
  }

  int ans = 0;
  for(int i = 1;i <= n;i++){
    if(find(i,as[i])) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1408
import std.stdio;
import std.conv;
import std.algorithm;
import std.range;
import std.string;
import std.typecons;
import std.math;
import std.random;
import std.range;
import std.functional;
class H
{
    int c;
    H l;
    H r;
    H p;
    dchar v;
    int d;
}
void dd(H h, int d)
{
    h.d = d;
    if (h.l)
    {
        dd(h.l, d + 1);
    }
    if (h.r)
    {
        dd(h.r, d + 1);
    }
}
void main()
{
    auto S = readln.strip;
    auto h = new H[256];
    H[] np;
    foreach (i; 0..256)
    {
        h[i] = new H;
        h[i].v = i;
    }
    foreach (i; S)
    {
        h[i].c++;
    }
    np = h.dup.sort!((x, y) => x.c < y.c).filter!(x => x.c).array;
    while (np.length != 1)
    {
        auto z = new H;
        z.r = np[0];
        z.l = np[1];
        z.r.p = z;
        z.l.p = z;
        z.c = z.l.c + z.r.c;
        np ~= z;
        np.sort!((x, y) => x.c < y.c);
        np = np.filter!(x => !x.p).array;
    }
    dd(np[0], !np[0].l && !np[0].r);
    int l = 0;
    foreach (i; S)
    {
        l += h[i].d;
    }
    writeln(l);
}


Measured memory_bytes: 2584
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

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

int64 lcm(int64 a, int64 b) {
		return a / gcd(a, b) * b;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

typedef pair<int, int> P;
vector<int> di = {1, 0, -1, 0};
vector<int> dj = {0, 1, 0, -1};

void solve() {
		int h, w; cin >> h >> w;
		vector<string> s(h);
		rep (i, h) {
			cin >> s[i];
		}
		int ans = -1;
		rep (si, h) {
			rep (sj, w) {
				if (s[si][sj] == '#') continue;
				vector<vector<int>> dist(h, vector<int>(w, INF));
				queue<P> q;
				q.push(P(si, sj));
				dist[si][sj] = 0;
				auto update = [&](int i, int j, int p) {
					if (dist[i][j] != INF) return;
					dist[i][j] = p;
					q.push(P(i, j));
				};
				while(!q.empty()) {
					int i = q.front().first;
					int j = q.front().second; q.pop();
					rep (dir, 4) {
						int ni = i + di[dir];
						int nj = j + dj[dir];
						if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
						if (s[ni][nj] == '#') continue;
						update(ni, nj, dist[i][j] + 1);
					}
					rep (p, h) {
						rep (q, w) {
							if (dist[p][q] != INF) {
								ans = max(ans, dist[p][q]);
							}
						}
					}
				}
			}
		}
		cout << ans << endl;
    return;
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 256
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

const int N = 420;
int dp[N][N];
signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n, ma, mb;
  cin >> n >> ma >> mb;
  int a[n], b[n], c[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  const int INF = 123456;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 405; j >= 0; j--) {
      for (int k = 405; k >= 0; k--) {
        dp[j + a[i]][k + b[i]] = min(dp[j + a[i]][k + b[i]], dp[j][k] + c[i]);
      }
    }
  }
  int ans = INF;
  for (int i = 1; i < N; i++) {
    for (int j = 1; j < N; j++) {
      if (i * mb == j * ma) {
        ans = min(ans, dp[i][j]);
      }
    }
  }
  if (ans == INF) ans = -1;
  cout << ans << "\n";
}



Measured memory_bytes: 1792
import java.io.*;
import java.util.*;
import java.math.*;

public class Main {

	Scanner sc = new Scanner(System.in);

	void run(){
		LinkedList<String> used = new LinkedList<String>();
		String my = "aaaa";
		
		for(int s = 1;;s++){
			System.out.println("?" + my);
			System.out.flush();
			String buffer = sc.next();
			if(!buffer.startsWith("a")){
				System.out.println("!OUT");
				System.out.flush();
				return;
			}
			if(used.contains(buffer)){
				System.out.println("!OUT");
				System.out.flush();
				return;
			}
			used.add(buffer);
			
			char ch = buffer.charAt(buffer.length()-1);
			int f = s/10;
			int se= s%10;
			my = String.valueOf(ch) + String.valueOf((char) (f + 'a'))+String.valueOf((char) (se + 'a'))+"a"; 
		}
		
	}
	
	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxx = 2e5 + 7;
const int Inf = 1 << 30;
const LL INF = 1LL << 60;
int n;
int a[maxx];
int cnt[maxx];
vector <int> vec[maxx];

int main() {
	cin >> n;
	for(int i = 2; i <= n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	for(int i = 1; i <= n; i++) printf("%d\n", cnt[i]);
	return 0;
}

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

int64_t n, k;
int64_t x[60], y[60], c[60];
double t;

using pt = pair<double, double>;

pt operator+(pt lhs, pt rhs){ return {lhs.first + rhs.first, lhs.second + rhs.second}; }
pt operator-(pt lhs, pt rhs){ return {lhs.first - rhs.first, lhs.second - rhs.second}; }
pt operator*(pt lhs, double rhs){ return {lhs.first * rhs, lhs.second * rhs}; }

double dist(pt p1, pt p2){
    return sqrt( pow(p1.first-p2.first, 2.0) + pow(p1.second-p2.second, 2.0) );
}

pair<bool, pair<pt, pt>> getpt(int i, int j){
    long double r1 = t / c[i];
    long double r2 = t / c[j];
    long double d = dist({x[i], y[i]}, {x[j], y[j]});
    if(r1 + r2 < d) return {false, {}};
    if(abs(r1 - r2) > d) return {false, {}};
    long double d1 = (d * d + r1 * r1 - r2 * r2) / (2.0 * d);
    long double d2 = (d * d - r1 * r1 + r2 * r2) / (2.0 * d);
    long double xx = r1 * r1 - d1 * d1;
    if(xx < 0) return {false, {}};
    pt rr = { (x[i] - x[j]) / d,  (y[i] - y[j]) / d };
    pt v  = { (y[i] - y[j]) / d, -(x[i] - x[j]) / d };
    pt ret1 = pt{ x[j], y[j] } + rr * d2;
    pt ret2 = v * sqrt(xx);
    return {true, {ret1, ret2}};
}

bool check(pt point){
    int cnt = 0;
    for(int i=0;i<n;++i){
        if(c[i] * dist({x[i], y[i]}, point) <= t){
            ++cnt;
            if(cnt >= k) return true;
        }
    }
    return false;
}

int main(){
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);

    cin >> n >> k;
    for(int i=0;i<n;++i){
        cin >> x[i] >> y[i] >> c[i];
    }
    pt dx = { 1e-8, 0.0 }, dy = { 0.0, 1e-8 };
    double eps = 1e-15;
    double ok = 2e5, ng = 0;
    while(ok - ng > eps && (ok - ng) > eps * ok){
        t = (ok + ng) * 0.5;
        vector<pt> cand;

        for(int i=0;i<n;++i){
            cand.emplace_back(x[i], y[i]);
            for(int j=0;j<n;++j){
                auto p = getpt(i, j);
                if(p.first){
                    cand.push_back(p.second.first);
                    cand.push_back(p.second.first + p.second.second);
                    cand.push_back(p.second.first - p.second.second);
                }
            }
        }
        for(auto point: cand){
            if(check(point)) goto l_ok;
            if(check(point+dx)) goto l_ok;
            if(check(point+dy)) goto l_ok;
            if(check(point-dx)) goto l_ok;
            if(check(point-dy)) goto l_ok;
        }
        ng = t;
        continue;
        l_ok:
        ok = t;
    }
    cout << ok << endl;

    return 0;
}

Measured memory_bytes: 516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll yen = 100;
    ll X;
    cin >> X;
    int year = 0;
    for(;;){
        year++;
        yen*=1.01;
        if(yen >= X)break;
    }
    cout << year << "\n";
}

Measured memory_bytes: 3656
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn main() {
    let mut v = read_vec::<usize>();
    if v[1] == 100 {
        v[1] += 1;
    }
    let ans = v[1] * 100usize.pow(v[0] as u32);
    println!("{}",ans);
}


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

int main() {
  int a,b,c;
  char d,e;
  cin >> a>>d>>b>>e>>c;

  if(b<=4){cout <<"Heisei"<<endl;}
  else if(b>4){cout<<"TBD";}
  
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll n, A, B, MOD;
struct matrix
{
	vector<vector<ll> >mat;
	matrix(int N, int M)
	{
		mat = vector<vector<ll> >(N, vector<ll>(M, 0));
	}
	matrix(vector<vector<ll> >a)
	{
		mat = a;
	}
	vector<ll>&operator[](int i)
	{
		return mat[i];
	}
	void ident()
	{
		for(int i = 0; i < sz(mat); i++)
			for(int j = 0; j < sz(mat); j++)
				mat[i][j] = (i == j);
	}
	matrix operator*(const matrix &o)
	{
		matrix ret(sz(mat), sz(o.mat[0]));
		for(int i = 0; i < sz(ret.mat); i++)
			for(int j = 0; j < sz(ret.mat[i]); j++)
				for(int k = 0; k < sz(mat[0]); k++)
					ret[i][j] = (ret[i][j] + mat[i][k] * o.mat[k][j]) % MOD;
		return ret;
	}
};
matrix expo(matrix a, ll pw)
{
	matrix ret(a);
	ret.ident();
	while(pw > 0)
	{
		if(pw & 1)
			ret = ret * a;
		a = a * a;
		pw >>= 1;
	}
	return ret;
}
ll cnt[20], p10[20];
int digcnt(ll a)
{
	return a ? 1 + digcnt(a / 10) : 0;
}
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	cin >> n >> A >> B >> MOD;
	ll sum = 0;
	for(int digs = 1; digs <= 18; digs++)
	{
		ll l = 0, r = n;
		while(l < r)
		{
			ll mid = (l + r + 1) / 2;
			ll val = A + (mid - 1) * B;
			int d = digcnt(val);
			if(d <= digs)
				l = mid;
			else
				r = mid - 1;
		}
		cnt[digs] = l - sum;
		if(l == n)
			break;
		sum += cnt[digs];
	}
	p10[0] = 1;
	for(int i = 1; i <= 18; i++)
		p10[i] = p10[i - 1] * 10ll % MOD;
	ll ans = 0, cur = 1;
	for(int i = 1; i <= 18; i++)
	{
		matrix mm({{ans, (A + (cur - 1) * B) % MOD, B % MOD}});
		matrix tran({{p10[i], 0, 0}, {1, 1, 0}, {0, 1, 1}});
		tran = expo(tran, cnt[i]);
		mm = mm * tran;
		ans = mm[0][0];
		cur += cnt[i];
	}
	cout << ans << "\n";
	return 0;
}

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

class Main {
    public static void main(String[] args) {
        String[] line = new Scanner(System.in).nextLine().split(" ", 3);
        int count = 1;
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        int c = Integer.parseInt(line[2]);
        if (a != b) {
            count += 1;
            if (a != c && b != c) {
                count += 1;
            }
        } else if (a != c || b != c) {
            count += 1;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 23124
n = gets.chomp.to_i
x = gets.chomp.split(' ').map(&:to_i)

sorted_x = x.sort
median_right_i = n / 2
median_left_i = median_right_i - 1
median_left = sorted_x[median_left_i]
median_right = sorted_x[median_right_i]

if median_left == median_right
  n.times { puts median_left }
  exit 0
end

x.map do |xi|
  xi <= median_left ? median_right : median_left
end.each { |median| puts median }


Measured memory_bytes: 26980
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
			if(n == 1) {
				System.out.println("Hello World");
			}else {
				int a = sc.nextInt();
				int b = sc.nextInt();
				System.out.println(a+b);
			}
		
	}

}


Measured memory_bytes: 21204
#import sys
#input = sys.stdin.readline
from collections import defaultdict
INF = 10**9

def dfs_for_Ford_Fulkerson(N,E,capacity,s,g,flowing):
    stack = [(s,INF)]
    root = [0]*N
    root[s] = -1
    V = [False]*N
    V[s] = True
    while stack:
        # print(stack)
        u, flow = stack.pop()
        # print(u, E[u])
        for v in E[u]:
            # print(v)
            # print(V[v])
            # print(v, not V[v], capacity[(u,v)]>0)
            if not V[v] and capacity[(u,v)] > 0:
                root[v] = u
                V[v] = True
                if v == g:
                    if capacity[(u,v)] < flow:
                        flow = capacity[(u,v)]
                    break
                stack.append((v, min(flow, capacity[(u,v)])))
        else:
            continue
        break
    else:
        return False
    ## 更新
    now = g
    while now != s:
        before = root[now]
        capacity[(before, now)] -= flow
        capacity[(now, before)] += flow
        now = before
    flowing[0] += flow
    # print(capacity, flow)
    return True

def Ford_Fulkerson(N,E,capacity, s, g):
    flowing = [0]
    while dfs_for_Ford_Fulkerson(N,E,capacity,s,g, flowing):
        pass
    return flowing[0]

def main():
    N, M = map( int, input().split())
    E = [[] for _ in range(N)]
    capacity = defaultdict( int)
    for i in range(M):
        u, v, c = map( int, input().split())
        E[u].append(v)
        capacity[(u,v)] = c
        E[v].append(u)

    print( Ford_Fulkerson(N,E,capacity,0,N-1))
        
    
if __name__ == '__main__':
    main()



Measured memory_bytes: 6292
#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>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,x;
    cin>>n>>x;
    int cnt=1,sum=0,l;
    rep(i,n){
        cin>>l;
        sum+=l;
        if(sum<=x)cnt++;
    }
    cout<<cnt<<endl;

    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double llf;
#define ft first
#define sd second
const int N=1e5+5,K=1000+5;
int x[N],y[N];
bool c[N];
int cnt[K];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	{
		char chr;
		for(int i=1;i<=n;++i){
			scanf("%d%d%*c%c",x+i,y+i,&chr);
			c[i]=(x[i]/k&1)^(y[i]/k&1)^(chr=='B');
		}
	}
	
//	printf("c=");
//	for(int i=1;i<=n;++i)printf("%d ",c[i]);
//	puts("");
	
	int ans=0;
	for(int t=2;t--;)
		for(int i=0;i<k;++i){
			memset(cnt,0,sizeof(cnt));
			int now=0;
			for(int j=1;j<=n;++j){
				now+=c[j];
				cnt[y[j]%k]+=c[j]?-1:1;
			}
			for(int j=0;j<k;++j){
				ans=max(ans,now);
				now+=cnt[j];
			}
			for(int j=1;j<=n;++j)
				if(x[j]%k==i)
					c[j]^=1;
		}
	printf("%d\n",ans);
}

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

int main()
{
    char T[4], S[4];
    cin >> T;
    cin >> S;
    int cnt = 0;
    for(int i = 0; i <3; ++i) {
        if(S[i]==T[i]) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()] 
b = [int(i) for i in input().split()] 
c = [int(i) for i in input().split()] 

ans = 0
for i in range(n):
    A = a[i]-1
    ans += b[A]
    if i > 0:
        if a[i] == a[i-1]+1:
            ans += c[A-1]

print(ans)

Measured memory_bytes: 38256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
//const int inf = 1e9; //1(1倍)e(指数)9(10^9)
//const ll MX = 1e18; //1(1倍)e(指数)18(10^18)
//const ll MOD = 1e9 + 7; //1000000007で割った余りを聞かれたら使う
//加算代入演算子は+=
//int 2^31 10^9まで
//intは10桁、long longは18桁、doubleは308桁、long double は4932桁
//10^10くらいまででdoubleは誤差が発生しちゃう。なるべく整数にすること
//doubleからlong longにキャストするときは、+0.5で切り捨ての誤差を調整
//__int128()で128bit対応の整数（多倍長整数）
//||は片方が成り立つとき
int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    if(a % 3 == 0 or b  % 3 == 0 or (a + b) % 3 == 0) printf("Possible\n");
    else printf("Impossible\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;
lli x, y, z, k;
vector <lli> a(1500);
vector <lli> b(1500);
vector <lli> c(1500);
vector <lli> res;

int main(){
	ios_base::sync_with_stdio(false);
	cin >> x >> y >> z >> k;
	for(int i=0; i<x; i++) cin >> a[i];
	for(int i=0; i<y; i++) cin >> b[i];
	for(int i=0; i<z; i++) cin >> c[i];

	sort(a.begin(), a.begin()+x, greater<lli>());
	sort(b.begin(), b.begin()+y, greater<lli>());
	sort(c.begin(), c.begin()+z, greater<lli>());

	lli ctr = 0;

	for(int i=0; i<x; i++){
		if((i+1) > k) break;
		for(int j=0; j<y; j++){
			if((i+1)*(j+1) > k) break;
			for(int p=0; p<z;  p++){
				if((i+1)*(j+1)*(p+1) > k) break;
				res.pb(a[i]+b[j]+c[p]);
			}
		}
	}

	sort(ALL(res), greater<lli>());
	for(int i=0; i<k; i++) cout << res[i] << endl;

	return 0;
}

Measured memory_bytes: 1400
#include<iostream>
using namespace std;
int N,K,n=1;
int main(){
	cin>>N>>K;
	for(int i=1;i<=N;i++){
		int x=n*2;
		int y=n+K;
		if(x<y) n*=2;
		else n+=K;
	}
	cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int i,a,n,m,x;
  vector<int> y(110,0);
  cin >> n >> m >> x;
  for(i=0;i<m;i++){
    cin >> a;
    y[a]=1;
  }
  int ans=(1<<29),sum=0;
  for(i=x;i<=n;i++){
    if(y[i]==1){
      sum++;
    }
  }
  if(ans>sum){
    ans=sum;
  }
  sum=0;
  for(i=x;i>=0;i--){
    sum+=y[i];
  }
  if(ans>sum){
    ans=sum;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

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

  int ans = 999999;
  for(int i = 1; i <= n / 2; i++) {
    int a = i;
    int b = n - a;

    int tmp_a = a;
    int tmp_b = b;
    int sum_a = 0;
    int sum_b = 0;
    while(tmp_a != 0) {
      sum_a += tmp_a % 10;
      tmp_a /= 10;
    }
    while(tmp_b != 0) {
      sum_b += tmp_b % 10;
      tmp_b /= 10;
    }

    if(ans > sum_a + sum_b) {
      ans = sum_a + sum_b;
    }
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

#define FOR(var,start,end) for(int var=start; var<end; var++)
#define REP(var,cnt) FOR(var,0,cnt)

int main(void) {

	int N, A, B;
	cin >> N >> A >> B;
	
	int x = A*N;
	if ( x > B ) {
		cout << B << endl;
	} else {
		cout << x << endl;
	}
}


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

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

void get_N1234 (int64 *n1, int64 *n2, int64 *n3, int64 *n4)
{
  int cnt;

  if (n2 == NULL) {
    cnt = scanf("%lld", n1);
    return;
  }
  if (n3 == NULL) {
    cnt = scanf("%lld %lld", n1, n2);
    return;
  }
  if (n4 == NULL) {
    cnt = scanf("%lld %lld %lld", n1, n2, n3);
    return;
  }
  cnt = scanf("%lld %lld %lld %lld", n1, n2, n3, n4);
  return;
}

void omit_LF (void)
{
  char c;
  int  cnt;
  
  cnt = scanf("%c", &c);
  return;
}

char *get_S (int64 n)
{
  char *buf;
  int  i;
  int  cnt;

  buf = malloc((size_t)(n * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  cnt = scanf("%s", buf);

  return buf;
}

char *get_SN (int64 max, int64 *size)
{
  char *buf;
  int  i;
  int  n;

  buf = malloc((size_t)(max * sizeof(char)));
  if (buf == NULL) {
    return NULL;
  }

  scanf("%s", buf);

  n = strlen(buf);

  *size = n;
  
  return buf;
}

int64 *get_NSeq (int64 n)
{
  int64 *buf;
  int64 i;

  buf = malloc((size_t)(n * sizeof(int64)));
  for (i=0; i<n; i++) {
    get_N(&buf[i]);
  }

  return buf;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

int main()
{
  int64 N,R,v,r;
  int i;
  
  get_NK(&N, &R);

  v = 0;
  if (N < 10) {
    v = 100*(10-N);
  }

  r = R + v;

  printf("%lld", r);
  return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



int main() {
    int N;
    while (cin >> N) {
        vector<long long> a(N), b(N);
        for (int i = 0; i < N; ++i) cin >> a[i];
        for (int i = 0; i < N; ++i) cin >> b[i];

        long long res = 0;
        for (int i = 0; i < N; ++i) {
            long long diff = a[i] - b[i];
            if (diff > 0) res += diff;
        }
        cout << res << endl;
    }
}   


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vector<string> s(n);
    ll b = 0, a = 0, ba = 0, res = 0;
    REP(i, n){
        cin >> s[i];
        ll tmp = s[i].size();
        REP(j, tmp - 1){
            if(s[i][j] == 'A' && s[i][j + 1] == 'B') res++;
        }

        if(s[i][0] == 'B'){
            if(s[i][tmp - 1] == 'A') ba++;
            else b++;
        }
        else if(s[i][tmp - 1] == 'A') a++;
    }
    if(b > 0 && b == a && ba > 0){
        res += ba + b;
        cout << res << endl;
        return 0;
    }
    if(ba) res += ba - 1;
    ll btoa = min(a, b);
    res += btoa;
    a -= btoa;
    b -= btoa;
    if(a < 0) a = 0;
    if(b < 0) b = 0;
    if(ba && a) res++;
    if(ba && b) res++;
    cout << res << endl;
    return 0;
}

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

#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;

const double PI = acos(-1.0);

// long long積のオーバーフロー検出
bool detect_mul_overflow(ll a, ll b)
{
    return a >= LONG_MAX / b;
}

int lcm(int a, int b)
{
    //最小公倍数
    return a / __gcd(a, b) * b;
}

struct edge
{
    int from, to, cost;
};

// int型の2次元配列(3×4要素の)の宣言
// vector<vector<int>> data(3, vector<int>(4));
ll N;



int main()
{
    cin>>N;
    vec<int> A(N,0);
    ll sum=0;
    ll tmp=0;

    rep(i,N){
        cin>>A[i];
    }

    loop(i,1,N){
        if(A[i]<A[i-1]){
            tmp=A[i-1]-A[i];
            sum+=tmp;
            A[i]=A[i-1];
        }
    }

    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 4044
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define f first
#define s second
using namespace std;
int h, w, m, mx, my;
map<string, int> mp;
vector<pair<int,int>> vecx, vecy;
int x[300001], y[300001];
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> h >> w >> m;
    for(int i = 1; i <= m; i++){
        int a, b; cin >> a >> b; string str = ""; str += to_string(a); str+= " "; str += to_string(b);
        mp[str] = 1; x[a]++; y[b]++; mx = max(mx, x[a]); my = max(my, y[b]);
    }
    for(int i = 1; i <= h; i++)if(x[i] == mx)vecx.pb({x[i], i});
    for(int i = 1; i <= w; i++)if(y[i] == my)vecy.pb({y[i], i});
    //sort(vecx.begin(), vecx.end()); sort(vecy.begin(), vecy.end());

    for(int i = 0; i < vecx.size(); i++){
        for(int j = 0; j < vecy.size(); j++){
            string temp =""; temp += to_string(vecx[i].s); temp += " "; temp += to_string(vecy[j].s);
            if(mp.find(temp) == mp.end()){
                cout << mx+my << endl; return 0;
            }
            else continue;
        }
    }
    cout << mx+my-1 << endl;
    return 0;
}


Measured memory_bytes: 37448
#!/usr/bin/env python3
import sys


def solve(N: int):
    print(N**3)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define fi first
#define se second
#define bug cout<<"--------------"<<endl
using namespace std;
typedef long long ll;
const double PI=acos(-1.0);
const double eps=1e-6;
const int inf=1e9;
const ll llf=1e18;
const int mod=1e9+7;
const int maxn=1e5+10;
int n;
struct ppo{
	int a,b,c;
	bool operator <(const ppo &r) const {
		if(a==r.a&&b==r.b) return c<r.c;
		if(a==r.a) return b<r.b;
		return a<r.a;
	}
};
set<ppo>q;
int a[45],b[45],c[45];
int ma,mb;
int ans=inf;
int gcd(int a,int b){
	return b==0?a:gcd(b,a%b);
}
void dfs(int pos,int x,int y,int z){
	if(pos==(n+1)/2){
		q.insert(ppo{x,y,z});
		return;
	}
	dfs(pos+1,x+a[pos],y+b[pos],z+c[pos]);
	dfs(pos+1,x,y,z);
}
void dd(int pos,int x,int y,int z){
	if(pos==n+1){
		for(int i=1;i<=8;i++){
			int ka=ma*i,kb=mb*i;
			auto it=q.lower_bound(ppo{ka-x,kb-y,0});
			if(it!=q.end()){
				int da=it->a+x;
				int db=it->b+y;
				if(da==ka&&db==kb){
					ans=min(ans,z+it->c);
				}
			}
		}
		return;
	}
	dd(pos+1,x+a[pos],y+b[pos],z+c[pos]);
	dd(pos+1,x,y,z);
}
int main(){
	ios::sync_with_stdio(false);
	//freopen("in","r",stdin);
	cin>>n>>ma>>mb;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i]>>c[i];
	}
	dfs(1,0,0,0);
	dd((n+1)/2,0,0,0);
	if(ans==inf) cout<<-1<<endl;
	else cout<<ans<<endl;
	return 0;
}


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

typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template < typename _T > inline void _DBG(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _DBG(s + 1, a...); }

#ifdef LOCAL
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0) cout
#endif

// ********************** CODE ********************** //

const int N = 1e5 + 7;

bool vis[N][100];

int suma(int n)
{
    int res = 0;
    while(n > 0)
    {
        res += n % 10;
        n /= 10;
    }
    return res;
}

int n;

void dfs(int r, int s)
{
    if(s >= 99) return;
    if(vis[r][s]) return;
    vis[r][s] = 1;
    for(int i = 0; i < 10; i++)
        dfs((10 * r + i) % n, s + i);
}

int main()
{
    _upgrade
    cin >> n;
    for(int i = 0; i < n; i++)
        dfs(i, suma(i));
    //while(n % 2 == 0) n /= 2;
    //while(n % 5 == 0) n /= 5;
    int res = 1e9;
    for(int i = 1; i < 99; i++)
        if(vis[0][i]) res = min(res, i);
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 233344
n,k,q = list(map(int, input().split()))
win_lst = []
for i in range(q):
  winner = int(input())
  win_lst.append(winner)

ct_lst = [0] * n
for x in win_lst:
  ct_lst[x-1] += 1

ttl = sum(ct_lst)
for y in ct_lst:
  if (k-ttl + y) >= 1:
    print("Yes")
  else:
    print("No")


Measured memory_bytes: 8592
#include<bits/stdc++.h>
using namespace std;
int main()
{
 ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
 unsigned int n;
 cin>>n;
 set<string>s;
 for(unsigned int h=0;h<n;h++)
 {
   string t;
   cin>>t;
   if(t.size()<=10)
   {
      if(s.find(t)==s.end())
      s.insert(t);
      
    
   }
 }
 cout<<s.size()<<endl;
 
 
 return 0;
 }

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}


vector<int> normalize(const vector<ll> v) {
  const int N = v.size();
  vector<int> res(N);
  vector<pair<ll,int> > t(N);
  REP(i, N) t[i] = { v[i], i };
  sort(ALL(t));
  int r = 0;
  REP(i, N) {
    r += (i > 0 && t[i - 1].first != t[i].first);
    res[t[i].second] = r;
  }
  return res;
}

// 最上位ビットを残してあとは 0 にする
int highestOneBit(unsigned int i) {
  i |= (i >>  1);
  i |= (i >>  2);
  i |= (i >>  4);
  i |= (i >>  8);
  i |= (i >> 16);
  return i - (i >> 1);
}

struct BIT {
  int n;
  vector<ll> tree;
  BIT(int n):n(n),tree(n+1) {}
  void fill(ll val) {
    REP(i, n+1) tree[i] = (i&-i) * val;
  }
  void add(int idx, ll val) {
    for (int x=idx+1; x<=n; x+=x&-x) tree[x] += val;
  }
  // sum[0, idx]
  ll range(int idx) {
    ll sum=0;
    for (int x=idx+1; x>0; x-=x&-x) sum += tree[x];
    return sum;
  }
  // sum[a, b]
  ll range(int a, int b) {
    return range(b) - range(a - 1);
  }
  // sum [0, i] が k より大きい最小の i を求める
  int get(ll k) {
    int p = highestOneBit(n);
    for (int q = p; q > 0; q >>= 1, p |= q) {
      if (p >= n || k < tree[p]) p ^= q;
      else k -= tree[p];
    }
    return p;
  }
};

struct Query {
  int t;
  ll a, b;
};


const int MAX_Q = 212345;
int main2() {
  int Q = nextInt();
  vector<Query> qs;
  vector<ll> as_;
  vector<int> as;
  REP(q, Q) {
    int t = nextInt();
    ll a = 0, b = 0;
    if (t == 1) {
      a = nextInt();
      b = nextInt();
    }
    qs.push_back((Query){t, a, b});
    as_.push_back(a);
  }
  as = normalize(as_);

  map<int,ll> rev;
  REP(i, as.size()) {
    rev[ as[i] ] = as_[i];
  }
  // pv(ALL(as));
  // pv(ALL(as_));
  // pv(ALL(rev));

  BIT bit(MAX_Q + 10);
  int K = 0;
  ll B = 0;
  ll C = 0;

  ll prev_x = 0;
  REP(q, Q) {
    if (qs[q].t == 1) {
      bit.add(as[q], 1);
      B += qs[q].b;
      K++;
      int mi = bit.get((K-1)/2);
      ll x = rev[mi];
      if (K % 2 == 1) {
        C += abs(x - qs[q].a);
      } else {
        C += abs(prev_x - qs[q].a);
      }
      prev_x = x;
    }
    if (qs[q].t == 2) {
      ll ans = B + C;
      int mi = bit.get((K-1)/2);
      ll x = rev[mi];
      printf("%lld %lld\n", x, ans);
    }
  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 17964
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          N (int)2e5+5
#define          pb push_back
#define          mod 1000000007
#define          ld long double
#define          vi vector<int>
#define          eb emplace_back
#define          vpii vector<pii>
#define          mii map<int,int>
#define          int long long 
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) rbegin(x),rend(x)
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define          PI acos(-1.0)
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update > 
OS ;

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

inline void INP()
{
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);   
	    freopen("output.txt","w",stdout);
	#endif 
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q;
string s;
vi adj[N];
int vis[N],par[N],a[N];

void go()
{
	cin >> s;
	if( s.size() >= 6 and s[2] == s[3] and s[4] == s[5] ) cout << "Yes\n";
	else cout << "No\n";
}

int32_t main()
{
	//INP(); 
	FAST;     
	int t=1; 
	// cin>>t;
	test(t) go();
}

 

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

int main() {
    string a, b;
    char op;
    cin >> a >> op >> b;
    int na = 0, nb = 0;
    for(char x: a) {
        na = na * 10 + x - '0';
    }
    for(char x: b) {
        nb = nb * 10 + x - '0';
    }
    if(op == '-')
        cout << na - nb;
    else
        cout << na + nb;
}

Measured memory_bytes: 256