akhauriyash/Code-Regression huggingface dataset:
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    auto c = [&](ll x, ll y, ll z){
        return x * x + y * y + z * z + x * y + y * z + x * z;
    };
    vector<ll> ans(n+1);
    for(int x = 1; x * x <= n; x++){
        for(int y = 1; y * y <= n; y++){
            for(int z = 1; z * z <= n; z++){
                if(c(x, y, z) <= n)ans[c(x, y, z)]++;
            }
        }
    }
    rep(i,1,n+1)cout << ans[i] << "\n";
}

Measured memory_bytes: 3628
x = input()
ans = []
for i in range(len(x)):
    if (x[i] == "S"):
        ans.append("S")
    else:
        if (len(ans) != 0):
            if (ans[-1] == "S"):
                ans.pop(-1)
            else:
                ans.append("T")
        else:
            ans.append("T")
print(len(ans))      

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

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

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

    int ans = 0;
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            ans += a[i] * a[j];

    cout << ans << '\n';

    return 0;
}


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

    for(int i=1;i<=A;i++){
        if(i!=A){
            for(int j=1;j<=31;j++){
                if(i==j)ans+=1;
            }
        }else{
            for(int j=1;j<=B;j++){
                if(i==j)ans+=1;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  
  vector<int> ans(N);
  rep(i, N) ans[A[i]-1] = i+1;
  
  rep(i, N) cout << ans[i] << " ";
  
  cout << endl;

}

Measured memory_bytes: 1536
import sys


def input():
    return sys.stdin.readline()[:-1]

#N = int(input())
#A = [int(x) for x in input().split()]
#a, b, c = map(int, input().split())
#name1 = str(input())
#alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


a, b= map(int, input().split())
if a%3 * b%3 *(a+b)%3 ==0:
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 2940
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<list>
#include<vector>
#include<string>
using namespace std;

int main(){
    int k,a,b;
    int flag =0;
    cin >> k;
    cin >> a >> b;
    for(int i=a;i<=b;i++){
        if(i%k == 0){
            flag = 1;
        }
    }
    if(flag == 1){
        cout << "OK" << endl;
    }
    else
    {
        cout << "NG" << endl;
    }
    
    return 0;
}

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

int main() {
    char alpha;
    cin >> alpha;
    if (65 <= alpha && alpha <= 90) {
        cout << "A";
    } else {
        cout << "a";
    }

    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main()
{
    long long x, k, d;cin>>x>>k>>d;
    long long ret = 0;
    x = abs(x);
    if (x/d > k)
    {
        ret = x - k*d;
    }
    else
    {
        long long kk = x/d;
       // ret = min(ret, x - kk*d);
        k -= kk;
        if (k%2==1) ret=abs(x - kk*d - d);
        else ret =x - kk*d;
    }
    cout<<ret<<endl;

}


Measured memory_bytes: 3608
import sys
sys.setrecursionlimit(100000)
 
 
N, K = list(map(int, input().split()))
ab = []
for i in range(N-1):
    ab.append(list(map(int, input().split())))
 
ki = []
 
for i in range(N):
    ki.append(dict())
    ki[-1]["eda"] = []
 
for i in range(N-1):
    ki[ab[i][0] - 1]["eda"].append([ab[i][1] - 1])
    ki[ab[i][1] - 1]["eda"].append([ab[i][0] - 1])
 
def P(m ,n):
    if m <= 0 or n <= 0:
        return 0
    else:
        num = 1
        for i in range(n):
            num = num*(m-i) % 1000000007
        return num
 
def saiki(i, base, ki):
    num = 1
    eda_num = len(ki[i]["eda"])-1
    if eda_num == 0:
        return num
    num *= P(K-2, eda_num)
 
    for edge in ki[i]["eda"]:
        if edge[0] != base:
            num *= saiki(edge[0], i, ki)
 
    num = num % 1000000007
    return num
 
total_num = K
if len(ki[0]["eda"]) != 0:
    total_num *= P(K-1, len(ki[0]["eda"]))
    for edge in ki[0]["eda"]:
        total_num *= saiki(edge[0], 0, ki)
        total_num = total_num % 1000000007
        if total_num == 0:
            break
 
print(total_num)

Measured memory_bytes: 179288
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int N, P;
	cin >> N >> P;
	map<int, int>m;
	for (int i = 2; i * i <= P; i++) {
		while (P % i == 0) {
			P /= i;
			m[i]++;
		}
	}
	m[P]++;
	int ans = 1;
	for (auto i : m) {
		if (i.second >= N) {
			int num = pow(i.first, i.second / N);
			ans *= num;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

using namespace std;

#define foreach(i,c) for(__typeof__((c).begin()) i=(c).begin();i!=(c).end();++i)

int main()
{
	for(int n;cin>>n,n;){
		cin.ignore();
		vector<string> words;
		while(n--){
			string line; getline(cin,line);
			istringstream iss(line);
			for(string w;iss>>w;)
				words.push_back(w);
		}
		char c; cin>>c;
		
		map<string,int> m;
		for(int i=0;i<words.size();i++)
			m[words[i]]++;
		
		set<pair<int,string> > s;
		foreach(i,m)
			if(i->first[0]==c)
				s.insert(make_pair(-i->second,i->first));
		
		if(s.empty())
			cout<<"NA"<<endl;
		else{
			int cnt=0;
			foreach(i,s){
				cout<<(i==s.begin()?"":" ")<<i->second;
				if(++cnt==5)
					break;
			}
			cout<<endl;
		}
	}
	return 0;
}

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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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

ll solve(ll n){
    return n * n * n;
}

int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n , K;
    cin >> n >> K;
    if(K&1){
        int D = n / K;
        cout << solve(D) << endl;
    }else{
        int D = n / K;
        if(n % K >= K/2)D++;
        cout << solve(D) + solve(n/K) << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int i, j, k, l;
	int n;
	int pat;
	
	while (scanf("%d", &n) != EOF) {
		pat = 0;
		for (i = 0; i < 10; i++)
			for (j = 0; j < 10; j++)
				for (k = 0; k < 10; k++)
					for (l = 0; l < 10; l++)
						if( i + j + k + l == n)
							pat++;
		printf("%d\n", pat);
	}

	return 0;
}

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

int main(){

    int n;
    cin >> n;
    vector<ll> a(90);

    a[0]=2;
    a[1]=1;
    for(int i=1;i<=n;i++){
        a[i+1]=a[i]+a[i-1];
    }
    cout << a[n] << endl;

    return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
a = [input() for _ in range(h)]
dp = [[0] * w for _ in range(h)]
dp[0][0] = 1
for i in range(h):
    for j in range(w):
        if a[i][j] == '.':
            if i < h - 1:
                dp[i+1][j] = dp[i][j]
            if j < w - 1:
                dp[i][j+1] = (dp[i][j+1] + dp[i][j]) % 1000000007
print(dp[h-1][w-1])

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

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(c - a) <= d)cout << "Yes" << endl;
	else {
		if (abs(b - a) <= d && abs(c - b) <= d)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    for(int i=0; i<n; i++) cin >> l[i];

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

    int ans = 0;

    for(int i=n-1; i>n-1-k; i--){
        ans += l[i];
    }

    cout << ans << endl;

}

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

void solve(){
    int N, W;
    cin >> N >> W;
    vector<int> v(N), w(N);
    for(int i=0; i<N; i++)
        cin >> v[i] >> w[i];
    
    vector<vector<int>> dp(N+1, vector<int>(W+1,0));
    
    for(int i=0; i<N; i++){
        for(int j=0; j<=W; j++){
            if(j-w[i]>=0)
                dp[i+1][j] = max(dp[i][j], dp[i+1][j-w[i]]+v[i]);
            else
                dp[i+1][j] = dp[i][j];
        }
    }
    
    cout << dp[N][W] << endl;

}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}



Measured memory_bytes: 6852
import java.util.*;

public class Main {

	String str;
	int p, n;
	char ans;
	static final int INF = 1<<30;
	static final int LONG = INF+1;

	void run(){
		Scanner in = new Scanner(System.in);
		for(;;){
			str = in.next();
			n = in.nextInt();
			if(str.equals("0") && n==0) return ;
			ans = '0';
			solve();
			System.out.println(ans);
		}
	}

	void solve(){
		if(n == 0 && str.length()>=1 && Character.isUpperCase(str.charAt(0))){
			ans = str.charAt(0);
			return ;
		}
		p = 0;
		int len = expr();
		if(len <= n) return ;
		p = 0;
		int t = term();
		if(t <= n){
			str = str.substring(p);
			n -= t;
			solve();
			return ;
		}
		p = 0;
		num();
		if(Character.isUpperCase(str.charAt(p))){
			ans = str.charAt(p);
			return ;
		}
		else{
			p++;
			int q = p;
			int b = expr();
			n %= b;
			str = str.substring(q, p);
			solve();
			return ;
		}
	}
	
	int expr(){
		if(p==str.length() || str.charAt(p)==')') return 0;
		int r = term(), a = expr();
		if(r == LONG || a == LONG){
			return LONG;
		}
		else{
			return r + a > n+1?LONG:r+a;
		}
	}

	int term(){
		if(Character.isUpperCase(str.charAt(p))){
			p++;
			return 1;
		}
		else{
			int a = num();
			if(Character.isUpperCase(str.charAt(p))){
				p++;
				return a;
			}
			p++;
			int b = expr();
			p++;
			if( b == LONG ){
				return LONG;
			}
			else{
				return a*b;
			}
		}
		
	}
	
	int num(){
		if(p==str.length()) return INF;
		int q = p;
		char c = str.charAt(p);
		if(!Character.isDigit(c)) return INF;
		p++;
		int a = num(), b = c-'0';
		if(a==INF) return b;
		for(int i=0; i<p-q-1;i++){
			b *= 10;
		}
		return b + a;
	}

	public static void main(String args[]){
		new Main().run();
	}
}

Measured memory_bytes: 12000
using System;
using System.Collections.Generic;
class Program
    {
    	static void Main(string[] args)
    	{
    		string[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);
            int ans = 0;

            if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1)
            {
                Console.WriteLine(0);
                return;
            }
            while(ans < 32)
            {
                int bit = 1 << ans;
                if ((a & bit) != (b & bit)) break;
                if ((b & bit) != (c & bit)) break;
                ans++;
            }
            if (ans == 32) Console.WriteLine(-1);
            else Console.WriteLine(ans);
            
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 11092
#include <iostream> 
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
using namespace std;

int main() {
	int n,a;
	set<int>s;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (s.count(a)) {
			cout << "NO" << endl;
			return 0;
		}
		s.insert(a);
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 9600
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#define il inline
#define re register
#define fo(i,j,k) for(register int i=j;i<=k;i++)
#define inf 0x7fffffff
typedef long long ll;
using namespace std;
il ll read()
{
	re ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return f*x;	
}
int n,k,c,cnt,pre;
string s;
int dp1[200010],dp2[200010],ans[200010]; 
int main()
{
	n=read(),k=read(),c=read();
	cin>>s;
	s=" "+s;
	pre=-c-1;
    for(int i=1;i<=n;i++)
	{
    	if(s[i]=='x')  dp1[i]=dp1[i-1];
    	else
    	{
    		if(pre+c+1<=i)
			{
    			dp1[i]=dp1[i-1]+1;
    			pre=i;
    		}
    		else dp1[i]=dp1[i-1];
		}
    }
	pre=n+c+1;
    for(int i=n;i>=1;i--)
	{
    	if(s[i]=='x') dp2[i]=dp2[i+1];
    	else 
    	{
    		if(pre-c-1>=i){
    			dp2[i]=dp2[i+1]+1;
    			pre=i;
    		}
    		else dp2[i]=dp2[i+1];
    	}
    }
//	fo(i,1,n) printf("%d %d\n",dp1[i],dp2[i]);
	fo(i,1,n)
	{
		if(dp1[i-1]+dp2[i+1]==k-1&&s[i]=='o')
		{
			ans[++cnt]=i;
		}
	}
	fo(i,1,cnt) printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 4160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X,Y,A,B,C;
  cin >> X >> Y >> A >> B >> C;
  vector<int> a(A);
  vector<int> b(B);
  vector<int> c(C);
  for(int i=0;i<A;i++){
    cin >> a[i];
  }
  for(int i=0;i<B;i++){
    cin >> b[i];
  }
  for(int i=0;i<C;i++){
    cin >> c[i];
  }
  sort(a.rbegin(), a.rend());
  sort(b.rbegin(), b.rend());
  vector<int> d;
  for(int i=0;i<X;i++){
    d.push_back(a[i]);
  }
  for(int i=0;i<Y;i++){
    d.push_back(b[i]);
  }
  for(int i=0;i<C;i++){
    d.push_back(c[i]);
  }
  sort(d.rbegin(), d.rend());
  long long ans=0;
  for(int i=0;i<X+Y;i++){
   ans += d[i];
  }
  cout << ans << endl;
}

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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  fspcnt = 0;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int a,b,t;
  cin >> a >> b >> t;
  cout << (t/a)*b;
  
}

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

    int a, b;
    cin >> a >> b;

    if(b / k - a / k > 0) cout << "OK" << endl;
    else if(b % k == 0 || a % k ==0) cout << "OK" << endl;
    else cout << "NG" << endl;

    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int moji[4001][4001];
int main(){
  string s,t;
  int ma;
  while(cin >> s >> t){
    fill_n(*moji,4001*4001,0);
    ma = 0;
    for(int i=0;i<s.size();i++){
      for(int j=0;j<t.size();j++){
	if(s[i] == t[j]){
	  moji[i][j] = (i==0)?1:moji[i-1][j-1]+1;
	  ma = max(ma,moji[i][j]);
	}
      }
    }
    cout << ma << endl;
  }
  return (0);
}

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

int A[100],n;

void push(int a){
  A[++n] = a;
}

int pop(){
  n--;
  return A[n + 1];
}

int main(){
  int x,y;
  char s[100];
  
  n = 0;
  while(scanf("%s",s) != EOF){
    if ( s[0] == '+' ){
      y = pop();
      x = pop();
      push(x + y);
    }
    else if ( s[0] == '-' ){
      y = pop();
      x = pop();
      push(x - y);
    }
    else if ( s[0] == '*' ){
      y = pop();
      x = pop();
      push(x * y);
    }
    else {
      push(atoi(s));

    }
  }
  printf("%d\n",pop());
  
  return 0;
}


Measured memory_bytes: 2104
module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";var r=n(1),i=new(n(2))(r.readFileSync("/dev/stdin","utf8").trim().split(/\s+/g));n(4)(i)},function(t,e){t.exports=require("fs")},function(t,e,n){"use strict";var r=n(3);t.exports=class{constructor(t){this.inp=new r(t)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}add(t){this.inp.enq(t)}}},function(t,e,n){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}}},function(t,e,n){"use strict";t.exports=function(t){for(var e=t.in(),n=t.in(),r=new Array(e).fill(0),i=0;i<n;i++){var o=t.in(),s=t.in();r[o-1]++,r[s-1]++}for(var u=0;u<e;u++)if(r[u]%2==1)return void console.log("NO");console.log("YES")}}]);

Measured memory_bytes: 45500
#include <cstdio>

int exchange_A_to_N(char);

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

    int max = 0;
    bool used[2][26];
    for(int i = 0; i <= N - 2; i++){
        for(int p = 0; p < 2; p++){
            for(int q = 0; q < 26; q++){
                used[p][q] = false;
            }
        }
        for(int j = 0; j <= i; j++){
            used[0][exchange_A_to_N(S[j])] = true;
        }
        for(int j = N - 1; j > i; j--){
            used[1][exchange_A_to_N(S[j])] = true;
        }
        
        int pmax = 0;
        for(int j = 0; j < 26; j++){
            if(used[0][j] == true && used[1][j] == true){
                pmax++;
            }
        }
        if(pmax > max){
            max = pmax;
        }
    }
    printf("%d\n",max);

    return 0;
}

int exchange_A_to_N(char c){
    
    return (c - 'a');
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define debug(x) cout<<#x<<"="<<x<<endl;
using namespace std;
const int MAX=55;
int c[MAX];
int depth[MAX];
int graph[MAX][MAX];
int Brige[MAX][MAX];
int Root;
int Ancestor[MAX];
int n;
void findnode(int k,int kfather,int deep)
{
	int i,tot;
	c[k]=1;depth[k]=deep;
	Ancestor[k]=deep;tot=0;
	for(i=0;i<n;i++)
	{
		if(graph[i][k]&&i!=kfather&&c[i]==1)
		Ancestor[k]=min(Ancestor[k],depth[i]);
		if(graph[i][k]&&c[i]==0)
		{
			findnode(i,k,deep+1);
			tot++;
			Ancestor[k]=min(Ancestor[k],Ancestor[i]);
			if(Ancestor[i]>depth[k]&&graph[k][i]==1)Brige[k][i]=1;
		}
		
	}
	c[k]=2;
}
int main(void)
{
	int m;
	memset(graph,0,sizeof(graph));
	memset(Ancestor,0,sizeof(Ancestor));
	memset(c,0,sizeof(c));
	memset(Brige,0,sizeof(Brige));
	memset(depth,0,sizeof(depth));
	scanf("%d%d",&n,&m);
	rep(i,0,m)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		u--;v--;
		graph[u][v]++;
		graph[v][u]++;
	}
	findnode(1,0,0);
	int cnt=0;
	rep(i,0,n)
	{
		rep(j,0,n)
		{
			if(Brige[i][j]==1)cnt++;
			//printf("%d ",Brige[i][j]);
		}
		//cout<<endl;
	}
	printf("%d",cnt);
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v);
#ifdef APURBA
#define HERE cout<<"here - "<<__LINE__<<"\n";
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)
{
    cout<<endl;
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cout << *it << " = " << a << " ";
    err(++it, args...);
}
#else
#define HERE
#define debug(args...)
#endif
const ll mod = 998244353 ;
const int N = 3000+5;
typedef pair<int,int> pii;

ll dp[N][N][5];
ll r,c,k;
vector<vector<ll> >a;

bool issafe(ll i, ll j)
{
    return i>=0 && j>=0 && i<r && j<c;
}
ll solve(ll x, ll y , ll koto)
{
    //debug(x,y,koto);
    if(x==r-1 && y==c-1)
    {
        if(koto<3)
        {
            return a[x][y];
        }
        return 0;
    }
    ll &ret = dp[x][y][koto];
    if(ret!=-1)
        return ret;

    ll ans =0;

    if(issafe(x+1,y))
    {
        if(a[x][y] && koto<3)
        {
            ans = max(ans , a[x][y] + solve(x+1,y,0));
        }
        ans = max(ans , solve(x+1,y,0));
    }
    if(issafe(x,y+1))
    {
        if(a[x][y] && koto<3)
        {
            ans = max(ans , a[x][y] + solve(x,y+1,koto+1));
        }
        ans = max(ans , solve(x,y+1,koto));
    }
    //debug(x,y,koto,ans);
    return ret = ans;
}


void TEST_CASES(int cas)
{
    memset(dp,-1,sizeof dp);
    scanf("%lld %lld %lld",&r,&c,&k);
    a.resize(r,vector<ll>(c));
    for(int i=0;i<k;i++)
    {
        ll u,v,w;
        scanf("%lld %lld %lld",&u,&v,&w);
        u--;
        v--;
        a[u][v]=w;
    }
    debug(a);
    printf("%lld\n",solve(0,0,0));
}


/*

*/

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        TEST_CASES(++cas);
    }
    return 0;
}



template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v)
{
    for(auto i:v)
    {
        os<<"Key : "<<i.first<<" , Value : "<<i.second<<endl;
    }
    return os;
}


Measured memory_bytes: 426976
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;

int main(){
  string S;
  cin >> S;
  if(S.size()%2!=0){
    cout << "No" << endl;
    return 0;
  }
  int j=0;
  vector<char> s(S.size());
  for(char tmp : S){
    s.at(j)=tmp;
    j++;
  }
  for(int i=0;i<S.size()/2;i++){
    if(s.at(2*i)!='h'){
      cout << "No" << endl;
      return 0;
    }
    if(s.at(2*i+1)!='i'){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int n, p[200010],ans=0,min=300000;
	cin >> n;
	for (int i = 1; i <= n;i++) {
		cin >> p[i];
		if (p[i]<min) {
			min = p[i];
			ans ++ ;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
cnt = 0

def divide_by_2(array):
  rest = array % 2
  global cnt
  if np.all(rest == 0):
    cnt += 1
    divide_by_2(array / 2)
    
divide_by_2(A)
print(cnt)

Measured memory_bytes: 12488
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);

	int N, R;
	N = sc.nextInt();
	R = sc.nextInt();

	if (N >= 10) {
	    System.out.println(R);
	} else {
	    System.out.println(R + 100 * (10 - N));
	}
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c=0;
	cin>>a>>b;
	if(b==1)
	cout<<"0";
		else
		{
	b-=a;
	c++;	
		while(b>0)
		{
		b-=(a-1);
		c++;
	}	cout<<c;}	
	return 0;
}

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

int main(){
    int X;
    cin >> X;
    if(X == 2) cout << '2';
    else{
        bool han = true;
        while(han){
            han = false;
            for(int i = 3;i < X;i+=2){
                if(X % i == 0){
                    X++;
                    han = true;
                    break;
                }
            }
            
        }
        cout << X;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
using namespace std;
int a[1000000];
long long ans;
int n, m;
int main() {
	scanf("%d %d", &n, &m);
  for (int i= 1; i <= n; i ++)
    scanf("%d", &a[i]);
  sort(a  +1, a + n+1);
  int l = max(0, n - m);
  for (int i = 1; i <= l; i ++)
    ans += a[i];
  printf("%lld\n",ans);
}

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

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

	int k, n;
	cin >> k >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++)
		cin >> a[i];
		
	int res = a[0] + k - a[n - 1];
	for (int i = 0; i < n - 1; i++)
		res = max(res, a[i + 1] - a[i]);

	cout << k - res << endl;			
	return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>){
    val input = readLine()!!
    when(input){
        "1"  -> { issaiji() }
        "2"  -> { nisaiji() }
        else -> throw IllegalArgumentException("1歳か2歳のみ許容します")
    }
}

fun issaiji(){
    println("Hello World")
}
fun nisaiji(){
    val num1 = readLine()!!.toInt()
    val num2 = readLine()!!.toInt()
    println(num1 + num2)
}

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

int key(int n)
{
    int s = 0;
    int m = 1;
    for (int i = 2; i <= n; i++) {
        if (n % i == 0) {
            s += i;
            m = max(m, i);
            while (n % i == 0) {
                n /= i;
            }
        }
    }
    return m - (s-m);
}

int main()
{
    int a, b;
    while (cin >> a >> b && a != 0) {
        int x = key(a);
        int y = key(b);
        cout << (x <= y ? "b" : "a") << endl;
    }
    return 0;
}

Measured memory_bytes: 856
#[allow(unused_macros)]
macro_rules! input {
    ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } };
    ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ( $ next : expr ) => { };
    ( $ next : expr , ) => { };
    ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) };
    ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) };
    ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) };
    ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 };
    ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) };
}

fn main() {
    input! {
        n: usize,
        s: chars
    }

    let pre = s .iter()
        .map(|c| *c)
        .take(n)
        .collect::<Vec<_>>();
    let mut post = s .iter()
        .map(|c| *c)
        .skip(n)
        .collect::<Vec<_>>();
    post.reverse();

    let mut hmap = std::collections::HashMap::new();
    for mask in 0..1<<n {
        let ptn1 = bit_filter(mask, &pre);
        let ptn2 = bit_filter((1<<n)-1 ^ mask , &pre);
        *hmap.entry((ptn1, ptn2)).or_insert(0u64) += 1;
    }
    let mut hmap2 = std::collections::HashMap::new();
    for mask in 0..1<<n {
        let ptn1 = bit_filter(mask, &post);
        let ptn2 = bit_filter((1<<n)-1 ^ mask, &post);
        *hmap2.entry((ptn1, ptn2)).or_insert(0u64) += 1;
    }
    let mut ret = 0u64;
    for (key, &value) in hmap.iter() {
        if let Some(src) = hmap2.get(key) {
            ret += value * src;
        }
    }
    println!("{}", ret);
}

#[allow(dead_code)]
pub fn bit_filter<T: Clone>(b: usize, v: &[T]) -> Vec<T> {
    let mut ret = vec![];
    for i in 0..v.len() {
        if (b >> i) & 1 == 1 {
            ret.push(v[i].clone());
        }
    }
    ret
}


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

using ll = long long;
using ull = unsigned long long;
#define repi(n) for (int i = 0; i < (n); i++)
#define repj(n) for (int j = 0; j < (n); j++)
#define repk(n) for (int k = 0; k < (n); k++)
#define rep(i, a, b) for (auto i = (a); i < (b); i++)
#define itr(itr) for (auto&& v : (itr))
#define updatemax(t, v) (t = std::max(t, (v)))
#define updatemin(t, v) (t = std::min(t, (v)))

int main() {
  ll n;
  cin >> n;
  ll re = 0;
  repi(n) re += (i + 1) * (n - i);
  repi(n - 1) {
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a > b) swap(a, b);
    re -= (a + 1) * (n - b);
  }
  cout << re << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
const int N=200005;
#define inf 1e18+8
const int mod=1e9+7;
#define pii pair<int, int>
#define vi vector<int>
#define sz(x) (int)x.size()
#define set multiset
#define all(x) begin(x), end(x)
#define vpii vector<pair<int,int> > 
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
//int dp[N];
int dp1[N];
vi adj[N];
vi adj2[N];
int vis[N];
vi printDivisors(int n) 
{ 
    vi temp;
    // Note that this loop runs till square root 
    for (int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            // If divisors are equal, print only one 
            if (n/i == i) 
                temp.pb(i);
  
            else // Otherwise print both 
                {
                    temp.pb(i);
                    temp.pb(n/i);

                }
        } 
    } 
    return temp;
}
int dp[3001][3001];
int arr[N];
int rec(int first, int last)
{
    if(dp[first][last]!=-1) return dp[first][last];
    if(last<first) return 0;
   // if((last-first)==1) return dp[first][last]=max(arr[first],arr[last]);
    if(first==last) return dp[first][last] = arr[first];
    return dp[first][last]=max(arr[first]+min(rec(first+2,last),rec(first+1,last-1)),arr[last]+min(rec(first,last-2),rec(first+1,last-1)));

}
signed main()
{
    int n;cin>>n;
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            dp[i][j]=-1;
        }
    }
    for(int i=1;i<=n;i++)
    { 
        cin>>arr[i];
        sum+=arr[i];
    }

    //cout<<rec(1,n);
    cout<<rec(1,n)-(sum-rec(1,n));
    return 0;

}
 
    

Measured memory_bytes: 83492
A, B, C, D = list(map(int, input().strip().split()))

time= 0
if(B <= C):
    time = 0
elif(D <= A):
    time = 0
elif(A <= C)and(B <= D):
    time = B - C
elif(A <= C)and(D <= B):
    time = D - C
elif(C <= A)and(D <= B):
    time = D - A
elif(C <= A)and(B <= D):
    time = B - A
print(time)


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


def solve(N: int, A: "List[int]"):
    if N == 0:
        if A == [0]:
            print('0')
        elif A == [1]:
            print('1')
        else:
            print('-1')
        return

    if N == 1:
        if A == [0, 1]:
            print('2')
        elif A == [0, 2]:
            print('3')
        else:
            print('-1')
        return

    if A[0] != 0:
        print('-1')
        return

    f = [0 for i in range(N)]

    f[0] = 1
    count = sum(A) - 1

    for d in range(1, N):
        f[d] = 2 * min(f[d - 1], count) - A[d] + min(max(f[d - 1] - count, 0), f[d - 1])
        count -= min(f[d - 1], count)
        if f[d] <= 0:
            print('-1')
            return

    if A[-1] > 2 * f[N-1]:
        print('-1')
        return

    print(sum(f) + sum(A))
    return


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

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N - 0 + 1)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 24700
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int n, m, l;
using P = pair<int, ll>; // 回数, 使ったエネルギー
const int maxn = 305;
ll edge[maxn][maxn];
P d[maxn][maxn];


void dijkstra(int s) {
    // cout << endl << s << endl;
    int used[maxn];
    fill_n(used, maxn, 0);
    
    d[s][s] = P(0, 0);
    
    int u = -1;
    rep(i, n) {
        // 一番costが小さいの
        // 第一引数がinfなら第二引数はなんでもいい
        P mincost = P(inf, 0);
        // usedじゃないうちでcost小さい
        rep(j, n) {
            if (used[j] || d[s][j] > mincost) continue;
            mincost = d[s][j];
            u = j;
        }
        // cout << "u " << u << endl;
        if (mincost == P(inf, 0)) break;
        used[u] = 1;
        
        rep(v, n) {
            if (used[v] == 1 || edge[u][v] == -1) continue;
            
            ll tmp = d[s][u].S + edge[u][v];
            int cnt = d[s][u].F;
            if (tmp > l) {
                tmp = edge[u][v];
                if (tmp > l) continue;
                cnt++;
            }
            // cout << v << " " << cnt << " " << tmp << endl;
            if (cnt > d[s][v].F) continue;
            if (cnt == d[s][v].F && tmp >= d[s][v].S) continue;
            
            d[s][v] = P(cnt, tmp);
            
        
        }
    }
    // rep(j, n) cout << d[s][j].F << " " << d[s][j].S << endl;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    cin >> n >> m >> l;
    rep(i, n) rep(j, n) edge[i][j] = -1;
    
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        edge[a][b] = c;
        edge[b][a] = c;
    }
    
    rep(i, n) rep(j, n) d[i][j].F = inf;
    rep(i, n) {
        dijkstra(i);
    }
    
    int q;
    cin >> q;
    rep(i, q) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        cout << (d[s][t].F == inf ? -1 : d[s][t].F) << endl;
    }
}



Measured memory_bytes: 2688
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int x, y; cin >> x >> y;
    cout << x + y / 2 << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

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

int main() {
	//入力
	int N;
	cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; i++)
	{
		cin >> H[i];
	}

	//処理
	int ans = 0;
	//i 今見ている山
	for (int i = 0; i < N; i++)
	{
		//自分より高い山がなかったかどうかのフラグ
		bool flag = true;

		//j これから調べる山 iより西側なので、i未満について調べる
		for (int j = 0; j < i; j++)
		{
			if (H[j] > H[i]) flag = false;
		}

		if (flag) ans++;
	}

	//出力
	cout << ans << endl;
}



Measured memory_bytes: 384
/* ABC146-A
   Takatan */

#include<stdio.h>
int main(void){
    int number1, number2, number3;

    scanf( "%d %d %d" , &number1, &number2, &number3);
    if(number1+number2+number3>21){
        printf( "bust\n" );
    }else{
        printf( "win\n" );
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int board[3][3];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	bool ans=false;
	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>board[i][j];
		}
	}
	int N;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int b;
		cin>>b;
		for(int ii=0;ii<3;ii++)
		{
			bool key=false;
			for(int jj=0;jj<3;jj++)
			{
				if(board[ii][jj]==b){
					board[ii][jj]=-1;
					key=true;
					break;
				}
			}
			if(key)break;
		}
	}
	for(int i=0;i<3;i++)
	{
		bool key=true;
		for(int j=0;j<3;j++)
		{
			if(board[i][j]!=-1)key=false;
		}
		if(key){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	for(int i=0;i<3;i++)
	{
		bool key=true;
		for(int j=0;j<3;j++)
		{
			if(board[j][i]!=-1)key=false;
		}
		if(key){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	if((board[0][0]==-1&&board[0][0]==board[1][1]&&board[1][1]==board[2][2])||(board[0][2]==-1&&board[0][2]==board[1][1]&&board[1][1]==board[2][0]))
	{
		cout<<"Yes"<<endl;
			return 0;
	}
	cout<<"No"<<endl;
	return 0;
}

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

char a[1 << 20];
int dp[1 << 20][2];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> a;
	int n = strlen(a);
	for (int i = 0; i < n; i++) {
		if (i == 0) {
			if (a[i] == 'P') {
				dp[i][1] = 0;
			}
			if (a[i] == 'D') {
				dp[i][0] = 1;
			}
			if (a[i] == '?') {
				dp[i][1] = 0;
				dp[i][0] = 1;
			}
			continue;
		}
		if (a[i] == 'P') {
			dp[i][1] = max(dp[i - 1][0], dp[i - 1][1]);
		}
		if (a[i] == 'D') {
			dp[i][0] = max(dp[i - 1][0] + 1, dp[i - 1][1] + 2);
		}
		if (a[i] == '?') {
			dp[i][1] = max(dp[i - 1][0], dp[i - 1][1]);
			dp[i][0] = max(dp[i - 1][0] + 1, dp[i - 1][1] + 2);
		}
	}
	int cnt = 0;
	if (dp[n - 1][0] < dp[n - 1][1]) cnt = 1;
	for (int i = n - 1; i >= 0; i--) {
		if (a[i] == '?') {
			if (cnt == 0) a[i] = 'D';
			else a[i] = 'P';
		}
		if (a[i] == 'P') {
			if (dp[i][1] == dp[i - 1][0]) cnt = 0;
			else cnt = 1;
		}
		if (a[i] == 'D') {
			if (dp[i][0] == dp[i - 1][0] + 1) cnt = 0;
			else cnt = 1;
		}
		if (a[i] == '?') {
			if (cnt == 1) {
				if (dp[i][1] == dp[i - 1][0]) cnt = 0;
				else cnt = 1;
			} else {
				if (dp[i][0] == dp[i - 1][0] + 1) cnt = 0;
				else cnt = 1;
			}
		}
	}
	cout << a << endl;
	return 0;
}



Measured memory_bytes: 5392
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush=
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var A = cin.ReadInt;
			if(A==1) {
				Console.WriteLine(0);return;
			}
			var B = cin.ReadLong;
			var N = cin.ReadLong;
			var dp = new long[A];
			for(int i = 1; i<A; i++) {
				var floor = (i*B)/A;
				var ceil = (i*B)%A==0 ? floor : floor+1;
				if(ceil>N) break;
				dp[i]=A*(ceil%B)-(A*ceil)%B;
			}
			Console.WriteLine(dp.Max()/B);
		}
	}
	static class ExtendClass {
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
		
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator=separator;
			this._stream=stream;
			inputStream=new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count!=0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i<tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i<N; ++i)
				ret[i]=Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i<N; ++i) ret[i]=ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i<N; ++i) ret[i]=ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i<N; ++i) ret[i]=ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek()==-1; }
		}
	}

}

Measured memory_bytes: 35852