akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException
import java.lang.NumberFormatException
import java.lang.StringBuilder

object AMain{
    fun solve(){
        val n = nextInt()
        val a = arrayListOf<Long>()
        for (i in 1..n) a.add(nextLong())

        a.sortDescending()

        var ans = a[0]

        for (i in 2 until n){
            ans += a[i/2]
        }

        println(ans)
    }

    // Scanner based on uwi-san's Java FastScanner
    val stream = System.`in`
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0

    fun hasNextByte(): Boolean{
        if(ptr < buflen){
            return true
        }else{
            ptr = 0
            try{
                buflen = stream.read(buffer)
            }catch (e: IOException){
                e.printStackTrace()
            }
            if(buflen <= 0){
                return false
            }
        }
        return true
    }

    fun readByte() =
        if(hasNextByte()) buffer[ptr++]
        else -1

    fun isPrintableChar(c: Byte) = c in 33..126

    fun hasNext(): Boolean{
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++
        return hasNextByte()
    }

    fun next(): String{
        if(!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while(isPrintableChar(b)){
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }

    fun nextLong(): Long{
        if(!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if(b == '-'.toByte()){
            minus = true
            b = readByte()
        }
        if(b !in '0'.toByte()..'9'.toByte())
            throw NumberFormatException()
        while(true){
            if(b in '0'.toByte()..'9'.toByte()){
                n *= 10
                n += b - '0'.toByte()
            }else if(!isPrintableChar(b)){
                return if(minus) -n else n
            }else{
                throw NumberFormatException()
            }
            b = readByte()
        }
    }

    fun nextInt(): Int{
        val n1 = nextLong()
        if(n1 !in Int.MIN_VALUE..Int.MAX_VALUE)
            throw NumberFormatException()
        return n1.toInt()
    }

    fun NextDouble() = next().toDouble()
}

fun main(){
    AMain.solve()
}



Measured memory_bytes: 47524
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

const LL MOD = 1000000007;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n,m;
    cin>>n>>m;
    VL b(n+1, 1);
    REP(i,m){
        LL a;
        cin>>a;
        b[a] = 0;
    }
    VL dp(n+10, 0);
    dp[0] = 1;
    REP(i,n){
        dp[i + 1] = (dp[i + 1] + dp[i]) % MOD * b[i+1];
        dp[i + 2] = (dp[i + 2] + dp[i]) % MOD * b[i+2];
    }
    PUTS(dp[n]);
}

Measured memory_bytes: 1792
from itertools import permutations, combinations,combinations_with_replacement,product

n, m = map(int,input().split())

s = [1 for _ in range(n)]
t = [1 for _ in range(m)]

a = list(combinations(s, 2))
b = list(combinations(t, 2))

print(int(len(a)) + int(len(b)))


Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define ALL(v) (v).begin(),(v).end()
#define MP(a,b) make_pair(a,b)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    list<int> l;
    int N;
    cin >> N;
    REP(i, N){
        string s;
        int x;
        cin >> s;
        if(s == "insert"){
            cin >> x;
            l.push_front(x);
        }else if(s == "delete"){
            cin >> x;
            for(auto itr = l.begin(); itr != l.end(); ++itr){
                if(*itr == x){
                    l.erase(itr);
                    break;
                }
            }
        }else if(s == "deleteFirst"){
            l.pop_front();
        }else{
            l.pop_back();
        }
    }
    for(auto itr = l.begin(); itr != l.end();){
        cout << *itr;
        ++itr;
        cout << (itr != l.end() ? " " : "\n");
    }

    return 0;
}

Measured memory_bytes: 34368
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000
#define endl '\n'
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; }
using namespace std;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,k; cin>>a>>b>>k;
    rep(i,k){
        if(i%2==0){
            a/=2;
            b+=a;
        }else{
            b/=2;
            a+=b;
        }
    }
    cout<<a<<' '<<b<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main(){
    float d,t,s;
    cin >> d >> t>>s;
    if (d/s <= t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int bubbleSort(int num[], int N) {
	int count = 0;
	for (int i = 0; i < N; i++) {
		for (int j = N - 1; j >= 1 + i; j--) {
			if (num[j] < num[j - 1]) {
				swap(num[j], num[j - 1]);
				count++;
			}
		}
	}
	return count;
}

int main(void) {
	int N, num[100];

	cin >> N;
	for (int i = 0; i < N; i++) cin >> num[i];

	int count = bubbleSort(num, N);
	for (int i = 0; i < N; i++) {
		if (i > 0) cout << " ";
		cout << num[i];
	}
	cout << endl << count << endl;

	return 0;
}

Measured memory_bytes: 1160
n, y = gets.split.map(&:to_i)
 
y/=1000
y-=n # 全部千円の場合の不足額

if y < 0
  puts [-1,-1,-1] * " "
  exit
end

# p y
m=y%4; y-=9*m # 万札必要量
if y < 0
  puts [-1,-1,-1] * " "
  exit
end
m+=y/36*4; y%=36 # 万札貪欲
g=y/4 # 五千円札
s=n-m-g # 残りが千円札
ans = s < 0 ? [-1,-1,-1] : [m, g, s]
puts ans * " "

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

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

	while (Q--) {
		llong x; cin >> x;

		llong sum = 0;
		llong res = 0;
		int right = 0;
		for (int left = 0; left < N; left++) {
			while (right < N && sum + a[right] <= x) {
				sum += a[right];
				right++;
			}

			res += (right - left);

			if (left == right) right++;
			else sum -= a[left];
		}

		cout << res << endl;
	}

	return 0;
}


Measured memory_bytes: 3168
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;

int main() {
	int a;
	scanf("%d", &a);
	printf("%d:",a);
	for (int b = 2; b <= sqrt(a); b++) {
		while (1) {
			if (a%b)break;
			a /= b;
			printf(" %d", b);
		}
	}
	if (a != 1)printf(" %d", a);
	printf("\n");
}

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

int64_t minll(int64_t a, int64_t b){
    if(a < b) return a;
    return b;
}

int main() {
    int n; cin >> n;
    vector<int> x(n);
    rep(i,n) cin >> x[i];
    vector<vector<int>> l(101,vector<int>(n));
    rep(i,n){
        rep(j,101){
            l[j][i] = (x[i]-j)*(x[i]-j);
        }
    }

    vector<int> d(101,0);
    rep(i,101){
        int &di = d[i];
        rep(j,n){
            di += l[i][j];
        }
    }
    sort(d.begin(),d.end());
    cout << d[0] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1))
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int W, H;
	cin >> W >> H;
	vector<int>p(W),q(H);
	rep(i, W)cin >> p[i];
	rep(i, H)cin >> q[i];

	sort(ALL(p),greater<int>());
	sort(ALL(q), greater<int>());

	int Hn = H+1, Wn = W+1, ans = 0;
	while (2 <= Hn || 2 <= Wn) {
		int ha = p.size() ? p[p.size() - 1] : std::numeric_limits<int>::max();
		int wa = q.size() ? q[q.size() - 1] : std::numeric_limits<int>::max();
		if (ha < wa) {
			ans += Hn * ha;
			Wn--;
			p.resize(p.size() - 1);
		}
		else {
			ans += Wn * wa;
			Hn--;
			q.resize(q.size() - 1);
		}
	}
	cout << ans << endl;
}


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

int main()
{
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N;++i){
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
	vector<int> num(5);
	cin >> num[0] >> num[1] >> num[2] >> num[3] >> num[4];
	sort(num.begin(), num.end());
	reverse(num.begin(), num.end());
	printf("%d %d %d %d %d\n", num[0],num[1],num[2],num[3],num[4]);
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000000;

#define MAX_V 1000000
// (行き先, 容量, 逆辺)
struct edge {
	int to, cap, rev;
};
vector<edge> G[MAX_V]; // グラフの隣接リスト
int level[MAX_V]; // sからの距離
int iter[MAX_V]; // どこまで調べ終わったか

int N;
P red[MAX_V], blue[MAX_V];
// fromからtoへ向かう容量capの辺をグラフに追加
void add_edge(int from, int to, int cap) {
	G[from].push_back((edge){to, cap, G[to].size()});
	G[to].push_back((edge){from, 0, G[from].size() - 1});
}

// sからの最短距離を計算
void bfs(int s) {
	memset(level, -1, sizeof(level));
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while(!que.empty()) {
		int v = que.front(); que.pop();
		rep(i, 0, G[v].size()) {
			edge &e = G[v][i];
			if(e.cap > 0 && level[e.to] < 0) {
				level[e.to] = level[v] + 1;
				que.push(e.to);
			}
		}
	}
}

// 増加パスを探す
int dfs(int v, int t, int f) {
	if(v == t) return f;
	for(int &i = iter[v]; i < G[v].size(); i++) {
		edge &e = G[v][i];
		if(e.cap > 0 && level[v] < level[e.to]) {
			int d = dfs(e.to, t, min(f, e.cap));
			if(d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

// sからtへの最大流を求める
int max_flow(int s, int t) {
	int flow = 0;
	for(;;) {
		bfs(s);
		if(level[t] < 0) return flow;
		memset(iter, 0, sizeof(iter));
		int f;
		while((f = dfs(s, t, INF)) > 0) flow += f;
	}
}

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

	cin >> N;
	rep(i, 0, N) {
		int a, b;
		cin >> a >> b;
		red[i] = make_pair(a, b);
	}
	rep(i, 0, N) {
		int a, b;
		cin >> a >> b;
		blue[i] = make_pair(a, b);
	}

	int s = N + N, t = s + 1;
	rep(i, 0, N) add_edge(s, i, 1);
	rep(i, 0, N) add_edge(N + i, t, 1);

	rep(i, 0, N) {
		rep(j, 0, N) {
			int a = red[i].first, b = red[i].second;
			int c = blue[j].first, d = blue[j].second;
			if(a < c && b < d) {
				add_edge(i, N + j, 1);
			}
		}
	}

	cout << max_flow(s, t) << endl;

}


Measured memory_bytes: 34944
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define de(c) cout << #c << " = " << c << endl
#define dd(c) cout << #c << " = " << c << " "
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int n,m;

int main(int argc, char const *argv[])
{
#ifdef indiewar
    freopen("in.txt","r",stdin);
#endif
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= (m+1)/2; i++){
        cout << i << " " << m+2-i << endl;
    }
    for(int i = 1; i <= m/2; i++){
        cout << m+1+i << " " << 2*m+2-i << endl;
    }
    return 0;
}

// 10 *

/* when you submit
	1.n = 0 or n = 1 ?
	2.array bounds ?
	3.int overflow ?
	4.multiple test cases ?
	Keep calm  think twice and code once
*/
//a b c d
//1 2 3 4
//2 3 4 1 bd
//3 4 1 2 ac
//4 1 2 3

//a b c d e f           34 25
//1 2 3 4 5 6 ab cd     cd be
//2 3 4 5 6 1 af bc     bc ad
//3 4 5 6 1 2 ef ab     ab cf
//4 5 6 1 2 3           af be
//5 6 1 2 3 4
//6 1 2 3 4 5

Measured memory_bytes: 3672
S = input()
T = input()

nt = len(T)
ns = len(S)
ans = 1000

for i in range(ns-nt+1):
  buf = 0
  for j in range(nt):
    if S[i+j]!=T[j]:
      buf += 1
  ans = min(ans, buf)
print(ans)

Measured memory_bytes: 67480
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF 99999999
#define eps 1e-9

int main(){
    int n,m;
    while(cin>>n>>m){
        if(n==0&&m==0)break;
        
        string s[1100];
        int a[1100],b[1100];
        rep(i,n){
            cin>>s[i]>>a[i]>>b[i];
        }
        rep(i,m){
            int x;
            cin>>x;
            bool f=true;
            rep(i,n){
                if(x<=b[i] && (b[i]-a[i])<x){
                    cout<<s[i]<<" "<<x-(b[i]-a[i])<<endl;
                    f=false;
                    break;
                }
            }
            if(f)cout<<"Unknown"<<endl;
        }
    }
}

Measured memory_bytes: 1280
#
import sys
import math
import numpy as np
import itertools
# いくつか入力
k,n = (int(i) for i in input().split())  

# 空白区切りの数列をリストに代入
a = [int(i) for i in input().split()] 

b = sorted(a)
#print(b)
maxd=0
for i in range(n-1):
    maxd = max(maxd,b[i+1]-b[i])

maxd = max(maxd,k-b[n-1]+b[0])

print(k-maxd)




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

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

int main()
{
	scanf("%d",&n);
	int ans;
	scanf("%d",&ans);
	for (int i=1;i<n;i++) {
		int x; scanf("%d",&x);
		ans=gcd(ans,x);
	}
	cout<<ans;
	return 0;
}

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

vector<int>N[100001];
int dis[100001];
bool vis[100001];
 queue<int>q;

void BFS(int src)
{
    memset(vis,0,sizeof(vis));
    q.push(src);
    dis[src] = 0;

    while(!q.empty())
    {
        int curr = q.front();
        q.pop();

        if(vis[curr] == 0)
        {
            vis[curr] = 1;

            for(int child : N[curr])
        {
            if(dis[child] == 0)
                dis[child] = curr;
               // vis[child] = 1;
                q.push(child);
        }

        }


    }
}

int main()
{

    int n,m;
    cin>>n>>m;
    bool flag = 0;
    while(m--)
    {
        int a, b;
        cin>>a>>b;
        N[a].push_back(b);
        N[b].push_back(a);

        if(a == 1 || b == 1)
            flag = 1;
    }
    if(!flag) {
        cout<<"No\n";
        return 0;
    }
    BFS(1) ;

    cout<<"Yes\n";
    for(int i = 2; i <= n; i++)
    {
        cout<<dis[i]<<endl;
    }

    return 0;
}




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

int main(void) {
	int n;
	cin >> n;
	int light = 1;
	int button;
	int flag = 0;
	int count = 0;
	vector<int> v(n);
	int i;
	int number = 1;
	for (i = 0; i < n; i++)
	{
		cin >> v[i];
	}

	for (int t = 0; t < n; t++)
	{
		light = v[light-1];
		count++;
		if (light == 2)
		{
			flag = 1;
			break;
		}

	}
	if (flag == 1)
	{
		cout << count << endl;
	}
	else
	{
		cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define Rep(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define Repr(i, b, e) for(int (i) = (b) - 1; (i) >= (e); --(i))
#define Print(x) cout << (x) << endl 
#define Min2(a, b) ((a) < (b)) ? (a) : (b)
#define Max2(a, b) ((a) > (b)) ? (a) : (b)

typedef long long ll;

using namespace std;

string S, T;
int dp[1001][1001];

int min3(int a, int b, int c){
    return Min2(a, (Min2(b, c)));
}

int edit(){
    int s = S.length();
    int t = T.length();
    Rep(i, 0, s + 1) dp[i][0] = i;
    Rep(j, 0, t + 1) dp[0][j] = j;
    Rep(i, 0, s){
        Rep(j, 0, t){
            dp[i + 1][j + 1] = min3(dp[i][j] + !(S[i] == T[j]), dp[i][j + 1] + 1, dp[i + 1][j] + 1);
        }
    }
    return dp[s][t];
}

int main(){
    cin >> S >> T;
    Print(edit());
    return 0;
}


Measured memory_bytes: 7128
#include <iostream>
#include <climits>
#include <algorithm>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define vb vector<bool>
#define vs vector<string>
#define px(x) cout << x << endl
#define pfi(x) printf("%d\n", x)
#define pfs(x) printf("%s\n", x)
#define sfi(x) scanf("%d", &x)
#define sfs(x) scanf("%s", x)


int main() {
    string s;
    cin >> s;

    string new_s = "";
    for(int i=0; i<s.length(); i++){
        new_s += 'x';
    }
    cout << new_s << endl;





	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    private void solve() {
        int n = sc.nextInt();
        int[] ans = new int[n];

        for (int i = 1; i < n; i++) {
            int p = sc.nextInt() - 1;
            ++ans[p];
        }

        for (int x : ans) {
            out.println(x);
        }
    }

    private static PrintWriter out;
    private static MyScanner sc;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        private MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }

    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new MyScanner();
        new Main().solve();
        out.close();
    }
}


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

int dp[5010][5010];
int main() {
	int N, K, a[5010]; cin >> N >> K;
	for(int i=0; i<N; ++i) cin >> a[i];
	sort(a, a+N);
	int sm=0;
	while(a[sm]<K && sm<N) ++sm;
	if(sm==0){
	    cout << 0 << endl;
	    return 0;
	}
	sort(a, a+sm, greater<int>());
	dp[0][0]=dp[0][a[0]]=1;
	for(int i=1; i+1<sm; ++i){
	    for(int j=0; j<K; ++j){
	        if(j<a[i]) dp[i][j]=dp[i-1][j];
	        else dp[i][j]=max(dp[i-1][j], dp[i-1][j-a[i]]);
	    }
	}
	int ans=0; bool flag=true;
	while(flag && ans+1<sm){
	    for(int i=1; i<=a[sm-ans-1]; ++i){
	        if(dp[sm-ans-2][K-i]>0){
	            flag=false;
	            break;
	        }
	    }
	    if(flag) ++ans;
	}
	if(flag) ++ans;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 98048
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
typedef vector<P> vec;

double eps=1e-8;
double PI=acos(-1);

bool eq(double a,double b){return (b-a<eps&&a-b<eps);}
double dot(P a,P b){return real(b*conj(a));}
double cross(P a,P b){return imag(b*conj(a));}
P project(P a,P b,P c){b-=a;c-=a;return a+b*real(c/b);}
P reflect(P a,P b,P c){b-=a;c-=a;return a+conj(c/b)*b;}
int ccw(P a,P b,P c){
  b-=a,c-=a,a=c*conj(b);
  if(a.imag()>eps)return 1;//ccw
  if(a.imag()<-eps)return -1;//cw
  if(a.real()<-eps)return 2;//ob
  if(abs(b)+eps<abs(c))return -2;//of
  return 0;//os
}

//segment ab , point c
double dist(P a,P b,P c){
  if(dot(b-a,c-a)<0)return abs(c-a);
  if(dot(a-b,c-b)<0)return abs(c-b);
  return abs(cross(b-a,c-a))/abs(b-a);
}

bool isintersect(P a,P b,P c,P d){
  return ((ccw(a,b,c)*ccw(a,b,d)<=0)&&(ccw(c,d,a)*ccw(c,d,b)<=0));
}

//segment ab , segment cd
P intersect(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}

double dist(P a,P b,P c,P d){
  if(isintersect(a,b,c,d))return 0;
  double ab=min(dist(a,b,c),dist(a,b,d));
  double cd=min(dist(c,d,a),dist(c,d,b));
  return min(ab,cd);
}

double calcArea(vec &t){
  double res=0;
  int n=t.size();
  for(int i=0;i<n;i++)res+=cross(t[i],t[(i+1==n?0:i+1)]);
  return abs(res/2.0);
}

double atan(P p){ return atan2(p.imag(),p.real()); }

double Arg(P a,P b,P c){
  b-=a,c-=a;
  return arg(c*conj(b));
}

int inPolygon(vec &t,P p){
  int n=t.size();
  double sum=0;
  for(int i=0;i<n;i++){
    P a=t[i],b=t[(i+1==n?0:i+1)];
    if( ccw(a,b,p) == 0 )return 1;
    sum+= Arg(p,a,b);
  }
  //  printf("%.8f\n",sum);
  if( abs(sum) < 0.001 )return 0;
  else  return 2;
}

int main(){
  int n;
  cin>>n;
  vec t;
  double x,y;
  for(int i=0;i<n;i++){
    cin>>x>>y;
    t.push_back(P(x,y));
  }
  int q;
  cin>>q;
  while(q--){
    cin>>x>>y;
    cout<<inPolygon(t,P(x,y))<<endl;
  }

  return 0;
}

Measured memory_bytes: 1336
import scala.io.StdIn.readLine

object Main{
  def main(args : Array[String]): Unit ={
    val Array(n, k) : Array[Int] = readLine().split(' ').map(_.toInt)
    val H : Array[Int] = readLine().split(' ').map(_.toInt)
    // val H : Array[Int] = Array.fill(n)(readLine().toInt)
    if(n >= k) subMain(n, H, k).solve()
    else subMain(n, H, n).solve()
  }
}

case class subMain(n : Int, H : Array[Int], k : Int){
  val DP : Array[Int] = Array.fill(n)(Int.MaxValue)
  def CostOfIandJ(i : Int)(j : Int): Int = math.abs( H(i) - H(j) )
  def calculate(m : Int): Unit ={
    DP(0) = 0
    for(i <- 1 until k){
      def subCalculate(l : Int) = CostOfIandJ(i)(l)
      for(j <- 0 until i){
        val tmp : Int = subCalculate(j) + DP(j)
        DP(i) = math.min( DP(i), tmp )
      }
    }
    for(i <- k to m){
      def subCalculate(l : Int) = CostOfIandJ(i)(l)
      for(j <- i - k until i){
        val tmp : Int = subCalculate(j) + DP(j)
        DP(i) = math.min( DP(i), tmp )
      }
    }
  }
    /* too deep
    if(DP(m) != -1) return
    if(m == 0){
      DP(0) = 0
    }
    else{
      calculate(m - 1)
      def subCalculate(l : Int) = CostOfIandJ(m)(l)
      var MiN : Int = Int.MaxValue
      if(m < k){
        for(i <- 0 until m){
          val tmp = subCalculate(i) + DP(i)
          MiN = math.min(MiN, tmp)
        }
      }
      else{
        for(i <- m - k until m){
          val tmp = subCalculate(i) + DP(i)
          MiN = math.min( MiN , tmp )
        }
      }
      DP(m) = MiN
    }
  }*/
  def solve():Unit ={
    calculate(n - 1)
    println(DP(n - 1))
  }
}

Measured memory_bytes: 44616
#include <bits/stdc++.h>
using namespace std;
#define TR(i,v)       for(__typeof((v).begin())i=(v).begin();i!=(v).end();++i)
#define DEBUG(x)      cout<<#x<<" = "<<x<<endl
#define SIZE(p)       (int)(p).size()
#define MP(a,b)       make_pair((a),(b))
#define ALL(p)        (p).begin(),(p).end()
#define rep(i,n)      for(int i=0;i<(int)(n);++i)
#define REP(i,a,n)    for(int i=(a);i<(int)(n); ++i)
#define FOR(i,a,b)    for(int i=(int)(a);i<=(int)(b);++i)
#define FORD(i,b,a)   for(int i=(int)(b);i>=(int)(a);--i)
#define CLR(x,y)      memset((x),(y),sizeof((x)))
typedef long long LL;
typedef pair<int,int> pii;
const int maxn=100;
vector<int> g[maxn];
struct BCC
{
    int dfn[maxn], low[maxn], bccno[maxn], n, bcc_cnt;
    bool isCut[maxn];
    vector<int> keyV, bcc[maxn];
    vector<pair<int, int> > keyE;
    stack<int> st;
    BCC(int _n=0)
    {
        memset(dfn, 0, sizeof(dfn));
        memset(low, 0, sizeof(low));
        memset(isCut, 0, sizeof(isCut));
        keyV.clear(), keyE.clear();
        n = _n;
        bcc_cnt = 0;
    }
    void find_bbc()
    {
        for (int i=0; i<n; ++i)
            if (!dfn[i])
                dfs(i, 1);
    }
    void print(){
      printf("%d\n",SIZE(keyE));
    }
    int dfs(int u, int cnt)
    {
        int &lowu = low[u];
        lowu = dfn[u] = cnt;
        st.push(u);
        int part = cnt > 1;
        rep(i, (int)g[u].size())
        {
            int v = g[u][i];
            if (!dfn[v])
            {
                int lowv = dfs(v, cnt+1);
                lowu = min(lowu, lowv);
                if (lowv > dfn[u])
                    keyE.push_back(make_pair(u, v));
                if (lowv >= dfn[u])
                {
                    if (++part == 2)
                        keyV.push_back(u), isCut[u] = true;;
                    bcc[++bcc_cnt].clear();
                    bcc[bcc_cnt].push_back(u);
                    while (!st.empty())
                    {
                        int now = st.top();
                        st.pop();
                        bcc[bcc_cnt].push_back(now);
                        if (now == v)    break;
                    }
                }
            }
            else if (dfn[v] < dfn[u] && dfn[v] != dfn[u]-1)  // 用反向边更新lowu  注意不是树边！
            {
                lowu = min(lowu, dfn[v]);
            }
        }
        return lowu;
    }
}; 
int main(){
  int n,m;scanf("%d%d",&n,&m);
  rep(i,m){
    int u,v;scanf("%d%d",&u,&v);--u,--v;
    g[u].push_back(v),g[v].push_back(u);
  }
  static BCC ds(n);
  ds.find_bbc();
  ds.print();
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define cerr                                                                   \
  if (false)                                                                   \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

void solve(long long N, vector<long long> T, long long M, vector<long long> P,
           vector<long long> X) {
  ll all = 0;
  REP(i, N) all += T[i];

  REP(i, M) {
    ll ans = all - T[P[i] - 1] + X[i];
    cout << ans << endl;
  }
}

int main() {
  ios::sync_with_stdio(false);
  long long N;
  long long M;
  cin >> N;
  vector<long long> T(N - 1 + 1);
  for (int i = 0; i <= N - 1; i++) {
    cin >> T[i];
  }
  cin >> M;
  vector<long long> X(M - 1 + 1);
  vector<long long> P(M - 1 + 1);
  for (int i = 0; i <= M - 1; i++) {
    cin >> P[i];
    cin >> X[i];
  }
  solve(N, T, M, P, X);
  return 0;
}


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

int main(void){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int wake, sleep;
    wake = 60*h1 + m1;
    sleep = 60*h2 + m2;

    int on;
    on = sleep - wake - k;


    cout << on << endl;
}

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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

int main() {
    int H, N, sum = 0;
    cin >> H >> N;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        sum += A;
    }
    cout << (H - sum <= 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define FORR(I,A,B) for(int I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
int gcd(int a,int b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
int lcm(int a,int b){int c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl

struct Inversions{// tentosu
	// after init,u can get number of inversions num_inverstion(A)
	vector<ll> L,R;
	void initsize(ll n){//input size of A
		L.resize(n/2+2);
		R.resize(n/2+2);
	}
	ll merge(vector<ll> &A,ll n,ll left,ll mid,ll right){
		ll i,j,k;
		ll cnt = 0;
		ll n1 = mid - left;
		ll n2 = right - mid;
		for(i=0;i<n1;i++)L[i]=A[left+i];
		for(i=0;i<n2;i++)R[i]=A[mid+i];
		L[n1]=R[n2]=INT_MAX;//
		i=j=0;
		for(k=left;k<right;k++){
			if(L[i]<=R[j]){
				A[k]=L[i++];
			}else{
				A[k]=R[j++];
				cnt += n1-i;
			}
		}
		return cnt;
	}
	ll mergeSort(vector<ll> &A,ll n,ll left,ll right){
		ll mid;
		ll v1,v2,v3;
		if(left+1<right){
			mid = (left+right)/2;
			v1 = mergeSort(A,n,left,mid);
			v2 = mergeSort(A,n,mid,right);
			v3 = merge(A,n,left,mid,right);
			return v1+v2+v3;
		}else return 0;
	}
	ll num_inverstion(vector<ll> A){
		vector<ll> B=A;//Aの順番を変えたくないなら
		return mergeSort(B,B.size(),0,B.size());
	}
};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	Inversions In;
	string s;
	vector<ll> a;
	cin >> s;
	FOR(i,0,s.size()){
		if(s[i]=='B')a.push_back(1);
		else a.push_back(0);
	}
	In.initsize(a.size());
	cout << In.num_inverstion(a) << endl;
}


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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  string S;
  int x,y;
  cin>>S>>x>>y;
  vector<vector<int>> v(2);
  int t = 0,s = 0;
  for(int i = 0; i < (int)S.size();i++){
    if(S[i]=='F') t++;
    if(S[i]=='T') {
      v[s].push_back(t);t=0;
      s=1-s;
    }
    if(i==(int)S.size()-1&&t!=0)v[s].push_back(t); 
  }
  x-=v[0][0];
  v[0].erase(v[0].begin());
  map<int,bool> X,Y;
  X[0]=true;
  Y[0]=true;
  for(auto x:v[0]){
    map<int,bool> nx;
    for(auto y:X){
      nx[y.first+x]=true;
      nx[y.first-x]=true;
    }
    X=nx;
  }
  for(auto x:v[1]){
    map<int,bool> ny;
    for(auto y:Y){
      ny[y.first+x]=true;
      ny[y.first-x]=true;
    }
    Y=ny;
  }
  if(X[x]&&Y[y]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 768
# local search is all you need
# 「日付 d とコンテストタイプ q をランダムに選び、d 日目に開催するコンテストをタイプ q に変更する」を実装する

from time import time
t0 = time()

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from random import randint


def score(D, C, S, T):
    last = [-1] * 26
    # scores = [0]
    score = 0
    for d in range(D):
        # scores.append(scores[-1] + S[d][T[d]])
        score += S[d][T[d]]
        last[T[d]] = d
        for i in range(26):
            # scores[-1] -= C[i] * (d - last[i])
            score -= C[i] * (d - last[i])  # この場で一番罰則が大きいやつを使うとか？
    return score


D = a_int()
C = ints()
S = read_tuple(D)


def maximizer(newT, bestT, bestscore):
    tmpscore = score(D, C, S, newT)
    if tmpscore > bestscore:
        return newT, tmpscore
    else:
        return bestT, bestscore


def ret_init_T():
    '''greedyで作ったTを初期値とする。
    return
    ----------
    T, score ... 初期のTとそのTで得られるscore
    '''
    def _make_T(n_days):
        # editorialよりd日目の改善は、改善せずにd+n_days経過したときの関数にしたほうが
        # 最終的なスコアと相関があるんじゃない？
        T = []
        last = [-1] * 26
        for d in range(D):
            ma = -INF
            for i in range(26):
                tmp = S[d][i]
                for j in range(n_days):
                    tmp += C[i] * (d + j - last[i])
                if tmp > ma:
                    t = i
                    ma = tmp
            last[t] = d  # Tを選んだあとで決める
            T.append(t)
        return T

    T = _make_T(0)
    sco = score(D, C, S, T)
    for i in range(1, 20):
        T, sco = maximizer(_make_T(i), T, sco)
    return T, sco


bestT, bestscore = ret_init_T()


def add_noise(T):
    '''日付dとコンテストqをランダムに選びd日目に開催するコンテストのタイプをqに変更する'''
    ret = T.copy()
    d = randint(0, D - 1)
    q = randint(0, 25)
    ret[d] = q
    return ret


tt = time() - t0
# print(tt)
while tt < 1.9:
    bestT, bestscore = maximizer(add_noise(bestT), bestT, bestscore)
    tt = time() - t0

# print(bestscore)
# print(score(D, C, S, T))
print(*mina(*bestT, sub=-1), sep='\n')


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

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

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define esort(s) sort((s).begin(),(s).end())

typedef long long ll;
typedef pair<int,int> ipair;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

void solve(){
    int N,K; cin>>N>>K;
    int R,S,P; cin>>R>>S>>P;
    string T; cin>>T;
    vector<bool> check(N,false);

    ll score=0;
    rep(i,N){
        if((i>=K)&&(T[i-K]==T[i])&&check[i-K]) continue;
        if(T[i]=='r') {score+=P;check[i]=true;}
        else if(T[i]=='s') {score+=R;check[i]=true;}
        else if(T[i]=='p') {score+=S;check[i]=true;}
    }

    cout<<score<<endl;

    return;
}

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

    solve();
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include <cstdio>
using namespace std;
int main(int argc, char *argv[])
{
	char s[20];
	scanf("%s",s);
	int a=0;
	int c=0;
	int f=0;
	for(int i=0;i<strlen(s);i++)
	{
		if(isupper(s[i])&&s[i]!='A'&&s[i]!='C')
		{
			c=0;
			break;
		}
		else
		{
			if(s[i]=='C'&&i+1!=strlen(s)&&i!=1&&i!=0)
			c++;
		}
	}
	if(s[0]=='A'&&c==1)
	{
		f=1;
		printf("AC\n");
	}
	if(!f)
	{
		printf("WA\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define srt(a) sort(a.begin(),a.end())
#define rsrt(a) sort(a.rbegin(),a.rend())
#define lb(a,b) lower_bound(a.begin(),a.end(),b)
#define ub(a,b) upper_bound(a.begin(),a.end(),b)
#define MOD ((int)(1000000007 ))
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define float long double
#define bigint __int128
#define sqrt sqrtl
#define cbrt cbrtl
#define endl '\n'
typedef vector<int> vi;
typedef vector<float> vf;
typedef pair<float,int> fi;
typedef pair<int,int> ii;
typedef pair<float,float> ff;
typedef vector<ff> vff;
typedef vector<ii> vii;
typedef vector<fi> vfi;
typedef vector<vi> vvi;
typedef vector<vf> vvf;
typedef vector<vii> vvii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef priority_queue<int> pqi;
typedef priority_queue<ii> pqii;
typedef priority_queue<fi> pqfi;
typedef priority_queue <int, vector<int>, greater<int> > rpqi; 
typedef priority_queue <ii, vector<ii>, greater<ii> > rpqii; 
typedef priority_queue <fi, vector<fi>, greater<fi> > rpqfi;






typedef pair<ii,int> iii;
#define  f first.first
#define  s first.second
#define  t second

#define inf 1e15



int32_t main()
{
	IOS
	int n,m,l;cin>>n>>m>>l;
	vector<ii>g[n+1];
	
	for(int i=1;i<=m;i++)
	{
		int a,b,w;cin>>a>>b>>w;
		if(w>l)continue;
		g[a].push_back({b,w});
		g[b].push_back({a,w});
	}
	
	int dp[n+1][n+1];
	for(int i=1;i<=n;i++)
	{
		vector<ii>dis(n+1,{inf,inf});
		vector<bool>vis(n+1);
		priority_queue<iii,vector<iii>,greater<iii>>pq;
		
		dis[i]={0,0};
		pq.push({dis[i],i});
		while(pq.size())
		{
			int u=pq.top().t;pq.pop();
		    if(vis[u])continue;
			vis[u]=true;
			for(auto it:g[u])
			{
				int v=it.first;
				int w=it.second;
				
				int min_t=dis[u].first;
			    int trav=dis[u].second+w;
			    
				if( trav > l )
				{
					min_t++;
					trav=w;
				}
				if(  dis[v] > make_pair(min_t,trav) )
				{
					dis[v]={min_t,trav};
					pq.push({dis[v],v});
				}
			}
		}
		for(int j=1;j<=n;j++)
		dp[i][j]=dis[j].first+(dis[j].second!=0);
	}
	int q;cin>>q;
	for(int i=1;i<=q;i++)
	{
		int u,v;cin>>u>>v;
		cout<<(dp[u][v] < inf ? dp[u][v]-1 : -1)<<endl;
	}
	
}
	
		
	
	
	
	
	
	
	

 


Measured memory_bytes: 4952
#include <bits/stdc++.h>
#define long long long int
using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    string n;
    cin >> n;
    int k;
    cin >> k;

    int len = n.size();
    vector<vector<long>> d_less(len + 1, vector<long>(k + 1));
    vector<vector<long>> d_equal(len + 1, vector<long>(k + 1));

    d_equal[0][0] = 1;

    for (int i = 0; i < len; i++) {
        for (int j = 0; j <= k; j++) {
            for (char x = '0'; x <= '9'; x++) {
                int j2 = j + (x > '0');
                if (j2 > k) continue;
                d_less[i + 1][j2] += d_less[i][j];
                if (x < n[i]) {
                    d_less[i + 1][j2] += d_equal[i][j];
                } else if (x == n[i]) {
                    d_equal[i + 1][j2] += d_equal[i][j];
                }
            }
        }
    }
    long res = d_less[len][k] + d_equal[len][k];
    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
    int n; 
    ll a,b;
    cin >> n >> a >> b;
    ll x[100100];
    for(int i=0;i<n;i++) cin >> x[i];

    ll ans = 0;
    for(int i=0;i<n-1;i++){
        ans += min(b, (x[i+1]-x[i])*a);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/abc106/tasks/abc106_d

//参考：
//http://tutuz.hateblo.jp/entry/2018/08/19/064525

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,M,Q;
LL L[200000],R[200000];
LL p[100000],q[100000];

vector<LL> ans;

void solve(){
	//始点start,終点endの列車の数をtrain[start][end]とする
	vector<vector<LL>> train(N+1,vector<LL>(N+1,0));
	for(int i=0;i<M;i++){
		train[L[i]][R[i]]++;
	}
	//train[1][1] ~ train[x][y]の長方形の領域に含まれる
	//列車の数の和をaccum[x][y]とおく
	vector<vector<LL>> accum(N+1,vector<LL>(N+1,0));
	for(int h=1;h<=N;h++){
		for(int w=1;w<=N;w++){
			accum[h][w] = accum[h][w-1] + train[h][w];
		}
	}
	for(int h=1;h<=N;h++){
		for(int w=1;w<=N;w++){
			accum[h][w] = accum[h][w] + accum[h-1][w];
		}
	}
	for(int i=0;i<Q;i++){
		ans.push_back(accum[q[i]][q[i]] - accum[p[i]-1][q[i]]);
	}
}

int main(){
    cin >> N >> M >> Q;
    for(int i=0;i<M;i++) cin >> L[i] >> R[i];
    for(int i=0;i<Q;i++) cin >> p[i] >> q[i];

    solve();

	for(int i=0;i<Q;i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 10104
n = int(input())

l = [list(map(int,input().split())) for i in range(n)]

c = 0

for i in range(n):
    if l[i][0] < sum(l[i][1:]):
        print('No')
        break
    
    if (l[i][0] % 2) == sum(l[i][1:]) % 2:
        c += 1
    
    else:
        print('No')
        break

if c == n:
    print('Yes')

Measured memory_bytes: 27300
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll dp[100000];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin>>N;
    ll h[N];
    rep(i,0,N) cin>>h[i];
    rer(i,N-1,0){
        if(i==N-2) dp[i]=dp[i+1]+abs(h[i+1]-h[i]);
        else dp[i]=min(dp[i+1]+abs(h[i+1]-h[i]),dp[i+2]+abs(h[i+2]-h[i]));
    }
    cout <<dp[0]<<"\n";
}


Measured memory_bytes: 1792
#include <iostream>
#include <queue>
#include <vector>

typedef long long ll;

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    priority_queue<ll> que;
    for(int i = 0; i < n; ++i){
        ll a;
        cin >> a;
        que.push(a);
    }
    for(int i = 0; i < m;i++){
        ll b = que.top() / 2;
        que.pop();
        que.push(b);
    }
    ll sum = 0; 
    while(!que.empty()){
        sum += que.top();
        que.pop();
    }
    cout << sum << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5;
vector<int> graph[MAXN];
int indegrees[MAXN];
bool visit[MAXN];
int dist[MAXN];
void dfs(int cur){
    if(visit[cur]) return;
    visit[cur] = true;
    for(int j: graph[cur]){
        dist[j] = max(dist[j], dist[cur] +1);
        indegrees[j]--;
        if(indegrees[j]==0) dfs(j);
    }
}
int main() {
    ios::sync_with_stdio(false);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int n, m;
    cin>>n>>m;
    for(int i= 0; i< m; i++){
        int x, y;
        cin>>x>>y;
        graph[x-1].push_back(y-1);
        indegrees[y-1]++;
    }
    for(int i=0; i<n; i++){
        if(!visit[i] && indegrees[i] == 0) dfs(i);
    }
    int ans = 0;
    for(int i=0; i<n; i++) ans=max(ans, dist[i]);
    cout<<ans<<endl;
}


Measured memory_bytes: 9728
#include <stdio.h>
int main(void){
    int n,k,cnt,i,j;
    double ans=0;
    scanf("%d%d",&n,&k);
    for(i=1;i<=n;i++){
        j=i;
        double p=1;
        while(j<k){
            j*=2;
            p*=0.5;
        }
        ans += p/n;
    }
    printf("%.10f\n",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>

#define Rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())

#define eb emplace_back
#define ef emplace_front
#define dbg(x) cout<<#x" = "<<((x))<<endl
#define fs first
#define sc second
     
using namespace std;
     
     
typedef long long ll;
typedef pair<ll, ll> P;
     
     
int main(){
  ll N, K;

  cin >> N >> K;
  
  vector<P> lst(N);
  Rep(i, N){
    P tmp;
    cin >> tmp.second >> tmp.first;
    lst[i] = tmp;
  }

  Sort(lst);
  Reverse(lst);

  vector<ll> cnt(N+1, 0);
  priority_queue<ll, vector<ll>, greater<ll>> que;
  ll ans = 0;
  ll tmp = 0;
  ll v = 0;
  Rep(i, K){
    tmp += lst[i].first;
    cnt[lst[i].second]++;
    if(cnt[lst[i].second] >= 2) que.push(lst[i].first);
    else v++;
  }

  ans = tmp + v*v;

  for(int i = K; i < N; ++i){
    if(que.empty()) break;
    if(cnt[lst[i].second] == 0){
      ll subt = que.top(); que.pop();
      cnt[lst[i].second]++;
      tmp = tmp - subt + lst[i].first;
      v++;
      ans = max(ans, tmp + v*v);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3196