akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

int main() {
	// your code goes here
	int n;
	cin>>n;
	long k;
	cin>>k;
	int q;
	cin>>q;
	vector<long> v(n,k);
	for(int i=0;i<q;i++){
		int x;
		cin>>x;
		v[x-1]+=1;
	}
	long mx = 0;
	for(int i=0;i<n;i++) v[i]-=q;
	for(int i=0;i<n;i++){
		if(v[i]<=0) cout<<"No\n";
		else cout<<"Yes\n";
	}
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int h,w,d; cin >>h>>w>>d;
    vector<int> row(h*w, 0);
    vector<int> col(h*w, 0);
    int a;
    REP (i,h) {
        REP (j,w) {
            cin >> a;
            row[a-1] = i;
            col[a-1] = j;
        }
    }
    

    vector<int> cumrow(h*w, 0);
    vector<int> cumcol(h*w, 0);
    for (int i = 0; i < d; i++) {
        int j = i+d;
        while (j < h*w) {
            cumrow[j] = cumrow[j-d] + abs(row[j]-row[j-d]);
            cumcol[j] = cumcol[j-d] + abs(col[j]-col[j-d]);
            j += d;
        }
    }

    int q; cin >>q;
    vector<int> l(q);
    vector<int> r(q);
    REP (i,q) cin >> l[i] >> r[i];
    REP (i,q) {
        l[i]--;
        r[i]--;
    }

    for (int i = 0; i < q; i++) {
        int res = 0;
        res += (cumrow[r[i]] - cumrow[l[i]]);
        res += (cumcol[r[i]] - cumcol[l[i]]);
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<iomanip>

using namespace std;
using ll=long long;

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

ll gcd(ll a,ll b){
  if(b==0) return a;
  return gcd(b,a%b);
}

ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/g*b;
}

void Main(){
  int n;
  cin>>n;

  ll ans=1LL;

  rep(i,0,n){
    ll T;
    cin>>T;
    ans=lcm(ans,T);
  }
  cout<<ans<<endl;

}

int main(){
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  Main();
}

Measured memory_bytes: 256
#BBBBBBBBBBB

import sys
import math
import itertools
import collections
import heapq
import numpy as np

rl = sys.stdin.readline

t = rl()
li = []
for i in range(len(t)):
    if t[i] == '?':
        li.append('D')
    else:
        li.append(t[i])
print(''.join(li))

Measured memory_bytes: 28820
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define in(x, l, r) (ll)(l) <= (x) && (x) < (ll)(r)

bool can(int N, vector<int> A, int K, int a) {
    // a以下の長さにする時何回切る必要があるか？
    ll sum = 0;
    rep(i,0,N) {
        sum += (A[i]-1) / a;
    }
    if (sum <= K) return true;
    else return false;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i,0,N) cin >> A[i];

    int left = 1;
    int right = 1000000000;
    while (left != right) {
        if (can(N, A, K, (left+right)/2)) {
            right = (left+right)/2;
        } else {
            left = (left+right)/2 + 1;
        }
    }
    cout << left << endl;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0): d(n, -1) {}
    int find(int x) {
        if (d[x]<0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x==y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return -d[find(x)];
    }
};

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> p(n);
    rep(i, n) {
        cin >> p[i];
        p[i]--;
    }
    UnionFind u(n);
    rep(i, m) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        u.unite(x, y);
    }
    int ans = 0;
    rep(i, n) {
        if (u.same(i, p[i])) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline

A, B, C, X, Y = map(int, input().split())

m = 10 ** 18

for i in range(max(X, Y) + 1):
    a = A * (X - i)
    b = B * (Y - i)
    c = C * i * 2

    point = 0
    for v in [a, b, c]:
        if v > 0:
            point += v

    m = min(m, point)

print(m)

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

int main(){
  int A[3][3];
  bool bingo[3][3];
  int N;
  rep(i,3){
    rep(j,3){
      cin >> A[i][j];
    }
  }
  cin >> N;
  int b[N];
  rep(i,N){
    cin >> b[i];
  }
  rep(i,3){
    rep(j,3){
      bingo[i][j] = false;
      rep(k,N){
        if(b[k] == A[i][j]) bingo[i][j] = true;
      }
    }
  }
  
  string ans = "No";
  rep(i,3){
    if(true == bingo[i][0] && true == bingo[i][1] && true == bingo[i][2] && "No" == ans){
      ans = "Yes";
    }
  }
  rep(i,3){
    if(true == bingo[0][i] && true == bingo[1][i] && true == bingo[2][i] && "No" == ans){
      ans = "Yes";
    }
  }
  if(true == bingo[0][0] && true == bingo[1][1] && true == bingo[2][2] && "No" == ans){
    ans = "Yes";
  }
  if(true == bingo[0][2] && true == bingo[1][1] && true == bingo[2][0] && "No" == ans){
    ans = "Yes";
  }
  
  cout << ans << endl;
}


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

#define ll long long


int main()
{


    ll a;
    cin>>a;

    string b;
    cin>>b;

    ll c=((b[0]-'0')*100+(b[2]-'0')*10+(b[3]-'0'));
    cout<<(a*c)/100;

}



Measured memory_bytes: 3600
using System;

namespace ITP1_1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());

            bool[] spades = new bool[13];
            Initilize(spades);
            bool[] hearts = new bool[13];
            Initilize(hearts);
            bool[] clubs = new bool[13];
            Initilize(clubs);
            bool[] diamonds = new bool[13];
            Initilize(diamonds);

            for (int i = 0; i < count; i++)
            {
                string[] card = Console.ReadLine().Split();

                switch (card[0])
                {
                    case "S":
                        spades[int.Parse(card[1]) - 1] = true;
                        break;

                    case "H":
                        hearts[int.Parse(card[1]) - 1] = true;
                        break;

                    case "C":
                        clubs[int.Parse(card[1]) - 1] = true;
                        break;

                    case "D":
                        diamonds[int.Parse(card[1]) - 1] = true;
                        break;
                }
            }
            Outputline(spades, "S");
            Outputline(hearts, "H");
            Outputline(clubs, "C");
            Outputline(diamonds, "D");

        }
        static void Initilize(bool[] array)
        {
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = false;
            }
        }
        static void Outputline(bool[] array, string mark)
        {
            for (int i = 0; i < array.Length; i++)
            {
                if (array[i] != true) Console.WriteLine(mark + " " + (i + 1));
            }
        }
    }
}



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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int &i: a) cin >> i;
	string ans="APPROVED";
	for(int i: a){
		if(i%2 ==0){
			if(i%3 == 0 || i%5 == 0) continue;
			else ans = "DENIED";
		}else continue;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

import java.util.*;
import java.io.*;
import static java.lang.System.*;

// Scanner定義時のSystem省略できるか知りたいだけ
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(in);
		if(sc.nextInt() < sc.nextInt()){
			out.println("0");
		}
		else{
			out.println("10");
		}
	}
}


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

int main(){
  int n, k;
  cin >> n >> k;
  int M = k;
  int a[n]; ll b[n];
  rep(i,n) {
    cin >> a[i] >> b[i];
    M = max(a[i],M);
  }
  int bit = 0;
  while(M > 0) {
    M /= 2;
    bit++;
  }
  vector<int> bitk;
  vector<vector<int>> bita(n);
  rep(i,n) {
    rep(j,bit) {
      bita[i].push_back(a[i]%2);
      a[i] /= 2;
    }
    reverse(bita[i].begin(),bita[i].end());  
  }
  rep(j,bit) {
    bitk.push_back(k%2);
    k /= 2;
  }
  reverse(bitk.begin(),bitk.end());
  ll ans = 0;
  rep(i,bit+1) {
    ll c = 0;
    if(i < bit) {
      if(bitk[i] == 1) {
        rep(j,n) {
          bool can = true;
          rep(l,i) {
            if(bita[j][l] == 1 && bitk[l] == 0) can = false;
          }
          if(bita[j][i] == 1) can = false;
          if(can) c += b[j];
        } 
      }
    } else {
      rep(j,n) {
        bool can = true;
        rep(l,bit) {
          if(bita[j][l] == 1 && bitk[l] == 0) can = false;
        }
        if(can) c += b[j];
      } 
    }
    ans = max(ans,c);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 17792
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k,a[200000];
	long long ans=0;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
	}
	if(n<=k){
        printf("0\n");
	}else{
	    sort(a,a+n);
	    n-=k;
	    for(int i=0;i<n;i++){
            ans+=a[i];
        }
        printf("%lld\n",ans);
	}
    return 0;
}



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

using namespace std;

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

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;

int N;
int ans = 0;

void solve() {
    cin >> N;
    vi p(N);
    rep(i,N) cin >> p[i];
    int c = 0;
    rep(i,N) {
        if (p[i] == i+1) {
            c++;
        } else {
            if (c == 1) ans++;
            else if (c > 1) ans += ceil(1. * c / 2);
            c = 0;
        }
    }
    if (c == 1) ans++;
    else if (c > 1) ans += ceil(1. * c / 2);
    cout << ans << endl;
}

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


Measured memory_bytes: 640
#!/usr/bin/env python3

R, C, K = list(map(int, input().split()))

V = [[] for i in range(R)]
for i in range(K):
    r, c, v = list(map(int, input().split()))
    V[r-1].append([c, v])


# dp = [[[0 for j in range(R+1)] for i in range(C+1)]

# print(rck)
dp = [0] * (C+1)
for r in range(1, R+1):
    tmp0 = 0
    tmp1 = 0
    tmp2 = 0
    tmp3 = 0
    V[r-1].sort()
    for c, v in V[r-1]:
        tmp0 = max(dp[c], tmp0)
        tmp1 = max(dp[c], tmp1)
        tmp2 = max(dp[c], tmp2)
        tmp3 = max(dp[c], tmp3)

        tmp3 = max(tmp3, tmp2+v)
        tmp2 = max(tmp2, tmp1+v)
        tmp1 = max(tmp1, tmp0+v)

        dp[c] = max(tmp0, tmp1, tmp2, tmp3)
    for i in range(1, C+1):
        dp[i] = max(dp[i], dp[i-1])
    # print(dp)

print(dp[-1])


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

int main()
{
    int x, r, gohyakuen = 0, goen = 0, happiness = 0;
    cin >> x;

    gohyakuen = x / 500;

    r = x % 500;
    if (r != 0) {
        goen = r / 5;
    }

    happiness = gohyakuen * 1000 + goen * 5;

    cout << happiness << endl;
    return 0;
}


Measured memory_bytes: 256
import math


def main():
    s = list(input())
    if s.count("R") == 3:
        print(3)
        return
    if s[0] + s[1] == "RR" or s[2] + s[1] == "RR":
        print(2)
        return
    if s.count("R") >= 1:
        print(1)
        return
    print(0)


if __name__ == '__main__':
    main()


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

int compare_char(const void* left, const void* right) {
    char *left_char = (char *)left;
    char *right_char = (char *)right;

    return strcmp( left_char, right_char );
}

int main(void)
{
    int N,i,max=0,count=1;
    char S[200001][11];
    
    scanf("%d",&N);

    for(i=0; i<N; i++){
        scanf("%s",S[i]);
    }

    qsort(S, N, sizeof(S[0]), compare_char);//辞書順にソート

    for(i=0; i<N-1; i++){//数のカウント
        if(strcmp(S[i], S[i+1]) == 0){//文字列比較
            count++;
        } else {
           count = 1; 
        }

        if(max<count){
            max = count;
        }
    }

    //printf("max = %d\n",max);

    count = 1;

    for(i=0; i<N; i++){//出力
        if(strcmp(S[i], S[i+1]) == 0){//文字列比較
            count++;
        } else {
        count = 1; 
        }

        //printf("count = %d\n",count);

        if(max == count){
            printf("%s\n",S[i]);
        }
    }


    return 0;
}

Measured memory_bytes: 4476
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie acos(-1)
#define loop(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x) for(auto &a:x)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define endl "\n"
#define all(v) v.begin(),v.end()
#define w 100005
bool p(string s)
{
    string t=s;
    reverse(t.begin(),t.end());
    return t==s;
}
void solve()
{
    string s;
    cin>>s;
    int n=s.size();
    string check1=s.substr(0,(n-1)/2);
    string check2=s.substr((n+3)/2-1,n-(n+3)/2+1);
    if(p(check1) && p(check2) && p(s))
    cout<<"Yes";
    else
    cout<<"No"<<endl;
    //cout<<s<<" " <<check1<<" "<<check2<<endl;
}
int main() {
	// your code goes here

    solve();
	return 0;
}


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

int main() {
  int h[3], k[3], a, b, c, d; cin >> h[1] >> h[2] >> k[1] >> k[2] >> a >> b >> c >> d;
  int total1 = h[1] * a + h[1] / 10 * c + h[2] * b + h[2] / 20 * d;
  int total2 = k[1] * a + k[1] / 10 * c + k[2] * b + k[2] / 20 * d;
  if (total1 > total2) cout << "hiroshi" << endl;
  if (total1 < total2) cout << "kenjiro" << endl;
  if (total1 == total2) cout << "even" << endl;
  return 0;
}


Measured memory_bytes: 3112
/* _________________________________________________________________________________________________
  |                                                                                                 |
  |                             Author      : Aditya Ahuja                                          |
  |                             Date        : Thu, 20th Jun 2019                                    |
  |_________________________________________________________________________________________________|
*/
 
#include<bits/stdc++.h>
using namespace std;

// #define int long long

#define pb          push_back
#define F           first
#define S           second
#define rep(i,a,b)  for(int i=a; i<b; i++)
#define all(a)      (a).begin(),(a).end()
#define ret(x)      {cout << (x) << endl; return;}
#define sz(x)       (int)x.size()
#define type(x)     typeid(x).name()

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;

#define wa(x)       cout << (#x) << " -------- " << (x) << endl
#define pvi(v)      {for(auto it:v) cout << it << " "; cout << endl;}
#define line1	    printf("---------------------------\n")

// #define wa //
// #define line1 //
// #define pvi //
// #define printf //

void solve();
signed main() {
	//ios_base::sync_with_stdio(false); cin.tie(NULL);
	////cout << fixed << setprecision(10);

	int t=1; 
	//cin>>t;
	while(t--) solve();
	return 0;
}

//___________________________________________________________________________________________________

void solve() {

	string a,b;
	cin >> a >> b;

	int la = a.length();
	int lb = b.length();

	vii dp(la+1, vi(lb+1,0));

	rep(i,0,la+1){

		rep(j,0,lb+1){

			if(i == 0 || j == 0) dp[i][j] = 0;
			else if(a[i-1] != b[j-1]) dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
			else dp[i][j] = dp[i-1][j-1] + 1;
		}
	}

	// cout << dp[la][lb] << endl;

	// for(auto e:dp) pvi(e);

	int cx = la, cy=lb;
	string s;

	while( ! (cx == 0 || cy == 0) ){

		if(cx != 0 && dp[cx][cy] == dp[cx-1][cy]) cx--;
		else if(cy != 0 && dp[cx][cy] == dp[cx][cy-1]) cy--;
		else{

			// wa(cx);
			// wa(cy);
			// wa(a[cx-1]);
			// wa(b[cy-1]);

			assert(dp[cx][cy] = dp[cx-1][cy-1]+1);
			assert(a[cx-1] == b[cy-1]);
			s += a[cx-1];

			cx--;
			cy--;
			
			// line1;	
		}
	}

	reverse(all(s));
	cout << s << endl;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N;
  pair<int,int> x[210000];
  int res=0;
  cin >> N;

  rep(i,N) {
    int xx;
    cin >>xx;
    x[i] = make_pair(xx,i);
  }

  sort(x,x+N);

  int a[210000];// a[i] stands for the rank of Xi                               
  int b[210000];// b[i] stands for original content of X with rank i            
  rep(i,N){
    a[x[i].second] = i;
    b[i] = x[i].first;
  }

  rep(i,N){
    if(a[i]<=N/2-1) res = b[N/2];
    else res = b[N/2-1];
    cout << res << endl;
  }
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
  int f=0;
if(s.size()%2){cout<<"No";return 0;}
else{
for(int i=0;i<s.size();i+=2){if(s[i]!='h'|| s[i+1]!='i'){f=1;cout<<"No";break;}}
    }
if (f==0)cout<<"Yes";

}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define Yes "Yes"
#define No "No"
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
#define vint vector<int>
#define vll vector<ll>
typedef long long ll;

using namespace std;


int main(void){
	int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
	a--; b--; c--; d--;
	string str; cin >> str;
	int count = 0;
	rep2(i, a, c){
		if(str[i] == '#') count++;
		else count = 0;
		if(count >= 2){
			cout << "No" << endl;
			return 0;
		}
	}
	rep2(i, b, d){
		if(str[i] == '#') count++;
		else count = 0;
		if(count >= 2){
			cout << "No" << endl;
			return 0;
		}
	}

	if(c < d){
		cout << Yes << endl;
	} else{
		for(int i = max(1, b); i+1<=n && i <= d; i++){
			if(str[i-1] == '.' && str[i] == '.' && str[i+1] == '.'){
				cout << Yes << endl;
				return 0;
			}
		}
		cout << No << endl;
	}
	return 0;
}

Measured memory_bytes: 640
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        String s = scanner.next();
        if (s.equals("zyxwvutsrqponmlkjihgfedcba")) {
            System.out.println(-1);
        } else if (s.length() < 26) {
            for (char c = 'a'; c <= 'z'; c++) {
                if (s.indexOf(c) == -1) {
                    System.out.println(s + c);
                    return;
                }
            }
        } else {
            char c[] = s.toCharArray(), last = c[25];
            boolean[] use = new boolean[26];
            use[c[25] - 'a'] = true;

            for (int i = c.length - 2; i >= 0; i--) {
                if (last < c[i]) {
                    use[(last = c[i]) - 'a'] = true;
                } else {
                    for (int i1 = c[i] - 'a'; i1 < 26; i1++) {
                        if (use[i1]) {
                            System.out.println(s.substring(0, i) + (char)(i1 + 'a'));
                            return;
                        }
                    }
                }
            }
        }
    }
}

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

unsigned long long m[205][205];
vector< int > V;
int n,e;

void floyed_warshall(){
    for(int k = 1; k <= n; k++){
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                if(m[i][k] + m[k][j] < m[i][j]){
                    m[i][j] = m[i][k] + m[k][j];
                }
            }
        }
    }
}

int main(){

     int r,p;
    vector<int> cum;

    cin>>n>>e>>r;

    for(int i=0;i<r;i++){
        cin>>p;
        cum.push_back(p);
    }

    for(int i = 1 ; i <=  n ;i++){
        for(int j = 1 ; j <= n ;j++){
            if(i == j) m[i][j] = 0;
            else m[i][j] = 1e15;
        }
    }

    while(e--){
       int a,b;
       unsigned long long c;
       cin>>a>>b>>c;
       m[a][b] = min(c,m[a][b]);
       m[b][a] = min(c,m[b][a]);
    }

    floyed_warshall();

    unsigned long long ans = 1e15;

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

    do{
            unsigned long long an = 0;
            int last = cum[0];
            for(int i=1;i<r;i++){
                an += m[last][cum[i]];
                last = cum[i];
            }
            if(an<ans) ans = an;
        }while(next_permutation(cum.begin(),cum.end()));

    cout<<ans<<"\n";



    return 0;
}





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

int main(){
    int A,B,C,K;
    cin >> A >> B >> C >> K;
    for(int i = 0; i < K;i++){
        if(A < B && B < C){cout <<"Yes"<<endl;return 0;}
        if(A>=B)B*=2;
        else if(B>=C)C *= 2;
    }
    if(A < B && B < C){cout <<"Yes"<<endl;return 0;}
    else cout << "No"<<endl;
    return 0;
    
    
}






Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

ll N,K;
vector<ll> ans;

ll fuct(ll n) {
	if (n==0 or n==1) return 1;
    else return n*fuct(n-1)%MOD;
}

//aのb乗
ll calc(ll a, ll b) {
    if (b==0){
      return 1;
    }else if (b==1){
      return a;
    }else if (b%2==0){
      ll tmp=calc(a,b/2);
      return tmp*tmp%MOD;
    }else{
      return a*calc(a,b-1)%MOD;
    }
}

ll comb(ll n, ll k) {
	ll retval = ((fuct(n) * calc(fuct(k), MOD-2))%MOD * calc(fuct(n-k), MOD-2))%MOD;
	return retval;
}

int main(){
	cin >> N >> K;
	ans = vector<ll>(K,0);
	ll key = min(N-K+1,K);
	//i回の操作で, 
	for(int i=1;i<=key;i++)
	{
		ans[i-1] = (comb(N-K+1,i) * comb(K-1,i-1)) % MOD;
	}
	for(int i=0;i<K;i++)
	{
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 256
from collections import defaultdict

def testkilled(p,S,qry,N):
    pi=p
    c=S[pi]
    for q in qry:
        a,b=q
        if b=="R":
            d=1
        else:
            d=-1
        if c==a:
            pi+=d
            if pi==-1:
                return 1
            if pi==N:
                return 2
            c=S[pi]
    return 0

N,Q=[int(x) for x in input().split()]
S=input()
B=[1 for x in range(N)]
qry=[]
for q in range(Q):
    qry.append(input().split())
l=0
r=N
ans=N
while(r-l>1):
    p=(l+r)//2
    k=testkilled(p,S,qry,N)
    if k==1:
        l=p
    else:
        r=p
if testkilled(0,S,qry,N)==1:
    if testkilled(p,S,qry,N)==1:
        ans-= p+1
    else:
        ans-= p
    #print ("p",p,l,r)    
l=-1
r=N-1
while(r-l>1):
    p=(l+r)//2
    k=testkilled(p,S,qry,N)
    if k==2:
        r=p
    else:
        l=p
if testkilled(N-1,S,qry,N)==2:
    if testkilled(p,S,qry,N)==2:
        ans-= (N-p)
    else:
        ans-= (N-p-1)
#print ("p",p,l,r)
print(ans)
#print(testkilled(0,S,qry,N))
#print(testkilled(1,S,qry,N))
#print(testkilled(N-1,S,qry,N))


Measured memory_bytes: 93688
/******************
 *AUTHOR: speckrel*
 ******************/

//******************************************************************************
#include "bits/stdc++.h"
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define fpowll fpow<long long>
#define fpowi fpow<int>
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define all(v) (v).begin(), (v).end()


//Fast exponentiation
template <typename T>
T fpow(T base, T expo){
    if(expo==0){return 1;}
    else if(expo==1){return base;}
    else{
        if(expo%2==0){return fpow(base,expo/2)*fpow(base,expo/2);}
        else{return base*fpow(base,expo-1);}
    }
}

//******************************************************************************
//Auxiliary Functions go here
bool areDiff(int a,int b,int c){
    return ((a!=b)&&(b!=c)&&(c!=a));
}

bool isTri(int a,int b, int c){
    return (a+b>c);
}
//******************************************************************************
void solve(){
    static int coun=0;
    //cout<<"This is a test code "<<coun<<"\n";
    //coun++;
    int n,num=0;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    for(int i=0;i<n-2;i++){
        for(int k=i+1;k<n-1;k++){
            for(int j=k+1;j<n;j++){
                if((isTri(arr[i],arr[k],arr[j]))&&(areDiff(arr[i],arr[k],arr[j]))){++num;}
            }
        }
    }
    cout<<num;
}

// main function
int main(){
    IOS
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ll t=1;
    //cin>>t;

    while(t--){
        solve();
    }

    return 0;
}
//******************************************************************************


Measured memory_bytes: 3652
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int max = 0;
    for (int i = 0; i < n; i++) {
      int num = sc.nextInt();
      max += num;
    }
    System.out.println(max - n);
  }
}

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

// Template Headers {{{
using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long; using vll = vector<long long>;
template <class T> istream &operator>>(istream &, vector<T> &);
template <class T> ostream &operator<<(ostream &, const vector<T> &);
template <class T, class U> istream &operator>>(istream &, pair<T, U> &);
template <class T, class U> ostream &operator<<(ostream &, const pair<T, U> &);
constexpr int INF = 0x3f3f3f3f; constexpr ll BINF = 0x3f3f3f3f3f3f3f3fLL;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// }}}

int solve() {
	int n, x; cin >> n >> x;
	vi a(n); cin >> a;
	int cnt = 1, now = 0;
	for (int i=0;i<n;i++) {
		now += a[i];
		if (now <= x) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

// Template Main {{{
int main() {
	ios::sync_with_stdio(0);
	// precompute();
	// int t; cin >> t; for (int i=1;i<=t;i++)
	solve();
	// cout << (solve() ? "YES" : "NO") << endl;
	return 0;
}

template <class T> istream &operator>>(istream &is, vector<T> &v) {
	for (auto it=v.begin();it!=v.end();++it) is >> *it;
	return is;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
	for (auto it=v.begin();it!=v.end();) os << *it, os << " \n"[++it==v.end()];
	return os;
}

template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) {
	return is >> p.first >> p.second;
}

template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) {
	return os << p.first << ' ' << p.second;
}
// }}}

// vim: fdm=marker


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>

using namespace std;

#define BTCRATE 380000.0

int main(){
	
	int N;
	double l;
	char tmp[256];
	vector<double> money;
	vector<int> unit;
	double ans = 0.0;
	
	scanf("%d", &N);
	for(int i=0; i<N; i++){
		scanf("%lf", &l);
		scanf("%s", tmp);
		
		money.push_back(l);
		if(strcmp(tmp, "JPY") == 0) unit.push_back(1);
		else unit.push_back(0);
	}
	
	for(int i=0; i<N; i++){
		ans += money[i] * ((unit[i] == 1) ? 1 : BTCRATE);
	}
	
	printf("%lf\n", ans);
	
	return 0;
	
}


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

int main(){
  long long int a,b,i,n,j,k;
  string s;
  cin >> s;
  cin >> a;
  if(a==1){
    cout << s[0] << endl;
    return 0;
  }
  j=a;
  b=0;
  while(j!=1 && s[b]=='1'){
    j--;
    b++;
  }
  cout << s[b] << endl;
  return 0;
}


Measured memory_bytes: 256
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var MA = one[1];
  var MB = one[2];
  var list = new Array(N);
  for(var i = 0; i < N; i++){
    list[i] = nextIntArray();
  }
  var dp = new Array(N + 1);
  var maxValue = 401;
  for(var i = 0; i < N + 1; i++){
    dp[i] = new Array(maxValue);
    for(var j = 0; j < maxValue; j++){
      dp[i][j] = new Array(maxValue);
    }
  }
  dp[0][0][0] = 0;
  //dp[i][j][k] : i個目を買い、MA合計がj、MB合計がkになる時の最小コスト
  for(var i = 1; i <= N; i++){
	for(var j = 0; j < maxValue; j++){
		for(var k = 0; k < maxValue; k++){
			if(dp[i - 1][j][k] != null){
				dp[i][j][k] = dp[i - 1][j][k];
			}
		}
		
	}
    var item = list[i - 1];
    for(var j = 0; j < maxValue; j++){
      for(var k = 0; k < maxValue; k++){
        //myerr({i,j,k});
        if(dp[i - 1][j][k] != null){
          if(dp[i][j + item[0]][k + item[1]] == null){
            dp[i][j + item[0]][k + item[1]] = dp[i - 1][j][k] + item[2];
          }else{
            dp[i][j + item[0]][k + item[1]] = Math.min(dp[i - 1][j][k] + item[2], dp[i][j + item[0]][k + item[1]]);
          }
        }
      }
    }
  }
	var count = 1;
	var output = 10000;
	while(true){
		var getMA = MA * count;
		var getMB = MB * count;
		if(getMA < maxValue && getMB < maxValue){
			if(dp[N][getMA][getMB] != null){
				output = Math.min(output,dp[N][getMA][getMB]);
			}
		}else{
			break;
		}
		count++;
	}
	if(output == 10000){
		myout(-1);
	}else{
		myout(output);
	}
}

Measured memory_bytes: 87244
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

set<ll> primes(ll n) {
  ll p = 0;
  set<ll> ret;
  vector<bool> is_prime(n + 1, true);
  is_prime[0] = is_prime[1] = false;
  for (ll i = 2; i <= n; i++) {
    if (is_prime[i]) {
      ret.insert(i);
      for (int j = 2 * i; j <= n; j += i) {
        is_prime[j] = false;
      }
    }
  }
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x;
  cin >> x;
  set<ll> p = primes(200000);
  set<ll>::iterator it = p.lower_bound(x);
  cout << *it << endl;
  return 0;
}


Measured memory_bytes: 1152
#include <iostream>

using namespace std;

int main()
{
    int n;
    string s;
    cin>>n>>s;
    int x=0;
    int max=x;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='I')
            x++;
        else
            x--;
        if(max<x)
            max=x;
    }
    cout<<max;
    return 0;
}


Measured memory_bytes: 256
a, b = (float(x) for x in input().split())
list8 = []
ans = -1
for i in range(12500):
  if int(i * 0.08) == a:
    list8.append(i)
for j in range(10000):
  if int(j * 0.1) == b:
    if j in list8:
      ans = j
      break
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h1 = sc.nextInt();
        int m1 = sc.nextInt();
        int h2 = sc.nextInt();
        int m2 = sc.nextInt();
        int k = sc.nextInt();
        
        int t1 = h1*60+m1;
        int t2 = h2*60+m2;
        int ans = t2-t1-k;
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 35768
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int main(void) {
	int N,M,P;
	
	cin >> N;
	cin >> M;
	cin >> P;

	while (N != 0 || M != 0 || P != 0) {
		int vote;
		int vote_w;
		int sum_vote = 0; 
		int r;
		for (int i = 0; i < N; i++) {
			cin >> vote;
			sum_vote += vote;
			if (i+1 == M) {
				vote_w = vote;
			} 
		}
		if (vote_w > 0) {
			r = ((sum_vote*100) * (100-P));
			r = r/(100*vote_w);
		}else {
			r = 0;
		}
		cout << r << endl; 
		
		cin >> N;
		cin >> M;
		cin >> P;
	}
	return 0;
}

Measured memory_bytes: 2992
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll N;
  cin >> N;
  if(N == 1){
    cout << "Hello World" << rt;
  }
  else{
    ll A, B;
    cin >> A >> B;
    cout << A+B << rt;
  }
}

Measured memory_bytes: 256
from sys import stdin,stdout
def f(i,j,n,mat):
	ans = -1
	for k in range(n):
		ans += mat[i][k]+mat[k][j]
	return ans

def main():  	
	for x in stdin:
		A = list(map(int,x.split()))
		A.sort()
		if (A[0]==A[1] and A[1]!=A[2]) or (A[0]!=A[1] and A[1]==A[2]):print('Yes')
		else:print('No')

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
/**
*   @Author : MeGaCrazy
*   @InitTime : Thu Feb 21 15:08:53 2019
*   @Idea :
*
*
*
*
*
*  Happy Solving :)
**/
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+7;
int cum[N];
int main(){
#ifndef ONLINE_JUDGE
   //freopen("in","r",stdin);
   //freopen("out","w",stdout);
#endif
   int n,k;
   cin>>n>>k;
   vector<int>v;
   for(int i=0;i<n;i++){
   	int a;
   	cin>>a;
   	v.push_back(a);
   }
   auto it=lower_bound(v.begin(),v.end(),0);
   int pos;
   if(it!=v.end()){
      	pos=it-v.begin();


      	if(v[pos]==0){
      	  k--;
      	}else{
   	 v.insert(it,0);
   	}
   }else{
   	v.push_back(0);
   	pos=v.size()-1;
   }

	
   for(int i=1;i<v.size();i++){
   	cum[i]=cum[i-1]+abs(v[i]-v[i-1]);
   //	cerr<<cum[i]<<endl;
   }
   int l=max(0,pos-k);
   int ans=1e9;
   int r=min((int)v.size()-1,l+k);
   while(r<v.size()){
        int left=cum[pos]-cum[l];
        int right=cum[r]-cum[pos];
     //   cerr<<l<<" "<<r<<" "<<left<<" "<<right<<endl;
        ans=min(ans,min(left*2+right,right*2+left));
        r++;
        l++;
        if(l>pos)l=pos;
   }
   cout<<ans<<endl;
   




}

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

int main()
{
	int a,x;
	cin>>x>>a;
	
	if(x<a)
	{
		cout<<"0"<<endl;
	}
	if(x>=a)
	{
		cout<<"10"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
'''catupper
ポイントA.再帰DFSで全ての頂点をチェックし、辺の色を求める。上限に注意。
ポイントB.入力に注意。
頂点が連結しているということは、そこに辺があるということ。
辺は頂点を結ぶので、辺が連結している二つの頂点(a[i], b[i])で表現され、
まず、辺をedgeに格納する。
辺の色は辞書color_dictに格納している。
辺である(a[i], b[i])をキーとして使って、color_dict[(a[i], b[i])]で
その辺に対応する色の番号が分かるようにしている。
辞書のキーが配列になっているので、注意。
ポイントC.色を頂点の順番で辺毎に出力する。辺の数は頂点-1個。
for i in range(n-1):  
    print(color_dict[(a[i], b[i])])
疑問点：色が新しくなるのは分かるけど、
色が1から再び使えるようになる仕組みは下の通りで良いのか？
'''

import sys
sys.setrecursionlimit(1000000)#DFSは再帰の上限回数に注意

n = int(input())
edge = [[] for i in range(n)]
#どの頂点とどの頂点が繋がっているかを格納しておく配列
a = [0] * n#頂点aに繋がっている頂点bの番号を格納しておく配列
b = [0] * n

for i in range(n-1):
    a[i], b[i] = map(int, input().split())
    a[i] -= 1#0-indexにする
    b[i] -= 1
    edge[a[i]].append(b[i])#無向グラフとして入力する
    edge[b[i]].append(a[i])#二重配列に注意

color_dict = {}#色を格納しておく辞書
k = 0#求める色の数

def dfs(x, last = -1, ban_color = -1):
#lastは、どこから来たか、逆走を防ぐ。使っちゃいけない色も引数
#最初は、どこからも来ないし、どの色もOK
    global k#グローバル変数、宣言を忘れない
    color = 1#次の頂点については、再び1からチェックする
    #但し、繋がっている前の頂点と結ばれている辺の色は使えない
    for to in edge[x]:
    #このfor文はある頂点から繋がる次の頂点への辺の色を次々と決めている
    #同じ頂点に繋がる辺は同じ色に出来ないので、次々、色を新しくする
    #配列edgeに格納されている次の頂点toを順番にチェック。
    #edgeに格納されている、いま見ている頂点から繋がっている
    #全ての頂点をチェックすれば、dfs1回分のfor文はオシマイ。
    #次の頂点についても、同様にfor文でチェックし、
    #次の頂点から繋がる全ての頂点をチェックすることになるが、
    #それは次の話。    
        if to == last:continue
        #来た頂点に戻ろうとしたら、何もしない(条件1)
        if color == ban_color:color += 1
        #いま見ている頂点へ来た辺に使っている色なら、
        #新しい色にする(条件2)
        color_dict[(x, to)] = color#DFSして、color_dictに値が入る
        #使う色をタプルで辞書color_dictに格納する(作業)
        #辺(x, to)をキーとして、値colorをバリューに入れる。
        dfs(to, x, color)
        #深さ優先探索なので深く探索できる限り次から次へと探索する。
        #イメージ的には一つ下の階層の頂点を探索する。
        #いま見ている頂点ではないので、混乱しないこと。
        #次の頂点toについてDFS。来たのはxから。前の頂点で使った色はダメ。
        color += 1#いま見ている頂点から繋がる他の頂点へ行く辺の色として
        #新しい色を用意しておく(注意)
    k = max(k, color-1)    #何色を使ったか、その最大値を記録しておく。
    #用意した新しい色(上記の注意)は、まだ使っていないのでcolor-1。

dfs(0)#最初の頂点を示す0をDFSに入れてスタート。
#辞書color_dictに辺キーと色バリューが格納される。

print(k)#必要となる色数を出力
for i in range(n-1):
#辺の色を1から、辺の総数である頂点番号-1まで出力
    print(color_dict[(a[i], b[i])])
    #辺と色を格納した辞書に対してキーである辺を指定すると、
    #辺に対応する色が出力される
'''  以下の場合分けは不要。制約で1≤ai<bi≤Nだからか？
無向グラフで、aiで一通り、全ての辺が出力されるから？
    if (a[i], b[i]) in color_dict:#辞書から答を出力
        print(color_dict[(a[i], b[i])])
    else:
        print(color_dict[(b[i], a[i])])
'''


Measured memory_bytes: 84516
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;
template <typename T = vii>
using vec = vector<T>;

const ll INF = 1e18, MOD = 1e9 + 7;

const int MAX = 1e6;

vii primes({2});
inline void sieve(const int n = MAX) {
    vec<bool> is_prime(n + 1, 1);
    for (int i = 3; i * i <= n; i += 2) {
        if (is_prime[i]) {
            for (int j = 2 * i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }
    for (int i = 3; i <= n; i += 2) {
        if (is_prime[i]) primes.push_back(i);
    }
}

inline auto f(ll n) {
    int cnt = 0;

    for (const int p : primes) {
        if (ll(p) * p > n) break;
        if (n % p == 0) cnt++;
        while (n % p == 0) n /= p;
    }

    if (n > 1) {
        cnt++;
    }
    return cnt;
}

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);
    sieve();
    ll a, b;
    cin >> a >> b;
    const ll g = __gcd(a, b);
    const int cnt = f(g);
    cout << cnt + 1 << '\n';
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define FOR(i,x,y) for(int i=x;i<y;i++)
using namespace std;
int main(){
  vector<char> editor;
  char c;
  while(cin >> c){
    if(c == '0')editor.push_back('0');
    else if(c == '1')editor.push_back('1');
    else if(editor.size())editor.pop_back();
  }
  for(auto x:editor)cout << x;
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S, T;
    cin >> S >> T;
    int cnt = 0;
    int ans = 0;
    int j = 0;
    for(int i = 0 ; i < S.size() - T.size() + 1; i++){
        int cnt = 0;
        for(int j = 0; j < T.size(); j++){
            if(S[i + j] == T[j]) cnt++;
        }
        ans = max(ans, cnt);
    }
    cout << T.size() - ans << endl;
}

Measured memory_bytes: 3628
{-# LANGUAGE BangPatterns #-}

import           Control.Applicative
import           Debug.Trace

main :: IO ()
main = do
    (_:xs) <-  map read.words <$> getContents
    print $ solve xs

solve :: [Int] -> Int
solve (x:xs) = go (x-1) 1 xs
 where
  go !res !m (x:xs)
    | x <= m = go res m xs
    | x == m + 1 = go res x xs
    | (q, 0) <- divMod x (m+1), q > 0 = go (res+q-1) m xs
    | otherwise = go (div x (m+1) + res) m xs
  go res _ [] = res


Measured memory_bytes: 2428
/*
ID: Aman Raj
LANG: C++
TASK: money
*/
#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef  long long int ll;
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
//Â
using namespace std;
using namespace __gnu_pbds;
//Â
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
//#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
	int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
  //# define mod 1e9+7
   ll gcd(ll a,ll b)
   {
       if(a==0)return b;
       return gcd(b%a,a);
   }
//Â

ll power1(ll a, ll b)//a raised to power b
   {  if(b<=0) return 1; if(b==1) return a;
       ll c=power1(a,b/2);
        c*=c;c%=mod;if(b%2==1) c*=a;c%=mod;
        return c;
   }
   ll mi(ll a,ll m)
   { ll c= power1(a,m-2);

     return c;
   }
   ll n;
   vector<vector<ll> > v;
    vector<ll> vval;
     vector<ll> vans;
     vector<ll> visited;
     void dfs(ll i,ll a)
     {    vans[i]+=(a+vval[i]);
          visited[i]=1;
          for(auto x:v[i])
          {
              if(!visited[x])
              {
                  dfs(x,vans[i]);
              }
          }
     }
int main()
{    ifstream fin("money.in");
     ofstream fout("money.out");
     ll q; cin>>n>>q;
     v.resize(n+1);
     vval.resize(n+1,0);
     vans.resize(n+1,0);
       for(ll i=0;i<n-1;i++)
       {
          ll a,b;cin>>a>>b;
           v[a].push_back(b);
            v[b].push_back(a);
       }
       while(q--)
       {
           ll a,x;cin>>a>>x;
            vval[a]+=x;
       }
       visited.resize(n+1,0);

       dfs(1,0);
       for(ll i=1;i<vans.size();i++)
        cout<<vans[i]<<" ";
      return 0;
}


Measured memory_bytes: 24320
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>

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

using namespace std;
using ll = long long;
using P = pair<int, int>;
using TP = tuple<ll, ll, ll>;
ll MOD = 1e9+7;
ll INF = 1LL<<40;

ll rec(ll N, ll X){
    if(N==0){
        return 1;
    }
    
    ll len = ((ll)1 << N+1) - 3;
    ll num = ((ll)1 << N) - 1;
    if(X==1) return 0;
    else if(X <= len + 1) return rec(N-1, X-1);
    else if(X == len + 2) return num + 1;
    else if(X <= (len + 1) * 2) return num + 1 + rec(N-1, X-len-2);
    else return num * 2 + 1;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N, X;
    cin >> N >> X;
    cout << rec(N,X) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    if(a < b){
        for (int i = 0; i < b; ++i) {
            cout << a;
        }
        cout << endl;

        return 0;
    }

    for (int i = 0; i < a; ++i) {
        cout << b;
    }
    cout << endl;


    return 0;
}


Measured memory_bytes: 256