akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 266666,mo=1e9+7,M=6;
inline int power(int a, int n) {
	int res=1;
	while (n) {
		if (n&1) res=1LL*res*a%mo;
		a=1LL*a*a%mo; n>>=1;
	}
	return res;
}
int n;char s[N];
inline void add(int &x, int y){x=x+y<mo?x+y:x+y-mo;}
int pr[]={998244353,10,23336666,19260817,114514,993244853};
int ni[10];
struct node{
	int v[M+1];
	bool operator<(const node&a)const{
		rep(i,0,M-1)if(v[i]!=a.v[i])return v[i]<a.v[i];
		return 0;
	}
}c,a,k1,b1,k2,b2;map<node,int>Map;ll res;
void nisolve(node &k,node &b,int i){
	if(i==n){
		if(s[i]=='+'){rep(j,0,M-1)b.v[j]=mo-1,k.v[j]=1;}
		if(s[i]=='-'){rep(j,0,M-1)b.v[j]=1,k.v[j]=1;}
		if(s[i]=='>'){rep(j,0,M-1)k.v[j]=1LL*ni[j]%mo,b.v[j]=0;}
		if(s[i]=='<'){rep(j,0,M-1)k.v[j]=1LL*pr[j]%mo,b.v[j]=0;}
		return;
	}
		if(s[i]=='+'){rep(j,0,M-1)add(b.v[j],mo-k.v[j]);}
		if(s[i]=='-'){rep(j,0,M-1)add(b.v[j],k.v[j]);}
		if(s[i]=='>'){rep(j,0,M-1)k.v[j]=1LL*k.v[j]*ni[j]%mo;}
		if(s[i]=='<'){rep(j,0,M-1)k.v[j]=1LL*k.v[j]*pr[j]%mo;}
}
int main() {
	rep(i,0,M-1)ni[i]=power(pr[i],mo-2);
	read(n);scanf("%s",s+1);
	per(i,n,1){
		if(s[i]=='+'){rep(j,0,M-1)add(c.v[j],1);}
		if(s[i]=='-'){rep(j,0,M-1)add(c.v[j],mo-1);}
		if(s[i]=='>'){rep(j,0,M-1)c.v[j]=1LL*c.v[j]*pr[j]%mo;}
		if(s[i]=='<'){rep(j,0,M-1)c.v[j]=1LL*c.v[j]*ni[j]%mo;}
	}
	b2=c;
	cerr<<b2.v[1]<<endl;
	per(l,n,1){
	//	cerr<<"modify "<<b1.v[1]<<endl;
		Map[b1]++;
		nisolve(k1,b1,l);nisolve(k2,b2,l);
		node t;rep(j,0,M-1)t.v[j]=(1LL*k2.v[j]*c.v[j]+b2.v[j])%mo;
		cerr<<t.v[1]<<endl;res+=Map[t];
	}
	cout<<res;return 0;
}


Measured memory_bytes: 39552
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) c.begin(), c.end()
#define endl "\n"
#define sz(u) (int)(u.size())
#define L(x)(2*x)
#define R(x)(2*x+1)
#define M(x,y)((x+y)/2)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
void solve(){
    int h1,h2,m1,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    int cnt=0;
    cnt=60-m1+m2+(h2-h1-1)*60;
    cout<<max(cnt-k,0);
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    //cin>>t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
}


Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int N = sc.nextInt();
		
		int[] A = new int[N];
		for(int i=0; i<N; i++){
			A[i] = sc.nextInt();
		}
		
		int swap = 0;
		for(int i=0; i<N; i++){
			int idx_min = i;
			for(int j=i; j<N; j++){
				if(A[j] < A[idx_min]){
					idx_min = j;
				}
			}
			
			if(idx_min != i){
				int temp = A[i];
				A[i] = A[idx_min];
				A[idx_min] = temp;
				swap++;
			}
		}

		for(int i=0; i<N; i++){
			System.out.print(A[i]);
			if(i != N-1){
				System.out.print(" ");
			}
		}
		System.out.println();
		
		System.out.println(swap);
	}

	static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 24404
#include <iostream> 
#include <bits/stdc++.h>
#include <vector> 
#include <algorithm> 
#include <string>
#include <cmath>
#include <iomanip> 
#include<climits> 
#include <utility>   
#include <set>
#include <numeric> 
#include <iterator>
#include <map> 
using namespace std; 
#define ll long long int
//typedef pair<ll,ll> p; 
int main()
{
      int k,n;
      cin>>k>>n;
      int a[n];
      for(int i=0;i<n;i++)
      {
          cin>>a[i];
          
      }
      int p=0;
      for(int i=1;i<n;i++)
      {
          if(a[i]-a[i-1]>p)
          {
                p=a[i]-a[i-1];
          }
      }
      if(k-a[n-1]+a[0]>p)
      {
          p=k-a[n-1]+a[0];
      }
      cout<<k-p<<endl;
      
      
      
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(true){
        c-=b;
        if(c<=0){
            cout<<"Yes";
            return 0;
        }
        a-=d;
        if(a<=0){
            cout<<"No";
            return 0;
        }
    }
}

Measured memory_bytes: 3636
using System;

namespace ARC068
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var X = long.Parse(Console.ReadLine());
            var ans = X / 11;
            if (1 <= X % 11 && X % 11 <= 6) ans += 1;
            else if (7 <= X % 11) ans += 2;
            Console.WriteLine(X / 11 + ans);
        }
    }
}

Measured memory_bytes: 13140
#include <stdio.h>

int check(char a, char b, char c)
{
    if (a != b && a != c && b != c) {
        return 1;
    }
    return 0;
}

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

    // 全てのRGBの順列
    int i;
    int r = 0, g = 0, b = 0;
    for (i = 0; i < N; i++) {
        if (S[i] == 'R') r++;
        if (S[i] == 'G') g++;
        if (S[i] == 'B') b++;
    }
    long long result = (long long)(r * g * b);

    // 距離が同じでRGBなら除外
    // long long exc = 0;
    int head, center, tail;
    for (head = 0; head < N - 2; head++) {
        for (center = head + 1; center < N - 1; center++) {
            tail = center * 2 - head;
            if (tail > N - 1) break;
            if (check(S[head], S[center], S[tail])) {
                // exc++;
                result--;
            }
        }
    }
    // int head = 0;
    // int center = 1;
    // int tail = 2;
    // while (head < N - 2) {
    //     if (check(S[head], S[center], S[tail])) {
    //         // exc++;
    //         result--;
    //     }
    //     center += 1;
    //     tail += 2;
    //     if (tail > N - 1) {
    //         head++;
    //         center = head + 1;
    //         tail = head + 2;
    //     }
    // }

    // printf("%lld\n", exc);
    printf("%lld\n", result);
    return 0;
}

Measured memory_bytes: 2160
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import numpy as np
import copy
from collections import defaultdict, Counter
from itertools import product
from bisect import bisect_left, bisect_right

def s_inpl(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))

S = input()

if S == "A":
    print("T")
elif S == "T":
    print("A")
elif S == "C":
    print("G")
else:
    print("C")

Measured memory_bytes: 12496
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pl = pair<ll, ll>;
using Tl = tuple<ll, ll, ll>;

const ll INF = 1e15;
const ld eps = 1e-6;

int main(){
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  ll ans = 0;
  if(K % 2)
    ans = -(A - B);
  else
    ans = A - B;
  if(ans > 1e18)
    cout << "Unfair" << endl;
  else
    cout << ans << endl;
  return 0;
}


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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    int n, m, a;
    cin >> n >> m;
    rep(i, m) {
        cin >> a;
        n -= a;
    }
    if (n < 0)
        cout << -1 << endl;
    else
        cout << n << endl;
    return 0;
}

Measured memory_bytes: 3640
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define p 1000000007
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define LONGLONG_MAX 10000000000000000
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
vector<vector<int>>v;
vector<int>dp;
int dfs(int i){
	if(dp[i]!=-1)return dp[i];
	int x=0;
	for(auto j:v[i]){
		x=max(x,dfs(j)+1);
	}
	return dp[i]=x;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	v.resize(n);
	dp.assign(n,-1);
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		x--;y--;
		v[x].push_back(y);
		//v[y].push_back(x);
	}
	int x=0;
	for(int i=0;i<n;i++){
		x=max(x,dfs(i));
		//cout<<x<<" ";
	}
	cout<<x;
    return 0;
}

Measured memory_bytes: 7552
from collections import Counter

N = int(input())
S = input()

ctr = Counter(S)
res = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        k = 2 * j - i
        if k < N and (S[i] != S[j] and S[i] != S[k] and S[j] != S[k]):
            res += 1

print(ctr["R"] * ctr["G"] * ctr["B"] - res)


Measured memory_bytes: 74248
# coding: utf-8
# Your code here!
s=list(input())
t=list(input())

dp=[[0]*(len(t)+1) for i in range(len(s)+1)]

for i in range(1,len(s)+1):
    for j in range(1,len(t)+1):
        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])
            
#print(dp)

ans=""
ns=len(s)
nt=len(t)

while ns>0 and nt>0:
    #print(ns,nt,ans)
    if s[ns-1]==t[nt-1]:
        ans+=s[ns-1]
        ns-=1
        nt-=1
    elif dp[ns][nt]==dp[ns-1][nt]:
        ns-=1
    else:
        nt-=1
        
print(ans[::-1])

        

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

int read()
{
	int ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=0;
	if(ch=='-')flag=1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10+ch-'0';
	if(flag)ans=-ans;
	return ans;
}

long long rell()
{
	long long ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=0;
	if(ch=='-')flag=1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10ll+(long long)(ch-'0');
	if(flag)ans=-ans;
	return ans;
}

void writ(int n)
{
	char ch[25];
	int m=0;
	if(n<0)putchar('-'),n=-n;
	if(n==0)
	{
		putchar('0');
		return;
	}
	for(;n;n/=10)ch[m++]=n%10ll+'0';
	for(;m;)putchar(ch[--m]);
}

void wrll(long long n)
{
	char ch[25];
	int m=0;
	if(n<0)putchar('-'),n=-n;
	if(n==0)
	{
		putchar('0');
		return;
	}
	for(;n;n/=10ll)ch[m++]=n%10ll+'0';
	for(;m;)putchar(ch[--m]);
}
const int N=1<<8;
const int mod=998244353;
int x[N],y[N],po[N];

int main()
{
	int n;
	scanf("%d",&n);
	po[0]=1;
	for(int i=0;i<n;i++)
	{
		x[i]=read();y[i]=read();
		po[i+1]=po[i]*2ll%mod;
	}
	int ans=(po[n]-1-n+mod)%mod;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			int sum=0,a=y[i]-y[j],b=x[j]-x[i],c=x[i]*y[j]-x[j]*y[i];
			for(int k=j+1;k<n;k++)
			{
				if(x[k]*a+y[k]*b+c==0)sum++;
			}
			(ans+=mod-po[sum])%=mod;
			//printf("i=%d j=%d sum=%d\n",i,j,sum);
		}
	}
	printf("%d\n",ans);
	return 0;
}


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

int main() {
    long long A;
    long long B;
    cin >> A >> B;
    long long multiply = 0;
    bool find = false;
    if (A <= 9 && B <= 9) {
        if (A >= 1 && B >= 1) {
            multiply = (A * B);
            find = true;
        }
    }
    if (find == true) {
        cout << multiply << endl;
    }
    else {
        cout << "-1" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=1e5+10,mod=1e9+7;
inline void add(int &x,int y){
	x+=y;
	if(x>=mod) x-=mod;
}
char s[maxn];
int Next[maxn][3],sum[maxn],dp[maxn];
int main(){
	bool flag=1;
	scanf("%s",s+1);
	int n=strlen(s+1),ans=0;
	REP(i,2,n) flag&=(s[i]!=s[i-1]);
	if(flag){
		printf("1\n");
		return 0;
	}
	REP(i,1,n) sum[i]=(sum[i-1]+s[i]-'a'+1)%3;
	DREP(i,n,0){
		REP(j,0,2) Next[i][j]=Next[i+1][j];
		Next[i][sum[i]]=i;
	}
	dp[0]=1;
	REP(i,0,n){
		REP(j,1,2){
			int u=Next[i][(sum[i]+j)%3];
			if(u) add(dp[u],dp[i]);
		}
		if(i && sum[i]==sum[n]) add(ans,dp[i]);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 2304
#include <iostream>

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

int main(int argc, char const *argv[])
{
	int a = 0;
	cin >> a;
	int b = 0;
	cin >> b;
	cout << gcd(a,b) << endl;
	return 0;
}

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int M,D,ans=0;
    cin >>M>>D;
    //-----------------------------------
    repd(m,1,M+1){
        repd(d,1,D+1){
            if(d/10>=2 && d%10>=2 && m==(d/10)*(d%10)) ans++;
        }
    }


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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//ll GCD(ll x,ll y){
//    if(y == 0) return x;
//    else return GCD(y,x%y);
//}
const int MOD = 1000000007;

long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }
long long num(long long n, long long c, long long d) {
    long long G = GCD(c, d);
    long long L = c * d / G;
    return n - n / c - n / d + n / L;
}

int main() {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = num(b, c, d);
    
    cout << num(b, c, d) - num(a-1, c, d) << endl;
}




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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define forn(low,high,i) for(i = low;i < high;i++)
#define forrev(high,low,i) for(i = high; i >= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define line cout << __LINE__;
#define prv(a) for(auto x : a) cout << x << ' ';cout << '\n';
#define decimal_digits cout << fixed << setprecision(15);
#define dbg2(a,b) cerr << #a << " = " << a << " " << #b << " = " << b << '\n';        
#define debug(x) cerr << __LINE__ << ' ' << #x << " = " << x << '\n';
#define dln cerr << '\n';
#define dsp cerr << ' ';
#define pln cout << '\n';
#define psp cout << ' ';

typedef unordered_map<int,int> umi;
typedef unordered_map<ll,ll> uml;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int inf = 1e9;
const ll INF = 1e18;
const ll mod = 1e9 + 7;

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

int main(){
  fastio

  ll n, i, j, k, t;
  string s;
  ll ans = 0;

  cin >> i >> j;
  if(i == j){
    cout << "0\n";
  }else{
    if((i + j) % 2){
      cout << "IMPOSSIBLE\n";
    }else{
      cout << (i + j) / 2 << '\n';
    }
  }

  ktj();
}


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

int main(){
  int H,W;
  cin >> H >>W;
  string tmp1;
  for (int i=0;i<W+2;i++){
    cout << "#";
  }
  cout <<endl;
  for (int i=0;i<H;i++){
    cin >> tmp1;
    tmp1.push_back('#');
    tmp1.insert(0,"#");
    cout << tmp1<<endl;
  }
  for (int i=0;i<W+2;i++)
    cout <<"#";
  cout <<endl;
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, M, R;
    cin >> N >> M >> R;

    vector<ll> r(R);
    rep (i, R) {
        cin >> r[i];
    }

    ll d[210][210];
    rep (i, 210) {
        rep (j, 210) {
            if (i != j) {
                d[i][j] = INF;
            }
        }
    }

    rep (i, M) {
        ll A, B, C;
        cin >> A >> B >> C;
        d[A][B] = C;
        d[B][A] = C;
    }

    for (ll k = 1; k <= N; k++) {
        for (ll i = 1; i <= N; i++) {
            for (ll j = 1; j <= N; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

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

    ll ans = INF;
    do {
        ll tmp = 0;
        rep (i, R-1) {
            tmp += d[r[i]][r[i+1]];
        }
        ans = min(tmp, ans);
    } while (next_permutation(r.begin(), r.end()));

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

Measured memory_bytes: 640
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        m: usize,
        x: i64,
        y: i64,
        xs: [i64; n],
        ys: [i64; m],
    }

    let ans = (x + 1..y + 1).any(|z| xs.iter().all(|&x| x < z) && ys.iter().all(|&y| y >= z));

    println!("{}", if ans { "No War" } else { "War" });
}


Measured memory_bytes: 4352
import collections
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
l = IL()
cl = collections.Counter(l)

key = list(cl.keys())
value = list(cl.values())

ans = 0
for i in range(len(key)):
	k = int(key[i])
	v = value[i]
	if k <= v:
		ans += v-k
	else:
		ans += v

print(ans)

Measured memory_bytes: 27036
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n, m;
ll a[100000];
vector <pair <ll, int> >b;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>m;
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<m;i++) {
        int t;
        ll t1;
        cin>>t>>t1;
        b.push_back(make_pair(t1,t));
    }
    sort(a,a+n);
    sort(b.begin(),b.end());
    int ch=0;
    for(int i=m-1;i>=0;i--){
        if(a[n-1]<b[i].first&&b[i].second+ch-1>n-1){
            for(int j=ch;j<n;j++){
                a[j]=b[i].first;
            }
            break;
        }
        if(a[min(n-1,b[i].second+ch-1)]<b[i].first){
            for(int j=ch;j<min(n,b[i].second+ch);j++){
                a[j]=b[i].first;
            }
            ch=b[i].second+ch;
        }
        else{
            bool c=true;
            int k=ch;
            while(c&&k<n){
                if(a[k]<b[i].first){
                    a[k]=b[i].first;
                    k++;
                }
                else{
                    c=false;
                }
            }
            break;
        }
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        ans+=a[i];
    }
    cout << ans << "\n";
}

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

int main(){
  int n;cin >> n;ll sum=0;
  rep(i,n-1)sum+=i+1;
  cout << sum << endl;}

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

int main()
{
	double kg;

	while (cin >> kg){
		if (kg <= 48.0) cout << "light fly" << endl;
		else if (kg <= 51.0) cout << "fly" << endl;
		else if (kg <= 54.0) cout << "bantam" << endl;
		else if (kg <= 57.0) cout << "feather" << endl;
		else if (kg <= 60.0) cout << "light" << endl;
		else if (kg <= 64.0) cout << "light welter" << endl;
		else if (kg <= 69.0) cout << "welter" << endl;
		else if (kg <= 75.0) cout << "light middle" << endl;
		else if (kg <= 81.0) cout << "middle" << endl;
		else if (kg <= 91.0) cout << "light heavy" << endl;
		else cout << "heavy" << endl;
}
	return (0);
}

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

int main(){
    char a;
    cin >> a;
    if('a'<=a && a<='z'){
        cout << 'a' << endl;
    }else{
        cout  << 'A' << endl;
    }
    return 0;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplece_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    string st;
    cin >> st;
    string hoge = "AC";

    Rep(i, st.size()) {
        if (hoge[0] == st[i-1] && hoge[1] == st[i]) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double lb;
typedef unsigned int ui;
typedef unsigned long ul;
typedef pair<int,int> pi;
typedef pair<long long, long long> pl;
typedef vector<int> vi;
typedef priority_queue<int> pq;
typedef priority_queue<int,vector<int>,greater<int>> pqq;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

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

int k;
string s;

cin>>k>>s;

if(s.size()<=k) cout<<s;
else{
	for(int i=0; i<k; i++){
		cout<<s[i];
		}
		cout<<"...";
	
	}


}
 
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do smth instead of nothing and stay organized
*/


Measured memory_bytes: 3540
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

def tree_left(node, it):
    c = next(it)

    if c == "(":
        node[0] = [None, None]
        tree_left(node[0], it)
        c = next(it)

    if c == ",":
        tree_right(node, it)
    else:
        assert False

def tree_right(node, it):
    c = next(it)

    if c == "(":
        node[1] = [None, None]
        tree_left(node[1], it)
        c = next(it)

    if c == ")":
        pass
    else:
        assert False

def tree_parse(s):
    root = [None, None]

    s = s[1:]
    it = iter(s)
    tree_left(root, it)

    return root

def tree_dump(node):
    s = ""

    s += "("
    if node[0]:
        s += tree_dump(node[0])
    s += ","
    if node[1]:
        s += tree_dump(node[1])
    s += ")"

    return s

def intersection(t1, t2):
    if t1 is None or t2 is None:
        return None

    node = [None, None]
    node[0] = intersection(t1[0], t2[0])
    node[1] = intersection(t1[1], t2[1])
    return node

def union(t1, t2):
    if t1 is None and t2 is None:
        return None
    elif t1 is None:
        return t2
    elif t2 is None:
        return t1

    node = [None, None]
    node[0] = union(t1[0], t2[0])
    node[1] = union(t1[1], t2[1])
    return node

def main():
    for line in sys.stdin:
        op, s1, s2 = line.split()
        tree1 = tree_parse(s1)
        tree2 = tree_parse(s2)
        #print(tree_dump(tree1))
        #print(tree_dump(tree2))
        if op == "i":
            ans = intersection(tree1, tree2)
            print(tree_dump(ans))
        elif op == "u":
            ans = union(tree1, tree2)
            print(tree_dump(ans))

if __name__ == "__main__": main()

Measured memory_bytes: 7496
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <tuple>
#include <algorithm>
using namespace std;

#define mx 500005

int arr[mx];
tuple<int,int,int> queries[mx];
int answer[mx];

int tree[4*mx];

void set_at(int ind, int l, int r, int pos, int val){
    if(pos<l or pos>r) return;
    if(l==r){
        tree[ind]=val;
    }
    else{
        int m=(l+r)/2;
        set_at(2*ind,l,m,pos,val);
        set_at(2*ind+1,m+1,r,pos,val);
        tree[ind]=tree[2*ind]+tree[2*ind+1];
    }
}

int sum_over(int ind, int l, int r, int x, int y){
    if(r<x or l>y) return 0;
    if(l>=x and r<=y) return tree[ind];

    int m=(l+r)/2;
    return sum_over(2*ind,l,m,x,y)+sum_over(2*ind+1,m+1,r,x,y);
}

int main(){
    int n,q;
    scanf("%d %d",&n,&q);

    for(int i=0;i<n;i++) scanf("%d",arr+i);
    for(int i=0;i<q;i++){
        int l,r;
        scanf("%d %d",&l,&r);
        queries[i]={l-1,r-1,i};
    }
    sort(queries,queries+q);

    memset(tree,0,sizeof(tree));
    map<int,int> nxt;

    int qind=q-1;

    for(int i=n-1;i>=0;i--){
        int val=arr[i];
        if(nxt.find(val)!=nxt.end()){
            set_at(1,1,n,nxt[val]+1,0);
        }
        set_at(1,1,n,i+1,1);
        nxt[val]=i;

        while(qind>=0 and get<0>(queries[qind])==i){
            answer[get<2>(queries[qind])]=sum_over(1,1,n,1+get<0>(queries[qind]),1+get<1>(queries[qind]));
            qind--;
        }
    }

    for(int i=0;i<q;i++){
        printf("%d\n",answer[i]);
    }
}


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

int main()
{
	int n, d1, d2, c = 0;
	bool f = 0;
	scanf("%d", &n);
	while (n--) {
		scanf("%d%d", &d1, &d2);
		if (d1 == d2) f |= (++c>=3);
		else c = 0;
	}
	puts(f ? "Yes" : "No");
}

Measured memory_bytes: 3800
#include<stdio.h>
#define MAX 100000
#define TRUE 1
#define FALSE 0

int binarySearch(int,int);
int S[MAX];
int main(){
  int i, n, q, T[MAX], C = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&T[i]);
  }
  for(i=0; i<q; i++){
  if(binarySearch(T[i],n) == TRUE) C++;
  }

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

int binarySearch(int key,int n){
  int left = 0;
  int right = n;
  int mid;
  while(left < right){
    mid = (left + right) / 2;
    if(S[mid] == key) return TRUE;
    else if(key < S[mid]) right = mid;
    else left = mid + 1;
  }
  return FALSE;
}



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

int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	int i = 1, j,ic, sum = 0;
	while (i <= N)
	{
		j = i;
		ic = 0;
		while (j)
		{
			ic += j % 10;
			j /= 10;
		}
		if (A <= ic && ic <= B)
			sum += i;
		i++;
	}
	cout << sum << endl;

}


Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>

using namespace std;

double dist(double x1, double y1, double x2, double y2){
	return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

int main(){
	int w, n;

	char bar[10];
	vector<int> a(31);
	const char delim = ',';
	int left, right;

	for(int i = 1; i <= 30; i++){
		a[i] = i;
	}

	cin >> w >> n;

	while(n--){
		cin >> bar;
		left = atoi(strtok(bar, &delim));
		right = atoi(strtok(NULL, &delim));
		swap(a[left], a[right]);
	}

	for(int i = 1; i <= w; i++){
		cout << a[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1208
#include <cstring>
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long ll;
const int MAXN = 2010;
const int MOD = 1e9+7;
int _w;

int C[MAXN][MAXN], sum[MAXN][MAXN], f[MAXN][MAXN];
void prelude() {
    for( int i = 0; i < MAXN; ++i ) {
        f[i][0] = sum[i][0] = C[i][0] = 1;
        for( int j = 1; j <= i; ++j )
            C[i][j] = (C[i-1][j] + C[i-1][j-1]) % MOD;
        for( int j = 1; j < MAXN; ++j )
            sum[i][j] = (sum[i][j-1] + C[i][j]) % MOD;
        for( int j = 1; j < MAXN; ++j )
            f[i][j] = (f[i][j-1] + sum[i][j]) % MOD;
    }
}

int solvet( int t, int b ) {
    int ans = 1; // i == 0
    for( int i = 1; i <= min(t-1, b); ++i )
        ans = int((ans + (ll)f[i-1][t-i-1] * C[b][i]) % MOD);
    return ans;
}

int main() {
    prelude();
    int a, b;
    _w = scanf( "%d%d", &a, &b );
    if( !a || !b ) return puts("1"), 0;
    int ans = 0;
    for( int t = 1; t <= a+1; ++t )
        ans = (ans + solvet(t, b-1)) % MOD;
    printf( "%d\n", ans );
    return 0;
}

Measured memory_bytes: 47616
ans = 0
x = input().split()
x = list(map(int, x))
a = [0] * (x[0])
for n in range(x[0]):
	a[n] = input().split()
	a[n] = list(map(int, a[n]))
a.sort()
counter = 0
while x[1] > 0:
	ans += a[counter][0]
	a[counter][1] -= 1
	x[1] -= 1
	if a[counter][1] == 0:
		counter += 1
print(ans)

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

ll inf=1ll<<60,mod=1000000007;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,i,l,r,ans=0;
	cin>>n;
	for (i=0;i<n;i++){
		cin>>l>>r;
		ans+=r-l+1;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int Prime(int n)
{
    int i;
    if(n == 2)
        return 1;   

    if(n % 2 == 0 || n < 2)
        return 0;

    for(i = 3; i <= sqrt(n); i += 2)
    {
        if(n % i == 0)
            return 0;
    }

    return 1;
}

int main(void)
{
    int n,cnt = 0,i;
    
    scanf("%d", &n);
    
    for(i = 0; i < n; ++i)
    {
        int x;
        scanf("%d", &x);
        cnt += Prime(x);
    }

    printf("%d\n", cnt);

    return 0;
}



Measured memory_bytes: 2060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC150A
{
    class Program
    {
        static void Main(string[] args)
        {
            int K, X;

            var word = Console.ReadLine().Split(' ');//全体をSpace区切りで文字列として認識

            K = int.Parse(word[0]);//文字列から数字を取り出す
            X = int.Parse(word[1]);//上意

            if(500*K>=X) Console.WriteLine("Yes");//文字列XXXを表示する
            else Console.WriteLine("No");//文字列XXXを表示する

            Console.ReadKey();//プログラムの最後に書こう
        }
    }
}


Measured memory_bytes: 11092
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i < k; i++) {
            sb.append(x - (k-i)).append(" ");
        }
        sb.append(x).append(" ");
        for (int i = 1; i < k; i++) {
            sb.append(x + i).append(" ");
        }
        System.out.println(sb.toString());
        sc.close();

    }

}


Measured memory_bytes: 21844
# coding: utf-8


II = lambda: int(input())
MI = lambda: map(int, input().split())


def gcd(a, b):
    if b == 0:
        return a
    if a < b:
        return gcd(b, a)
    return gcd(b, a % b)

def main():
    N, X = MI()
    xs = []
    for x in MI():
        x -= X
        if x != 0:
            xs.append(abs(x))
    a = xs[0]
    for x in xs:
        a = gcd(a, x)
    return a


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 14444
#include <bits/stdc++.h>
#define LL long long
#define dob complex<double>
#define Abs(a) ((a) < 0 ? (-(a)) : (a))
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define Swap(a, b) ((a) ^= (b), (b) ^= (a), (a) ^= (b))
#define writeln(x) (write(x), putchar('\n'))
#define lowbit(x) ((x)&(-(x)))
using namespace std;
const int N = 100000;
const int yzd = 1e9+7;
void read(int &x) {
    char ch; bool flag = 0;
    for (ch = getchar(); !isdigit(ch) && ((flag |= (ch == '-')) || 1); ch = getchar());
    for (x = 0; isdigit(ch); x = (x<<1)+(x<<3)+ch-48, ch = getchar());
    x *= 1-2*flag;
}
void print(int x) {if (x > 9) print(x/10); putchar(x%10+48); }
void write(int x) {if (x < 0) putchar('-'); print(Abs(x)); }

int n, m, s, t, u, v, c;
struct tt {int to, next, cost; }edge[(N<<2)+5];
int path[N+5], top;
int ans1[N+5], ans2[N+5], vis[N+5], in[N+5];
LL dist1[N+5], dist2[N+5];
queue<int>Q;
vector<int>to[N+5];

void add(int u, int v, int c) {
    edge[++top].to = v, edge[top].cost = c, edge[top].next = path[u], path[u] = top;
}
void SPFA(int s, LL *dist) {
    dist[s] = 0; Q.push(s); vis[s] = 1;
    while (!Q.empty()) {
	int u = Q.front(); Q.pop(); vis[u] = 0;
	for (int i = path[u]; i; i = edge[i].next)
	    if (dist[edge[i].to] > dist[u]+edge[i].cost) {
		dist[edge[i].to] = dist[u]+edge[i].cost;
		if (!vis[edge[i].to]) {
		    vis[edge[i].to] = 1; Q.push(edge[i].to);
		}
	    }
    }
}
void topsort(int s, LL *dist, int *ans) {
    for (int u = 1; u <= n; u++) {
	to[u].clear();
	for (int i = path[u]; i; i = edge[i].next)
	    if (dist[edge[i].to] == dist[u]+edge[i].cost) to[u].push_back(edge[i].to), ++in[edge[i].to];
    }
    ans[s] = 1; Q.push(s);
    while (!Q.empty()) {
	int u = Q.front(), size = to[u].size(); Q.pop();
	for (int i = 0; i < size; i++) {
	    if (--in[to[u][i]] == 0) Q.push(to[u][i]); (ans[to[u][i]] += ans[u]) %= yzd;
	}
    }
}
void work() {
    read(n), read(m), read(s), read(t);
    for (int i = 1; i <= m; i++) {
	read(u), read(v), read(c); add(u, v, c); add(v, u, c);
    }
    memset(dist1, 127/3, sizeof(dist1));
    SPFA(s, dist1); topsort(s, dist1, ans1);
    memset(dist2, 127/3, sizeof(dist2));
    SPFA(t, dist2); topsort(t, dist2, ans2);
    int ans = 1ll*ans1[t]*ans1[t]%yzd;
    for (int u = 1; u <= n; u++) {
	if (dist1[u] == dist2[u] && dist2[u]*2 == dist1[t]) (ans -= 1ll*ans1[u]*ans1[u]%yzd*ans2[u]%yzd*ans2[u]%yzd) %= yzd;
	for (int i = path[u]; i; i = edge[i].next)
	    if (dist1[u]+edge[i].cost+dist2[edge[i].to] == dist1[t] && dist1[u]*2 < dist1[t] && dist2[edge[i].to]*2 < dist1[t])
		(ans -= 1ll*ans1[u]*ans1[u]%yzd*ans2[edge[i].to]%yzd*ans2[edge[i].to]%yzd) %= yzd;
    }
    writeln((ans+yzd)%yzd);
}
int main() {
    work();
    return 0;
}

Measured memory_bytes: 17500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map <string,ll> mp;
ll num[5];
int main() {
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++){
        string s;
        cin>>s;
        mp[s]++;
    }
    for(auto i=mp.begin();i!=mp.end();i++){
        if(i->first=="AC")  num[1]=i->second;
        if(i->first=="WA")  num[2]=i->second;
        if(i->first=="TLE")  num[3]=i->second;
        if(i->first=="RE")  num[4]=i->second;
    }
    for(ll i=1;i<=4;i++){
        if(i==1)    cout<<"AC x "<<num[i]<<endl;
        if(i==2)    cout<<"WA x "<<num[i]<<endl;
        if(i==3)    cout<<"TLE x "<<num[i]<<endl;
        if(i==4)    cout<<"RE x "<<num[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3596
A, B, C = list(map(int, input().split()))
rs = []
flag = 0

for i in range(1, int(1e20)):
    r = A * i % B
    if r == C:
        flag = 1
        break
    if r in rs:
        break
    rs.append(r)

ans = 'YES' if flag else 'NO'
print(ans)

Measured memory_bytes: 3060
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author KY2001
 */


#include "bits/stdc++.h"
#define int long long
#define For(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define Max(x) *max_element(ALL(x))
#define Min(x) *min_element(ALL(x))
#define Lower_bound(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define Upper_bound(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int bpm(int x, int y) {
  if (x == 0)
    return 0;
  else if (y == 0) {
    return 1;
  }
  int ans = 1;
  x %= MOD;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) {
      ans *= x;
      ans %= MOD;
    }
    x = x * x;
    x %= MOD;
  }
  return ans;
}

class CMakeARectangle {
public:
  int solve(std::istream &cin, std::ostream &cout) {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) { cin >> A[i]; }
    sort(ALL(A));
    vector<int> two_edges;
    rep(i, N - 1) {
      if (A[i + 1] == A[i]) {
        two_edges.emplace_back(A[i]);
        i++;
      }
    }
    sort(ALL(two_edges));
    if (two_edges.size() < 2){
      cout<<0<<endl;
      return 0;
    }
    cout << two_edges[two_edges.size() - 1] * two_edges[two_edges.size() - 2]
         << endl;
  }
};


signed main() {
	CMakeARectangle solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1660
def main():
    import sys
    input = sys.stdin.readline

    def find(x):
        if par[x] < 0:
            return x
        else:
            px = find(par[x])
            wei[x] += wei[par[x]]
            par[x] = px
            return px

    def weight(x):
        find(x)
        return wei[x]


    def unite(x,y,w):
        w += wei[x]-wei[y]
        x = find(x)
        y = find(y)
        
        if x == y:
            return False
        else:
            if par[x] > par[y]:
                x,y = y,x
                w = -w
            par[x] += par[y]
            par[y] = x
            wei[y] = w
            return True

    def same(x,y):
        return find(x) == find(y)

    def size(x):
        return -par[find(x)]

    def diff(x,y):
        return weight(y)-weight(x)

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


    par = [-1]*n
    wei = [0]*n

    for i in range(m):
        l,r,d = map(int,input().split())
        l,r = l-1,r-1
        if same(l,r):
            if d != diff(l,r):
                print('No')
                exit()
        else:
            unite(l,r,d)
    print('Yes')
            
if __name__ == '__main__':
    main()

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

class Dice {
public:
	Dice(int num[6]) {
		t = num[0];
		b = num[5];
		n = num[4];
		s = num[1];
		w = num[3];
		e = num[2];
	}
	bool operator == (Dice& d) {
		for (int i = 0; i < 4; i++) {
			if (t == d.t) {
				if (compDice(d))return true;
			}
			roll_e();
		}
		for (int i = 0; i < 3; i++) {
			roll_n();
			if (t == d.t) {
				if (compDice(d))return true;
			}
		}
		return false;
	}
	bool compDice(Dice& d) {
		for (int i = 0; i < 4; i++) {
			if (t == d.t && b == d.b && n == d.n &&
				s == d.s && w == d.w && e == d.e) {
				return true;
			}
			spin_left();
		}
		return false;
	}

	void roll_e() {
		int temp = w;
		w = b;
		b = e;
		e = t;
		t = temp;
	}
	void roll_w() {
		for (int i = 0; i < 3; i++)roll_e();
	}
	void roll_n() {
		int temp = s;
		s = b;
		b = n;
		n = t;
		t = temp;
	}
	void roll_s() {
		for (int i = 0; i < 3; i++)roll_n();
	}
	void spin_left() {
		int temp = n;
		n = e;
		e = s;
		s = w;
		w = temp;
	}
	int getTop() {
		return t;
	}
private:
	int t, b;
	int n, s, w, e;
};


int main() {
	int d1[6];
	int d2[6];

	for (int i = 0; i < 6; i++) cin >> d1[i];
	for (int i = 0; i < 6; i++)cin >> d2[i];

	Dice dice1(d1);
	Dice dice2(d2);

	if (dice1 == dice2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // freopen("temp.1", "r", stdin);

  int D, N;
  cin >> D >> N;
  ll v;
  v = 1;
  for (int i = 0; i < D; i++) {
    v *= 100;
  }
  if (D == 0 && N == 100)
    N++;
  if (D == 1 && N == 100)
    N++;
  if (D == 2 && N == 100)
    N++;
  cout << v * N << endl;
  return 0;
}

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

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

#ifdef SANJU
    #define localsys 1
#else
    #define localsys 0
#endif

using   lli     =   long long;
using   lld     =   long double;
using   ulli    =   unsigned long long int;
using   pll     =   pair<lli, lli>;
using   ttt     =   pair<lli, pll>;
using   vttt    =   vector<ttt>;
using   vll     =   vector<pll>;
using   vl      =   vector<lli>;
using   vi      =   vector<int>;
using   vvi     =   vector<vector<int>>;
using   cd      =   complex<lld>;

void sanjeev(int kkkk)
{
    int n;
    cin>>n;
    vector<int>A;
    for(int i=0;i<n;i++)
    {
        int t;
        cin>>t;
        A.push_back(t);
    }

    int fr[n+1]={0};

    fr[0]=0;
    fr[1]=abs(A[1]-A[0]);

    for(int i=2;i<A.size();i++)
    {
        int a=abs(A[i]-A[i-1])+fr[i-1];
        int b=abs(A[i]-A[i-2])+fr[i-2];
        fr[i]=min(a,b);
    }

    cout<<fr[n-1];

}

int main()
{
    if(!localsys) ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cout << fixed << setprecision(10);
    int t=1;
    //cin>>t;
    fol(i,0,t) { sanjeev(i+1); }
    if(localsys) system("pause");
}


Measured memory_bytes: 1144