akhauriyash/Code-Regression huggingface dataset:
/* maybemaybemaybeno */
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef long double ld ;
#define f(i,s,n) for(int i=s;i<(int)n;i++) 
// const int MAXN = 2e5+5 ;
#define pb push_back 
#define X first 
#define Y second 
#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define pli pair<ll,int> 
#define pil pair<int,ll> 
#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setprecision(10) ;
#define is(x) cout<<#x<<" : "<<x<<endl ;
// #define DEBUG

int main()
{
    fio ;
    /* ======================Start of code ================ */
    ld a,b,h,m;cin>>a>>b>>h>>m ;
    ld thetaH = h*30+(m/2) ;
    ld thetaM = 6*m ;
    ld thetaB = abs(thetaH-thetaM) ;
    ld rad = (M_PI*thetaB)/180 ;

    ld ans = sqrt(a*a+b*b-2*a*b*cos(rad)) ;
    cout<<setprecision(18)<<ans<<"\n" ;
    /* ======================End of code ================== */
}

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

int n, i, j, k;
bool v[100005];
string a, b[4] = {"dream", "erase", "dreamer", "eraser"};
int main()
{
	cin >> a;
	v[a.size()] = 1;
	for (i = a.size() - 1; i >= 0; i--) {
		for (j = 0; j < 4; j++) {
			if (i + b[j].size() > a.size()) continue;
			for (k = 0; k < b[j].size(); k++) {
				if (a[i + k] != b[j][k]) break;
			}
			if (k == b[j].size() && v[i + b[j].size()]) break;
		}
		if (j < 4) v[i] = 1;
	}
	cout << (v[0] ==1 ? "YES" : "NO");
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main()
{
  long long int n, a, b;
  scanf("%lld %lld %lld", &n, &a, &b);

  long long int d = n/(a+b);
  long long int m = n%(a+b);
  
  long long int ans = d*a;
  if(m>a) ans += a;
  else ans += m;
  
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	var A, B, C int
	fmt.Scan(&A, &B, &C)
	a1 := A*10 + B + C
	a2 := A + B*10 + C
	a3 := A + B + C*10
	fmt.Println(max(max(a1, a2), a3))
}


Measured memory_bytes: 512
n,m=gets.split.map(&:to_i)
d=n.times.map{[100000]*n}
n.times{|i|d[i][i]=0}
path=$<.map{|s|
  a,b,c=s.split.map(&:to_i)
  a-=1
  b-=1
  d[a][b]=c
  d[b][a]=c
  [a,b,c]
}
n.times{|i|
  n.times{|j|
    n.times{|k|
      d[j][k]=[d[j][k],d[j][i]+d[i][k]].min
    }
  }
}
puts path.count{|(a,b,c)|c>d[a][b]}


Measured memory_bytes: 2172
#include <bits/stdc++.h>
using namespace std;
const int maxn=100005;
bool vis[maxn];
int main(int argc, char const *argv[])
{
	ios::sync_with_stdio(false);
	int n;
	while(cin>>n){
		int x,y;
		memset(vis,0,sizeof(vis));
		for(int i=0;i<n;i++){
			cin>>x>>y;
			for(int j=x;j<=y;j++){
				vis[j]=1;
			}
		}
		int ans=0;
		for(int i=0;i<maxn;i++){
			if(vis[i]) ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

struct mint {
    const int mod = 1e9 + 7;
    ll x;
    
    mint (ll x = 0) : x((x % mod + mod) % mod) {
        
    }
    
    mint& operator=(const long long a) {
        x = a % mod;
        return *this;
    }
    
    mint& operator=(const mint a) {
        x = a.x % mod;
        return *this;
    }
    
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    
    mint& operator-=(const mint a) {
        if ((x += (mod - a.x)) >= mod) x -= mod;
        return *this;
    }
    
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    
    mint inv() const {
        return pow(mod - 2);
    }
    
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    const int mod = 1e9 + 7;
    int n, m;
    cin >> n >> m;
    vector<int> s(n), t(m);
    rep(i, n) cin >> s[i];
    rep(i, m) cin >> t[i];
    vector<vector<mint>> dp(n + 1, vector<mint>(m + 1, 0));
    rep(i, n + 1) dp[i][0] = 1;
    rep(i, m + 1) dp[0][i] = 1;
    reps(i, 1, n + 1) {
        reps(ii, 1, m + 1) {
            dp[i][ii] = dp[i][ii - 1] + dp[i - 1][ii];
            if (s[i - 1] != t[ii - 1]) dp[i][ii] -= dp[i - 1][ii - 1];
        }
    }
    cout << dp[n][m].x << endl;
    return 0;
}


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

int main(){
    int n;
    int a[100];
    int i;
    
    cin >> n;
    for (i = 0; i < n; i++){
        cin >> a[i];
    }
    
    for (i = n-1; i >= 0; i--){
        if (i != 0){
            cout << a[i] << " ";
        }else{
            cout << a[i] << endl;
        }   
    }

    return 0;
}

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

int N, A[1 << 20], C[1 << 20];
long long ans = 0;

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

    for(int c = 1;c < N;c++) {
      
      int l = 0, r = N-1;
      long long tans = 0;
      while(l < N) {
        C[l]++;C[r]++;
        if(C[l] > 1 || C[r] > 1) {
           break;
        }
        tans += A[l] + A[r];
        if(N - 1 - l  > c) {
        	ans = max(ans, tans);
        }
        l += c;
        r -= c;
      }
     
      l= 0; r =N-1;
      while ( l<N) {
       C[l] =C[r] = 0;
       l += c;
       r -= c;
      }
    }
    cout << ans;
	return 0;
}

Measured memory_bytes: 2688
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

constexpr int MAXN = 2e5 + 42;

vector<int> grafo[MAXN];
ll sum[MAXN];

void dfs(int v, int u) {
  for (int i : grafo[v]) {
    if (i != u) {
      sum[i] += sum[v];
      dfs(i, v);
    }
  }
}

int main() {
  int N, Q;
  cin >> N >> Q;
  for (int i = 1; i < N; i++) {
    int a, b;
    cin >> a >> b;
    grafo[a].push_back(b);
    grafo[b].push_back(a);
  }
  for (int i = 0; i < Q; i++) {
    int x, p;
    cin >> p >> x;
    sum[p] += x;
  }
  dfs(1, 1);
  for (int i = 1; i <= N; i++) {
    cout << sum[i] << ' ';
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 24320
N = int(input())
AB = []
for _ in range(N):
    AB.append(tuple(map(int, input().split())))

AB.sort(key=lambda x: (x[1], x[0]))

t = 0
for a, b in AB:
    t += a
    if t > b:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 44512
#include<bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Fore(i,a,b) for(int i=a;i>=b;i--)
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mkp make_pair
#define pb push_back
#define sz size()
#define met(a,b) memset(a,b,sizeof(a))
#define iossy ios::sync_with_stdio(false)
#define fr freopen
#define pi acos(-1.0)
#define Vector Point
typedef pair<int,int> pii;
const long long linf=1LL<<62;
const int iinf=1000000009;
const double dinf=1e17;
const int Mod=1e9+9;
typedef long long ll;
typedef long double ld;
const int maxn=1000005;
int n,ans;
int a[maxn];
int b[maxn];
int r1[maxn],r2[maxn];
int vs1[100005],vs2[100005];
int rt1,rt2;
bool cmp1(int a,int b){
	return vs1[a]>vs1[b];
}
bool cmp2(int a,int b){
	return vs2[a]>vs2[b];
}
int chk(){
	int cnt=0;
	For(i,3,n) b[i]=b[i-2];
	For(i,1,n) if(a[i]!=b[i]) cnt++;
	return cnt;
}
void solve(){
	iossy;
	cin>>n;ans=iinf;met(vs1,0);met(vs2,0);rt1=0;rt2=0;
	For(i,1,n) {
		cin>>a[i];
		if(i%2){
			vs1[a[i]]++;
			if(vs1[a[i]]==1) r1[rt1++]=a[i];
		}else {
			vs2[a[i]]++;
			if(vs2[a[i]]==1) r2[rt2++]=a[i];
		}
	}
	sort(r1,r1+rt1,cmp1);
	sort(r2,r2+rt2,cmp2);
	For(i,0,min(100,rt1-1)){
		For(j,0,min(100,rt2-1)){
			b[1]=r1[i];b[2]=r2[j];
			if(b[1]==b[2]){
				if(vs1[b[1]]>=vs2[b[2]]) b[2]++;
				else b[1]++;
			}
			ans=min(ans,chk());
		}
	}
	cout<<ans<<endl;
}
int main(){
	int t=1;
	while(t--) solve();
	return 0;
}


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

#define ll long long
#define pi acos(-1)
#define valid(a , b) a >= 0 && a < r && b >= 0 && b < c && arr[a][b] == '.'

int main()
{
    //ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    /*
    #ifndef ONLINE_JUDGE
    freopen("input.cpp", "r" , stdin);
    //freopen("output.cpp" , "w" , stdout);
    #endif // ONLINE_JUDGE
    //*/
    int a , b;cin >> a >> b;
    cout << (int)ceil(a * 1.0 /b) << endl;
    return 0;
}


Measured memory_bytes: 256
a=input()
b=input()
if len(a)>len(b):
    print("GREATER")
elif len(a)<len(b):
    print("LESS")
else:
    for i in range(len(a)):
        if int(a[i])>int(b[i]):
            print("GREATER")
            break
        elif int(a[i])<int(b[i]):
            print("LESS")
            break
        else:
            pass
    else:
        print("EQUAL")

Measured memory_bytes: 9116
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}
inline int  in(){int n;scanf("%lld",&n);return n;}
inline void out(int n){printf("%lld\n",n);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int n;
int a(int a){
    int cnt=0;
    while(true){
        if(a&1) return cnt;
        a/=2;
        cnt++;
    }
}

signed main(){
    io();
    cin>>n;
    vi vec(n);
    int sum=0;
    rep(i,n) {
        cin>>vec[i];
        sum+=a(vec[i]);
    }
    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 384
import sys
import math
input = lambda:sys.stdin.readline().strip()
def f(a,b,x):
    return (a*x)//b-(a*(x//b))
a,b,n = map(int,input().split())
if n<b-1:
    print(f(a,b,n))
else:
    print(f(a,b,b-1))

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;

int f(long long x) {
    return (x > 0) ? +1 : -1;
}

void normalize(pair<long long, long long> &p) {
    long long g = __gcd(p.first, p.second);
    p.first /= g;
    p.second /= g;

    if(p.first == 0) {
        p.second = 1;
    }

    if(p.second == 0) {
        p.first = -1;
    }

    if(f(p.first) * f(p.second) > 0) {
        if(p.first < 0) {
            p.first *= -1;
            p.second *= -1;
        }
    } else {
        if(p.first > 0) {
            p.first *= -1;
            p.second *= -1;
        }
    }
}

long long quickPow(long long a, long long b) {
    if(b == 0)
        return 1;

    long long ans = quickPow(a, b / 2);

    ans = (ans * ans) % MOD;
    if(b % 2)
        ans = (ans * a) % MOD;

    return ans;
}

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

    int n;  cin >> n;
    vector<pair<long long, long long> > a(n);

    for(auto &val : a)  cin >> val.first >> val.second;

    map<pair<long long, long long>, long long> mp;

    long long cnt00 = 0;

    for(auto val : a) {
        if(val == make_pair(0LL, 0LL)) {
            cnt00++;
            continue;
        }
        normalize(val);
        mp[val]++;
    }

    long long ans = 1;

    for(auto link : mp) {
        auto vect = link.first;
        long long cnt = link.second;

        if(cnt == 0)
            continue;

        auto solve = [&](pair<long long, long long> &perp) -> bool {
            if(mp[perp] > 0) {
                long long a = cnt;
                long long b = mp[perp];
                long long mult = ((quickPow(2, a) + quickPow(2, b)) % MOD);
                mult = (((mult - 1) % MOD) + MOD) % MOD;
                ans = (ans * mult) % MOD;
                //cerr << "!!! " << vect.first << ' ' << vect.second << ' ' << mult << '\n';
                mp[perp] = 0;
                return true;
            }

            return false;
        };

        //cerr << vect.first << ' ' << vect.second << ' ' << quickPow(2, cnt) << '\n';

        decltype(vect) perp = {vect.second, -vect.first};

        if(solve(perp)) {
            continue;
        }

        perp = {-vect.second, vect.first};

        if(solve(perp)) {
            continue;
        }

        ans = (ans * quickPow(2, cnt)) % MOD;
    }

    ans = (((ans - 1) % MOD) + MOD) % MOD;

    ans = (ans + cnt00) % MOD;

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 43688
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> a(3);
    rep(i, 3) {
      cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans;
    ans = abs(a[0] - a[1]) + abs(a[1] - a[2]);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        int c = input.nextInt();
        if ((a < b) && (b < c))
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 26220
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll f(ll n){
    return (n*n + 4) / 8;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string O,E;
    cin >> O >> E;
    ll N = O.size() + E.size();
    rep(i,0,N){
        if(i % 2 == 0){
            cout << O[i/2];
        }else{
            cout << E[i/2];
        }
    }
    cout << endl;
}

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

int main() {
int64_t n,k;
cin>>n>>k;
vector<int64_t> a(n);
for(int i=0;i<n;i++){
cin>>a.at(i);
}
  int count=0;
for(int i=0;i<n;i++){
  if(a.at(i)>=k){
    count++;
  }
}

cout<<count;



}

Measured memory_bytes: 1024
from sys import stdin

# 各文字を分かりやすいようにintで
A = 0
G = 1
C = 2
T = 3

# mod定義
mod = 10**9 + 7

# 3 <= N <= 100
N = int(stdin.readline().rstrip())

# dp[101][4][4][4]の初期化
dp = [[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(101)]


"""
# ダメな条件
AGC(012)
GAC(102)
ACG(021)
A?GC(0?12)
AG?C(01?2)

# 変数の定義
c1: 後ろから3番目の文字
c2: 後ろから2番目の文字
c3: 後ろから1番目の文字
a: 追加する文字列
"""

dp[0][T][T][T] = 1

for i in range(N):
    for c1 in range(4):
        for c2 in range(4):
            for c3 in range(4):
                for a in range(4):
                    # ダメな条件の時は処理しない
                    if c2 == A and c3 == G and a == C: continue # AGC
                    if c2 == G and c3 == A and a == C: continue # GAC
                    if c2 == A and c3 == C and a == G: continue # ACG
                    if c1 == A and c3 == G and a == C: continue # A?GC
                    if c1 == A and c2 == G and a == C: continue # AG?C
                    
                    # 足し込む
                    # 例えば ?TAC の4文字の数は ATA, GTA, CTA, TTA の3文字の集合の総数
                    # ただ、上でダメな条件はcontinueしてるので含まれない
                    dp[i+1][c2][c3][a] += dp[i][c1][c2][c3]
                    dp[i+1][c2][c3][a] %= mod

ans = 0

for c1 in range(4):
    for c2 in range(4):
        for c3 in range(4):
            ans += dp[N][c1][c2][c3]
            ans %= mod

print(ans)

Measured memory_bytes: 47216
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

int main() {
	int n;
	scanf( "%d", &n );
	int a, b;
	for ( int i = 0; i < n; i++ ) {
		scanf( "%d %d", &a, &b );
		printf( "%d\n", a % b ? a % b : b );
	}
	return 0;
}

Measured memory_bytes: 1192
#!/usr/bin/env python3
import sys
import math
INF = float("inf")

MOD = 2  # type: int


def solve(N: int, A: "List[int]"):
    m = INF
    for a in A:
        m = min(m, a & -a)
    print(int(math.log2(m)))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s;
	getline(cin, s);
	cout << s;
	if (s[s.size()-1]=='s') cout << "es\n";
	else cout << "s\n";
	return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <algorithm>
#define mod 1000000007
#define MN 405
using namespace std;
int sum[MN][MN],pro[MN][MN],f[MN][MN],a[MN],b[MN];
int n,m;

inline int read()
{
	int n=0,f=1; char c=getchar();
	while (c<'0' || c>'9') {if(c=='-')f=-1; c=getchar();}
	while (c>='0' && c<='9') {n=n*10+c-'0'; c=getchar();}
	return n*f;
}

inline void rw(int& x,int y) {x+=y; if (x>=mod)x-=mod;}

int main()
{
	register int i,j,k;
	n=read(); m=read();
	for (i=1;i<=n;++i) a[i]=read();
	for (i=1;i<=n;++i) b[i]=read();
	for (i=1;i<MN;++i)
		for (pro[i][0]=j=1;j<MN;++j)
			pro[i][j]=1LL*pro[i][j-1]*i%mod;
	for (i=1;i<=n;++i)
		for (j=a[i];j<=b[i];++j)
			for (k=0;k<=m;++k)
				rw(sum[i][k],pro[j][k]);
	f[0][0]=1;
	for (i=1;i<=n;++i)
		for (j=0;j<=m;++j)
			for (k=0;k<=j;++k)
				f[i][j]=(1LL*f[i-1][j-k]*sum[i][k]+f[i][j])%mod;
	printf("%d",f[n][m]);
}

Measured memory_bytes: 2048
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        double[] abcxy = Console.ReadLine().Split().Select(double.Parse).ToArray();
        if (abcxy[0] > abcxy[2] * 2)
        {
            abcxy[0] = abcxy[2] * 2;
        }
        if (abcxy[1] > abcxy[2] * 2)
        {
            abcxy[1] = abcxy[2] * 2;
        }
        if (abcxy[0] + abcxy[1] < abcxy[2] * 2)
        {
            abcxy[2] = (abcxy[0] + abcxy[1]) / 2;
        }
        double min = Min(abcxy[3], abcxy[4]);
        Console.WriteLine(min * abcxy[2] * 2 + Ceiling(abcxy[3] > abcxy[4] ? (abcxy[3] - abcxy[4]) * abcxy[0] : (abcxy[4] - abcxy[3]) * abcxy[1]));
    }
}

Measured memory_bytes: 13396
from sys import stdin
from operator import itemgetter


def main():
    lines = stdin.readlines()
    N, K = map(int, lines[0].split())
    abn = [[int(abi) for abi in line.split()] for line in lines[1:]]
    abn.sort(key=itemgetter(0))
    cnt = 0
    for ai, bi in abn:
        cnt += bi
        if K <= cnt:
            print(ai)
            break
    return


main()


Measured memory_bytes: 29868
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::io::{stdin, stdout, BufWriter, Write};

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>,
}

impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();
    let out = &mut BufWriter::new(stdout());

    let a: i32 = scan.next();
    let b: i32 = scan.next();
    let c: i32 = scan.next();
    if a < b && b < c {
        writeln!(out, "Yes").ok();
    } else {
        writeln!(out, "No").ok();
    }
}



Measured memory_bytes: 5032
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int N,M;
int POW[13],table[1000],sequence[1012];

void func(){

	for(int i = 0; i < N; i++)scanf("%d",&table[i]);

	bool FLG;

	int count,left,right;
	for(int state = 0; state < POW[M]; state++){
		count = 0;
		for(int loop = 0; loop < M; loop++){
			if(state&(1 << loop))count++;
		}
		if(count != table[0])continue;

		for(int loop = 0; loop < M; loop++){
			if(state&(1 << loop)){
				sequence[loop] = 1;
			}else{
				sequence[loop] = 0;
			}
		}

		FLG = true;

		left = 0,right = M;
		for(int i = 1; i <= N-1; i++){
			if(sequence[left] == 1){
				count--;
			}
			if(table[i] < count || table[i] > count+1){
				FLG = false;
				break;
			}

			if(table[i] == count){
				sequence[right] = 0;
			}else{ //table[i] == count+1
				sequence[right] = 1;
				count++;
			}
			left++;
			right++;
		}
		if(!FLG)continue;
		else{
			for(int i = 0; i < N+M-1; i++)printf("%d",sequence[i]);
			printf("\n");
			return;
		}
	}

	printf("Goofy\n");
}


int main(){

	for(int i = 0; i < 13; i++)POW[i] = pow(2,i);

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3384
/*
	Author: Hamza Hasbi
	Copyrights: "h.hamza" ==> "www.hamzahasbi.me"
	Date: 20/08/2017 12:55:18
*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define uld unsigned long double
#define ui unsigned int
#define ud unsigned double
#define uf unsigned float
#define pi 2*acos(0.0)
#define module cin.ignore()
#define rep(i,l,r) for(auto i=l;i<=r;i++)
#define range(x,y) for(auto x:y)
//inline long longlcm(ll a,ll b) {return a*b/__gcd(a,b);}
//inline long long gcd(ll a,ll b) {return 1LL*b == 0 ? a : gcd(1LL*b, a*1LL % b*1LL);}
using namespace std;

int main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	scanf("%d",&n);
	vector<unsigned long long>a(n);
	map<unsigned long long,int>mp;
	for(int i=0;i<n;i++) {
		scanf("%lld",&a[i]);
		mp[a[i]]++;
	}
	sort(a.rbegin(),a.rend());
	unsigned long long h=0,w=0;
	unsigned long long mx=0LL;
	for(int i=0;i<n;i++){
		if(mp[a[i]]<2) continue;
		if(mp[a[i]]>=2){
			if(h==0) h=a[i],mp[a[i]]-=2;
			else if(w==0) w=a[i],mp[a[i]]-=2;
			if(w!=0 && h!=0) {
				mx=max(h*w,mx);
			}
		}
	}
	cout<<mx<<endl;
	return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"


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

	return gcd(b, a % b);
}

int main()
{
	ll a, b, c, d = 0;
	cin >> a >> b >> c >> d;

	ll div_c = b / c - (a - 1) / c;
	ll div_d = b / d - (a - 1) / d;

	ll x = gcd(c, d);
	ll tmp1 = b / (c * d / gcd(c, d));
	ll tmp2 = (a - 1) / (c * d / gcd(c,d));
	ll div_cd = tmp1 - tmp2;

	COUT((b - a + 1) - div_c - div_d + div_cd);


	return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
    int w,h,x,y,r;
    cin>>w>>h>>x>>y>>r;
    if (x-r>=0&&y-r>=0&&x+r<=w&&y+r<=h)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}


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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin>>n;
	
	int arr[n];
	for(int i=0;i<n;i++)
	{
	    cin>>arr[i];
	}
	
	int curr_max = arr[0];
	long long int total_heights = 0;
	
	for(int i=1;i<n;i++)
	{
	    if(arr[i] < curr_max)
	    {
	        total_heights += curr_max - arr[i];
	    }
	    else
	    {
	        curr_max = max(curr_max, arr[i]);
	    }
	}
	
	cout<<total_heights<<'\n';
	
	return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);

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

  vector<int> h(n);
  REP(i,n)cin >> h[i];

  vector<bool> gd(n,true);


  REP(i,m){
    int a,b;
    cin >> a >> b;
    a--; b--;

    if(h[a]>h[b]){
      gd[b] = false;
    }else if(h[a]<h[b]){
      gd[a] = false;
    }else{
      gd[a] = false;
      gd[b] = false;
    }


  }
  int ans=0;
  REP(i,n)if(gd[i])ans++;

  cout << ans << endl;
}



Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (long long i = l; i < r; i++)
using namespace std;
typedef pair<int, int> P;

struct edge {
	int to, cost;
};
class dijkstra {
	int V;
	int d[100002];
	priority_queue<P, vector<P>, greater<P>> que;
	void update(int s, vector<edge> G[]) {
		fill(d, d + V + 1, 100000000000ll);
		d[s] = 0;
		que.push(make_pair(0, s));
		while (!que.empty()) {
			P p = que.top();
			que.pop();
			int v = p.second;
			if (d[v] < p.first) continue;
			rep(i, G[v].size()) {
				edge e = G[v][i];
				if (d[e.to] > d[v] + e.cost) {
					d[e.to] = d[v] + e.cost;
					que.push(make_pair(d[e.to], e.to));
				}
			}
		}
	}

  public:
	dijkstra(int v, int s, vector<edge> G[]) {
		V = v;
		update(s, G);
	}
	int find(int e) {
		return d[e];
	}
};
int gcd(int a, int b) {
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
bool prime(int a) {
	if (a == 1) return false;
	for (int i = 2; i * i <= a; i++) {
		if (a % i == 0) return false;
	}
	return true;
}
class Union_Find {
  private:
	vector<int> t, s;

  public:
	Union_Find(int max_length) {
		rep(i, max_length + 1) {
			t.push_back(i);
			s.push_back(1);
		}
	}
	void Union(int x, int y) {
		if (same(x, y)) return;
		int tx = Find(x), ty = Find(y);
		if (s[tx] < s[ty]) {
			s[ty] += s[tx];
			t[tx] = ty;
		}
		else if (s[tx] > s[ty]) {
			s[tx] += s[ty];
			t[ty] = tx;
		}
		else if (tx > ty) {
			t[tx] = ty;
			s[ty] += s[tx];
		}
		else {
			t[ty] = tx;
			s[tx] += s[ty];
		}
	}
	int Find(int n) {
		if (t[n] == n)
			return n;
		else
			return t[n] = Find(t[n]);
	}
	bool same(int x, int y) {
		return Find(x) == Find(y);
	}
	int get_Size(int a) {
		return s[a];
	}
};
signed main() {
	int a,b;
	cin>>a>>b;
	if(a<=5)cout<<0<<endl;
	else if(a<=12)cout<<b/2<<endl;
	else cout<<b<<endl;
}


Measured memory_bytes: 764
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
ls = [2,1]
i = 2
def lucas(n):
	global i
	if n == 0:
		return 
	else:
		n -= 1
		memo = ls[i-2] + ls[i-1]
		ls.append(memo)
		i += 1
		lucas(n)			

lucas(86)
print(ls[n])

Measured memory_bytes: 9120
#include <stdio.h>
#define rep(x)for(i=0;i<x;i++)

int main(){
	int n,i,l=0,r=0;char s[210];
	scanf("%d\n%s",&n,s);
	rep(n){
		if(s[i]=='(')l++;
		else if(s[i]==')')l--;
		if(l<0){r++;l++;}
	}
	rep(2050000000)n*=n;
	rep(r)printf("(");
	printf("%s",s);
	rep(l)printf(")");
	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10 ** 9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

def tree_walk(node):
    par, sib, deg, dep, hei, l, r = nodes[node]
    preo.append(node)
    if l != -1:
        tree_walk(l)
    ino.append(node)
    if r != -1:
        tree_walk(r)
    posto.append(node)
    return

N = INT()

# node: [parent, sibing, degree, depth, height, l, r]
nodes = [[-1, -1, 0, 0, 0, -1, -1] for i in range(N)]
preo = []
ino = []
posto = []

for i in range(N):
    node, l, r = MAP()
    if l != -1:
        nodes[l][0] = node
        nodes[node][5] = l
    if r != -1:
        nodes[r][0] = node
        nodes[node][6] = r

for i in range(N):
    # 木の巡回
    if nodes[i][0] == -1:
        tree_walk(i)

print('Preorder')
print(' ', end='')
print(*preo)
print('Inorder')
print(' ', end='')
print(*ino)
print('Postorder')
print(' ', end='')
print(*posto)



Measured memory_bytes: 5628
N = int(input())
a = list(map(int,input().split()))

cnt4 = 0
cnt1 = 0
cnt2 = 0
for i in a:
    if i % 4 == 0:
        cnt4+=1
    elif i % 2 != 0:
        cnt1+=1
    else:
        cnt2 += 1

if cnt4 >= cnt1:
    print("Yes")
elif cnt2 == 0 and cnt4 >= cnt1-1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  rep(i,n) v[i]--;
  int ans = 0;
  vector<int> cnt(n, -1);
  rep(i,n) {
    cnt[i] = v[i];
    if (cnt[v[i]] == i) ans++; 
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 4044
def make_st(s, xs):
    if not s:
        return xs

    y = s[-1]
    ys = []
    for x in xs:
        ys.append(y + "+" + x)
        ys.append(y + "-" + x)
    return make_st(s[:-1], ys)

s = input()

for x in make_st(s[:-1], [s[-1]]):
    if eval(x) == 7:
        print(x+"=7")
        break



Measured memory_bytes: 3060
#include <cstdint>
#include <iostream>
#include <string>

using namespace std;

int64_t Changes(const string &str, char &prev)
{
    int64_t changes = 0;
    for (const auto &ch : str) {
        if (ch == prev) {
            changes += 1;
            prev = 0;
        } else {
            prev = ch;
        }
    }
    return changes;
}

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

    int64_t times;
    cin >> times;

    if (str[0] != str.back()) {
        char prev = 0;
        cout << times * Changes(str, prev) << "\n";
        return 0;
    }

    char prev = 0;
    auto one_changes = Changes(str, prev);
    auto two_changes = Changes(str, prev);
    auto three_changes = Changes(str, prev);

    auto res = one_changes + (two_changes + three_changes) * ((times - 1) / 2);
    if (times > 1 && (times - 1) % 2 == 1) {
        res += two_changes;
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
/*

かけ算九九をしなさい。

*/
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

int main()
{
	int i,k,result;
	for(i=1; i<=9; i++){
		for(k=1; k<=9; k++){
			result=i*k;
			printf("%dx%d=%d\n",i,k,result);
		}
	}
	return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  
  /*
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  */
  
  if (s == "MON")
    cout << 6 << "\n";
  if (s == "TUE")
    cout << 5 << "\n";
  if (s == "WED")
    cout << 4 << "\n";
  if (s == "THU")
    cout << 3 << "\n";
  if (s == "FRI")
    cout << 2 << "\n";
  if (s == "SAT")
    cout << 1 << "\n";
  if (s == "SUN")
    cout << 7 << "\n"; 

}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
    // Your code here!
    int a,b;
    scanf("%d %d",&a,&b);
    // printf("%d,%d",a,b);
    int i,c,d;
    c=a;
    d=b;
    for(i=1;i<b;i++){
        c=a*(int)pow(10,(float)i)+c;
    }
    for(i=1;i<a;i++){
        d=b*(int)pow(10,(float)i)+d;
    }
    if(c>d){
        printf("%i\n",c);
    }else{
        printf("%i\n",d);
    }
    // printf("%i\n",(int)pow(10,2));
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
 
int main(){
  int n;
  int i,j;
  int sum;
  int min,mink = -1 ,dif1=0, dif2=0;
  sum = 0;
 
  scanf("%d",&n);
 
  if(n<2 || n>100){
    return 0;
  }
 
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
 
    sum += a[i];
  }
 
  for(i=0;i<n;i++){
      dif1 =0, dif2 = 0;
    for(j=0;j<=i;j++){
       dif1 += a[j];
    }
    dif2 = sum - dif1;
 
    if(dif2 > dif1)
      min = dif2 - dif1;
    else{
      min = dif1 - dif2;
    }
 
    if(mink == -1){
      mink = min;
    }else if(mink > min){
      mink = min;
    }
  }
 
  printf("%d",mink);
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
using namespace std;
int vis[200010];
int sta[200010];

int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)==2&&n&&m)
    {
        int f=0,k=0,t=0;
        memset(vis,0,sizeof(vis));
        for(int i=1;i<=m;i++)
        {
            int a,b;
            scanf("%d%d",&a,&b);
            if(a==1&&b==n){f=1;break;}
            if(a==1)sta[k++]=b;
            //printf("sta=%d\n",b);}
            if(b==n)vis[a]=1;
        }
        if(f==1){printf("POSSIBLE\n");continue;}
        for(int i=0;i<k;i++)
        {
            if(vis[sta[i]]==1){f=1;break;}
        }
        if(f==1)printf("POSSIBLE\n");
        else printf("IMPOSSIBLE\n");
    }
    return 0;
}


Measured memory_bytes: 1280
n, l = [int(x) for x in input().split()]

taste = 0
for i in range(n):
    taste = taste + l + i

diff_min = abs(taste)
result = 0
for i in range(n):
    taste2 = 0
    for j in range(n):
        if j == i:
            pass
        else:
            taste2 = taste2 + l + j

    diff = abs(taste - taste2)
    if diff < diff_min:
        diff_min = diff
        result = taste2


print(result)



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

int main()
{
	for( int i = 1; i <= 9; i++ )
	{
		for( int j = 1; j <= 9; j++ )
		{
			cout << i << "x" << j << "=" << i*j << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1116
#include <stdio.h>
#include <string.h>

int main (){
	char word[1010];
  	scanf ("%[^\n]", word);
  	getchar();
  	int U = strlen(word);
  	
  	if (word[U-1] == 's'){
    	printf ("%ses\n", word);
    }
  	else {
    	printf ("%ss\n", word);
    }
  
return 0;
}

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

int N,M;

pair<bool,int>v[100001];
vector<pair<int,int>>e[100001];

void dfs(int i,int x){
	v[i]={true,x};
	for(auto a:e[i]){
		if(v[a.first].first){
			if(v[i].second+a.second!=v[a.first].second){
				cout<<"No";
				exit(0);
			}
		}else{
			dfs(a.first,v[i].second+a.second);
		}
	}
}

main(){
	cin>>N>>M;
	for(int i=0;i<M;++i){
		int L,R,D;
		cin>>L>>R>>D;
		e[L].push_back({R,D});
		e[R].push_back({L,-D});
	}
	for(int i=1;i<=N;++i){
		if(!v[i].first){
			dfs(i,0);
		}
	}
	cout<<"Yes";
}


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

int main(){
    int n, d, tmp, ans = 0;

    std::cin >> n >> d;

    std::vector<std::vector<int>> x(n, std::vector<int> (d));

    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            std::cin >> x[i][j];
        }
    }

    for(int i = 0; i < n - 1; i++){
        for(int j = i + 1; j < n; j++){
            double count = 0;
            for(int k = 0; k < d; k++){
                count += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }

            count = sqrt(count);

            int sum = (int)count;
            if(count - sum == 0){
                ans++;
            }
        }
    }

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

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// MOD :
var MOD = 1000000007

func mpow(x, n int) int {
	ans := 1
	for n != 0 {
		if n&1 == 1 {
			ans = ans * x % MOD
		}
		x = x * x % MOD
		n = n >> 1
	}
	return ans
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()
	n := (N + 1) / 2
	if N%2 == 0 {
		n++
	}
	A := make([]int, n)

	flag := true
	for i := 0; i < N; i++ {
		a := getInt()
		a = (a + 1) / 2

		A[a]++
		if a == 0 && A[a] >= 2 {
			flag = false
			break
		} else if A[a] > 2 {
			flag = false
			break
		}
	}

	if flag == false {
		out(0)
	} else {
		if N%2 == 1 {
			n = N - 1
		}
		n = N / 2
		out(mpow(2, n))
	}

}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    ll n, k, a[200005] = {}, z = 0;
    cin >> n >> k;
    fr1(n) a[i % k]++;
    z = a[0] * a[0] * a[0];
    fr1(k - 1) {
        if (((k - i) % k * 2) % k == 0) {
            z += a[i] * a[k - i] * a[k - i];
        }
    }
    cout << z;
}


Measured memory_bytes: 1792
n, m = list(map(int,input().split()))
nums = [list(map(int,input().split())) for i in range(n)]
ans = 1e20
for c, t in nums:
  if t <= m:
    ans = min(c, ans)
if ans < 10000:
  print(ans)
else:
  print('TLE')

Measured memory_bytes: 38256
m=input()
A=int(m)
n=input()
t=n.split()
N=[]
sum=0
for i in range(0,A):
    N.append(int(t[i]))
for k in range(0,A):
    for l in range(k,A):
        if k!=l:
            sum=sum+N[k]*N[l]
print(sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
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; }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) do{}while(0)
#endif



ll n;
vector<int> v[200001];

int t = 0;
int max_distance = 0;
void dfs( int node, int parent, int dist ){
	if ( max_distance < dist ){
		max_distance = dist;
		t = node;
	}
	for ( auto next_node : v[node] ){
		if ( next_node != parent )
			dfs( next_node, node, dist+1 );
	}
}

int main(){
	cin >> n;
	rep(i,n-1){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	
	dfs( 0, -1, 0 );
	dfs( t, -1, 0 );
	
	//cout << max_distance << endl;
	
	cout << (max_distance%3 == 1 ? "Second" : "First" ) << endl;
	
	return 0;
}




Measured memory_bytes: 23768
N = int(input())

ans = [0] * 10050

for i in range(1, 105):
    for j in range(1, 105):
        for k in range(1, 105):
            v = i*i+j*j+k*k+i*j+i*k+j*k
            if v < 10050:
                ans[v] += 1

for i in range(N):
    print(ans[i+1])


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

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

	int N, K, Q, tmp;
	cin >> N >> K >> Q;
	int initial_score = K - Q;
	vector<int> A(N, initial_score);

	for (int i = 0; i < Q; i++) {
		cin >> tmp;
		A[tmp - 1]++;
	}

	for (int i = 0; i < N; i++) {
		if (A[i] > 0) printf("Yes\n");
		else printf("No\n");
	}

	return 0;
}

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

using namespace std;

int main(){
    int64_t n, m;
    cin >> n >> m;
    vector<int64_t> A(n);
    for (auto &a: A){
        cin >> a;
        a /= 2;
    }

    int64_t lcm = 1, gcd = A[0];
    for (const auto &a: A){
        lcm = lcm * a / __gcd(lcm, a);
        gcd = __gcd(gcd, a);
    }
    cout << ((lcm / gcd) & 1 ? (m / lcm + 1) / 2 : 0L) << endl;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>//////////////////////////////////////////
#define deb(...)/////////////////////////////////////////////////
#define DBP(...)/////////////////////////////////////////////////
#ifdef LOC///////////////////////////////////////////////////////
#include"debuglib.h"/////////////////////////////////////////////
#endif///////////////////////////////////////////////////////////
#define x first//////////////////////////////////////////////////
#define y second/////////////////////////////////////////////////
#define pb push_back/////////////////////////////////////////////
#define sz(x)int((x).size())/////////////////////////////////////
#define each(a,x)for(auto&a:(x))/////////////////////////////////
#define all(x)(x).begin(),(x).end()//////////////////////////////
#define rep(i,b,e)for(int i=(b);i<(e);i++)///////////////////////
using namespace std;using ll=long long;using Pii=pair<int,int>;//
using Vi=vector<int>;void run();int main(){cin.sync_with_stdio///
(0);cin.tie(0);cout<<fixed<<setprecision(18);run();return 0;}////
//-------------------------------------------------------------//

void run() {
	int n; cin >> n;
	cout << (n-2)*180 << '\n';
}


Measured memory_bytes: 256
n,x,y=[int(i) for i in input().split()]
x-=1
y-=1
ans=[0]*(n-1)

for i in range(n-1):
    for j in range(i+1,n):
        if i<j and j<=x:
            min_len=j-i
        elif i<=x and x<j and j<y:
            if j<=(x+y)//2:
                min_len=j-i
            else:
                min_len=(y-j)+1+(x-i)
        elif x<i and i<j and j<y:
            min_len=min(j-i,y-j+1+i-x)
        elif x<i and i<y and y<=j:
            if i>=(x+y)//2:
                min_len=j-i
            else:
                min_len=(j-y)+1+(i-x)
        elif y<=i and i<j:
            min_len=j-i

        elif i<=x and x<y and y<=j:
            min_len=j-y+1+x-i
        min_len-=1
        ans[min_len]+=1

for i in ans:
    print(i)
            

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define int long long
#define mod 1000000007
#define N 300010
using namespace std;

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int F[N],S[N],n,A,B;
signed main()
{
	int L=0,R=0;
	scanf("%lld%lld%lld",&n,&A,&B);
	if (A>B) swap(A,B);
	for (int i=1;i<=n;i++)
		scanf("%lld",&S[i]);
	for (int i=3;i<=n;i++)
		if (S[i]-S[i-2]<A) {puts("0"); return 0;}
	S[0]=S[1]-B; F[0]=1;
	for (int i=1;i<=n;i++)
	{
		while (S[i]-S[R+1]>=B&&R+1<=i) R++;
		if (L<=R) F[i]=(F[R]+mod-(L?F[L-1]:0))%mod;
		F[i]=(F[i-1]+F[i])%mod;
		if (S[i]-S[i-1]<A) L=i-1;
	}
	printf("%lld\n",(F[n]+mod-(L?F[L-1]:0))%mod);
}

Measured memory_bytes: 3072
# coding: utf-8
# Your code here!

from collections import deque

N = int(input())
A = deque(list(map(int, input().split())))
ans = A.popleft()

if 0 in A:
    print(0)
    exit()

for i in range(N - 1):
    ans *= A.popleft()
    if ans > pow(10, 18):
        print(-1)
        exit()
else:
    print(ans)

Measured memory_bytes: 22496
a, b, c = map(int, input().split())
minimum = min(a, b, c)
maximum = max(a, b, c)
middle = sum((a, b, c)) - (minimum + maximum)
ans = 0
tmp = minimum

while tmp <= (middle - 2):
    tmp += 2
    ans += 1

if tmp == middle:
    ans += (maximum - tmp)
else:
    maximum += 1
    ans += (maximum - tmp)
print(ans)


Measured memory_bytes: 38256