akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main()
{
    // 整数の入力
    string s1,s2;
    cin >> s1;
    cin >> s2;
    int size1,size2;
    size1=s1.size();
    size2=s2.size();
    for(int i=0;i<size1;i++){
        cout << s1[i];
        if(i<size2)
            cout << s2[i];
    }
    cout << endl;
    return 0;
}


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

using namespace std;
 
int x, y, z, ans;

int main()
{
	scanf("%d %d %d", &x, &y, &z);
	
	ans = (x - z) / (y + z);
	
	printf("%d\n", ans);
			
	return 0;
} 

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

int main(){
    int n;  cin >> n;
    int ans=0;
    for(int i=0; i<n; i++){
        int x;  cin >> x;
        int cnt=0;
        while(0<x && x%2==0){
            x /= 2;
            cnt += 1;
        }
        ans += cnt;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    char a;
    // gets(a);
    do
    {
        scanf("%c", &a);
        if (a >= 'a' && a <= 'z')
        {
            a = a - 32;
        }
        else if (a >= 'A' && a <= 'Z')
        {
            a = a + 32;
        }
        printf("%c", a);
    } while (a != '\n');
    return 0;
}


Measured memory_bytes: 2060
#include <iostream>
#include<stdio.h>
#include<cstring>
using namespace std;

int main()
{
    int N,X;
    while(cin>>N){
            cin>>X;
    int*m=new int[N];
        int min_point=0;
        for(int i=0;i<N;i++){
            cin>>m[i];
            X=X-m[i];
            if(m[i]<m[min_point])min_point=i;
        }
        int j=X/m[min_point];
        cout<<N+j<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
//2019.8.10 by ljz
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define unl __int128
#define eps 5.6e-8
#define RG register
#define db double
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define gc getchar
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
//inline int read() {
//    res s=0,ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
inline int read() {
    res s=0,ch=gc(),w=1;
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s*w;
}
inline LL Read() {
    RG LL s=0;
    res ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG unl x){
//    if(x>10)write(x/10);
//    putchar(int(x%10)+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//clock_t start=clock();
//inline void ck(){
//    if(1.0*(clock()-start)/CLOCKS_PER_SEC>0.1)exit(0);
//}
namespace MAIN{
    int n;
    string s;
    map<string,int> mp;
    int a[10+10];
    char str[10+10];
    LL ans;
    inline void MAIN(){
        n=read();
        for(res i=1;i<=n;i++){
            scanf("%s",str+1);
            res l=int(strlen(str+1));
            s.clear();
            sort(str+1,str+l+1);
            for(res i=1;i<=l;i++)s.pb(str[i]);
            ans+=mp[s],mp[s]++;
        }
        printf("%lld\n",ans);
    }
}
int main(){
//    srand(19260817);
//    freopen("signin.in","r",stdin);
//    freopen("signin.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);++i)
typedef int64_t ll ;
const ll MOD = 1000000007;

ll dp[100010][13];

int main() {
  string S;

  cin >> S;

  dp[0][0] = 1;

  // dp[i][j]: i文字目までの数値で、mod13が j である数値の総数
  for ( int i=0; i<S.length(); ++i ) {
    for ( int j=0; j<13; ++j ) {
      // "?"の場合は、その桁の数値が 0-9 全ての場合で調べる
      // それ以外の数値の場合は、その数値の場合のみ調べる
      for ( int n=0; n<10; ++n ) {
        if ( (S[i] != '?') && (S[i] != (n + '0')) ) continue;
        // AB という文字列だとして、A mod 13 が既知の場合に
        // i を一つ増やした場合（数値として扱う桁を右に一つ増やした場合）の mod13 は
        // (A * 10 + B) mod 13 で計算できる。
        // A mod 13 = Y とすると、
        // ((A mod 13) * (10 mod 13) + (B mod 13)) mod 13 = (Y * 10 + B) mod 13
        // となる。（B は 0 ～ 10 なので、13は超えない）
        dp[i+1][(j * 10 + n) % 13] += dp[i][j];
//        dp[i+1][(j * 10 + n) % 13] %= MOD;
      }
//      dp[i+1][j] = dp[i+1][j] % MOD;
    }
    REP(j,13)  dp[i+1][j] %= MOD;
  }

  cout << (dp[S.length()][5]) << endl;
  
}


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

As = [0] * (N + 1)
Bs = [0] * (M + 1)

for i in range(1, N + 1):
  As[i] = As[i - 1] + A[i - 1]
  if As[i] > K:
    i -= 1
    break

for j in range(1, M + 1):
  Bs[j] = Bs[j - 1] + B[j - 1]
  if Bs[j] > K:
    j -= 1
    break

if i < j:
  As, Bs = Bs, As
  i, j = j, i

j = 0
n = i
while i:
  while j + 1 < len(Bs) and As[i] + Bs[j + 1] <= K:
    j += 1
  n = max(n, i + j)
  #print(As, Bs, i, j, n)
  i -= 1

print(n)

Measured memory_bytes: 40776
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main(){
    int64_t A,B,C,K;

    cin>> A >> B>> C >> K;

    int64_t temp;

    if(A >= K){
        temp = K;
    }
    else if(A+B >= K){
        temp = A;
    }
    else{
        temp = A -(K-A-B);
    }

    cout<< temp <<endl;

}



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

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

    int maxCount = 1;

    map<string, int> stringAppearCount;

    for (int i = 0; i < n; ++i)
    {
        string input;
        cin >> input;

        if (stringAppearCount.count(input))
        {
            ++stringAppearCount.at(input);
            maxCount = max(maxCount, stringAppearCount.at(input));
        }
        else
        {
            stringAppearCount.insert(make_pair(input, 1));
        }
    }

    vector<string> identicalMaxCountStringVec;
    for (auto itr = stringAppearCount.begin(); itr != stringAppearCount.end(); ++itr)
    {
        pair<string, int> singleStringMap = *itr;
        if (singleStringMap.second == maxCount)
        {
            identicalMaxCountStringVec.push_back(singleStringMap.first);
        }
    }

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

    for (auto itr = identicalMaxCountStringVec.begin(); itr != identicalMaxCountStringVec.end(); ++itr)
    {
        cout << *itr << endl;
    }
}

Measured memory_bytes: 26868
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,j,k,z,t,x,y=0,n,m;
    vector<long long int>v,p;
    v.push_back(0),p.push_back(0);
    cin>>n>>m>>k;
    for(i=1;i<=n;i++)
    {
        cin>>x;
        v.push_back(v[i-1]+x);
    }
    for(i=1;i<=m;i++)
    {
        cin>>x;
        p.push_back(p[i-1]+x);
    }
    x=0;
    for(i=0;i<=n;i++)
    {
        if(v[i]>k)
            break;
        j=upper_bound(p.begin(),p.end(),k-v[i])-p.begin();
        x=max(x,i+j-1);
    }
    cout<<x<<endl;


}


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

void main()
{
  auto rd = readln.split, n = rd[0].to!int, k = rd[1].to!size_t;
  auto d = readln.split.to!(int[]);
  auto db = new bool[](10);
  foreach (di; d) db[di] = true;

  while (toDigits(n).any!(i => db[i])) ++n;
  writeln(n);
}

auto toDigits(int n)
{
  int[] r;
  for (; n > 0; n /= 10) r ~= n % 10;
  return r;
}


Measured memory_bytes: 1276
#include <iostream>
using namespace std;
int main() {
  int N,K;
  std::string S;
  
  cin >> N >> K >> S;
  
  if(S[K-1]=='A')S[K-1]='a';
  if(S[K-1]=='B')S[K-1]='b';
  if(S[K-1]=='C')S[K-1]='c';
  cout << S << "\n";
  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc143/tasks/abc143_d>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    vector<int> L(N); for(auto& in:L) cin >> in;
    sort(L.begin(),L.end());
    
    for(int ai = 0; ai < N; ai++){
        for(int bi = ai+1; bi < N; bi++){
            int a = L[ai];
            int b = L[bi];
            
            // a < b + c : ok
            // b < c + a : ok
            
            // c < a + b
            
            res += (int)(lower_bound(L.begin()+bi+1,L.end(),a+b) - L.begin()) - bi - 1;
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 200000000000
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力

vector<vector<ll> > G;
vector<bool> seen;


//ll fcnt=1;
void dfs(ll v){
    seen[v] = 1;

    rep(i,G[v].size()){
        if(seen[G[v][i]] == 0){
            dfs(G[v][i]);
        }
    }

}

int main() {
    
    while(1){
        G.clear();
        seen.clear();
        ll w,h;
    
        cin >> w>>h;
        if(w==0 &&h==0) break;
        ll cnt=1;
        map<pair<ll,ll>,ll> m;
        
        rep(i,h){
            rep(j,w){
                bool c;
                cin >>c;
                if(c){
                    m[mp(i,j)] = cnt;
                    cnt++;
                }
            }
        }
        G.resize(cnt);
        seen.resize(cnt);


        rep(i,h){
            rep(j,w){
                if(m[mp(i,j)]){
                    if(m[mp(i-1,j-1)]){
                        G[m[mp(i,j)]].pb(m[mp(i-1,j-1)]);
                    }
                    if(m[mp(i,j-1)]){
                        G[m[mp(i,j)]].pb(m[mp(i,j-1)]);
                    }
                    if(m[mp(i-1,j)]){
                        G[m[mp(i,j)]].pb(m[mp(i-1,j)]);
                    }
                    if(m[mp(i,j+1)]){
                        G[m[mp(i,j)]].pb(m[mp(i,j+1)]);
                    }
                    if(m[mp(i+1,j)]){
                        G[m[mp(i,j)]].pb(m[mp(i+1,j)]);
                    }
                    if(m[mp(i+1,j-1)]){
                        G[m[mp(i,j)]].pb(m[mp(i+1,j-1)]);
                    }
                    if(m[mp(i-1,j+1)]){
                        G[m[mp(i,j)]].pb(m[mp(i-1,j+1)]);
                    }
                    if(m[mp(i+1,j+1)]){
                        G[m[mp(i,j)]].pb(m[mp(i+1,j+1)]);
                    }

                }
            }
        }
        /*rep(i,G.size()){
            rep(j,G[i].size()){
                cout << G[i][j];
            }
            cout << endl;
        }*/

        /*rep(i,h){
            rep(j,w){
                cout << m[mp(i,j)]<< " ";
            }
            cout << endl;
        }*/
        ll ans = 0;
        rep(i,h){
            rep(j,w){
                if(m[mp(i,j)]){
                    if(seen[m[mp(i,j)]] == 0){
                        dfs(m[mp(i,j)]);
                        ans++;
                    }
                }
            }
        }
        

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

}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int x,a,b;
  int aa,ab;
  cin>>x>>a>>b;
  aa=abs(x-a);
  ab=abs(x-b);
  if(aa<ab) cout<<"A"<<endl;
  else cout<<"B"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
using namespace std;
using i64 = int64_t;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)
constexpr i64 MOD = 1000000007;
constexpr i64 INF = 1LL << 60;

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; cin >> n;
	i64 a[10000], b[10000];
	rep(i, 0, n) cin >> a[i];
	rep(i, 0, n) cin >> b[i];

	i64 sa = 0, sb = 0;
	i64 ca = 0, cb = 0;
	rep(i, 0, n) {
		sa += a[i];
		sb += b[i];
		if (a[i] > b[i]) cb += a[i] - b[i];
		else ca += (b[i] - a[i] + 1) / 2;
	}
	if (sb - sa >= max(ca, cb)) cout << "Yes";
	else cout << "No";

	return 0;
}

Measured memory_bytes: 3780
N, M = [int(i) for i in input().split()]
t = []
for i in range(M):
    t += [[int(i) for i in input().split()]]

for i in range(1000):
    s = str(i)
    if len(s) != N:
        continue
    isOK = True
    for it in t:
        if len(s) < it[0]:
            isOK = False
        else:
            isOK = isOK and (s[it[0]-1] == str(it[1]))
    if isOK:
        print(s)
        exit()
    
print(-1)


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


int main() {
	int n;
	cin>>n;
	vector<int> a(n);

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

	int sol=0;

	for(int i=1; i<n-1; i++){
		if((a[i]>a[i-1] && a[i]<a[i+1]) || (a[i]<a[i-1] && a[i]>a[i+1]))
		{
			sol++;
		}
	}
	cout<<sol;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)


int main() {
	string s;
	cin >> s;
	int n = s.size();

	int max = 0;
	int flag = 1;
	FOR(i, 1, n - 1) {
		if (s[i] != '9') {
			flag = 0;
		}
	}
	if (flag == 1) {
		cout << s[0] - '0' + 9 * (n - 1) << endl;
	}
	else {
		cout << s[0] - '0' + 9 * (n - 1) - 1 << endl;
	}


	return 0;
}



Measured memory_bytes: 256
n,m,p = map(int,input().split())
# キュー
from collections import deque

# bellman_ford
# 負の経路がある場合は、(-1,-1)を返却する
def bellman_ford(links, start, end, n):
    inf = 10**10
    d = [inf] * (n+1)
    d[start] = 0
    parent = [-1] * (n+1)

    for _ in range(n):
        update = False
        for i in range(1,n+1):
            for j in links[i]:
                cost,neigh = j
                if(d[neigh] > d[i] + cost):
                    d[neigh] = d[i] + cost
                    parent[neigh] = i
                    update = True

        if(not update):
            # 経路の算出
            route = [end]
            now = end
            while(now != start):
                now = parent[now]
                route.append(now)

            return d,route[::-1]

    # 負の経路がある場合（n-1回の更新で終わらない場合）
    return -1,-1

abc = []
graph = [[] for _ in range(n+1)]
graph_rev = [[] for _ in range(n+1)]
for i in range(m):
    a,b,c = map(int,input().split())
    abc.append((a,b,p-c))
    graph[a].append(b)
    graph_rev[b].append(a)

can_go_1 = set()
can_go_n = set()

d = deque()
d.append(1)
while(d):
    tmp = d.pop()
    can_go_1.add(tmp)
    for i in graph[tmp]:
        if(not i in can_go_1):
            d.append(i)

d = deque()
d.append(n)
while(d):
    tmp = d.pop()
    can_go_n.add(tmp)
    for i in graph_rev[tmp]:
        if(not i in can_go_n):
            d.append(i)

can_go = can_go_1 & can_go_n

graph2 = [[] for _ in range(n+1)]
for tmp in abc:
    a,b,c = tmp
    if(a in can_go)&(b in can_go):
        graph2[a].append((c,b))

d , _ = bellman_ford(graph2, 1, n, n)
if(d == -1):
    print(-1)
else:
    ans = d[n] * -1
    print(max(0,ans))


Measured memory_bytes: 55592
import java.util.*

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        var N = sc.next().toLong()
        val a = mutableListOf<Char>()
        while (N > 0) {
            N -= 1
            a += 'a' + (N % 26).toInt()
            N /= 26
        }

        pw.println(a.reversed().joinToString(""))
    }
}


Measured memory_bytes: 38380
#include <bits/stdc++.h>
using namespace std;
using u32 = uint32_t;

int main() {
	u32 A, B, C;
	cin >> A >> B >> C;
	
	if(A == B && B != C) {
		cout << "Yes";
	} else if (A == C && B != C) {
		cout << "Yes";
	} else if (B == C && A != C) {
		cout << "Yes";
	} else {
		cout << "No";
	}
	
	return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc090/tasks/abc090_b


def is_palindromic(x):
    s = str(x)
    if s == s[::-1]:
        return True
    return False


a, b = map(int, input().split())
cnt = 0
for i in range(a, b + 1):
    if is_palindromic(i):
        cnt += 1
print(cnt)


Measured memory_bytes: 2940
contain_5_7_5 :: [Int] -> Bool
-- Implement code below
contain_5_7_5 arr = cnt 5 arr == 2 && cnt 7 arr == 1
cnt x arr = sum [1 | y <- arr, y == x]




-- IO related, you don't have to modify it.
main = getLine >>= putStrLn. f. contain_5_7_5. map read. words
  where f True = "YES"
        f False = "NO"


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
template <class T> vector<T> make_vec(size_t a, T val) {
    return vector<T>(a, val);
}
template <class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec(ts...))>(a, make_vec(ts...));
}
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
template <typename T> struct edge {
    int to;
    T cost;
    edge(int t, T c) : to(t), cost(c) {}
};
template <typename T> using WGraph = vector<vector<edge<T>>>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

template <ll MOD = 998244353, ll primroot = 3> class ConvolutionNTT {
  private:
    vector<ll> a, b;
    ll modpow(ll v, ll n) {
        ll x = 1, p = v;
        while(n > 0) {
            if(n % 2 == 0) {
                p = (p * p) % MOD;
                n /= 2;
            } else {
                x = (x * p) % MOD;
                n--;
            }
        }
        return x;
    }
    ll modinv(ll v) { return modpow(v, MOD - 2); }

  public:
    ConvolutionNTT(vector<ll> &_a, vector<ll> &_b) {
        a = _a;
        b = _b;
    }

    vector<ll> ntt_rec(vector<ll> a, bool is_inverse = false) {
        int n = a.size();
        if(n == 1)
            return a;
        vector<ll> f0(n / 2), f1(n / 2);
        for(int i = 0; i < (n / 2); i++) {
            f0[i] = (a[i * 2]);
            f1[i] = (a[i * 2 + 1]);
        }
        f0 = ntt_rec(f0, is_inverse), f1 = ntt_rec(f1, is_inverse);
        ll zeta = modpow(is_inverse ? modinv(primroot) : primroot, MOD / n);
        ll pow_zeta = 1;
        for(int i = 0; i < n; i++) {
            a[i] = (f0[i % (n / 2)] + pow_zeta * f1[i % (n / 2)]) % MOD;
            pow_zeta *= zeta;
            pow_zeta %= MOD;
        }
        return a;
    }

    vector<ll> ntt(vector<ll> a, bool is_inverse) {
        vector<ll> ret = ntt_rec(a, is_inverse);
        int n = ret.size();
        if(is_inverse) {
            for(int i = 0; i < n; i++) {
                ret[i] *= modinv(n);
                ret[i] %= MOD;
            }
        }
        return ret;
    }

    vector<ll> convolve() {
        int s = a.size() + b.size() - 1;
        int t = 1;
        while(t < s)
            t *= 2;
        a.resize(t);
        b.resize(t);

        vector<ll> A = ntt(a, false);
        vector<ll> B = ntt(b, false);
        vector<ll> C(t);
        for(int i = 0; i < t; i++) {
            C[i] = (A[i] * B[i]) % MOD;
        }
        C = ntt(C, true);
        return C;
    }
};

int main() {
    int N, M;
    scanf("%d",&N);
    scanf("%d",&M);
    
    vector<ll> A(N), B(M);
    rep(i, N) scanf("%d",&A[i]);
    rep(i, M) scanf("%d",&B[i]);
    ConvolutionNTT<> ntt(A, B);
    auto C = ntt.convolve();
    for(int i = 0; i < N + M - 1; i++){
        printf("%d",C[i]);
        printf((i==N+M-2?"\n":" "));
    }
}


Measured memory_bytes: 93312
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pll pair<ll,ll>
#define sll set<ll>
#define msll multiset<ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define vpl vector<pll>
#define gll greater<ll>
#define gpl greater<pll>
#define spl set<pll>
#define mspl multiset<pll>
#define lb lower_bound
#define bp __builtin_popcount
#define ub upper_bound
#define prq priority_queue
#define mp make_pair
#define pb push_back
#define mem(x,y) memset(x, y, sizeof x)
#define endl "\n"
#define sz(x) (ll)x.size()
#define sqr(x) x*x
#define rapido ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef int ll;
typedef long double ld;
ll mx=INT_MAX;
ll mn=INT_MIN;
ll MOD=1e9+7;
const ll maxs=1e5+10;
ll max2d=1e3+3;
// ll INF = 1e18;
const ll lg=22; 

void code_idhr_h(){
    for(ll i=1; i<=5; i++){
        ll X; cin>>X;
        if(X==0) cout<<i;
    }
}

int main(){
    rapido;
    ll T=1; //cin>>T;
    while(T--){
        code_idhr_h();
    }
    return 0;
}

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

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

    switch(n%10) {
        case 3:
            puts("bon");
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            puts("pon");
            break;
        default:
            puts("hon");
            break;
    }
}


Measured memory_bytes: 3648
import Data.Array.Unboxed

binarySearch :: Int -> (Int, Int) -> UArray Int Int -> Bool
binarySearch target (start, end) arr
  | start == end    = target == arr!i
  | target == arr!i = True
  | target < arr!i  = binarySearch target (start, i) arr
  | otherwise       = binarySearch target (i+1, end) arr
  where i = floor $ (fromIntegral (end + start)) / 2

main = do
  n <- fmap read getLine
  seqNum <- fmap (map read . words) getLine
  let arr = listArray (1, n) seqNum
  _ <- getLine
  targets <- fmap (map read . words) getLine
  putStrLn $ show . length . filter (\x -> binarySearch x (1, n) arr) $ targets

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

int compare_int(const void *a, const void *b){
    return *(long*)b - *(long*)a;
}

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

int main(){
		int n,i;
		long a[100000],k,b,max=0;
		scanf("%d%ld",&n,&k);
		scanf("%ld",&a[0]);b=a[0];
		for(i=1;i<n;i++){
				scanf("%ld",&a[i]);
				b=gcd(b,a[i]);
		}
		qsort(a,n,sizeof(long),compare_int);
		for(i=0;a[i]>=k;i++){
				if((a[i]-k)%b==0){
						puts("POSSIBLE");
						return 0;
				}
		}
		puts("IMPOSSIBLE");
		return 0;
}


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

int main(){
  int N, i;
  string S;
  cin >> N >> S;
  for (i = 0; i < S.length(); i++) {
    int x = S[i] - 'A';
    x = (x + N) % 26;
    putchar('A'+x);
  }
  cout << endl;
 }


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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int arr[n];
	long long int a=0;
	for(int i=0;i<n;i++) {cin>>arr[i]; a^=arr[i];}
	long long int c=a;
    vector<long long int>ans;
    for(int i=0;i<n;i++){
        a=c;
        a^=arr[i];
        ans.push_back(a);
    }
    for(auto it: ans) cout<<it<<' ';
	return 0;
	
}

Measured memory_bytes: 6136
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;
const ll INF=1e16;
int main()
{
    int n, m, k; cin>>n>>m>>k;
    ll p[100010], j[100010];
    vector<int> v[100010];
    for(int i=0; i<n; i++) cin>>p[i];
    for(int i=0; i<n; i++){
        int c; cin>>c; c--;
        v[c].push_back(i);
    }
    for(int i=0; i<n; i++) cin>>j[i];
    vector<P> g[100010];
    for(int i=0; i<m; i++){
        int u1, v1; ll t;
        cin>>u1>>v1>>t;
        u1--; v1--;
        g[u1].push_back({t, v1});
        g[v1].push_back({t, u1});
    }
    priority_queue<P, vector<P>, greater<P>> que;
    ll d[2][100010];
    fill(d[0], d[0]+n, INF);
    fill(d[1], d[1]+n, INF);
    ll mx=1e9+7;
    d[0][0]=0;
    que.push({0, 0});
    while(!que.empty()){
        P pr=que.top();
        que.pop();
        int x=pr.second%n;
        int r=pr.second/n;
        if(d[r][x]<pr.first) continue;
        if(r==0){
            if(d[1][x]>d[0][x]+mx-p[x]){
                d[1][x]=d[0][x]+mx-p[x];
                que.push({d[1][x], x+n});
            }
        }
        for(auto q:g[x]){
            int y=q.second;
            if(d[r][y]>d[r][x]+q.first){
                d[r][y]=d[r][x]+q.first;
                que.push({d[r][y], r*n+y});
            }
        }
    }
    for(int i=0; i<k; i++){
        ll ans=-INF;
        for(auto x:v[i]){
            ans=max(ans, -d[1][x]-d[0][x]+mx+j[x]);
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

int main()
{
  string s,t;
  cin>>s>>t;
  bool flag=true;
  for(auto i:t)
    for(auto j:s)
      if(i>j)
      {
        cout<<"Yes\n";
        return 0;
      }
      else if(i!=j)
         flag=false;
  if(!flag)
  cout<<"No\n";
  else if(s.length()<t.length())
    cout<<"Yes\n";
  else
    cout<<"No\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>
#include <string>
#include <iomanip>
#include <valarray>
#include <vector>


int main(int argc, char *argv[])
{
    std::cout << std::fixed << std::setprecision(0);
    int h,w;
    while(1){
        std::cin >> h >> w;
        if(h+w == 0)break;

        std::string out = "";
        for(int i = 0; i < h; ++i){
            for(int j = 0; j < w; ++j){
                if((i+j)%2 == 0){
                    out += "#";
                }
                else{
                    out += ".";
                }
            }
            out += "\n";
        }
        std::cout << out << std::endl;
    }

    return 0;
}

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

int main(){
  int p,q,r,result;
  cin >> p >> q >> r;
  if(p + q < q + r){
    result = p + q;
  }
  else{
    result = q + r;
  }
  if(p + r < result){
    result = p + r;
  }
  cout << result << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define num(a) a-'0'
#define charr(a) (a - 'A' + 1)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define maxs(a,b) if(b>a)a=b
#define mins(a,b) if(b<a)a=b
#define debug(x) cerr<<"["<<#x<<":"<<x<<"] "
#define debug2(a,b) debug(a);debug(b)
#define debug3(a,b,c) debug2(a,b);debug(c)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/(__gcd(a,b))
#define print(arr) for(auto it = arr.begin();it < arr.end();it ++){cout << *it << " ";}cout << ln;
#define all(a) (a).begin(), (a).end()
#define vi vector<long long>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"
typedef long double ld;
typedef double d;
using namespace std;
int modF=1e9+7;
int INF=1e11;

void solve(){
	int n;
	cin>>n;
	v<p<int,int>> a(n);
	int counter=0;
	int ans=0;
	rep(i,0,n){
		cin>>a[i].f>>a[i].s;
		if(a[i].f==a[i].s){
			counter++;
			maxs(ans,counter);
		}
		else{
			counter=0;
		}
	}
	if(ans>=3){
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}
}

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

Measured memory_bytes: 3616
def main():
    n,k,*a=map(int,open(0).read().split())
    a,f=sorted(a[:n])[::-1],sorted(a[n:])
    ok=10**12
    ng=-1
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        l=k
        for b,g in zip(a,f):
            if b*g>mid:
                l-=b-mid//g
        if l<0:ng=mid
        else:ok=mid
    print(ok)
main()

Measured memory_bytes: 128056
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

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

ll H, W;
char s[100][100];

int main() {
	cin >> H >> W;

	repi(i, 1, H + 1) {
		repi(j, 1, W + 1) {
			rd(s[i][j]);
		}
	}

	bool judge = false;

	repi(i, 1, H + 1) {
		if (judge) break;
		repi(j, 1, W + 1) {
			if (judge) break;
			if (s[i][j] == '#') {
				bool f = true;
				repi(k, 0, 4) f &= (s[i + m4x[k]][j + m4y[k]] == '.');
				if (f) judge = true;
			}
		}
	}

	if (judge) wrln("No");
	else wrln("Yes");

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt() - 1;
        }
        int count = 0;
        for (int i = 0 ; i < n ; i++) {
            if (a[a[i]] == i) {
                count++;
            }
        }
        System.out.println(count/2);
    }

}


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

int main(){

  int N,save,sum;
  cin >> N;
  save = N;
  
  while(N > 0){
  
    sum += (N % 10);
    N /= 10;
    
  }
  
  if(save % sum == 0){
  
    cout << "Yes" << endl;
    
  }else{
  
    cout << "No" << endl;
  
  }
  
  return 0;
  
}

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

int main()
{
    int n; cin >> n;
    double notax = n/1.08;
    int tax1 = int(notax)*1.08;
    int tax2 = int(notax+1)*1.08;
    int tax3 = int(notax-1)*1.08;
    int ans = 0;
    if(n == tax1) ans = int(notax);
    else if(n == tax2) ans = int(notax+1);
    else if(n == tax3) ans = int(notax-1);
    else{
        cout << ":(" << endl;
        return 0;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n - 1) {
        int x;
        cin >> x;
        a[x - 1]++;
    }

    rep(i, n) cout << a[i] << endl;
    return 0;
}


Measured memory_bytes: 4044
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>

using namespace std;

int main(){
	int a;
	int b;
	for (a = 1; a <= 9; a++){
		for (b = 1; b <= 9; b++){
			cout << a << "x" << b << "=" << a * b << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1116
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

vector<ll>relation[20], money(20, 1);
char s[110][110];
int dp[110][110];

int keta(int x) {
	int y = 0;
	while (x > 0) {
		y++;
		x /= 10;
	}
	return y;
}

int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k % 2 == 0) {
		cout << a - b << endl;
	}
	else {
		cout << b - a << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#define digit(N) cout << fixed << setprecision((N))
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

ll cost(vector<pair<int, ll>> v)
{
   int N = v.size();
   for (auto &p : v) // N より大きい必要がない
      p.first = min(p.first, N);

   sort(v.rbegin(), v.rend());

   priority_queue<int> pq;
   ll res = 0;

   for (int i = N, j = 0; i > 0; i--)
   {
      while (j < N && v[j].first == i) // 配置できるものを pq に入れる
      {
         pq.push(v[j].second);
         j++;
      }

      if (pq.empty())
         continue;
      res += pq.top();
      pq.pop();
   }

   return res;
}

int main()
{
   int t;
   cin >> t;
   while (t--)
   {
      int N;
      cin >> N;
      vector<pair<int, ll>> left, right;

      ll ans = 0;

      for (int i = 0; i < N; i++)
      {
         ll k, l, r, m;
         cin >> k >> l >> r;
         ans += min(l, r);

         ll d = max(l, r) - min(l, r);

         if (l > r)
            left.emplace_back(k, d);
         if (r > l)
            right.emplace_back(N - k, d);
      }

      ans += cost(left);
      ans += cost(right);
      cout << ans << "\n";
   }
}

Measured memory_bytes: 8800
n,k=map(int,input().split())
A=tuple(map(int,input().split()))
s=1
state=[s]
count={}
for i in range(1,k+1):
    s=A[s-1]
    if s in count:
        start=state.index(s)
        end=len(state)
        print(state[start+(k-start)%(end-start)])
        break
    else:
        count[s]=i
        state.append(s)
        continue
else:
    print(s)


Measured memory_bytes: 32336
N, K = map(int, input().split())
l = list(map(int, input().split()))
c = [0 for i in range(N)]
for i in l:
    c[i - 1] += 1
c.sort(reverse = True)
total = 0
for i in range(K):
    total += c[i]
print(N - total)

Measured memory_bytes: 25748
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <tuple>
#include <numeric>
#include <utility>
#include <climits>
#include <float.h>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>
#pragma GCC target ("avx2")

using namespace std;

typedef long long ll;
typedef long double ld;
constexpr ll INF = LLONG_MAX;
constexpr double DINF = DBL_MAX;
constexpr ll mod = 1e9+7;
constexpr ll mod2 = 998244353;
constexpr double PI = M_PI;

template<typename T>
vector<T> make_v(size_t a){
  	return vector<T>(a);
}

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts){
  	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

long long fact(long long n, long long mod){
  long long x = 1;
  while(n > 1ll){
    x = (x * n) % mod;
    n--;
  }
  return x;
}
 
long long expo(long long a, long long p, long long mod){
  if(p == 0ll){
    return 1ll;
  }else if(p % 2ll == 0){
    long long cmp = expo(a, p/2ll, mod);
    return (cmp * cmp) % mod;
  }else{
    return (expo(a, p-1, mod) * a) % mod;
  }
}

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

	long long n, m, x;
	cin >> n >> m >> x;
	vector<ll> c(n);
	vector<vector<ll> > a(n, vector<ll>(m) );
	for(int i = 0; i < n; i++){
		cin >> c[i];
		for(int j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	long long ans = INF;
	for(ll bit = 0; bit < (1ll << n); bit++){
		long long tmp = bit, cost = 0;
		vector<ll> get(m, 0);
		for(int i = 0; i < n; i++){
			if(tmp % 2){
				cost += c[i];
				for(int j = 0; j < m; j++){
					get[j] += a[i][j];
				}
			}
			tmp /= 2;
		}
		bool judge = false;
		for(int i = 0; i < m; i++){
			if(get[i] < x){
				judge = true;
			}
		}
		if(!judge){
			ans = min(ans, cost);
		}
	}
	if(ans == INF){
		cout << -1 << endl;
	}else{
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define MAX_V 100
#define INF (1 << 21)

int cost[MAX_V][MAX_V];
int d[MAX_V];
bool used[MAX_V];
int V;

int s = 0; // start

void dijkstra()
{
    for (int i = 0; i < V; i++) {
        d[i] = INF;
        used[i] = false;
    }

    d[s] = 0;
    for(;;) {
        int v = -1;
        for (int u = 0; u < V; u++) {
            if (!used[u] && (v == -1 || d[u] < d[v]))
                v = u;
        }
        if (v == -1) break;

        used[v] = true;

        for (int u = 0; u < V; u++) {
            d[u] = min(d[u], d[v] + cost[v][u]);
        }
    }

    for (int u = 0; u < V; u++) {
        cout << u << " " << (d[u] == INF ? -1 : d[u]) << endl;
    }

}
int main()
{
    cin >> V;

    for (int i = 0; i < V; i++) {
        for (int j = 0; j < V; j++) {
            cost[i][j] = INF;
        }
    }
    for (int i = 0; i < V; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v, c;
            cin >> v >> c;
            cost[u][v] = c;
        }
    }

    dijkstra();

    return 0;
}



Measured memory_bytes: 3132
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> pii;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int maxn = 300 + 11;
const int MOD = 1e9 + 7;
int N, M, T;
LL dp[maxn][maxn][maxn];
int main(){
    cin >> N >> M;
    dp[0][1][1] = 1;
    for (int i = 0; i < M; i++){
        for (int j = 0; j <= min(i + 1, N); j++){
            for (int k = 0; k <= j; k++){
                dp[i+1][j+1][k] += dp[i][j][k]*(N-j);
                dp[i+1][j][k] += dp[i][j][k]*(j-k);
                dp[i+1][j][j] += dp[i][j][k]*k;
                dp[i+1][j+1][k] %= MOD;
                dp[i+1][j][k] %= MOD;
                dp[i+1][j][j] %= MOD;
            }
        }
    }
    cout << dp[M][N][N] % MOD << endl;
    return 0;
}


Measured memory_bytes: 227584
// failed to generate code

#include <bits/stdc++.h>
using namespace std;

int main(){
	string s,t;
  cin >> s;
	cin >> t;
  int n = -1;
	for (int i = 0; i<s.size()-t.size()+1; i++) {
		bool flg = true;
		for (int j = i; j<i+t.size(); j++) {
			if (s[j] != '?' && s[j] != t[j-i]) flg = false;
		}
		if (flg) n = i;
	}
	if (n == -1) cout << "UNRESTORABLE\n"; else {
		for (int i = 0; i<n; i++) {
			if (s[i] == '?') cout << "a"; else cout << s[i];
		}
		for (int i = n; i<n+t.size(); i++) {
			cout << t[i-n];
		}
		for (int i = n+t.size(); i<s.size(); i++) {
			if (s[i] == '?') cout << "a"; else cout << s[i];
		}
		cout << "\n";
	}
}


Measured memory_bytes: 256
// acdart C++
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <ctime>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <vector>
#include <bitset>
#include <cctype>
#include <fstream>
#include <numeric>
#include <utility>
#include <iomanip>
#include <complex>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long long LL;
typedef unsigned long long ull;
typedef unsigned long long ULL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector< vi > vvi;
typedef vector< vd > vvd;
typedef vector< vll > vvll;
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define PI 3.1415926535897932384626433832795
#define mod9 1000000009ll
#define mod7 1000000007ll
#define inf 0x3f3f3f3f
#define inf8  1023456789ll
#define inf16 10000000000000000ll
#define SZ(x) ((int)(x).size())
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define rep(i, v) for(int i=0;i<sz(v);++i)
#define lp(i, n) for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n) for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n) for(int i=(j);i>=(int)(n);--i)
#define gcd(x, y) __gcd(x, y)
#define lson (id << 1)
#define rson (id << 1 | 1)
#define lowb(x) (x & (-x))
#define eps 1e-7
/*********default*********/
#define maxm
#define maxn

int main()
{
	// ios::sync_with_stdio(false);
	int n, x;
	ll p = 1, tmp = 1;
	
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		p *= 3;
		if (x & 1) tmp *= 1;
		else tmp *= 2;
	}
	printf("%lld\n", p - tmp);
}


Measured memory_bytes: 256
"""D - 2017-like Number
"""

import math


class Sieve:
    """Sieve of Eratosthenes.

    List primes up to n.
    """

    def __init__(self, n):
        self.__prime = []
        is_prime = [i >= 2 for i in range(n + 1)]

        for i in range(2, int(math.sqrt(n)) + 1):
            if is_prime[i]:
                for j in range(i * i, n + 1, i):
                    is_prime[j] = False

        for i in range(2, n + 1):
            if is_prime[i]:
                self.__prime.append(i)

    def prime(self):
        return self.__prime


class Fenwick:
    """Fenwick Tree implementation with 1-based index.

    Valid index: [1, N]
    """

    def __init__(self, N):
        self.fen = [0 for _ in range(N + 1)]

    def add(self, idx, val):
        while idx < len(self.fen):
            self.fen[idx] += val
            idx += idx & (-idx)

    def accum(self, idx):
        ret = 0
        while idx > 0:
            ret += self.fen[idx]
            idx -= idx & (-idx)
        return ret

    def sum(self, begin, end):
        return self.accum(end) - self.accum(begin - 1)


if __name__ == '__main__':
    Q = int(input())  # number of query
    A = [0 for _ in range(Q)]  # answer

    PRIMES = Sieve(10 ** 5).prime()
    # print(PRIMES[:100])

    IS_PRIME = [False for _ in range(10 ** 5 + 1)]
    for prime in PRIMES:
        IS_PRIME[prime] = True
    # print(IS_PRIME[:100])

    ACCUM = Fenwick(10 ** 5 + 1)
    for i in range(1, 10 ** 5 + 1):
        if IS_PRIME[i] and IS_PRIME[(i + 1) // 2]:
            ACCUM.add(i, 1)

    # print(ACCUM.fen)

    for i in range(Q):
        l, r = map(int, input().split())
        A[i] = ACCUM.accum(r) - ACCUM.accum(l - 1)

    print('\n'.join(map(str, A)))


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

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

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

  cin >> q;
  for (int i = 0; i < q; ++i) {
    int b, e, k;
    cin >> b >> e >> k;

    int cnt = 0;
    for (int j = b; j < e; ++j)
      if (a[j] == k)
        ++cnt;
    cout << cnt << endl;
  }
}


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

int main() {
    int k;
    cin >> k;
    vector<int> a(1000001);

    a[1] = 7%k; 
    for(int i = 2; i <= k; i++) {
        a[i] = (a[i-1]*10 + 7) % k;
    }

    for(int i = 1; i <= k; i++) {
        if(a[i] == 0) {
            cout << i << endl;
            return 0;
        }
    }

    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 7204
s = input()
n = len(s)

ret = 0
for i in range(n):
    for j in range(i + 1, n + 1):
        # [i,j)
        t = s[i:j]
        if all(c in 'ACGT' for c in t):
            ret = max(ret, j - i)

print(ret)


Measured memory_bytes: 2940