akhauriyash/Code-Regression huggingface dataset:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

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

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

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

R, C, K = getNM()
point = [[0] * C for i in range(R)]
for i in range(K):
    r, c, v = getNM()
    point[r - 1][c - 1] = v

# dp[j][n] j列目にn個まで取った時の最大値
# 蟻本で出てた、前と後のdpを取り替える作業をしないと盛大にTLEる
prev = [[0] * 4 for _ in range(C + 1)]

for i in range(R):
    next = [[0] * 4 for _ in range(C + 1)]
    for j in range(C):
        # ①取った時
        # n = 2, n = 1, n = 0と逆順にやらないとバグる
        # (n = 0の処理を先に行うと、n = 1の時「変更後の」n = 0で計算を行ってしまうため)
        # (つまりpoint[i][j]のアイテムを何回も取得するため）
        
        # ②より扱うjの数が小さくなるので先に処理する
        # (こちらは②でprev[j + 1][n]の計算をする時「変更後の」prev[j][n]で計算する必要があるため）
        for n in range(2, -1, -1):
            prev[j][n + 1] = max(prev[j][n + 1], prev[j][n] + point[i][j])

        # ②取らない時
        for n in range(4):
            prev[j + 1][n] = max(prev[j + 1][n], prev[j][n])

        # ③下段に降りた時
        next[j][0] = max(prev[j])

    # dpの取り替え
    prev = next

print(max(prev[C - 1]))

Measured memory_bytes: 223956
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class AAC {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            char[] c = s.next().toCharArray();
            if (c[1] == 'R') c[1] = 'B';
            else c[1] = 'R';
            w.println(c);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public String next() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            StringBuilder res = new StringBuilder();

            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 25480
#include <iostream>
#include <algorithm>

using namespace std;

const int mod = 1e9 + 7;

#define int long long

void solve() {
    int n, m;
    int ans1 = 1, ans2=1;
    cin >> n >> m;
    int cn, cm;
    if (abs(n - m) > 1) {
        cout << 0;
        return;
    }
    int t;
    if (n < m) {
        t = m;
        m = n;
        n = t;
    }
    cn = n; cm = m;
    for (int i = 0; i < n; ++i) {
        ans1 = (ans1 *= cn--) % mod;
    }
    for (int i=0; i < m; ++i) {
        ans2 = (ans2 *= cm--) % mod;
    }
    int ans;
    ans = (ans1 * ans2) % mod;
    if (n == m) {
        ans = (ans *= 2) % mod;
    }
    cout << ans;
}

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


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

ll a[55];

void power(){
  ll cur=1;
  rep(i,0,56){
    a[i]=cur;
    cur*=2;  }
}

ll solve(int n,ll x){
  if(x==0) return 0;
  if(n==0) return 1;
  if(x<=(a[n+1]-2)) return solve(n-1,x-1);
  return a[n]+solve(n-1,min(x-a[n+1]+1,a[n+1]-3));
}

int main(){
  int n;
  ll x;
  cin>>n>>x;
  power();
  cout<<solve(n,x)<<endl;
}

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

int main() {
  int x, y; scanf("%d%d", &x, &y);
  auto gcd = [](int x, int y) {
    while (x&&y) x > y ? x %= y : y %= x;
    return x + y;
  };
  long long lcm = x * 1ll * y / gcd(x, y);
  if (x == y || lcm == x) {
    puts("-1");
    return 0;
  }
  long long ans = lcm + x;
  printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <unordered_map>
using namespace std;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

bool compare_by_b(tuple<int, string, int> a, tuple<int, string, int> b) {
    if(get<2>(a) != get<2>(b)){
        return get<2>(a) > get<2>(b);
    }
}

bool compare_by_string(tuple<int, string, int> a, tuple<int, string, int> b) {
    if(get<1>(a) != get<1>(b)){
        return get<1>(a) < get<1>(b);
    }else{
      	return get<2>(a) > get<2>(b);
    }
}

int check(vector<int> &v, int k, long weight)
{
  int i=0;
  for(int j=0;j<k;j++)
  {
    long tmp = 0;
    while(tmp + v[i] <= weight)
    {
      tmp += v[i];
      i++;
      if(i == v.size()) return v.size();
    }
  }
  return i;
}


long binary_search(vector<int> &v, int k)
{
	long left = 0;
  	long right = v.size() * 10000; //適宜書き換え
  	long mid;
  	while(right - left > 1)
    {
      	mid = (left + right) / 2;
      	int num = check(v,k,mid);
      	if(num >= v.size()) right = mid;
      	else left = mid;
    }
  	return right;
}

bool isComb(vector<int> &elem, int idx, int sum)
{
  if(sum == 0) return true;
  else if(idx >= elem.size() || sum < 0) return false;
  return isComb(elem, idx+1, sum) || isComb(elem, idx+1, sum - elem[idx]);
}

int Merge(vector<int> &v, int left, int mid, int right)
{
  int count = 0;
  int n_left = mid -left;
  int n_right = right -mid;
  vector<int> v_left(n_left);
  vector<int> v_right(n_right);
  for(int i=0;i<n_left;i++) v_left[i] = v[left+i];
  for(int i=0;i<n_right;i++) v_right[i] = v[mid+i];
  int i=0,j=0;
  for(int k=left;k<right;k++)
  {
    count++;
    if(i < n_left && j < n_right && v_left[i] <= v_right[j])
    {
      v[k] = v_left[i];
      i++;
    }
    else if(i < n_left && j < n_right && v_left[i] > v_right[j])
    {
      v[k] = v_right[j];
      j++;
    }
    else if(i < n_left && j >= n_right)
    {
      v[k] = v_left[i];
      i++;
    }
    else if(i >= n_left && j < n_right)
    {
      v[k] = v_right[j];
      j++;
    }
  }
  return count;
}

int MergeSort(vector<int> &v, int left, int right)
{
  int count = 0;
  if(left + 1 < right)
  {
    int mid = (left + right) / 2;
    count += MergeSort(v, left, mid);
    count += MergeSort(v, mid, right);
    count += Merge(v, left, mid, right);
  }
  return count;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
  	const long div = 1000000007;
	int n, k;
  	cin >> n >> k;
  	int diff;
  	if(k == 1) diff = 0;
  	else diff = n-k;
  	cout << diff << endl;
  	return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> cnt(N, 0);
  for (int i = 0; i < N; i++) {
    int num;
    cin >> num;
    cnt[num - 1]++;
  }
  sort(cnt.begin(), cnt.end());
  int s = 0;
  for (int i = N - K - 1; i >= 0; i--) s += cnt[i];
  cout << s << endl;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
from bisect import bisect_left, bisect_right

N, M = map(int, input().split())
AB = [[0, 0]] + [[int(i) for i in input().split()] for _ in range(N)] + [[1 << 40, 0]]
LR = [[int(i) for i in input().split()] for _ in range(M)]

N += 2

# 座圧
compressed = sorted([a for a, b in AB])
bomb = [0] * N
for a, b in AB :
  a = bisect_left(compressed, a)
  bomb[a] = b
diff = [bomb[i-1] ^ bomb[i] for i in range(1, N)]

# 辺を貼る
vec = [[] for _ in range(N)]
convert = {}
for i, (l, r) in enumerate(LR) :
  if compressed[-1] < l or r < compressed[0] : continue
  l = bisect_left(compressed, l) - 1
  r = bisect_right(compressed, r) - 1
  if r <= l : continue
  vec[l].append(r)
  vec[r].append(l)
  convert[(l, r)] = i

# 全域木の構築
visited = [False] * N
parent = [-1] * N
ret = []
def dfs(pre, cur) :
  for nex in vec[cur] :
    if nex == pre or visited[nex] :
      continue
    visited[nex] = True
    dfs(cur, nex)
  if pre == -1 and diff[cur] == 1 :
    return False
  if diff[cur] == 1 :
    diff[cur] ^= 1
    diff[pre] ^= 1
    ret.append(convert[(min(pre, cur), max(pre, cur))] + 1)
  return True

for i in range(N - 1) :
  if visited[i] : continue
  visited[i] = True
  if not dfs(-1, i) :
    print(-1)
    break
else :
  ret.sort()
  print(len(ret))
  print(*ret)

Measured memory_bytes: 170836
#include<iostream>
#include<complex>
#include<cstdio>

using namespace std;

typedef complex<double> Point;
typedef complex<double> Vector;

#define EPS 0.0000001

Point A, B, C;

void getR(double alpha, double beta, double l, double r, double R, double &ans, bool &suc){
    double a, b, c;
    a = 1.0/((tan(beta)*tan(beta)));
    b = 2*r/(tan(alpha)*tan(beta)) - 2*l/tan(beta) - 4*r;
    c = l*l - 2*r*l/tan(alpha) + r*r/(tan(alpha)*tan(alpha));
    double rr1 = (-b - sqrt(b*b-4*a*c))/(2*a);
    double rr2 = (-b + sqrt(b*b-4*a*c))/(2*a);
    suc = false;
    if ( 0 <= rr1 && rr1 <= R ) { ans = rr1; suc = true;}
    if ( 0 <= rr2 && rr2 <= R ) { ans = rr2; suc = true;}
}

void compute(){
    double a = abs(B - C);
    double b = abs(A - C);
    double c = abs(A - B);
    double s = (a + b + c)/2.0;
    double R = sqrt(s*(s-a)*(s-b)*(s-c))/s;
    double X = acos((c*c + b*b - a*a)/(2*c*b));
    double Y = acos((c*c + a*a - b*b)/(2*c*a));
    double Z = acos((a*a + b*b - c*c)/(2*a*b));

    double l = 0, r = 2*R;
    double r1, r2, r3;
    bool suc1, suc2;
    while(1){
	r1 = (l + r)/2.0;
	//			cout << r1 << endl;
	getR(X/2, Y/2, c, r1, R, r2, suc1);
	getR(X/2, Z/2, b, r1, R, r3, suc2);
	//	if ( !suc1 || !suc2 ) continue;
	Vector v1 = A - B;
	Vector v2 = A - C;
	v1 = polar(r2/sin(Y/2), arg(v1) - Y/2) + B; 
	v2 = polar(r3/sin(Z/2), arg(v2) + Z/2) + C; 
	double d = abs(v1 - v2);
	if ( fabs(d - (r2+r3)) < EPS ) break;
	if ( d < r2+r3 || !suc1 || !suc2) l = r1;
	else r = r1;
    }
    
    printf("%.5lf %.5lf %.5lf\n", r1, r2, r3);
}

main(){
    while(1){
	cin >> A.real() >> A.imag();
	cin >> B.real() >> B.imag();
	cin >> C.real() >> C.imag();
	if ( A.real() == 0 && A.imag() == 0 && 
	     B.real() == 0 && B.imag() == 0 && 
	     C.real() == 0 && C.imag() == 0 ) break;
	compute();
    }
}

Measured memory_bytes: 996
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int A,B;
	cin>>A>>B;
	if(B%A==0)cout<<A+B<<endl;
	else cout<<B-A<<endl;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

int N, M;
int d[100][100];
int a[1000], b[1000], c[1000];

int main() {
	cin >> N >> M;
	
	fill(d[0], d[N], INF);
	REP(i, M) {
		scanf("%d %d %d", a + i, b + i, c + i);
		a[i]--; b[i]--;
		d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
	}
	REP(i, N) d[i][i] = 0;
	
	REP(k, N) REP(i, N) REP(j, N) chmin(d[i][j], d[i][k] + d[k][j]);
	
	int ans = 0;
	
	REP(i, M) {
		bool ok = true;
		REP(j, N) if (ok) REP(k, N) if (ok) {
			if (d[j][a[i]] + c[i] + d[b[i]][k] <= d[j][k]) ok = false;
		}
		if (ok) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int P, Q, R;
  cin >> P >> Q >> R;

  cout << std::min({P + Q, Q + R, P + R}) << endl;

  return 0;
}


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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;

typedef pair<ll,ll> ii;

int a[N];
int b[N];
int vis[N];

int p[N];
int c[N];

int lead(int x) {   return  p[x] == 0 ? x : p[x] = lead(p[x]);  }

vector<int> g[N];

ii  dfs(int u)  {
    vector<ii>  vec;

    for(int v : g[u])
        vec.pb(dfs(v));
    
    ll  S = b[u];
    ll  F = g[u].empty() ? max(a[u],b[u]) : 1e18;

    for(ii  T : vec)    S += T.X;
    for(ii  T : vec)    {
        ll  nxt = max(T.Y,1ll * c[u]) + S - T.X;

        if (F > nxt)
            F = nxt;
    }
    return  ii(S,F);
}

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

    int n;  cin >> n;
    int m;  cin >> m;

    for(int i = 1 ; i <= n ; ++i)   {
        cin >> a[i];
        cin >> b[i];
        c[i] = a[i] - b[i];

        if (c[i] < 0)
            c[i] = 0;
    }
    vector<int> perm(n);

    iota(all(perm),1);
    sort(all(perm),[&](int x,int y) {   return  c[x] < c[y];    });

    for(int i = 1 ; i <= m ; ++i)   {
        int x;  cin >> x;
        int y;  cin >> y;

        g[x].pb(y);
        g[y].pb(x);
    }
    for(int x : perm)   {
        vector<int> vec = g[x]; g[x].clear();
        vis[x] = 1;

        for(int y : vec)    {
            y = lead(y);
            if (vis[y] && y != x)   {
                g[x].pb(y);
                p[y] = x;
            }
        }
    }
    cout << dfs(perm[n - 1]).Y << endl;
}

Measured memory_bytes: 18744
#include <stdio.h>

int main(void)
{
    int n, e, w, s, u, d;
    int n2, e2, w2, s2, u2, d2;
    char in[10];
    int m;
    int sum;
    int i;
    
    while (1){
        scanf("%d", &m);
        if (m == 0){
            break;
        }
        
        n = 5; e = 3; w = 4; s = 2; u = 1; d = 6;
        sum = u;
        for (i = 0; i < m; i++){
            scanf("%s", in);
            switch (in[0]){
              case 'N':
                n2 = u; e2 = e; w2 = w; s2 = d; u2 = s; d2 = n;
                break;
    
              case 'E':
                n2 = n; e2 = u; w2 = d; s2 = s; u2 = w; d2 = e;
                break;
    
              case 'W':
                n2 = n; e2 = d; w2 = u; s2 = s; u2 = e; d2 = w;
                break;
    
              case 'S':
                n2 = d; e2 = e; w2 = w; s2 = u; u2 = n; d2 = s;
                break;
    
              case 'R':
                n2 = w; e2 = n; w2 = s; s2 = e; u2 = u; d2 = d;
                break;
    
              case 'L':
                 n2 = e; e2 = s; w2 = n; s2 = w; u2 = u; d2 = d;
               break;
    		}
            n = n2; e = e2; w = w2; s = s2; u = u2; d = d2;
    		sum += u;
    	}
    	printf("%d\n", sum);
    }

	return (0);
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e18;
const ll N=1e7+10;
ll d[N],num[N],prime[N]; //sd是约数和
bool vis[N];
void fun(){
    memset(vis,0,sizeof(vis));
    num[1]=1;
    d[1]=1;
    prime[0]=0;
    for(ll i=2;i<N;i++)
    {
        if(!vis[i])
        {
            prime[++prime[0]]=i;
            d[i]=1;
            num[i]=2;
        }
        for(ll j=1;j<=prime[0]&&i<=N/prime[j];j++)
        {
            vis[i*prime[j]]=1;
            if(i%prime[j]==0)
            {
                d[i*prime[j]]=d[i]+1;
                num[i*prime[j]]=num[i]/(d[i]+1)*(d[i]+2);
                break;
            }
            d[i*prime[j]]=1;
            num[i*prime[j]]=num[i]*2;
        }
    }
}
int main() {
    fun();
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        ans+=i*num[i];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 174848
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
#define all(v) v.begin(), v.end()
const int INF = 1 << 30;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    ll n;
    cin >> n;
    vector<ll> a(n, 0);
    rep(i, n) cin >> a[i];
    ll sum = 0;
    ll prev = 0;
    rep(i,n){
        if (prev > a[i]) 
            sum += prev - a[i];
        else
            prev = a[i];
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 4768
#include<stdio.h>
int main()
{
    int a,b,i,j,k;
    scanf("%d",&a);
    int x[a][6];
    for(i=0;i<a;i++){
        for(j=0;j<6;j++){
            scanf("%d",&x[i][j]);
        }
    }

    for(i=0;i<a-1;i++){
        for(j=i+1;j<a;j++){
            for(k=0;k<122;k++){
                if(x[i][0]==x[j][0]&&x[i][5]==x[j][5]){
                    if(x[i][1]==x[j][1]&&x[i][4]==x[j][4]){
                        if(x[i][2]==x[j][2]&&x[i][3]==x[j][3]){
                            puts("No");
                            return 0;
                        }
                    }
                    else{
                        b=x[j][1];x[j][1]=x[j][2];x[j][2]=x[j][4];
                        x[j][4]=x[j][3];x[j][3]=b;
                    }
                }
                if(k%2){
                    b=x[j][1];x[j][1]=x[j][0];x[j][0]=x[j][4];
                    x[j][4]=x[j][5];x[j][5]=b;
                }
                else{
                    b=x[j][5];x[j][5]=x[j][2];x[j][2]=x[j][0];
                    x[j][0]=x[j][3];x[j][3]=b;
                }
            }
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 580
wlist = []
city, road = map(int, input().split())
for i in range(road):
    wlist.append(list(map(int, input().split())))
dst = []
for i in range(city):
    count = 0
    for k in wlist:
        if i+1 in k:
            count += 1
    dst.append(count)
for d in dst:
    print(d)


Measured memory_bytes: 2940
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
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
int main(){
    int n;cin>>n;
    vector<int> x;
    int ans=10000000;
    rep(i,n){
        int a;
        cin>>a;
        x.push_back(a);
    }
    for(int i=1;i<=100;i++){
        int sum=0;
      rep(j,n){
          sum+=pow((x[j]-i),2);
      }
      ans=min(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
S = str(input())
ans = 0
if len(S) == 1:
    print('No')
    ans = 1
    sys.exit()
if S[-1] == 'h' and ans != 1:
    print('No')
    ans = 1
    sys.exit()
if S[-1] == 'i' and S[-2] != 'h':
    print('No')
    sys.exit()
for i in range(len(S)-1):
    if S[i] != 'h' and S[i] != 'i' and ans != 1:
        print('No')
        ans = 1
        break
    if S[i] == 'i' and S[1-1] != 'h' and ans != 1:
        print('No')
        ans = 1
        break
    if S[i] == 'h' and S[i+1] != 'i' and ans != 1:
        print('No')
        ans = 1
        break
if ans == 0:
    print('Yes')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define long int64_t
int main()
{
   int n, count{0}, first, second, total{0};
   cin >> n;
   if(!(n%2)){
      vector<int> v(n);
      for (int i = 0; i < n; ++i)
         cin >> v[i];

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

      total = v[n/2] - v[n/2-1];

      cout << total;
   }
   else
      cout << "0";
   return 0;
}


Measured memory_bytes: 640
//#pragma warning(disable:4996)
//#include <Windows.h>
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

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

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

void input();
void solve();

void daminput();

int main() {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	input();
	//daminput();
	solve();
	return 0;
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////

string S;

void input() {
	cin >> S;
}

void daminput() {
}

void solve() {
	if (S == string("AAA") || S == string("BBB"))cout << "No\n";
	else cout << "Yes\n";
}

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;


int main(){
	ll n, m, r; cin >>n>> m>> r;
	
	vector<int> root(r);
	for(int i = 0; i < r; ++i){cin >> root[i]; --root[i];}
	sort(root.begin(), root.end ());
	
	vector<vector<long long> > dp(n, vector<long long>(n, INF64));
    for (int i = 0; i<n; ++i) dp[i][i] = 0;
    
    // input
    for (int i = 0; i < m; ++i) {
        ll a, b, w; cin >> a >> b >> w;
        --a; --b;
        dp[a][b] = w; dp[b][a] = w;
    }
    
    // Floyd-Warshall
    for (int k = 0; k < n; ++k)
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
    ll ans = INF64;
    do {
    	ll tmp = 0;
         for(int i = 0; i < r-1; ++i){
         	tmp += dp[root[i]][root[i+1]];
         }
         ans = min(ans, tmp);
    } while( next_permutation(root.begin(), root.end()) );
    cout << ans << endl;
    return 0;
}

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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

int main() {
  ll A, B;
  cin >> A >> B;

  ll ans = 0;

  if ((A+B) % 2) {
    cout << "IMPOSSIBLE\n";
    return 0;
  }

  cout << (A+B)/2 << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C;
    cin >> A >> B;

    cout << (A-1)*(B-1)<< endl;
    // if(A==12)
    // 	cout << 1<<endl;
    // else
    // 	cout << A+1<<endl;
    

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;

    // if(A%2==1 && B%2==1)
    // 	puts("Yes");
    // else
    // 	puts("No");
	
}


Measured memory_bytes: 256
// finish date: 2018/06/06
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <functional>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define pii pair<int,int>
const int bigmod = 1000000007;
#define INF 1050000000

void deriv(int N, vi &ope, int base) {
    int c = base;
    while (c <= N) {
        rep(i, N) {
            if (i + c >= N) break;
            ope[i + c] = min(ope[i + c], ope[i] + 1);
        }
        c *= base;
    }
}

int main() {
    int N;
    cin >> N;
    N++;
    vi ope(N);
    rep(i, N) ope[i] = i;
    deriv(N, ope, 6);
    deriv(N, ope, 9);
    cout << ope[N - 1] << endl;

    return 0;
}






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

int main(){
	int n,i;
	cin >> n;
	vector<int> a(n);
	map<int,long long> cnt;
	
	for(i=0;i<n;i++)
	{
		cin >> a[i];
		cnt[a[i]]++;
	}
	
	long long ret=0;
	map<int,long long>::iterator p;
	
	for(p=cnt.begin();p!=cnt.end();p++){
		ret+=(p->second-1)*p->second/2;
	}
	
	map<int, long long> tmpMap;
	
	for(i=0;i<n;i++)
	{
	    if (tmpMap[n]==0)
	    {
	       long long n=cnt[a[i]];
	       long long tmp=ret-(n-1)*n/2+(n-1)*(n-2)/2;
	       cout << tmp <<"\n";
	       tmpMap[n] = tmp;
		}
		else
		{	    
		   cout<<tmpMap[n]<<"\n";
	    }
	}
	
	return 0;
}

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



int main() 
{
  ll N; cin>>N;
  vector<ll> vecA(N);
  rep(i,N)
  {
    cin>>vecA.at(i);
  }
  sort(vecA.begin(),vecA.end());
  reverse(vecA.begin(),vecA.end());
  ll L=0;
  rep(i,N-1)
  {
    if(vecA.at(i)==vecA.at(i+1))
    {
      if(L==0) {L=vecA.at(i); i++; continue;}
      cout<<L*vecA.at(i)<<endl; return 0;
    }
  } 
  cout<<0<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#define int long long
using namespace std;

int powmod(int a, int n, int mod) {
	if (n == 0) return 1;
	if (n % 2 == 0) return powmod((a * a) % mod, n / 2, mod);
	return (a * powmod(a, n - 1, mod)) % mod;
}

int mod = 998244353;
int p2[5000];
int fact[5000];
int factInv[5000];

void init() {
	int i;
	
	p2[0] = 1; fact[0] = 1; factInv[0] = 1;
	for (i = 1; i < 5000; i++) {
		p2[i] = (p2[i - 1] * 2) % mod;
		fact[i] = (i * fact[i - 1]) % mod;
		factInv[i] = powmod(fact[i], mod - 2, mod);
	}
}

int comb(int n, int k) {
	if (k < 0 || k > n) return 0;
	return fact[n] * factInv[k] % mod * factInv[n - k] % mod;
}

int k, n;

signed main() {
	init();
	cin >> k >> n;
	
	int ans[4001] = {0};
	for (int i = 2; i <= 2 * k; i++) {
		if (i > k + 1) {
			ans[i] = ans[2 * k + 2 - i];
			cout << ans[i] << endl;
			continue;
		}
		
		//(0, 0)の個数を全探索
		for (int x = 0; x <= (i - 1) / 2; x++) {
			int y = (i - 1) / 2 - x;
			int z = y + k + 1 - i;
			
			ans[i] += p2[y] * comb(n + z - y - 1, z - 1) % mod * comb(x + y, y) % mod;
			if (i % 2 == 0) {
				ans[i] += p2[y] * comb(n + z - y - 2, z - 1) % mod * comb(x + y, y) % mod;
			}
			ans[i] %= mod;
		}
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
  int h,w; cin >> h >> w;
  char c[h+1][w+1];
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++) cin >> c[i][j];
  }
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cout << c[i][j];
    }
    cout << endl;
    for(int j=1;j<=w;j++){
      cout << c[i][j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
a = []
s = int(input())
a.append(s)
for i in range(1000000):
    if a[i]%2 == 0:
        x = a[i]/2
        if x in a:
            print(i+2)
            break
        else:
            a.append(x)
    else:
        x = 3*a[i] + 1
        if x in a:
            print(i+2)
            break
        else:
            a.append(x)

Measured memory_bytes: 3060
#include <iostream>
#include <complex>

using namespace std;

typedef complex<double> Point;

//ツ円Aツつェツ円Bツづーツ環ョツ全ツづ可甘慊づ楪つゥツ板サツ津ィツつキツづゥ
bool includesCircle(const Point &ca, double ra, const Point &cb, double rb) {
    return norm(ca-cb) < pow(ra-rb, 2) && rb < ra;
}

//ツ円Aツづ円Bツつェツ古ーツづュツづづつ「ツづゥツつゥツ板サツ津ィツつキツづゥ
bool intersectsCircle(const Point &ca, double ra, const Point &cb, double rb) {
    return norm(ca-cb) <= pow(ra+rb, 2);
}

int main() {
    int N;
    cin >> N;
    while(N--) {
        Point ca, cb;
        double ra, rb;
        cin >> ca.real() >> ca.imag() >> ra >> cb.real() >> cb.imag() >> rb;
        if(includesCircle(ca, ra, cb, rb)) cout << 2 << endl;
        else if(includesCircle(cb, rb, ca, ra)) cout << -2 << endl;
        else if(intersectsCircle(ca, ra, cb, rb)) cout << 1 << endl;
        else cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#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); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;


int main(){
  int N, M;
  cin >> N >> M;
  vector<pair<ll, int>> AB(N);
  REP(i, N){
    cin >> AB[i].first >> AB[i].second;
  }
  sort(AB.begin(), AB.end());

  ll ans = 0;
  int sum = 0;
  REP(i, N){
    if(AB[i].second + sum <= M){
      sum += AB[i].second;
      ans += AB[i].first * AB[i].second;
    }
    else{
      int diff = M-sum;
      sum += diff;
      ans += AB[i].first * diff;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1792
l, r = map( int, input().split())

amr = []
for x in range(l,r+1):
    if len(amr) >= 2019:
        break
    amr.append(x%2019)
# print(amr)
amr = list(set(amr))
ij_mod = []
for i in range(len(amr)-1):
    for j in range(i+1,len(amr)):
        ij_mod.append((amr[i]*amr[j])%2019)
print(min(ij_mod))




Measured memory_bytes: 205988
#include <stdio.h>
#include <string.h>

int main() {
  char input[4];
  scanf("%s", input);

  char endChar;
  for (short i = 0; i < 4; i += 1) {
    if (input[i] == '\0') {
      break;
    }
    endChar = input[i];
  }

  char output[4];

  if (endChar == '2' || endChar == '4' || endChar == '5' || endChar == '7' || endChar == '9') {
    strcpy(output, "hon");
  } else if (endChar == '0' || endChar == '1' || endChar == '6' || endChar == '8') {
    strcpy(output, "pon");
  } else {
    strcpy(output, "bon");
  }

  printf("%s", output);

  return 0;
}


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

int c(const void* a,const void* b) {
	int x=*(const int*)a;
	int y=*(const int*)b;
	if(x>y)return 1;
	if(x<y)return -1;
	return 0;
}

int main(void) {
	int N;
	int L[999];
	int i;
	int ans = 0;
	if(scanf("%d",&N)!=1)return 1;
	N*=2;
	for(i=0;i<N;i++) {
		if(scanf("%d",&L[i])!=1)return 1;
	}
	qsort(L,N,sizeof(*L),c);
	for(i=0;i<N;i+=2) {
		ans+=L[i];
	}
	printf("%d\n",ans);
	return 0;
}

/*
a < b < c < d

a, b
c, d

a, c
b, d

a, d
b, c

最初はa,c、他はa,bなので最初がつよい

*/

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B == C + D){
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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; }

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

ll n,m;
vpll G[100005];
bool checked[100005];
ll dist[100005];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>n>>m;
  rep(i,m){
    ll a,b,c; cin>>a>>b>>c;
    a--,b--;
    G[a].emplace_back(b,c);
    G[b].emplace_back(a,-c);
  }
  queue<pll> q;
  rep(i,n){
    if(checked[i]) continue;
    checked[i]=true;
    q.emplace(i,0);
    dist[i]=0;
    while(!q.empty()){
      ll v=q.front().first, c=q.front().second;
      q.pop();
      for(auto np: G[v]){
        ll nv=np.first, nc=np.second;
        if(checked[nv]){
          if(dist[nv]!=dist[v]+nc){
            cout<<"No"<<endl;
            return 0;
          }
          continue;
        }
        dist[nv]=dist[v]+nc;
        q.emplace(nv,dist[nv]);
        checked[nv]=true;
      }
    }
  }
  cout<<"Yes"<<endl;
  
}

Measured memory_bytes: 14576
h,w,d = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(h)]
q = int(input())
l = [list(map(int,input().split())) for _ in range(q)]
dic = {}
for i in range(len(a)):
    for j in range(len(a[i])):
        dic[a[i][j]] = (i,j)
sum = [0]*(h*w+1)
for i in range(d+1,h*w+1):
    sum[i] = sum[i-d]+abs(dic[i][0]-dic[i-d][0])+abs(dic[i][1]-dic[i-d][1])
for l_ in l:
    print(sum[l_[1]]-sum[l_[0]])

Measured memory_bytes: 47728
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
char c[105];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    scanf("%s",c+1);
    int n=strlen(c+1);
    int ans=0;
    for(int i=1,j=n;i<j;(c[i]!=c[j]&&++ans),i++,j--);
    printf("%d\n",ans);
    return 0;
}

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

int main(){
	string S;
	cin >> S;
	int cnt1 = 0, cnt2 = 0;
	for(int i=0; i<S.size(); i++){
		int a = S[i] - '0';
		if(a == 0) cnt1++;
		else cnt2++;
	}
	cout << 2*min(cnt1, cnt2) << endl;
	return 0;
}

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

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);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {

        void solve(InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int[] A = in.nextIntArray(N);
            
            int[] ans = new int[N];
            for (int i = 0; i < N; ++i) {
                ans[A[i] - 1] = i + 1; 
            }
            
            StringBuilder sb = new StringBuilder();
            for (int student : ans) {
                sb.append(student).append(' ');
            }
            
            out.println(sb.toString().trim());
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

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

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for(int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  string t;
  cin >> t;

  re(i, t.size()) {
    if(t[i] == '?') t[i] = 'D';
  }
  cout << t << endl;

  return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
vector <int> p(n);
for(int i=0;i<n;i++)
cin>>p[i];
for(int i=0;i<n;i++)
p[i]++;
queue <int>q;
int s;
int mx=0;
for(int i=0;i<n;i++)
{
    s+=p[i];
q.push(p[i]);
if (q.size()>k)
{s-=q.front();
 q.pop();
}

if (q.size()==k)
{
mx=max(mx,s);
}
}
double ans=mx;
ans/=2;
printf ("%.10f\n",ans);
}

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

const int M = 1e6 + 100;
int l[M], r[M];
int id[M], tp[M];

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		int ll = 0, rr = 0;
		for (char c : s) {
			if (c == '(') ++ll;
			else if (ll) --ll;
			else ++rr;
		}
		l[i] = ll, r[i] = rr, id[i] = i;
		if (r[i] == 0) tp[i] = 1;
		else if (l[i] == 0) tp[i] = 4;
		else if (l[i] >= r[i]) tp[i] = 2;
		else if (l[i] < r[i]) tp[i] = 3;
	}
	sort(id, id + n, [&] (int a, int b) {
		if (tp[a] != tp[b]) return tp[a] < tp[b];
		if (tp[a] == 2) {
			if (r[a] != r[b]) return r[a] < r[b];
			else return l[a] > l[b];
		}
		if (tp[a] == 3) return l[a] > l[b];
		return false;
	});
	int sum = 0;
	for (int i = 0; i < n; i++) {
		sum -= r[id[i]];
		if (sum < 0) break;
		sum += l[id[i]];
	}
	if (sum != 0) cout << "No" << "\n";
	else {
		cout << "Yes" << "\n";
	}
}

Measured memory_bytes: 19180
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n,q;
    cin>>n;
    vector<int> S(n);
    for(int i=0;i<n;i++) cin>>S[i];
    cin>>q;
    vector<int> T(q);
    for(int i=0;i<q;i++) cin>>T[i];

    int sum=0;

    for(int i=0;i<q;i++)
    {
        int x=T[i];
        int low=0,high=n-1,mid;
        while(low<=high)
        {
            mid=(low+high)/2;
            if(S[mid]==x) {sum++;break;}
            else if(S[mid]>x){high=mid-1;}
            else low=mid+1;
        }
    }
    cout<<sum<<endl;
    return 0;
}





Measured memory_bytes: 3272
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////

int n,k;
signed main(){
  cin>>n>>k;
  int ans = 0, t = 1;
  while(t <= n){
    t *= k;ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

int main(){
  char s[100001];
  int k;
  
  scanf("%s", s);
  scanf("%d", &k);

  int len = strlen(s);
  while(k > 0){
    for(int j = 0; j < len - 1; j++){
      int t = 'z' - s[j] + 1;
      if(s[j] != 'a' && t <= k){
        s[j] = 'a';
        k -= t;
      }
    }
    if(k != 0){
      s[len - 1] = 'a' + (s[len - 1] - 'a' + k) % 26;
      k = 0;
    }
  }
  printf("%s\n", s);

  return 0;
}


Measured memory_bytes: 384
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

int main()
{
   	string a,b;cin >> a >> b;
   	if(a.size() != b.size() - 1)
   	{
   		cout << "No";
   		return 0;
   	}
   	bool ok = 1;
   	for(int i = 0;i < a.size();++i)
   	{
   		if(a[i] != b[i])
   		{
   			ok = 0;
   			break;
   		}
   	}
   	if(ok)	cout << "Yes";
   	else cout << "No";
    return 0;
}


Measured memory_bytes: 3628
/*It is better to taste failure 
	  than to regret*/
		
            #include <algorithm>
        #include <bitset>
        #include <cassert>
        #include <chrono>
        #include <cmath>
        #include <complex>
        #include <cstdio>
        #include <cstdlib>
        #include <cstring>
        #include <ctime>
        #include <deque>
        #include <functional>
        #include <iomanip>
        #include <iostream>
        #include <iterator>
        #include <limits>
        #include <climits>
        #include <list>
        #include <map>
        #include <numeric>
        #include <queue>
        #include <random>
        #include <ratio>
        #include <set>
        #include <sstream>
        #include <stack>
        #include <string>
        #include <unordered_map>
        #include <unordered_set>
        #include <utility>
        #include <vector>
        using namespace std;
         
        typedef long long ll;
        typedef long double LD;
        #define int ll
        #define double LD
        #define pb push_back
        #define mp make_pair
        #define REP(i,n) for (int i = 0; i < n; i++)
        #define loop(i,n) for (int i = 0; i < n; i++)
        #define FOR(i,a,b) for (int i = a; i < b; i++)
        #define REPD(i,n) for (int i = n-1; i >= 0; i--)
        #define FORD(i,a,b) for (int i = a; i >= b; i--)
        #define remax(a,b) a = max(a,b)
        #define remin(a,b) a = min(a,b)
        #define mem(a, b) memset(a, b, sizeof a)
        #define append push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define print(x) cout << (x) << endl
        #define PRECISION(x) cout << fixed << setprecision(x)
        #define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
        #define Test(){int t;cin >> t;for(int i=1;i<=t;i++){cout << "Case #" << i << ": ";solve();}}
        #define test(){int t; cin>>t; for(int i=1;i<=t;i++){solve();}}
        #define vi vector<int>
        #define vii vector<pair<int,int> > 
        #define vci vector<pair<char,int> >
        #define vic vector<pair<int,char> > 
        #define N 200005
        #define pb push_back
        const double PI=acos(-1);
        const int MOD = 1000000007;
        const int FMOD = 998244353;
        
        void solve()
        {
        	string s;
        	cin>>s;
        	
        	int n=s.size();
        	if(s[n-1]=='s')
        	{
        		s+='e';
        		s+='s';
			}
			else
			{
				s+='s';
			}
			cout<<s;
		}
        signed main()
        {
        	//test();
        	solve();
		}

Measured memory_bytes: 3628
from collections import defaultdict


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s = (s + self.tree[i]) % 1000000007
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] = (self.tree[i] + x) % 1000000007
            i += i & -i


n, m = list(map(int, input().split()))
sss = list(map(int, input().split()))
ttt = list(map(int, input().split()))

sid = defaultdict(list)
for i, s in reversed(list(enumerate(sss))):
    sid[s].append(i)

bit = Bit(n + 1)
bit.add(1, 1)

for t in ttt:
    if t not in sid:
        continue
    for i in sid[t]:
        bit.add(i + 2, bit.sum(i + 1))

print(bit.sum(n + 1))


Measured memory_bytes: 44232
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long ans = 0;
            for(long i = 1; i < N; i++)
            {
                ans = ans + i;
            }



            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140