akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 using namespace std;
 #define ll long long int
 int main()
  {   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
       ll c=0,x,i,j,n,y,e;
        cin>>n;
         ll a[n],sum=0;
          for(i=0;i<n;i++)
             {cin>>a[i];
              c=max(c,a[i]);
             }
             ll b[c+1]={0};
              for(i=0;i<n;i++)
               b[a[i]]++;
             y=0;
             for(i=2;i<=c;i++)
             {  x=0;
                 for(j=i;j<=c;j+=i)
                  x+=b[j];
                  if(x>1)
                  { y=1;
                   break;
                  }
             }
               if(y==0)
                cout<<"pairwise coprime"<<endl;
               else
               {  e=a[0];
                  for(i=0;i<n;i++)
                    e=__gcd(e,a[i]);
                   if(e!=1)
                    cout<<"not coprime"<<endl;
                   else
                    cout<<"setwise coprime"<<endl;
               }
  }


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

int main(void){
    int N, M, pbuf;
    string Sbuf;

    cin >> N >> M;
    vector<int> WAs(N, 0);
    vector<bool> ifAC(N, false);

    for(int i=0; i<M; i++){
        cin >> pbuf >> Sbuf;
        pbuf--;
        if(ifAC[pbuf])continue;
        if(Sbuf=="AC"){
            ifAC[pbuf]=true;
        }else{
            WAs[pbuf]++;
        }
    }

    int penalty=0;
    int cleared=0;
    for(int i=0; i<N; i++){
        if(ifAC[i]){
            penalty += WAs[i];
            cleared++;
        }
    }

    cout << cleared << ' ' << penalty << endl;

    return 0;
}

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

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

	for(int n; cin >> n && n;) {
		int sum = 0;
		for(int i = 0; i < n / 4; ++i) {
			int hit;
			cin >> hit;
			sum += hit;
		}
		cout << sum << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1192
from collections import deque

def BFS(t):
    tree=[[] for i in range(n)]
    for i in list:
      tree[i[0]-1].append(i[1]-1)
      tree[i[1]-1].append(i[0]-1)

    dist=[-1 for i in range(n)]
    dist[t-1]=0

    que=deque()
    que.append(t-1)
    while que:
        x=que.popleft()
        for p in tree[x]:
            if dist[p]==-1:
                que.append(p)
                dist[p]=dist[x]+1
    return dist

n,u,v=map(int,input().split())
list=[list(map(int,input().split())) for i in range(n-1)]

u_dist=BFS(u)
v_dist=BFS(v)

l=0
for u_d,v_d in zip(u_dist,v_dist):
 if u_d<v_d:
  l=max(l,v_d)

print(l-1)

Measured memory_bytes: 49104
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  if(a < b){
    int temp = a+b;
    a = temp - a;
    b = temp - b;
  }
  int c = 1;
  if(b == 0)return a;
  while(c != 0){
    c = a%b;
    if(c == 0)return b;
    a = b;
    b = c;
  }
}
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0;i < n;i++)cin >> a[i];
  int lgcd[n+1];
  int rgcd[n+1];
  lgcd[0] = 0;
  rgcd[n] = 0;
  //0~i-1番目までの累積gcd
  for(int i = 0;i < n;i++)lgcd[i+1] = gcd(lgcd[i],a[i]);
  //n~i番目までの累積gcd
  for(int i = n-1;i >= 0;i--)rgcd[i] = gcd(rgcd[i+1],a[i]);
  int MAX;
  MAX = 0;
  for(int i = 0;i < n;i++){
    int l = lgcd[i];
    int r = rgcd[i+1];
    MAX = max(MAX,gcd(l,r));
  }
  cout << MAX << endl;
}

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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, w;
    cin >> n >> w;
    vector<int> weight(n), v(n);
    for(int i = 0; i < n; ++i) {
        cin >> weight[i] >> v[i];
    }
    int MX = n * 1000 + 10;
    vector<int> dp(MX, (int) 1e9 + 1);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int val = MX - 1; val >= 0; --val) {
            if(val + v[i] < MX) {
                dp[val + v[i]] = min(dp[val + v[i]], dp[val] + weight[i]);
            }
        }
    }
    
    for(int val = MX - 1; val >= 0; --val) {
        if(dp[val] <= w)
            return cout << val << '\n', 0;
    }
}

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

int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  if(s.at(k-1)=='A')
    s.at(k-1)='a';
  else if(s.at(k-1)=='B')
    s.at(k-1)='b';
  else if(s.at(k-1)=='C')
    s.at(k-1)='c';
  cout << s;
}

Measured memory_bytes: 256
N = int(input())
S = input()

cnt = 0
o = 0
for s in S:
    if s == '(':
        cnt -= 1
    else:
        cnt += 1
        if cnt > o:
            o = cnt
c = o - cnt
o, c = max(o, 0), max(c, 0)

ans = '(' * o + S + ')' * c
print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int K = sc.nextInt();
        String S = sc.next();
      String ans = S;
      if(S.length() > K) ans = S.substring(0, K) + "..." ;
      System.out.println(ans);
    } 
}

Measured memory_bytes: 38556
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()



int main(){
  ll N,ans=0;
  cin >> N;
  vector<int64_t> P(1000000,0),W(1000000,0);
  P.at(0)=2;
  ll t=0;
  for(ll i=3;i<=1000000;i++){
    ll a=0;
    for(ll j=0;j<=t;j++){
      if(P.at(j)*P.at(j)>i){
        break;
      }
      if(i%P.at(j)==0){
        a=1;
        break;
      }
    }
    if(a==0){
      t++;
      P.at(t)=i;
    }
  }
  for(ll i=0;i<=t;i++){
    while(N%P.at(i)==0){
      N/=P.at(i);
      W.at(i)++;
    }
    ll x=1;
    while(W.at(i)>0){
      if(W.at(i)>=x){
        ans++;
        W.at(i)-=x;
        x++;
      }else{
        W.at(i)=0;
      }
    }
  }
  if(N!=1){
    ans++;
  }
  cout << ans << endl;
  
  
}

Measured memory_bytes: 18808
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		int E = sc.nextInt();
		int F = sc.nextInt();

		sc.close();

		List<Integer> x = new ArrayList<>(); // F以下の、あり得る水の量
		for (int ai = 0; ai * A * 100 <= F; ai++) {
			for (int bi = 0; ai * A * 100 + bi * B * 100 <= F; bi++) {
				x.add(ai * A * 100 + bi * B * 100);
			}
		}

		List<Integer> y = new ArrayList<>(); // F以下の、あり得る砂糖の量
		for (int ci = 0; ci * C <= F; ci++) {
			for (int di = 0; ci * C + di * D <= F; di++) {
				y.add(ci * C + di * D);
			}
		}

		double con = Double.NEGATIVE_INFINITY;
		int ans1 = 0;
		int ans2 = 0;

		for (int w : x) {
			for (int s : y) {
				if (w + s > F) {
					continue;
				}
				if (s * 100 <= E * w) { //溶けきるか
					double con2 = (double) s / (s + w);
					if (con < con2) {
						con = con2;
						ans1 = w + s;
						ans2 = s;
					}
				}
			}
		}

		out.println(ans1 + " " + ans2);

	}

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


Measured memory_bytes: 29672
#include <iostream>
#include <iomanip>
#include <vector>
#include <tuple>
#include <algorithm>

typedef long long ll;
using namespace std;
int main (){
    int n,m;
    cin >> n >> m;
    vector<tuple<ll,ll,ll>> pref(m);
    vector<ll> newpref(m);
    for (int i = 0; i < m; i++){
        cin >> get<0>(pref[i]) >> get<1>(pref[i]);
        get<2>(pref[i])=i;
    }
    sort(pref.begin(),pref.end());
//    for (int i = 0; i < m; i++){
//        cout << get<0>(pref[i]) << " " << get<1>(pref[i]) << " " << get<2>(pref[i]) << "\n";
//    }
    ll idx=1;
    newpref[get<2>(pref[0])]=get<0>(pref[0])*1000000+idx;
    for (int i = 1; i < m; i++){
        if(get<0>(pref[i])!=get<0>(pref[i-1])) idx=1;
        else idx++;
        newpref[get<2>(pref[i])]=get<0>(pref[i])*1000000+idx;
    }

    for (int i = 0; i < m; i++){
        cout << std::setw(12) << std::setfill('0') << newpref[i] << "\n";
    }

}

Measured memory_bytes: 4608
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

signed main() {
  string s;
  cin >> s;
  s += '?';
  for (int i = 1; i < s.length()-1; i++) {
    if (s[i-1] == s[i]) {
      cout << i << ' ' << i+1;
      return 0;
    }
    if (s[i-1] == s[i+1]) {
      cout << i << ' ' << i+2;
      return 0;
    }
  }
  cout << -1 << ' ' << -1;
}


Measured memory_bytes: 512
#include <cstdlib>
#include <iostream>
#include <stack>
#include <string>
#include <sstream>
using namespace std;

bool IsNumber(const std::string& s) {
  string::const_iterator it = s.begin();
  while (it != s.end() && isdigit(*it)) ++it;
  return !s.empty() && it == s.end();
}

int main() {
  string line;
  getline(cin, line);

  stack<int> S;
  string str;
  istringstream iss(line);
  while (iss >> str) {
    if (IsNumber(str)) {
      S.push(atoi(str.c_str()));
    } else {
      if (str == "+") {
        int rhs  = S.top();
        S.pop();
        int lhs  = S.top();
        S.pop();
        S.push(lhs + rhs);
      } else if (str == "-") {
        int rhs  = S.top();
        S.pop();
        int lhs  = S.top();
        S.pop();
        S.push(lhs - rhs);
      } else if (str == "*") {
        int rhs  = S.top();
        S.pop();
        int lhs  = S.top();
        S.pop();
        S.push(lhs * rhs);
      }
    }
  }

  cout << S.top() << endl;

  return 0;
}


Measured memory_bytes: 3232
# coding:utf-8


def main():
    R, G, B, N = map(int, input().split())
    ans = 0
    rgb_list = [R, G, B]
    rgb_list.sort()
    for r in range(int(N/rgb_list[-1])+1):
        tempN = N - r * rgb_list[-1]
        # print(r)
        if tempN == 0:
            ans += 1
            # print(r, 0, 0)
            continue
        for g in range(int(N/rgb_list[-2])+1):
            # print(g)
            tempN2 = tempN - g * rgb_list[-2]
            if tempN2 == 0:
                ans += 1
                continue
            elif tempN2 < 0:
                break
            else:
                if tempN2 % rgb_list[0] == 0:
                    ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 40688
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] input = Console.ReadLine().Split(' ');
                int t = int.Parse(input[0]);
                int h = int.Parse(input[1]);
                int s = int.Parse(input[2]);

                if (t == -1) break;

                int sec1 = 7200 - t * 60 * 60 - h * 60 - s;
                int sec2 = sec1 * 3;

                Console.WriteLine(new TimeSpan(0, 0, sec1));
                Console.WriteLine(new TimeSpan(0, 0, sec2));
            }
        }
    }
}

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

const int N = 10005;

int n;
string s[N];
string t;

bool can_smaller(string &a, string &b) {
  int sz = min((int)a.size(), (int)b.size());
  for (int i = 0; i < sz; ++i) {
    if (b[i] == '?') {
      if (a[i] == 'z') continue; else return true;
    }
    if (a[i] == '?') {
      if (b[i] == 'a') continue; else return true;
    }
    if (a[i] != b[i]) return a[i] < b[i];
  }
  return a.size() <= b.size();
}

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

  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> s[i];
  cin >> t;

  int l = n, r = 0;
  for (int i = 1; i <= n; ++i) {
    if (can_smaller(t, s[i])) --l;
  }
  for (int i = 1; i <= n; ++i) {
    if (!can_smaller(s[i], t)) ++r;
  }

  printf("%d", l + 1);
  for (int i = l + 2; i <= n + 1 - r; ++i) {
    printf(" %d", i);
  }
  printf("\n");
}

Measured memory_bytes: 896
#include<iostream>
#include<vector>

int main(){
	int n;
	int ans=0;
	std::vector<int> aList(100000, 0);

	std::cin>>n;

	for(int i=0; i<n; i++){
		int tmp;
		std::cin>>tmp;
		aList[tmp-1]++;
	}

	int right= 99999;
	int left= 0;

	while(right > left){
		if(aList[right]<=1){
			right--;
			continue;
		}

		if(aList[left]<=1){
			left++;
			continue;
		}

		aList[right]--;
		aList[left]--;
	}

	int redNum= 0;
	if(right == left){
		aList[right]= 2- aList[right]%2;
		redNum= aList[right]- 1;
	}

	for(int i=0; i<100000; i++)
		if(aList[i]>0)
			ans++;

	ans-= redNum;

	std::cout<<ans<<std::endl;

	return 0;
}

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

int main(void) {
  string s, t;
  cin >> s >> t;
  int n = s.length(), m = t.length();
  vector<vector<int>> dp(n + 10, vector<int>(m + 10, 0));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++)
      if (s[i - 1] == t[j - 1]) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
      } else {
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      }
  }

  int i = n, j = m;
  string ans = "";
  while (i >= 1 && j >= 1) {
    if (s[i - 1] == t[j - 1] && dp[i][j] == dp[i - 1][j - 1] + 1) {
      ans = s[i - 1] + ans;
      i--;
      j--;
    } else if (dp[i][j] == dp[i - 1][j]) {
      i--;
    } else {
      j--;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {
    string s;
    getline(cin, s);
    stringstream ss(s);

    stack<int> sta;
    string tmp;

    while (getline(ss, tmp, ' ')) {
        if ('0' <= tmp[0] && tmp[0] <= '9') {
            sta.push(stoi(tmp));
            continue;
        }

        int a = sta.top();
        sta.pop();
        int b = sta.top();
        sta.pop();

        switch (tmp[0]) {
            case '+':
                sta.push(b + a);
                break;
            case '-':
                sta.push(b - a);
                break;
            case '*':
                sta.push(b * a);
                break;
            default:
                break;
        }
    }
    cout << sta.top() << endl;
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

int main(){
    int N, M;
    cin>>N>>M;
    int Ans=0;
    Ans+=N*(N-1)/2;
    Ans+=M*(M-1)/2;
    cout<<Ans<<endl;
}


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

int main() {
	//vars;
	string w;
	bool flag = false;	//違う文字があるか;
	
	cin >> w;
	if (w.size() % 2 != 0)cout << "No" << endl;
	else {
		sort(w.begin(), w.begin() + w.size());
		for (int i = 0; i < w.size(); i += 2) {
			if (w[i] != w[i + 1]) {
				flag = true;
				break;
			}
		}
		if (flag == false)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

int mat[505][505];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int H, W, h, w;
	long long sum = 0;
	int i, j;
	
	cin>>H>>W>>h>>w;
	
	if (h * w == 1)
	{
		cout<<"No\n";
		return 0;
	}
	
	int x = 999999999 / (h * w - 1);
	for (i = 0; i < H; ++i) for (j = 0; j < W; ++j)
	{
		mat[i][j] = (i % h == h - 1 && j % w == w - 1 ? -(h * w - 1) * x - 1 : x);
		sum += mat[i][j];
	}
	
	if (sum <= 0)
	{
		cout<<"No\n";
		return 0;
	}
	cout<<"Yes\n";
	for (i = 0; i < H; ++i)
	{
		for (j = 0; j < W; ++j)
			cout<<mat[i][j]<<' ';
		cout<<'\n';
	}
}


Measured memory_bytes: 3968
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    // #pragma GCC optimize("Ofast")
    using namespace std;
    //library
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define F first
    #define S second
    #define pb push_back
    #define mkp make_pair
    #define int long long
    #define ld long double
    //scankar
    #define sz(x) (int)(x).size()
    #define all(x) x.begin(),x.end() 
    #define rall(x) x.rbegin(),x.rend()
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    typedef map<int,int> mii;
    typedef map<int,bool> mib;
    typedef map<char,int> mci;
    typedef map<string,int> msi;
    
    const int INF = 1e18L + 5;
    const int MAX = 2e6 + 7;
    const int MOD =  1000000007;
    const long double PI  =3.141592653589793238463;
    //direction
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ D $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;
    //debugger

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    int isprime[MAX];
    int spf[MAX];
    vector<int> vs;
    // 0 waale prime h,1 is non-prime
    void sieve()
    {
        fo(i,1,MAX)spf[i]=i;
        isprime[0]=isprime[1]=spf[0]=spf[1]=1;
    
        fo(i,2,MAX)
        {
            if(!isprime[i])
            {
                // vs.pb(i);
                for(int j=2*i;j<MAX;j+=i)
                {
                    isprime[j]=1;
                    if(j==spf[j])
                    spf[j]=i;
                }
            }
        }
    }

    int val,x,ans,tot,cnt;
    void solve()
    {
        cin>>n;
        // fo(i,2,10)deb(spf[i])
        fo(i,1,n)
        {
            x=n-i;
            ans=1;
            while(x>1)
            {
                val=spf[x];cnt=0;
                while(x>1 && x%val==0)cnt++,x/=val;
                ans*=(cnt+1);
            }
            tot+=ans;
        }
        cout<<tot<<endl;
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          THE GAME STARTS HERE                             //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        cout.tie(NULL);
        sieve();
        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

Measured memory_bytes: 34888
#include <stdio.h>
#include<iostream>
#include <algorithm>
#include <math.h>

using namespace std;
int max(int a,int b,int c){
	return max(max(a,b),max(b,c));
}
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int m = max(a,b,c);
	if((m*3-a-b-c)%2==1){
		cout<<(m*3-a-b-c)/2+2<<endl;
	}else{
		cout<<(m*3-a-b-c)/2<<endl;
	}
}



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

#define INF 1<<29
#define F first
#define S second;

typedef pair<int,int>P;
typedef struct{
  int cost,to;
}Edge;
int n,m;
vector<Edge>g[21];
int D[21];
int starts,goal; 

int daikusutora();

int main(){
  int a,b,c,d;
  int money,hasi;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    scanf("%d,%d,%d,%d",&a,&b,&c,&d);
    a--;b--;
    g[a].push_back((Edge){c,b});
    g[b].push_back((Edge){d,a});
  }
  scanf("%d,%d,%d,%d",&starts,&goal,&money,&hasi);
  starts--;goal--;
  money-=hasi;
  money-=daikusutora();
  money-=daikusutora();
  cout<<money<<endl;
}

int daikusutora(){
  for(int i=0;i<21;i++){
   D[i]=INF;
  }
  priority_queue<P,vector<P>,greater<P> >que;
  D[starts]=0;
  que.push(P(0,starts));
  while(!que.empty()){
    P p=que.top();que.pop();
    int now =p.F;
    int place =p.S;
    for(int i=0;i<g[place].size();i++){
      if(D[g[place][i].to]>now+g[place][i].cost){
	D[g[place][i].to]=now+g[place][i].cost;
	que.push(P(D[g[place][i].to],g[place][i].to));
      }
    }
  }
  int temp;
  temp=starts;
  starts=goal;
  goal=temp;
  return D[starts];
}

Measured memory_bytes: 1264
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long max = Long.MIN_VALUE;
		long min = Long.MAX_VALUE;
		for (int i = 0; i < N; i++) {
			long a = sc.nextLong();
			max = Math.max(max, a);
			min = Math.min(min, a);
		}
		System.out.println(max - min);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LLINF = 9223372036854775807;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

struct xy {
	int x;
	int y;
	int d;
};

int main() {
	int h, w; cin >> h >> w;
	vector<vector<char>> s(h, vector<char>(w));
	REP(i, h)REP(j, w)cin >> s[i][j];
	queue<xy> q; int ans = 0;
	REP(i, h)REP(j, w) {
		if (s[i][j] == '#')
			continue;
		else {
			vector<vector<bool>> f(h, vector<bool>(w, false));
			q.push({ i,j });
			f[i][j] = true;
			while (!q.empty()) {
				int x = q.front().x;
				int y = q.front().y;
				int d = q.front().d;
				q.pop();
				ans = max(ans, d);
				if (x != 0) {
					if (s[x - 1][y] == '.' && !f[x - 1][y]) {
						f[x - 1][y] = true;
						q.push({ x - 1, y,d + 1 });
					}
				}
				if (x != h - 1) {
					if (s[x + 1][y] == '.' && !f[x + 1][y]) {
						f[x + 1][y] = true;
						q.push({ x + 1, y,d + 1 });
					}
				}
				if (y != 0) {
					if (s[x][y - 1] == '.' && !f[x][y - 1]) {
						f[x][y - 1] = true;
						q.push({ x, y - 1,d + 1 });
					}
				}
				if (y != w - 1) {
					if (s[x][y + 1] == '.' && !f[x][y + 1]) {
						f[x][y + 1] = true;
						q.push({ x, y + 1,d + 1 });
					}
				}
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
    int N, M;
    scanf("%d %d",&N,&M);
    char line[M];
    for (int i=0; i<N; i++){
        scanf("%s",line);
        printf("%s\n",line);
        printf("%s\n",line);
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ff(i, x, n, k) for(int i=x;i<n;i+=k)
#define rf(i, x, n, k) for(int i=n-1;i>=x;i+=k)
#define ef(i, x, n, k) for(int i=x;i<=n;i+=k)
#define pb push_back
#define eb emplace_back
#define pp pop_back
#define mp make_pair
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int MOD = 1e9+7;
const ll INF = pow(10, 18)+5;

int main()
{
	fast_cin();
	long long n; cin >> n;
	long long arr[n];
	for (int i = 0; i < n; i ++)
		cin >> arr[i];

	long long dp[n] = {0};

	for (int i = 0; i < n; i ++){
		if (i == 0)
			dp[i] = 0;
		else 
			dp[i] = min(dp[i - 1] + abs(arr[i - 1] - arr[i]), dp[i - 2] + abs(arr[i - 2] - arr[i]));
	}

	cout << dp[n - 1] << '\n';

	return 0;
}

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

#define sc second
#define fr first

#define ll long long
#define pi pair<int,int>
#define ppi pair<pi,pi>
#define mp make_pair
using namespace std;


int main()
{

	ios::sync_with_stdio(0);
    cin.tie(0) , cout.tie(0);


	ll n, k; cin >> n >> k;
	vector<ll>v1, v2;
	for (int i = 0; i < n; i++)
	{
		int x; cin >> x;
		if (x <= 0)
			v1.push_back(x);
		else
			v2.push_back(x);
	}
	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());

	ll Fans = -2e18;
	ll s = -1e18, e = 1e18;
	while (s <= e)
	{
		ll mid = (s + e) / 2;
		ll cnt = 0;
		for (int i = 0; i < v1.size(); i++)
		{
			int s1 = 0, e1 = (int)v1.size() - 1;
			int ans = -1;
			while (s1 <= e1)
			{
				int mid1 = (s1 + e1) / 2;
				if (v1[i] * v1[mid1] <= mid)
				{
					ans = mid1;
					e1 = mid1 - 1;
				}
				else{
					s1 = mid1 + 1;
				}
			}
			if (ans != -1)
			{
				cnt += (int)v1.size() - ans;
				if (v1[i] * v1[i] <= mid)cnt--;
			}
			s1 = 0, e1 = (int)v2.size() - 1;
			ans = -1;
			while (s1 <= e1)
			{
				int mid1 = (s1 + e1) / 2;
				if (v1[i] * v2[mid1] <= mid)
				{
					ans = mid1;
					e1 = mid1 - 1;
				}
				else{
					s1 = mid1 + 1;
				}
			}
			if (ans != -1)
				cnt += (int)v2.size() - ans;
		}
		for (int i = 0; i < v2.size(); i++)
		{
			int s1 = 0, e1 = (int)v1.size() - 1;
			int ans = -1;
			while (s1 <= e1)
			{
				int mid1 = (s1 + e1) / 2;
				if (v2[i] * v1[mid1] <= mid)
				{
					ans = mid1;
					s1 = mid1 + 1;
				}
				else{
					e1 = mid1 - 1;
				}
			}
			if (ans != -1)
			{
				cnt += ans + 1;
			}
			s1 = 0, e1 = (int)v2.size() - 1;
			ans = -1;
			while (s1 <= e1)
			{
				int mid1 = (s1 + e1) / 2;
				if (v2[i] * v2[mid1] <= mid)
				{
					ans = mid1;
					s1 = mid1 + 1;
				}
				else{
					e1 = mid1 - 1;
				}
			}
			if (ans != -1)
			{
				cnt += ans + 1;
				if (v2[i] * v2[i] <= mid)cnt--;
			}
		}
		if (cnt / 2 >= k)
			Fans = mid, e = mid - 1;
		else{
			s = mid + 1;
		}
	}
	cout << Fans << '\n';
	assert(Fans != -2e18);

	return 0;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  int a,b;
  queue<pair<int,int>> que;
  vector<pair<int,int>> pairs;
  for(int i=0; i<m; i++){
    cin >> a >> b;
    pairs.push_back(make_pair(b,a));
  }
  sort(pairs.begin(),pairs.end());
  for(int i=0; i<m; i++){
    que.push(pairs.at(i));
  }
  int ans=0;
  //cout << que.size() << endl;
  while(que.size()){
    queue<pair<int,int>> tmp;
    pair<int,int> p = que.front();que.pop();
    int dan = p.first;
    ans++;
    while(que.size()){
      pair<int,int> np = que.front();que.pop();
      if(dan<=np.second){
        tmp.push(np);
      }
    }
    que = tmp;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2676
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;
/*
//単一連結リストの実装
struct ListNode {
	int data;
	struct ListNode* next;
};*//*
int ListLength(struct ListNode* head) {
	struct ListNode* current = head;
	int count = 0;
	while (current != NULL) {
		count++;
		current = current -> next;
	}
	return count;
}
*/

int main()
{
	int n = 0;
	int owari = 11451414;
	int result[50010] = {};
	int sa = owari;
	int count = 0;
	while (true) {
		int dataset[50010];
		cin >> n;
		if (n == 0) break;
		for (int i = 0; i < n; i++) {
			cin >> dataset[i];
		}
		sort(dataset, dataset + n);
		sa = owari;
		for (int i = 1; i < n; i++) {
			if (abs(dataset[i] - dataset[i - 1]) < sa) {
				sa = abs(dataset[i] - dataset[i - 1]);
			}
		}
		result[count] = sa;
		count++;
	}
	for (int i = 0; i < count; i++) {
		cout << result[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 3356
#include <iostream>
#include <string>

int main() {
    std::string str1, str2;
    std::cin >> str1;
    std::cin >> str2;

    int count=0;
    for(int i=0; i<str1.length(); i++) {
        if(str1[i] != str2[i]) 
            count++;
    }
    std::cout << count <<std::endl;
}

Measured memory_bytes: 3896
import re
s = input().replace("a","x").replace("b","x").replace("c","x").replace("d","x").replace("e","x").replace("f","x").replace("g","x").replace("h","x").replace("i","x").replace("j","x").replace("k","x").replace("l","x").replace("m","x").replace("n","x").replace("o","x").replace("p","x").replace("q","x").replace("r","x").replace("s","x").replace("t","x").replace("u","x").replace("v","x").replace("w","x").replace("y","x").replace("z","x")
print(s)

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] values = input.Split(' ');
            int N = int.Parse(values[0]);
            int M = int.Parse(values[1]);
 
            int s ;

            s = N * (N-1)/2 + M * (M - 1) / 2;

            Console.WriteLine((s).ToString());
        }
    }
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

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

Measured memory_bytes: 256
s = input()
k = int(input())
alpha = 'abcdefghijklmnopqrstuvwxyz'
n = len(s)
lis = set()
for i in range(26):
    for j in range(len(s)):
        if s[j] == alpha[i]:
            for l in range(j, j+k+1):
                if l < n:
                    lis.add(s[j:l+1])
lis = list(lis)
lis.sort()
#print(lis)
#print(k)
print(lis[k-1])

Measured memory_bytes: 41200
#include <iostream>
using namespace std;
int main(void){
int n;
  cin>>n;
  for(int j = 0;j < n;j++){
 int i,o;
 cin>>i>>o;
if (i % o != 0){
cout << i%o << endl;
}
	else cout << o << endl;
    }
    }



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  int N;
  cin >> N;
  vector<char> C(N);
  REP(i, N) cin >> C[i];
  ll ans = 0;
  int l = 0, r = N - 1;
  while (r - l > 0) {
    while (C[l] == 'R' && l < N - 1) l++;
    while (C[r] == 'W' && 0 < r) r--;
    if (r - l <= 0) break;
    swap(C[l], C[r]);
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
// AOJ 0272: The Lonely Girl's Lie
// 2017.10.14 bal4u@uu
// 2017.11.25

#include <stdio.h>
#include <string.h>

int a[40003], b[40003];
int f[100002];

char buf[280002], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, i, j, k, ans;
	int v, vmin, vmax;

	while (fgets(p=buf, 10, stdin) && *p != '0') {
		n = getint();

		for (j = 0; j < 2; j++) {
			memset(f, 0, sizeof(f));
			fgets(p=buf, sizeof(buf), stdin);
			vmin = vmax = v = getint(), p++, f[v]++;
			i = n-1; while (i--) {
				v = getint(), p++, f[v]++;
				if (v < vmin) vmin = v;
				else if (v > vmax) vmax = v;
			}
			if (!j) for (k = 0, i = vmax; i >= vmin; i--) while (f[i]) a[k++] = i, f[i]--;
			else    for (k = 0, i = vmax; i >= vmin; i--) while (f[i]) b[k++] = i, f[i]--;
		}

		for (ans = n, i = k = 0; k < n; i++, k += 2) {
			if (a[k] > b[i]) { ans = k + 1; break; }
		}
		if (ans == n) puts("NA");
		else printf("%d\n", ans);
	}
	return 0;
}

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

struct UF{
	int par[4000];
	int rank[4000];
	int si[4000];

	void init(int n){
		rep(i,n){
			par[i] = i;
			rank[i] = 0;
			si[i] = 1;
		}
	}

	int find(int x){
		if(par[x] == x) return x;
		else return par[x] = find(par[x]);
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;
		
		if(rank[x] < rank[y]){
			par[x] = y;
			si[y] += si[x];
		} else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
			si[x] += si[y];
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
} uf;
int n, m, k;
bool saw[4000];
ll sum = 0;
vector<PP> e;
vector<P> ee[4000];
ll par[30][4000];
ll cnt[30][4000];
ll dep[4000];

ll lca(int s, int t){
    ll ret = 0;
    if(dep[s] > dep[t]){
        ll dif = dep[s]-dep[t];
        for(int i = 0;;i++){
            if(dif == 0) break;
            if(dif&1){
                ret = max(ret,cnt[i][s]);
                s = par[i][s];
            }
            dif /= 2;
        }
    }
    if(dep[s] < dep[t]){
        ll dif = dep[t]-dep[s];
        for(int i = 0;;i++){
            if(dif==0)break;
            if(dif&1){
                ret = max(ret,cnt[i][t]);
                t = par[i][t];
            }
            dif /= 2;
        }
    }
    //cout << s << " " << t<< " " << ret << endl;
    if(s == t){
        return ret;
    }
    for(int i = 29; i >= 0; i--){
        if(par[i][s] == par[i][t]) continue;
        ret = max(ret,cnt[i][t]);
        ret = max(ret,cnt[i][s]);
        s = par[i][s];
        t = par[i][t];
    }
    ret = max(ret,cnt[0][t]);
    ret = max(ret,cnt[0][s]);
    return ret;
}

void dfs(int v){
    saw[v] = true;
    rep(i,ee[v].size()){
        if(saw[ee[v][i].first]) continue;
        dep[ee[v][i].first] = dep[v]+1;
        dfs(ee[v][i].first);
        par[0][ee[v][i].first] = v;
        cnt[0][ee[v][i].first] = ee[v][i].second;
    }
}

int main(){
    cin >> n >> m;
    uf.init(n);
    rep(i,m){
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        e.push_back(PP(c,P(a,b)));
    }
    sort(e.begin(),e.end());
    rep(i,e.size()){
        if(!uf.same(e[i].second.first,e[i].second.second)){
            uf.unite(e[i].second.first,e[i].second.second);
            ee[e[i].second.first].push_back(P(e[i].second.second,e[i].first));
            ee[e[i].second.second].push_back(P(e[i].second.first,e[i].first));
            //cout << e[i].second.second << " " << e[i].second.first << endl;
            sum += e[i].first;
        }
    }
    //cout << sum << endl;
    dfs(0);
    //rep(i,n) cout << dep[i] << " ";
    //cout << endl;
    for(int j = 1; j < 30; j++){
        rep(i,n){
            par[j][i] = par[j-1][par[j-1][i]];
            cnt[j][i] = max(cnt[j-1][i],cnt[j-1][par[j-1][i]]);
        }
    }
    cin >> k;
    rep(i,k){
        int s, t;
        cin >> s >> t;
        s--; t--;
        cout << sum - lca(s,t) << endl;
    }
}


Measured memory_bytes: 13032
require 'pp'
n, k = gets.split.map(&:to_i)
r, s, p = gets.split.map(&:to_i)
t = gets.chomp.chars


# p t
pre = nil
score = 0
n.times do |i|
  pre = t[i-k] if (i-k >= 0)
  # p pre
  if t[i] == 'r'
    if pre != 'r'
      score += p
    else
      t[i] = nil
    end
  elsif t[i] == 's'
    if pre != 's'
      score += r
    else
      t[i] = nil
    end
  elsif t[i] == 'p'
    if pre != 'p'
      score += s
    else
      t[i] = nil
    end
  end
  # p score
  # puts
end
p score

# 27 211 4996



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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010, mod = 1e9 + 7;

int n;
char s[N];

int qp(int a, int b)
{
	int res = 1;
	while (b)
	{
		if (b & 1) res = (LL)res * a % mod;
		a = (LL)a * a % mod;
		b >>= 1;
	}
	return res;
}

int main()
{
	scanf("%s", s + 1);
	n = strlen(s + 1);
	
	int cnt = 0, res = 0;
	for (int i = 1; i <= n; i ++ )
		if (s[i] == '1')
		{
			res = (res + (LL)qp(2, cnt) * qp(3, n - i) % mod) % mod;
			cnt ++ ;
		}
		
	res = (res + qp(2, cnt)) % mod;
	printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 3932
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll oo = 1e18;
const ll mod = 1e9 + 7,maxn = 100000000;
const double PI = acos(-1);

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll a, b, k;
    cin >> a >> b >> k;
    a-=k;
    if (a < 0) b+=a, a = 0;
    b = max(b, 0LL);
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * @author: pr4shan7 (प्रशांत)
 */
// #define _DEBUG

#ifndef _DEBUG
#define NDEBUG
#endif

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_set;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define ln '\n'
#define x first
#define y second
#define cai static_cast<int>
#define cal static_cast<long long>
const int N = 1e5 + 5;
const int INF = 1e9;
const int MV = 1e9 + 7;

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

#ifdef _DEBUG
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif

	int h, n; cin >> h >> n;
	int ar[n];
	int sum = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> ar[i];
		sum += ar[i];
	}

	if(sum >= h) cout << "Yes" << ln;
	else cout << "No" << ln;
	
	return 0;
}


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

using namespace std;

typedef long long int ll;
#define REP(i, I, N) for (ll i = I; i < N; ++i)
#define rep(i, N) REP(i, 0, N)

int main() {
    ll N, M, A, B, C, ans = 0;
    cin >> N >> M;
    priority_queue<pair<ll, ll>> que;
    rep(i, N) {
        cin >> A;
        que.push(make_pair(A, 1));
    }
    rep(i, M) {
        cin >> B >> C;
        que.push(make_pair(C, B));
    }
    rep(i, N) {
        pair<ll, ll> p = que.top();
        que.pop();
        ans += p.first;
        if (p.second > 1) {
            p.second--;
            que.push(p);
        }
    }

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

Measured memory_bytes: 6512
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;


int main(){
    int n;cin>>n;
    VEC(ll,a,n);
    int c = 0;
    int res = 1;
    rep(i,n-1){
        if(c==0){
            if(a[i]<a[i+1])c=1;
            else if(a[i]>a[i+1])c=2;
            continue;
        }
        else if(c==1){
            if(a[i]>a[i+1]){
                res++;
                c = 0;
            }
        }
        else if(c==2){
            if(a[i]<a[i+1]){
                res++;
                c = 0;
            }
        }
    }
    cout<<res<<endl;
}



Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;
int n,K,a[100010];
int main(){
	scanf("%d%d",&n,&K);
	for(int i=1;i<=n;++i){
		scanf("%d",&a[i]);
	}
	if(n==1){
		if(K==a[1]){
			puts("POSSIBLE");
		}
		else{
			puts("IMPOSSIBLE");
		}
		return 0;
	}
	sort(a+1,a+n+1);
	int GCD=a[1];
	for(int i=2;i<=n;++i){
		GCD=__gcd(GCD,a[i]-a[i-1]);
	}
	if(K<=a[n] && K%GCD==0){
		puts("POSSIBLE");
	}
	else{
		puts("IMPOSSIBLE");
	}
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main (void) {
  int a, b, c;
  int a1, b1, c1;
  int a2, b2, c2;
  
  scanf("%d %d %d", &a, &b, &c);
  a1 = b;
  b1 = a;
  c1 = c;
  a2 = c1;
  b2 = b1;
  c2 = a1;

  printf("%d %d %d\n", a2, b2, c2);

  return 0;
}




Measured memory_bytes: 128
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000


N,M = map(int,input().split())

Graph = [[mod for i in range(N)] for i in range(N)]
for i in range(N):
    Graph[i][i] = 0

routes = []
for i in range(M):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    routes.append([a,b,c])
    Graph[a][b] = c
    Graph[b][a] = c

min_Graph = copy.deepcopy(Graph)
used = [[0 for i in range(N)] for i in range(N)]
for k in range(N):
    for i in range(N):
        for j in range(N):
            min_Graph[i][j] = min(min_Graph[i][j],min_Graph[i][k]+min_Graph[k][j])

ans = 0
for i in range(M):
    a,b,c = routes[i]
    if min_Graph[a][b] == c:
        pass
    else:
        ans += 1

print(ans)


Measured memory_bytes: 6352
/*** Gather the Maps! ***/

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<n; ++i)
#define MAX_N 50
#define DAY 31

int main(){
	int n, m, f;
	bool flag;
	
	cin >> n;
	while(n!=0){
		bool maps[MAX_N][DAY]={};
		set<int> s[MAX_N];
		
		REP(i, n){
			cin >> m;
			REP(j, m){
				cin >> f;
				maps[i][f]=true;
			}
		}
		
		REP(i, MAX_N){
			s[i].insert(i);
		}
		
		for(int day=1; day<DAY; ++day){
			set<int> ss;
			REP(num, n){
				if(maps[num][day]){
					for(auto itr=s[num].begin(); itr!=s[num].end(); ++itr) ss.insert(*itr);
				}
			}
			
			REP(num, n){
				if(maps[num][day]) s[num]=ss;
			}
			
			flag=false;
			REP(num, n){
				if(s[num].size()==n){
					flag=true;
					break;
				}
			}
			if(flag){
				cout << day << endl;
				break;
			}
		}
		
		if(!flag) cout << -1 << endl;
		
		cin >> n;
	}
	return 0;
}

Measured memory_bytes: 3232
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <stack>

#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#pragma GCC optimmize("unroll-loops")

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << "-1\n"; return;}

void solve() {
    int d, t, s;
    cin >> d >> t >> s;
    cout << ((d + s - 1) / s <= t ? "Yes" : "No");
}

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

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


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
    vector<int> c(n-1),s(n-1),f(n-1);
    rep(i,n-1)cin>>c[i]>>s[i]>>f[i];
    rep(i,n){
        int ans = 0;
        rep2(j,i,n-1){
            ans = max(s[j],((ans+f[j]-1)/f[j])*f[j])+c[j];
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n+1);
    rep(i,k){
        int x;
        cin >> x;
        rep(j,x){
            int y;
            cin >> y;
            h[y]++;
        }
    }
    int cnt = 0;
    rep(i,n){
        if(h[i+1] == 0){
            // cout << "i:" << i << " " << h[i+1] << endl;
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3632
while True :
    a, op, b = map(str, input().split())
    a = int(a)
    b = int(b)
    
    if op == "?" :
        break
    else :
        if op == "+" :
            print(a + b)
        elif op == "-" :
            print(a - b)
        elif op == "*" :
            print(a * b)
        else :
            print(a // b)


Measured memory_bytes: 5596
#ABC147　C　やってる途中
n=int(input())
l=[]
for i in range(n):
  a=int(input())
  l_=[]
  for j in range(a):
    xy=list(map(int,input().split()))
    l_.append(xy)
  l.append(l_)
ans=0
for i in range(2**n):
  table=[0]*n
  flag=False
  for j in range(n):
    if (i>>j)&1:
      table[j]=1
  for j in range(n):
    for k in l[j]:
   
      if k[1]!=table[k[0]-1] and table[j]==1:
        flag=True
        break

        if flag:
          break

  if flag==True:
    continue


  ans = max(ans, table.count(1))


print(ans)

Measured memory_bytes: 9204
import sys
import re
import random
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def solve():
    n = getN()
    ans = 0
    cnt = 0
    for i in range(n):
        a, b = getList()
        if a == b:
            cnt += 1
        else:
            cnt = 0
        ans = max(ans, cnt)

    if ans >= 3:
        print("Yes")
    else:
        print("No")

def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

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

int main(){
    deque<char> dq;
    string str;
    char ch;
    int n, q1, q2;
    cin >> str >> n;
    for(char x : str){
        dq.push_back(x);
    }
    bool flag = false;
    rep(i, n){
        cin >> q1;
        if(q1 == 1){
            flag = !flag;
        } else {
            cin >> q2 >> ch;
            if(q2 - 1 == flag){
                dq.push_front(ch);
            } else {
                dq.push_back(ch);
            }
        }
    }
    if(flag) reverse(dq.begin(), dq.end());
    for(char x : dq) cout << x;
    cout << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
 int main()
 {
     char S[3];
     int i,m=0;
 
     scanf("%s",S);
 
     for(i=0;i<3;i++){
       if(S[i]=='o') m++;
     }
 
     printf("%d\n",700+(100*m));
 
     return 0;
 }

Measured memory_bytes: 1672
#include<bits/stdc++.h>
using namespace std;
int main(){
    long n;
    cin >> n;
    long a[n];
    map<long,long>mm;
    long sum = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        mm[a[i]]++;
        sum += a[i];
    }
   long q;
   cin >> q;
   long summ[q];
   for(int i=0;i<q;i++){
       int b,c;
       cin >> b >> c;
       sum += (c-b) * mm[b];
       summ[i] = sum;
       mm[c] += mm[b];
       mm[b] = 0;
   }
   for(int i=0;i<q;i++)cout << summ[i]<<endl;

}

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

for h in range(1, 3501):
    for w in range(1, 3501):
        bns = n * h * w
        bnb = 4 * h * w - n * (h + w)
        if bnb >= 1 and bns % bnb == 0:
            print(h, w, bns // bnb)
            exit()


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


int main() {
  int n;
  cin >> n;
  priority_queue<int> que;
  
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    que.push(a);
  }
  
  int alice = 0; 
  int bob = 0;
  for (int i = 0; i < n; i++) {
    int p = que.top();
    que.pop();
    if (i % 2 == 0) {alice+= p;}
    if (i % 2 == 1) {bob+= p;}
  }
  
  cout << alice - bob << endl;
}

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

using namespace std;

int main() {
    int n, k, m; 
	while(cin >> n >> k >> m, n) {
    	vector<int> flag(n);
    	for (int i = 0; i < n; ++i) flag[i] = i + 1;
    	m--;
    	while (flag.size() != 1) {
			flag.erase(flag.begin() + m);
    	    m = (m + k - 1) % flag.size();
		}
    	cout << flag[0] << endl;
	}

    return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

const ll INF=ll(1e18)+1;

int main(){ //log(INF)*NlogN
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(all(a));
    ll l=-INF,r=INF;
    while(r-l>1){
        ll mid=(l+r)/2;
        ll asum=0;
        rep(i,n){
            if(a[i]<0){
                ll al=-1,ar=n;
                while(ar-al>1){
                    ll amid=(al+ar)/2;
                    if(a[i]*a[amid]<mid) ar=amid;
                    else al=amid;
                }
                asum+=n-ar;
            }else{
                ll al=-1,ar=n;
                while(ar-al>1){
                    ll amid=(al+ar)/2;
                    if(a[i]*a[amid]<mid) al=amid;
                    else ar=amid;
                }
                asum+=ar;
            }
            if(a[i]*a[i]<mid) asum--;
        }
        asum/=2;
        if(asum<k) l=mid;
        else r=mid;
    }
    cout<<l<<endl;
    return 0;
}

Measured memory_bytes: 1792