akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    i64 d, a;
    std::cin >> n >> d >> a;

    std::vector<std::pair<i64, i64>> v;
    for (int i = 0; i < n; i++) {
        i64 x, h;
        std::cin >> x >> h;
        v.emplace_back(x, h);
    }

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

    std::deque<std::pair<i64, i64>> q;
    i64 ret = 0, c = 0;
    for (int i = 0; i < n; i++) {
        while (!q.empty() && q.front().first < v[i].first) {
            c -= q.front().second;
            q.pop_front();
        }
        i64 r = std::max(0ll, v[i].second - c * a);
        i64 t = (r + a - 1) / a;
        ret += t;
        c += t;
        q.emplace_back(v[i].first + 2 * d, t);
    }

    std::cout << ret << std::endl;

    return 0;
}


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

int main() {
  int N; cin >> N;
  int A[N]; for (int i=0; i<N; i++) cin >> A[i];
  sort(A, A+N);
  string ans = "YES";
  for (int i=0; i<N-1; i++) {
    if (A[i] == A[i+1]) {
      ans = "NO";
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


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

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define loop(i,a,b) for(int i=a;i>=b;i--)
#define forr(x,arr) for(auto& x:arr)
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-7
#define sz(x) ((lli)(x).size())

using   lli     =   long long;
using   lld     =   long double;
using   ulli    =   unsigned long long int;
using   pll     =   pair<lli, lli>;
using   ttt     =   pair<lli, pll>;
using   vttt    =   vector<ttt>;
using   vll     =   vector<pll>;
using   vl      =   vector<lli>;
using   vi      =   vector<int>;
using   vvi     =   vector<vector<int>>;
using   cd      =   complex<lld>;
const double PI = acos(-1);

#ifdef tejasp
#include "library/debugger.cpp"
#else
#define trace(...) {}
#define cotra(...) {}
#define end_routine() {}
#define localsys 0
#define endl '\n'
#endif

#define ca first.first
#define cb first.second
#define cc second.first
#define cd second.second
#define node pair<pll,pll>

node arr[410];
lli ans=0;
map<node,lli> mp;

void rotate(node &cur)
{
    lli temp=cur.ca;
    cur.ca=cur.cb;
    cur.cb=cur.cc;
    cur.cc=cur.cd;
    cur.cd=temp;
}

int calc(node &a, node &b)
{
    int ans=0;
    fol(i,0,4)
    {
        if(a==b) ans++;
        rotate(b);
    }
    return ans;
}

node reverse(node n)
{
    swap(n.cb,n.cd);
    return n;
}

void upd(node &l1, node &r1)
{
    node lef=reverse(l1), rig=r1;
    node uu({{lef.ca,lef.cb},{rig.cb,rig.ca}});
    node dd({{lef.cb,lef.cc},{rig.cc,rig.cb}});
    node ll({{lef.cc,lef.cd},{rig.cd,rig.cc}});
    node rr({{lef.cd,lef.ca},{rig.ca,rig.cd}});
    lli res1=mp[uu];
    lli res2=mp[dd];
    lli res3=mp[ll];
    lli res4=mp[rr];
    res1-=calc(uu,l1)+calc(uu,r1);
    res2-=calc(dd,l1)+calc(dd,r1)+calc(dd,uu);
    res3-=calc(ll,l1)+calc(ll,r1)+calc(ll,uu)+calc(ll,dd);
    res4-=calc(rr,l1)+calc(rr,r1)+calc(rr,uu)+calc(rr,dd)+calc(rr,ll);
    ans+=(res1*res2*res3*res4);
}

int tejas_919(int kkkk)
{
    lli n, m, k, q, u, v, temp=0;
    cin>>n;
    fol(i,0,n)
    {
        cin>>m>>k>>u>>v;
        arr[i]=node({{m,k},{u,v}});
        fol(j,0,4)
        {
            mp[arr[i]]++;
            rotate(arr[i]);
        }
    }
    fol(i,0,n)
    {
        fol(j,i+1,n)
        {
            fol(k,0,4)
            {
                upd(arr[i],arr[j]);
                rotate(arr[j]);
            }
        }
    }
    ans/=3;
    cout<<ans<<endl;
    return 0;
}

signed main()
{
    #ifdef tejasp
            freopen("input.txt", "rt", stdin);
            freopen("output.txt", "wt", stdout);
    #endif
    if(!localsys) { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); }
    cout << fixed << setprecision(10);
    int t=1;
    //cin>>t;
    fol(i,0,t) { tejas_919(i+1); }
    end_routine();
    if(localsys) system("pause");
}

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

int main() {
  float a, b;
  cin >> a >> b;
  int v = (int)max(a / 0.08, b / 0.1) + 1;

  if (floor(v * 0.08) != a || floor(v * 0.1) != b) {
    cout << -1 << endl;
    return 0;
  }

  while (true) {
    if (floor((v - 1) * 0.08) == a && floor((v - 1) * 0.1) == b) {
      v--;
    } else {
      cout << v << endl;
      return 0;
    }
  }

  cout << endl;
  return 0;
}

Measured memory_bytes: 256
function main(input) {
  const args = input.split('\n');
  const N = parseInt(args[0], 10);
  const ary = args[1].split(' ').map(n => parseInt(n, 10));
  
  const aryMax = (a, b) => {return Math.max(a, b);}
  const aryMin = (a, b) => {return Math.min(a, b);}
  let max = ary.reduce(aryMax);
  let min = ary.reduce(aryMin);
  
  console.log(max - min);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29832
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int a = in.nextInt();
            int b = in.nextInt();
            long ans = 0;
            for (int i = 1; i <= n; i++) {
                String str = String.valueOf(i);
                int sum = 0;
                for (char c : str.toCharArray()) {
                    sum += Integer.valueOf(String.valueOf(c));
                }

                if (a <= sum && sum <= b) {
                    ans += i;
                }
            }

            out.print(ans);
        }

    }
}



Measured memory_bytes: 25556
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
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; }
template<class T>T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }


void _main() {
  int N;
  string S;
  cin >> N >> S;
  vector<int> sum(N+1);
  sum[0] = 0;
  rep(i, 0, N) sum[i+1] = sum[i] + (S[i]=='#'?1:0);

  int ans = inf;
  rep(i, 0, N+1) {
    int t = 0;
    t += sum[i];
    t += N - i - (sum[N]-sum[i]);
    chmin(ans, t);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1428
// Problem : 
// 			D - Knapsack 1
// 			Editorial
// 		
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define all(a) a.begin(),a.end()
#define x first
#define y second
#define MOD 1000000007
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;
ll dp[101][100001];
ll final(vll &a,vll &w,ll W,ll i){
	//cout << W << " " << i << "\n";
	if(i==0 || W==0)return 0;
	else if(dp[i][W] != -1)return dp[i][W];
	else if(w[i-1] > W)return dp[i][W] = final(a,w,W,i-1);
	else return dp[i][W] =  max(final(a,w,W,i-1),a[i-1] + final(a,w,W-w[i-1],i-1));
}

int main() {
    // your code goes here
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,W;
    cin >> n >> W;
    vll a(n),w(n);
    for(int i = 0;i<n;i++)cin >> w[i] >> a[i];
    memset(dp,-1,sizeof(dp));
    ll out = final(a,w,W,n);
    cout << out << "\n";
    return 0;
}


Measured memory_bytes: 82576
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

    String S;

    public void solve() {
        S = next();

        if (S.startsWith("YAKI")) {
            out.println("Yes");
        } else {
            out.println("No");
        }
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const LL INF = 1e14;
const LL MOD = 1e9 + 7;

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

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VI a(n);
  INPUT(a);
  int ans = 0;
  int color = -1;
  REP2(i, 1, n)
  {
    if (a[i] == a[i-1])
    {
      a[i] = color;
      color--;
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n, m, x = map(int, input().split())
price = []
book = []
for i in range(n):
    tmp = list(map(int, input().split()))
    price.append(tmp[0])
    book.append(tmp[1:])

ans = 10**10
for bit in range(1 << n):
    score_sum = [0 for _ in range(m)]
    price_sum = 0
    for i in range(n):
        if ((bit >> i) & 1) == 1:
            price_sum += price[i]
            for j in range(m):
                score_sum[j] += book[i][j]
    flag = True
    for v in score_sum:
        if v < x:
            flag = False
    if flag:
        ans = min(ans, price_sum)

if ans == 10**10:
    print(-1)
else:
    print(ans)

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


int main(){
  int n;
  vector<int> vec(4);
  
  cin >> n;
  
  vec.at(0)=n/1000;
  vec.at(1)=(n/100)%10;
  vec.at(2)=(n/10)%10;
  vec.at(3)=n%10;
  
  if(vec.at(0)==vec.at(1) && vec.at(1)==vec.at(2))
    cout << "Yes" << endl;
  else if(vec.at(1)==vec.at(2) && vec.at(2)==vec.at(3))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
n = int(input())
D = list(map(int,input().split()))
m = int(input())
T = list(map(int,input().split()))
ans = "YES"
dict = {}
keyword = set(D) | set(T)
for d in keyword:
    dict.update({d:0})
for d in D:
    dict[d]+=1
for t in T:
    dict[t]-=1
    if dict[t]<0:
        ans = "NO"
        break
print(ans)


Measured memory_bytes: 68916
using System;
using System.Linq;
namespace ABC126
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ').ToArray();

            int N = int.Parse(line[0]);
            int K = int.Parse(line[1]);

            // Console.WriteLine($"{N} {K}");

            var S = Console.ReadLine().ToArray();

            S[K - 1] = (char)((int)S[K - 1] + 32);

            for(var i = 0; i < N; i++)
            {
                Console.Write(S[i]);
            }
            Console.WriteLine();
            
        }
    }
}


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

using namespace std;

int main(){
    string s;
    int n;
    //s = "ABCZ";
    //n = 4;
    cin >> n;
    cin >> s;

    for (int i = 0; i < s.size(); ++i) {
        char ch = (s[i] + n - 'A')%26 + 'A';
        cout << ch;

    }
  cout << endl;


}


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

long long f[1 << 16];

int a[16][16],n;

int rx, ry;

void process()
{
    f[rx] = max(f[rx] , f[ry] + f[rx^ry]);
}

void rec(int i)
{
    if (i<n)
    {
        if (rx & (1 << i))
        {
            ry = ry ^ (1 << i); rec(i+1);
            ry = ry ^ (1 << i); rec(i+1);
        }
        else
        {
            rec(i+1);
        }
    }
    else
    {
        process();
    }
}


int main()
{
    cin >> n;
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<n; j++)
        {
            cin >> a[i][j];
        }
    }
    bitset<16> b;
    for (int s=1; s<(1<<n) ;s++)
    {
        b = s;
        if (b.count() >= 2)
            for (int i=0; i<n; i++)
            {
                if (b[i])
                for (int j=i+1; j<n; j++)
                {
                    if (b[j])
                        f[s] += a[i][j];
                }
            }
    }
    for (int s=1; s<(1<<n) ;s++)
    {
        b = s;
        if (b.count() >= 2)
        {
            rx = s;
            ry = 0;
            rec(0);
        }
    }
    cout << f[(1 << n) - 1];
    return 0;
}


Measured memory_bytes: 768
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
constexpr ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&a!=c||a==c&&a!=b||b==c&&a!=b)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N; cin >> N;
    vector<ll> a(N);
    for(int i=0; i<N; i++) cin >> a[i];
    sort(a.begin(), a.end());
    ll n = a[N-1];

    ll r, maxv = -1;
    for(int i=0; i<N-1; i++){
        ll tmp = min(a[i], n-a[i]);
        if(maxv < tmp){
            maxv = tmp;
            r = a[i];
        }
    }

    cout << n << " " << r << endl;
}

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

using namespace std;
using ll = long long;
using ii = pair<int, int>;
#define ff first
#define ss second
#define pb push_back

const int N = 100005;

int main(){
	int n;
	ll xo = 0;
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		ll x;
		scanf("%lld", &x);
		xo |= x & 1;
	}
	printf("%s\n", xo ? "first" : "second");
	return 0;
}



Measured memory_bytes: 256
#include<cmath>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#include<utility>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fori(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int dX[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }, dY[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
/*
(char)'1' - (int)48 = (int)1;


*/


int main()
{
	vector<int> a;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int k;
		cin >> k;
		a.push_back(k);
	}
	sort(a.begin(), a.end());
	int ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int k;
		cin >> k;
		for (int l = 0; l < (int)a.size(); l++)
		{
			if (a[l] == k)
			{
				ans++;
				break;
			}
			if (a[l]>k)break;
		}


	}
	cout << ans << endl;
}

Measured memory_bytes: 1324
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1ll;while(b){if(b&1)ans=ans*a%MOD;a=a*a%MOD;b>>=1;}return ans;}
inline void getInt(int* p);
const int maxn=1000010;
const int inf=100000000;
/*** TEMPLATE CODE * * STARTS HERE ***/
int d[500][500];
int n,m;
int a[maxn];
int b[maxn];
int c[maxn];
int main()
{
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin);
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout);
	gbtb;
	cin>>n>>m;
	repd(i,1,m)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	repd(i,1,n)
	{
		repd(j,1,n)
		{
			d[i][j]=(i==j?0:inf);
		}
	}
	repd(i,1,m)
	{
		d[a[i]][b[i]]=min(d[a[i]][b[i]],c[i]);
        d[b[i]][a[i]]=min(d[b[i]][a[i]],c[i]);
	}
	repd(k,1,n)
	{
		repd(i,1,n)
		{
			repd(j,1,n)
			{
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	int ans=0;
	repd(k,1,m)
	{
		if(d[a[k]][b[k]]<c[k])
		{
			ans++;
		}
	}
	cout<<ans<<endl;

	
	
    return 0;
}

inline void getInt(int* p) {char ch;do {ch = getchar();} 
while (ch == ' ' || ch == '\n');if (ch == '-') {*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 - ch + '0';}}
else {*p = ch - '0';while ((ch = getchar()) >= '0' && ch <= '9') 
{*p = *p * 10 + ch - '0';}}}

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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];
#define debug(x) cout << #x << "= " << x<< endl;
// template starts
typedef long long int ll;

// template ends here

void solve(){
	// code starts from here
	ll D, T, S;
	cin >> D >> T >> S;
	if(S*T >= D) cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main(){
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	int T;
	T = 1;
	while(T--){
		solve();
	}

	return 0;
}


Measured memory_bytes: 3596
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))
#define ALL(x) (x).begin(), (x).end()
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((a) >> (b)) & 1
#define bitcount(a) __builtin_popcountll((a))
//
typedef long long lint;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;
//
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0};
const int dy[] = {0, -1, 1, 0, 0};
//
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N, A, B;
int X[101010];

signed main() {
  cin >> N >> A >> B;

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

  int sum = 0;
  for (int i = 1; i < N; i++) {
    int dist = X[i] - X[i - 1];
    sum += min(dist * A, B);
  }

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
	int angka,c=0;
	
	scanf("%d", &angka);
	
	for(int i=1; i<=angka; i++){
		if(i>0&&i<10) c++;
		else if(i>99&&i<1000) c++;
		else if(i>9999&&i<100000) c++;
	}
	
	printf("%d\n", c);
	return 0;
}

Measured memory_bytes: 128
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=15;
char s[N];int n;
int main(){
	scanf("%d%s",&n,s+1);
	printf("%s\n",n>=3200?s+1:"red");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<array>
using namespace std;
int main(){
int R;
cin>>R;
if(R<1200){
  cout<<"ABC"<<endl;
}else if(R<2800){
  cout<<"ARC"<<endl;
}else{
  cout<<"AGC"<<endl;
}
















}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

char A[110];
int main(){
    int N;
    cin >> N;
    REP(i,N){
        char c;
        cin >> c;
        A[i] = c;
    }

    int x = 0;
    int y = 0;
    REP(i,N){
        if(A[i] == '('){
            x++;
        }else{
            if(x > 0) x--;
            else y++;
        }
    }

    REP(i,y){
        printf("(");
    }
    REP(i,N){
        printf("%c", A[i]);
    }
    REP(i,x){
        printf(")");
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#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(){
	int N; 
	cin>>N; 
	vector<string>s(N);
	rep(i,N){
		cin>>s.at(i);
	}
	int M; 
	cin>>M; 
	vector<string>t(M);
	rep(i,M){
		cin>>t.at(i);
	}
	vector<string>u(N+M);
	rep(i,N){
		u.at(i)=s.at(i);
	}
	rep(i,M){
		u.at(N+i)=t.at(i);
	}
	int max=0;
	int money=0;
	rep(i,N+M){
		rep(j,N){
			if(u.at(i)==s.at(j)){
				money+=1;
			}
		}
		rep(k,M){
			if(u.at(i)==t.at(k)){
				money-=1;
			}
		}
		if(money>max){
			max=money;
		}
		money=0;
	}
	cout<<max<<endl;
return 0;}

/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll i,j,k,n,m,a[100010],l,r,ans;
bool check(ll H){
	for(ll i=m;i<=n;i++){
		ll u=a[i]-a[i-m+1];
		if(u<=H)return 1;
	}return 0;
}
int main(){
	cin>>n>>m;
	for(i=1;i<=n;i++)
		scanf("%lld",&a[i]);
	sort(a+1,a+1+n);
	l=0;
	r=(ll)1000000000;
	ans=(ll)1000000000;
	while(r>=l){
		ll Mid=(l+r)/2;
		if(check(Mid))r=Mid-1,ans=Mid;
		else l=Mid+1;
	}cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		Integer a[] = new Integer[N];

		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}

		Arrays.sort(a,Collections.reverseOrder());

		int cnt = 0;

		for (int i = 0; i < a.length; i++) {

			if(i==0) {
				cnt ++;
			} else if (i != 0 && a[i] != a[i - 1]) {
				cnt ++;
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 23508
// Learn more about F# at http://fsharp.org

open System

[<EntryPoint>]
let main _argv =
    stdin.ReadLine()
    |> (fun s ->
         match s with
         | "A" -> "T"
         | "T" -> "A"
         | "C" -> "G"
         | "G" -> "C"
         | _ -> "Invalid")
    |> printfn "%s"
    
    0 // return an integer exit code


Measured memory_bytes: 11868
# AOJ 0029 English Sentence

words = gets.chomp.split

frequency = Hash.new {|hash, key| hash[key] = 0}
words.each do |word|
  frequency[word] += 1
end

most_frequent_word = nil
max_frequency = 0
frequency.each do |word, f|
  if f > max_frequency
    most_frequent_word = word
    max_frequency = f
  end
end

longest_word = nil
max_length = 0
words.each do |word|
  if word.length > max_length
    longest_word = word
    max_length = word.length
  end
end

puts [most_frequent_word, longest_word].join(" ")

Measured memory_bytes: 6108
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


//k!
ll facctorialMethod(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum = sum%MOD*i%MOD;
    }
    return sum%MOD;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int n,k;cin>>n>>k;
    vector<int> v(n);
    rep(i,n)cin>>v[i];
    int dp[100010];
    Fill(dp,INF);
    dp[0] = 0;
    for(int i = 1;i<n;i++){
        for(int j = 1; j<=k;j++){
            if(i < j)break;
            dp[i] = min(dp[i],dp[i-j]+abs(v[i]-v[i-j]));
        }
    }
    cout << dp[n-1] << endl;
}



Measured memory_bytes: 1024
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 
public class Main {
 
    static Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) throws Exception {
        int N = sc.nextInt();
        int P = sc.nextInt();
        String S = sc.next();
 
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = S.charAt(i) - '0';
        }
 
        long ans = 0;
 
        if (P == 2 || P == 5) {
            int c = 0;
            for (int i = N - 1; i >= 0; i--) {
                if (A[i] % P == 0) {
                    c++;
                }
                ans += c;
            }
        } else {
            int m = 0;
            int k = 1;
            Map<Integer, Integer> count = new HashMap<>();
            count.put(0, 1);
            for (int i = N - 1; i >= 0; i--) {
                m = (A[i] * k + m) % P;
 
                Integer c = count.get(m);
 
                if (c == null) {
                    c = 1;
                } else {
                    ans += c;
                    c++;
                }
 
                count.put(m, c);
 
                k = (k * 10) % P;
            }
        }
 
        System.out.println(ans);
    }
 
}

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


Measured memory_bytes: 25516
#include <iostream>

int main(){
   int N, M;
   std::cin >> N >> M;
   int a, b;
   int count[N];
   for(int i=0; i<N; ++i) count[i] = 0;
   for(int i=0; i<M; ++i){
      std::cin >> a >> b;
      count[--a]++;
      count[--b]++;
   }
   for(int i=0; i<N; ++i)
      std::cout << count[i] << std::endl;

   return 0;
}


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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  string D(K, '0');
  for (int i = 0; i != K; ++i)
    cin >> D[i];
  while (to_string(N).find_first_of(D) != string::npos)
    ++N;
  cout << N << endl;
  return 0;
}


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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,bottom,ceiling) for(auto (i) = (bottom); (i) <= (ceiling); ++(i))
#define repD(i,ceiling,bottom) for(auto (i) = (ceiling); (i) >= (bottom); --(i))
#define repV(i,v) for(auto (i) = begin(v); (i) < end(v); ++(i))
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define divceil(n,d) ((n)/(d) + ((n)%(d) > 0))
#define parity(a,b) (((a) & 1LL)^((b) & 1LL)^1LL)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = (int)1e9 + 7;

ull next_subset(ull subset){
	ull tem = subset + (subset & -subset);
	ull btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}

int n,m,s,t;
ll cost_1[100001],cost_2[100001];
vector<pair<int,int>> adj_1[100001],adj_2[100001];

void solve(){
	
	fill(all(cost_1),INF_64);
	queue<int> q;
	cost_1[s] = 0;
	q.push(s);
	
	while(!q.empty()){
		int p = q.front();
		q.pop();
		rep(i,adj_1[p].size()){
			int v = adj_1[p][i].fir;
			int c = adj_1[p][i].sec; 
			if(cost_1[v] <= cost_1[p] + c) continue;
			cost_1[v] = cost_1[p] + c;
			q.push(v);
		}
	}
	
	fill(all(cost_2),INF_64);
	cost_2[t] = 0;
	q.push(t);
	
	while(!q.empty()){
		int p = q.front();
		q.pop();
		rep(i,adj_2[p].size()){
			int v = adj_2[p][i].fir;
			int c = adj_2[p][i].sec; 
			if(cost_2[v] <= cost_2[p] + c) continue;
			cost_2[v] = cost_2[p] + c;
			q.push(v);
		}
	}
	
	ll res[100001];
	res[n] = INF_64;
	
	repD(i,n-1,0){
		res[i] = min(res[i+1],cost_1[i+1] + cost_2[i+1]);
	}
	
	rep(i,n) cout<<1000000000000000-res[i]<<endl;
	
	return;
}

void input(){
	
	cin>>n>>m>>s>>t;
	rep(i,m){
		int u,v,a,b; cin>>u>>v>>a>>b;
		adj_1[u].pub(mkp(v,a));
		adj_1[v].pub(mkp(u,a));
		adj_2[v].pub(mkp(u,b));
		adj_2[u].pub(mkp(v,b));
	}
	
	return;
}

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





Measured memory_bytes: 16256
#include <stdio.h>          // printf(), putchar(), fgets()
#include <stdbool.h>
#include <ctype.h>          // isalpha()

const char NUL = '\0';
char line[1025];

bool
is_word(const char *t, const char *s, int l)
{
	if (l < 3 || 6 < l)
		return false;

	if (t >= line && *t != ' ' && *t != '.' && *t != ',')
		return false;

	if (*s != ' ' && *s != '.' && *s != ',' && *s != '\n' && *s != NUL)
		return false;

	return true;
}

int
main(int argc, char **argv)
{
	char word[7];

	fgets(line, sizeof(line), stdin);

	const char *s = line;
	const char *sep = "";
	while (*s != '\n' && *s != NUL)
	{
		while (!isalpha(*s) && *s != '\n' && *s != NUL)
			s++;

		int l = 0;
		int ix = 0;
		const char *t = s;
		for (; isalpha(*s) || *s == '\''; ++s, ++l)
		{
			if (l <= 6)
				word[ix++] = *s;
		}

		word[ix] = NUL;
		if (is_word(t - 1, s, l))
		{
			printf("%s%s", sep, word);
			sep = " ";
		}
	}

	putchar('\n');
	return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long H, long long N, std::vector<long long> A){
    int sum=0;
    for(int i=0;i<N;i++){
        sum += A[i];
    }
    if(sum>=H){
        cout <<"Yes"<<endl;
    }else{
        cout << "No" << endl;
    }

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H;
    scanf("%lld",&H);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(H, N, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
	int n; cin>>n;
  	vector<ll> a(n);
  	for(int i =0 ; i<n;i++)
      cin>>a[i];
  	vector<ll> dp(n);
  	dp[0] = 0LL;
  	if(n>1)
      dp[1] = abs(a[1]-a[0]);
  	for(int i = 2 ; i < n; i++)
      dp[i] =  min(dp[i-1] + abs(a[i-1] - a[i]), dp[i-2] + abs(a[i-2]-a[i]));
  	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 4832
import itertools

n, m = list(map(int, input().split()))
stl = [[] for _ in range(n)]

for i in range(m):
    a = input().split()
    for x in a[1:]:
        stl[int(x)-1].append(i)

ps = list(map(int, input().split()))

count = 0
for comb in itertools.product([True, False], repeat=n):
    cs = [0 for _ in range(m)]
    for i, t in enumerate(comb):
        if t:
            for l in stl[i]:
                cs[l] += 1

    if all([cs[i] % 2 == ps[i] % 2 for i in range(m)]):
        count += 1

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define _h cout<<"here"<<endl;
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define rep(i,n) for(int i=0;i<n;i+=1)
#define prd(a,n) rep(i,n) cout<<a[i]<<" \n"[i==n-1];// printf("%s\n"," " );
#define ff first
#define ss second
#define pu push_back
const int inf = 1e9+10;
const ll INF = 2e18+10;
const int Mod = 1e9+7;
const int MAXN = 1000010;
const int N=2e5+10;
const int M=210;
const int M1=1e9+7;
const int M2=1e9+9;
const int base=131;
int a[N];
int main()
{
  ios::sync_with_stdio(0), cin.tie(0); cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  int n,k;
  cin>>n>>k;
  for(int i=1;i<=n;i++) cin>>a[i];
  for(int i=k+1;i<=n;i++)
  {
    if(a[i]>a[i-k]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 4416
import java.util.*;

public class Main{
	public static void main(String args[]){
        Scanner sc1 = new Scanner(System.in);
        int a = sc1.nextInt();
        int b = sc1.nextInt();
        int c = sc1.nextInt();
        if(a == 7 && b == 5 && c == 5){
            System.out.print("YES");
        }else if(a == 5 && b == 7 && c == 5){
            System.out.print("YES");
        }else if(a == 5 && b == 5 && c == 7){
            System.out.print("YES");
        }else{
            System.out.print("NO");
        }
    }
}

Measured memory_bytes: 21204
#include<stdio.h>
#include<algorithm>
int*it,shop[100001],n,m,d,i;
main(){
	for(;scanf("%d%d%d",&d,&n,&m),shop[i=n]=d;i=!printf("%d\n",i)){
		for(;--i;)
			scanf("%d",shop+i);
		for(std::sort(shop,shop+n);m--;i+=std::min(*it - d, d - it[-1] ))
			scanf("%d",&d),
			it = std::upper_bound( shop, shop+n, d );
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <string.h>
#define LL long long
#include <vector>
#define siz 100005
#include <queue>
using namespace std;
int n;
int q,k;
struct node{
    int to;
    LL va;
};
vector<node>vec[siz];
LL dis[siz];
void bfs(int u,int fa){
    queue<node>que;
    node x,y;
    x.to = u;
    x.va = 0;
    que.push(x);

    while(!que.empty()){
       // int x,y;
       // cout<<"---------------"<<endl;
        x= que.front();
        que.pop();
        LL xx = x.to;
        LL xv = x.va;
       // cout<<xx<<endl;
        int len = vec[xx].size();
       // cout<<len<<endl;
        for(int i=0;i<len;i++){
            if(vec[xx][i].to!=u&&dis[vec[xx][i].to]==0){
                y.to = vec[xx][i].to;
                y.va = vec[xx][i].va+xv;
                dis[y.to] = y.va;
               // cout<<y.va<<" "<<dis[y.to]<<endl;
                que.push(y);
            }
        }
    }
}
void solve(){

  // cout<<q<<"--"<<k<<endl;
   bfs(k,-1);
   int a,b;
   while(q--){
    scanf("%d%d",&a,&b);
    LL ans = dis[a]+dis[b];
        cout<<ans<<endl;
   }
}
int main()
{

    while(~scanf("%d",&n)){
            for(int i=0;i<siz;i++){
        vec[i].clear();
        dis[i] = 0;
   }
        int x,y,v;
        for(int i=1;i<n;i++){
            scanf("%d%d%d",&x,&y,&v);
            node u;
            u.to = y;
            u.va = v;
            vec[x].push_back(u);
            u.to = x;
            vec[y].push_back(u);
        }
       // cout<<vec[1].size()<<endl;
      //  cout<<"--------------"<<endl;
        scanf("%d%d",&q,&k);
        solve();
    }
    return 0;
}


Measured memory_bytes: 10736
def opecode?(str)
  if (str=="+" || str=="-" || str=="/" || str=="*")
    true
  end
end

def calculation(nums,ope)
  if nums.size == 2
    if ope == "+"
      res = nums[0]+nums[1]
    elsif ope == "-"
      res = nums[0]-nums[1]
    elsif ope == "/"
      res = nums[0]/nums[1]
    else
      res = nums[0]*nums[1]
    end
    nums.delete_at(0)
    nums.delete_at(0)
    nums.insert(0,res)
  else
    if ope == "+"
      res = nums[-2]+nums[-1]
    elsif ope == "-"
      res = nums[-2]-nums[-1]
    elsif ope == "/"
      res = nums[-2]/nums[-1]
    else
      res = nums[-2]*nums[-1]
    end
    nums.delete_at(-1)
    nums.delete_at(-1)
    nums.insert(-1,res)
  end
  nums
end

def stack_calc
  array = readline.split(/[[:space:]]/)
  num_array=[]
  ans = 0
  array.each do |val|
    if opecode?(val)
      ans = calculation(num_array,val)
    else
      num_array.push val.to_i
    end
  end
  ans
end

puts stack_calc

Measured memory_bytes: 6880
// 2015/07/03 Tazoe

#include <iostream>
using namespace std;

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

	int M;
	cin >> M;

	int A[101];
	for(int i=1; i<=M; i++){
		cin >> A[i];
	}

	int S[101] = {0};

	for(int i=1; i<=M; i++){
		for(int j=1; j<=N; j++){
			int B;
			cin >> B;

			if(B==A[i]){
				S[j]++;
			}
			else{
				S[A[i]]++;
			}
		}
	}

	for(int j=1; j<=N; j++){
		cout << S[j] << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
int main(){
	string s;
	cin>>s;
	int mx=0;
	string t="";
	for(int i=0;i<s.size()-1;i++){
		t+=s[i];
		if(t.size()%2)continue;
		string t1="";
		string t2="";
		for(int j=0;j<t.size();j++){
			if(j<t.size()/2)t1+=t[j];
			else t2+=t[j];
		}
		if(t1==t2)mx=max(mx,i+1);
	}
	cout<<mx<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
long long n,m,i,j,a[100005];
int main()
{
	scanf("%lld%lld",&n,&m);
	fz1(i,n){
		scanf("%lld",&a[i]);
	}
	int mx=1;
	fz(i,2,n-1){
		if(a[i]+a[i+1]>a[mx]+a[mx+1]){
			mx=i;
		}
	}
	if(a[mx]+a[mx+1]<m){
		puts("Impossible");
		return 0;
	}
	puts("Possible");
	fz1(i,mx-1){
		printf("%lld\n",i);
	}
	fd(i,n,mx+1){
		printf("%lld\n",i-1);
	}
	return 0;
}

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

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define ll long long int
const int N = 1e6+10;

vector <int> adj[N];
int n,m;

int main() {
    scanf("%d %d",&n,&m);
    for (int i = 1; i <= m; i++) {
        int u,v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for (int i = 0; i < adj[1].size(); i++) {
        int u = adj[1][i];
        for (int j = 0; j < adj[u].size(); j++) {
            if (adj[u][j] == n) {
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}

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

int main(){
  string sumo;
  cin >> sumo;
  
  int count = 0;
  
  for( int i = 0; i < sumo.size(); i++ ){
    if( sumo.at(i) == 'x' ){
      count += 1;
    }
  else
    count == count;
  }
  
  if( count >= 8 ){
    cout << "NO" << endl;
  }
  
  else if( count < 8 ){
    cout << "YES" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000

typedef struct node{
  int left;
  int right;
  int p;

}Node;

Node node[MAX];
int depth[MAX];

void  depthSearch(int a,int b){
  depth[a]=b;
  if(node[a].left!=-1)depthSearch(node[a].left,b+1);

  if(node[a].right!=-1)depthSearch(node[a].right,b);
}

int main(){
  int i,j;
  int n;
  int id;
  int k;
  int c;
  int l;

  int a;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    node[i].p=-1;
    node[i].right=-1;
    node[i].left=-1;
  }
  
  for(i=0;i<n;i++){
    scanf("%d",&id);
    scanf("%d",&k);

    if(k!=0){
      for(j=0;j<k;j++){
	scanf("%d",&c);
	if(j==0)node[id].left=c;
	else {
	  node[l].right=c;
	}
	l=c;
	node[l].p=id;
      }
    }
  }

  for(i=0;i<n;i++){
    if(node[i].p==-1)depthSearch(i,0);    
  }



  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,node[i].p,depth[i]);

    if(node[i].p==-1){
      printf("root, ");
      printf("[");
    
      for(j=0,a=node[i].left; a!=-1 ;a=node[a].right,j++){
	if(j==0)printf("%d",a);
	else printf(", %d",a);
  }
      printf("]\n");
    }

    else if(node[i].left==-1){
      printf("leaf, ");
      printf("[]\n");
    }

    else {
      printf("internal node, ");
      printf("[");
      
      for(j=0,a=node[i].left; a!=-1 ;a=node[a].right,j++){
	if(j==0)printf("%d",a);
	else printf(", %d",a);
      }
      printf("]\n");

    }
      
  }
  return 0;
}



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

int main(){
	long long int a,b,n;
	cin>>n>>a>>b;
	if((a+b)&1){
		if(a>b)	swap(a,b);
		cout<<(b-a+1)/2+min(a-1,n-b)<<endl;
	}
	else{
		cout<<abs(a-b)/2<<endl;
	}
}


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

import sys
input=sys.stdin.readline

n,x,m=map(int,input().split())
values=[]
s=set()
loop_start=-1
for i in range(n):
    if x in s:
        loop_start=values.index(x)
        break
    values.append(x)
    s.add(x)
    x=(x*x)%m
if loop_start==-1:
    ans=sum(values)
    print(ans)
    exit()
else:
    ans=sum(values[:loop_start])
    loops=values[loop_start:]
    loops_sum=sum(loops)
    n-=loop_start
    l=len(loops)
    ans+=n//l*loops_sum+sum(loops[:n%l])
    print(ans)

Measured memory_bytes: 76084