akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    int n;
    cin>>n;
    vi a(n);
    map<int,int> cnt;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        cnt[a[i]]++;
    }
    int ans=0;
    for(auto u:cnt)
    {
        if(u.second>=u.first) ans+=u.second-u.first;
        else ans+=u.second;
    }
    print(ans);
}

Measured memory_bytes: 5120
s=list(input())
for i in range(len(s)):
    s.pop(-1)
    a=[]
    b=[]
    for i in range(len(s)//2):
        a.append(s[i])
        b.append(s[i+len(s)//2])
    if a==b:
        print(len(a)*2)
        break

Measured memory_bytes: 3060
n,k=map(int,input().split())
X=list(map(int,input().split()))
r=10**9
for i in range(n-k+1):
    a=X[i]
    b=X[i+k-1]
    if a*b>=0:
        t=max(abs(a),abs(b))
    else:
        t=min((-a)*2+b,(-a)+2*b)
    r=min(r,t)
print(r)

Measured memory_bytes: 14224
while True:
    a = int(input())
    if a == -1:
        break
    ans = []
    if a == 0:
        print(0)
    else:
        while a != 0:
            ans.append(a%4)
            a //= 4
        ans = list(map(str,ans))
        print("".join(ans[::-1]))


Measured memory_bytes: 5604
// inputに入力データ全体が入る
function Main(input) {
    input = input.split("\n");
    var s = input[0];
    var cnt = 0;
    var max = 0;
    for (var i = 0; i < s.length; i++) {
        var c = s[i];
        if (isACGT(c)) {
            cnt += 1;
        } else {       
	        max = Math.max(max, cnt);
	        cnt = 0;
        }
    }
  	// 最後に抜けた時用
  	max = Math.max(max, cnt);
    console.log(max);
}

function isACGT(input) {
    switch(input) {
        case 'A':
        case 'T':
        case 'C':
        case 'G': 
            return true;
        default: {
            return false;
        }
    }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
s=input() ; n=len(s)
t=input() ; m=len(t)

ans=[[0]*(n+1) for _ in range(m+1)]
dp=[[0]*(n+1) for _ in range(m+1)]

for i in range(1,m+1) :
    for j in range(1,n+1):
        if t[i-1] == s[j-1] :
            ans[i][j]='match' 
            dp[i][j]=dp[i-1][j-1]+1
        else:
            dp[i][j]=dp[i-1][j-1]
            ans[i][j]='lu'
            if dp[i-1][j]>=dp[i][j] :
                dp[i][j]=dp[i-1][j]
                ans[i][j]='u' 
            
            if dp[i][j-1]>=dp[i][j] :
                dp[i][j]=dp[i][j-1]
                ans[i][j]='l' 
for i in range(m+1):
    ans[i][0]='u'
for j in range(n+1):
    ans[0][j]='l'


answer=[]
i=m ; j=n 
while (i>=0 and j>=0):
    if ans[i][j]=='match' :
        answer.append(s[j-1])
        i-=1
        j-=1
    elif ans[i][j]=='l' :
        j-=1
    elif ans[i][j]=='lu':
        i-=1
        j-=1
    else:
        i-=1


answer.reverse()
print(''.join(answer))


Measured memory_bytes: 275984
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define Rep(i,n) for(int i=0;i<=(int)(n-1);i++)
#define REP(i,b,e) for(int i=b;i<(int)e;i++)
typedef long long ll;
typedef map<ll,ll> mll;
typedef vector<ll> vll;
ll INF=1e18;
int inf=1e9+1000;
 
string alpha="abcdefghijklmnopqrstuwvxyz";

ll N,K;
ll A[100002];


int main(){
    cin>>N>>K;
    Rep(i,N){
        cin>>A[i];
    }
    cout<<(N-2)/(K-1)+1<<endl;


    return 0;
}

Measured memory_bytes: 1024
import sys
from itertools import accumulate
from collections import Counter
from bisect import bisect as br, bisect_left as bl
from operator import itemgetter
class DammyMap:
    #1-indexed
    def __init__(self, A, B):
        #Aに初期状態の要素をすべて入れる,Bは値域のリスト
        #self.X, self.comp = self.compress(B)
        self.X = B[:]
        self.comp = {v : k for k, v in enumerate(D, 1)}
        self.size = len(self.X)
        self.tree = [0] * (self.size + 1)
        self.p = 2**(self.size.bit_length() - 1)
        self.dep = self.size.bit_length()
        
        CA = Counter(A)
        S = [0] + list(accumulate([CA[self.X[i]] for i in range(self.size)]))
        for i in range(1, 1+self.size):
            self.tree[i] = S[i] - S[i - (i&-i)]
        
    def compress(self, L):
        #座圧
        L2 = list(set(L))
        L2.sort()
        C = {v : k for k, v in enumerate(L2, 1)}
        # 1-indexed
        return L2, C
    
    def leng(self):
        #今入っている個数を取得
        return self.count(self.size)
    
    def count(self, i):
        #i(Bの元)以下の個数を取得
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
    
    def less(self, v):
        #v(Bの元である必要はない)未満の個数を取得
        i = bl(self.X, v)
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
    
    def leq(self, v):
        #v(Bの元である必要はない)以下の個数を取得
        i = br(self.X, v)
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        #iをx個入れる,負のxで取り出す,iの個数以上取り出すとエラーを出さずにバグる
        i = self.comp[i]
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
        
        
    def get(self, v):
        # v番目の値を取得
        if v <= 0:
            return -1
        s = 0
        k = self.p
        for _ in range(self.dep):
            if s + k <= self.size and self.tree[s+k] < v:
                s += k
                v -= self.tree[s]
            k //= 2
        return self.X[s]

N, Q = map(int, input().split())
stx = [tuple(map(int, sys.stdin.readline().split())) for _ in range(N)]
stx.sort(key = itemgetter(2))
D = [int(sys.stdin.readline()) for _ in range(Q)] 

T = DammyMap(D, D)
ans = [-1]*Q

for s, t, x in stx:
    tl = T.less(s - x)
    tr = T.less(t - x)
    d = tr - tl
    for _ in range(d):
        i = T.get(tl + 1)
        T.add(i, -1)
        ans[T.comp[i]-1] = x
print(*ans, sep = '\n')

Measured memory_bytes: 131736
n = int(input())
s = str(input())
rn = s.count("R")
gn = s.count("G")
bn = s.count("B")

ct=0
for i in range(n):
  for j in range(i+1,n):
    if 2*j - i >= n:
      break
    elif s[i]!=s[j] and s[j]!=s[2*j-i] and s[i]!=s[2*j-i]:
      ct += 1
 
print(rn*gn*bn-ct)

Measured memory_bytes: 9144
import java.util.*

fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map(String::toInt)
    val A = readLine()!!.split(" ").map(String::toLong)
    val queue = PriorityQueue<Long>(N, Comparator { o1: Long?, o2: Long? -> if (o1!! > o2!!) -1 else 1 })
    queue.addAll(A)

    repeat(M) {
        queue.add(queue.poll() / 2)
    }
    println(queue.sum())
}

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

const int MAXn = 1e5+8;
int vis[MAXn], h[MAXn];
vector<int> a[MAXn];
queue<int> q;
int ans = 0;
int n, m;

void bfs(){
	for(int i = 1; i<=n; i++){
		if(!vis[i]){
			q.push(i);
			vis[i] = 1;
			while(!q.empty()){
				int tmp = q.front();
				q.pop();
				bool isPeak = true;
				for(auto w : a[tmp]){
					if(h[w] >= h[tmp]) {
						isPeak = false;
					}
					if(!vis[w]){
						q.push(w);
						vis[w] = 1;
					}
				}
				if(isPeak){
				ans++;
				}
			}
		}
	}
}

int main(){
	cin >> n >> m;
	for(int i = 1; i<=n; i++){
		cin >> h[i];
	}
	int u,v;
	for(int i = 1; i<=m;i++){
		cin >> u >> v;
		a[u].push_back(v);
		a[v].push_back(u);
	}
	bfs();
	cout << ans;
	return 0;
} 

Measured memory_bytes: 9576
#include <iostream>
#include <map>

using namespace std;

class point
{
public:
	int x;
	int y;
	point(){}
	point(int _x, int _y) : x(_x), y(_y) {}
};

typedef pair<int, point> PIP;
typedef map<int, point> MIP;

int r, c, q;
int r1, r2, c1, c2;
int grid;

int main()
{
	MIP m;
	while( 1 )
	{
		cin >> r >> c >> q;
		if(r==0 && c==0 && q==0) break;

		m.clear();
		for(int y=0; y<r; y++)
		{
			for(int x=0; x<c; x++)
			{
				cin >> grid;
				m.insert(PIP(grid, point(x, y)));
			}
		}

		for(int i=0; i<q; i++)
		{
			cin >> r1 >> c1 >> r2 >> c2;
			MIP::iterator iter = m.begin();
			while(iter != m.end())
			{
				int x = (*iter).second.x;
				int y = (*iter).second.y;
				if(x>=c1 && y>=r1 && x<=c2 && y<=r2)
				{
					printf("%d\n", (*iter).first);
					break;
				}
				++iter;
			}
		}
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
   
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
   
int main()
{
    string s;
	cin>>s;
	int n=s.size();
	set<P> st;
	st.insert(P(0, 0));
	int dp[200001];
	int a[200001];
	dp[0]=0;
	a[0]=0;
	for(int i=1; i<=n; i++){
		a[i]=a[i-1]^(1<<(s[i-1]-'a'));
      if(a[i]==0){
        dp[i]=1;
        st.insert(P(a[i], i));
        continue;
      }
		dp[i]=dp[i-1]+1;
      auto itr=st.upper_bound(P(a[i], 1e9));
      itr--;
      if((*itr).first==a[i]){
        int i0=(*itr).second;
        dp[i]=min(dp[i], dp[i0]+1);
      }
		for(int j=0; j<26; j++){
			int a0=a[i]^(1<<j);
          if(a0==0){
            dp[i]=1;
            break;
          }
			auto itr=st.upper_bound(P(a0, 1e9));
			itr--;
			if((*itr).first==a0){
				int i0=(*itr).second;
				dp[i]=min(dp[i], dp[i0]+1);
			}
		}
		st.insert(P(a[i], i));
	}
	cout<<dp[n]<<endl;
    return 0;
}

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

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
    //   if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
	
	ll n;
	cin >> n;
	
	auto d = divisor(n);
	ll mn = 1LL << 60;
	for(auto x: d){
		ll tmp = (x - 1) + (n / x - 1);
		if(mn > tmp){
			mn = tmp;
		}
	}
	
	cout << mn << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,q,l,r,sum=0,a[100010];
  string s;
  cin>>n>>q>>s;
  for(int i=1;i<n;i++){
    if(s[i-1]=='A' && s[i]=='C') sum++;
    a[i]=sum;
  }
  for(int i=0;i<q;i++){
    cin>>l>>r;    
    cout<<a[r-1]-a[l-1]<<endl;
  }
}  

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

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

const int INF = 1 << 24;
 
int main(void){
    int res; cin >> res;

    for(char ope; cin >> ope, ope != '=';){
        int n; cin >> n;
        
        switch(ope){
            case '+':
                res += n;
                break;
            case '-':
                res -= n;
                break;
            case '*':
                res *= n;
                break;
            case '/':
                res /= n;
                break;
            default:
                break;
        }
    }
    cout << res << endl;
 
    return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n,p,ans;
		int mayor[];

		while(true){
			n=sc.nextInt();
			p=sc.nextInt();

			if(n+p==0) break;
			mayor=new int[n];
			for(int i=0;;i++){
				if(p==0){
					p=mayor[i%n];
					mayor[i%n]=0;
				}
				else{
					mayor[i%n]++;
					p--;
					if(p==0){
						if(check(n,i%n,mayor)){
							ans=i%n;
							break;
						}
					}
				}
			}
			System.out.println(ans);
		}
	}
	static boolean check(int n,int k,int m[]){

		for(int i=0;i<n;i++){
			if(i!=k){
				if(m[i]!=0){
					return false;
				}
			}
		}

		return true;
	}

}

Measured memory_bytes: 20236
package main

import (
	"fmt"
)

func main() {
    var a , b int
fmt.Scan(&a)
fmt.Scan(&b)

    if  a<b  {
        fmt.Println("a < b")
    } else if  a>b {
        fmt.Println("a > b")
    } else {
        fmt.Println("a == b")
    }
}



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

int main(void) {
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) {
        cin >> a[i];
    }
    int Max = a[0];
    int Max_idx = 0;
    int Min = a[0];
    int Min_idx = 0;
    FOR(i, 1, N) {
        if(a[i] > Max) {
            Max = a[i];
            Max_idx = i;
        }
        if(a[i] < Min) {
            Min = a[i];
            Min_idx = i;
        }
    }
    if(Max == Min) {
        cout << 0 << endl;
        return 0;
    }
    vector<pair<int, int>> ans;
    if(abs(Max) > abs(Min)) {
        for(int i=1; i<N; ++i) {
            a[i] += Max*2;
            ans.push_back({Max_idx+1, i+1});
            ans.push_back({Max_idx+1, i+1});
            Max = a[i];
            Max_idx = i;
        }
    } else {
        for(int i=N-2; i>=0; --i) {
            a[i] += Min*2;
            ans.push_back({Min_idx+1, i+1});
            ans.push_back({Min_idx+1, i+1});
            Min = a[i];
            Min_idx = i;
        }
    }
    cout << ans.size() << endl;
    for(auto x : ans) {
        cout << x.first << " " << x.second << endl;
    }
}

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

const int Mod = 1000000007;
class mll {
public:
	long long x;
	mll(long long x = 0) : x((x% Mod + Mod) % Mod) {};
	void operator += (const mll& a) {
		if ((x += a.x) >= Mod) x -= Mod;
	}
	void operator *= (const mll& a) {
		(x *= a.x) %= Mod;
	}
	mll operator * (const mll& a) const {
		mll ans = *this;
		ans *= a;
		return ans;
	}
	void pow(long long n) {
		long long xx = x;
		x = 1;
		while (n > 0) {
			if (n & 1) x = x * xx % Mod;
			xx = xx * xx % Mod;
			n >>= 1;
		}
	}
};

int main() {
	string L;
	cin >> L;
	long long N = L.length();
	mll ans = 0, now=1;
	for (long long i = 0; i < N; i++) {
		if (L[i] == '0') continue;
		mll d = 3;
		d.pow(N - i - 1);
		ans += now * d;
		now *= 2;
	}
	ans += now;
	cout << ans.x << endl;
}


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

int main() {
    int K, S;
    cin >> K >> S;
    int counts = 0;
    int maxX = min(K, S);
    for (int x = 0; x <= maxX; ++x){
        int ypz = S - x;
        if (ypz <= K){
            counts += ypz + 1;
        }else if (ypz <= 2 * K){
            counts += 2 * K - ypz + 1;
        }
    }
    cout << counts << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
sl = [input() for _ in [0]*n]
count = 0
dict = {}
for s_raw in sl:
  s = ''.join(sorted(s_raw))
  if s in dict:
    count += dict[s]
    dict[s] += 1
  else:
    dict.setdefault(s, 1)
print(count)

Measured memory_bytes: 24972
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
int main()
{
    ///"In the name of Allah,most gracious and most merciful"///

    ll i,j,x,y,z,count=100000000000,sum=0,n,ans=0;
    cin>>x>>y>>z;
    j=y/z;
    i=x/z;
    if(x%z==0)
        cout<<(j-i+1)<<endl;
    else
        cout<<(j-i)<<endl;

    return 0;
}







Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF (1LL<<60)
#define MOD 1000000007

long long N, A;
long long D[1000001];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> A;
  long long m = N;
  for (int t=1; t<=40; t++) {
    for (int k=1; k<=t; k++) {
      // x^k * (x+1)^(t-k) >= N
      long long lo = 0, hi = 1e13;
      while (hi - lo > 1) {
        long long mid = (lo+hi)/2;
        __int128 p = 1;
        rep(_, k) if (p < N) p *= mid;
        rep(_, t-k) if (p < N) p *= mid+1;
        if (p >= N) hi = mid;
        else lo = mid;
      }
      long long x = hi;
      //rep(i, k)cout<<x<<","; rep(i, t-k)cout<<x+1<<","; cout<<" >= "<<N<<"\n";
      m = min(m, A*(t-1) + x*k + (x+1)*(t-k));
    }
  }
  cout << m << "\n";
  return 0;
}


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

#define FastRead  ios_base::sync_with_stdio(0);cin.tie(0);
#define endl      "\n"
#define pi        acos(-1.0)

typedef long long unsigned llu;

int main()
{
    FastRead

    long double a,b,c,eps = 1.0e-14;

    cin>>a>>b>>c;

    if(sqrt(a)+sqrt(b)+eps<sqrt(c))
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int x;
    cin>>x;
    if(x==0)cout<<1<<endl;
    else cout<<0<<endl;



}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7,N = 1e5 + 1;
int dp[2][N],s,t,n,m;
long long dis[2][N];
struct edges{
	int x,y,w;
}e[N<<1];
struct node{
	int x,w;
	node(int a = 0,int b = 0){
		x = a;w = b;
	}
};
void add(int &a,int b){
	a+=b;
	a%=M;
	if(a >= M)a-=M;
	if(a < 0)a+=M;
}
vector<node>g[N];
bool vis[N];
void dijk(int s,bool at){
	long long *dis = ::dis[at];
	memset(vis,0,sizeof vis);
	int *dp = ::dp[at];
	dis[s] = 0;
	dp[s] = 1;
	priority_queue<pair<long long,int>>q;
	q.push({0,s});
	while(!q.empty()){
		int x = q.top().second;
		long long w = -q.top().first;
		q.pop();
		if(vis[x])continue;
		vis[x] = 1;
		for(auto i : g[x]){
			int y = i.x;
			long long cur = w + i.w;
			if(cur == dis[y])add(dp[y],dp[x]);
			if(cur >= dis[y])continue;
			dp[y] = dp[x];
			dis[y] = cur;
			q.push({-dis[y],y});
		}
	}
}
int main(){
	scanf("%d%d%d%d",&n,&m,&s,&t);	
	for(int i = 0;i < m;i++){
		scanf("%d%d%d",&e[i].x,&e[i].y,&e[i].w);
		int a = --e[i].x,b = --e[i].y,c = e[i].w;
		g[a].push_back({b,c});
		g[b].push_back({a,c});
	}
	for(int i = 0;i < n;i++)dis[0][i] = dis[1][i] = 1e18;
	dijk(--s,0);
	dijk(--t,1);
	long long mndis = dis[0][t];
	int ans = dp[0][t]*1LL*dp[0][t]%M,sz = 0;
	for(auto i : e){
		if(sz == m)break;
		++sz;
		long long mn = min(dis[0][i.x],dis[0][i.y]);
		long long mx = min(dis[1][i.x],dis[1][i.y]);
		if(mn == dis[0][i.y])swap(i.x,i.y);
		if(mn + mx + i.w == mndis && mn * 2 < mndis && mx * 2 < mndis)add(ans,-(dp[0][i.x]*1LL*dp[0][i.x]%M)*(dp[1][i.y]*1LL*dp[1][i.y]%M)%M);
	}
	for(int i = 0;i < n;i++)
		if(dis[0][i] == dis[1][i])add(ans,-(dp[0][i]*1LL*dp[0][i]%M)*(dp[1][i]*1LL*dp[1][i]%M)%M);
	printf("%d\n",ans);
}

Measured memory_bytes: 16724
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;

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

ll coun = 0;

int main()
{
  string s, t;
  cin >> s >> t;
  int ss = s.size();
  int ts = t.size();

  vector<string> l;

  rep(i, ss - ts + 1) {
    bool isMatch = true;
    rep(j, ts) {
      if (s[i + j] != t[j] && s[i + j] != '?') {
        isMatch = false;
      }
    }
    if (isMatch) {
      string tmp = s;
      rep(index, ts) {
        tmp[i + index] = t[index];
      }
      rep(index, ss) { // ? を置き換え
        if (tmp[index] == '?')
          tmp[index] = 'a';
      }
      l.push_back(tmp);
    }
  }

  sort(l.begin(), l.end());
  if (l.empty()) {
    cout << "UNRESTORABLE" << endl;
  } else {
    cout << l[0] << endl;
  }
}


Measured memory_bytes: 3632
#pragma comment(linker, "/STACK: 16777216")

#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back


using namespace std;
void dout() { cerr << endl; }
//typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl


using ll = long long;
//#ifdef __int128
//using hll = __int128;
//#endif
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}


#ifdef _getchar_nolock
#else
#define _getchar_nolock getchar_unlocked
#endif

template <typename T>
void freadT(T &x) {
    x = 0;
    char ch = _getchar_nolock();
    ll sign = 1;

    while (!isdigit(ch)) {
        if (ch == '-')
            sign *= -1;
        ch = _getchar_nolock();
    }

    while (isdigit(ch)) {
        x = x * 10 + ch - '0';
        ch = _getchar_nolock();
    }

    x *= sign;
}

int fparse(string s, int start_indx) {
    int x = 0;

    while (isdigit(s[start_indx])) {
        x = x * 10 + s[start_indx] - '0';
        ++start_indx;
    }

    return x;
}

//#define solvsh
//#define multi

#ifdef solvsh
#else


ll mod = 998244353;

ll add(ll a, ll b){
    return (a + b) % mod;
}
ll mult(ll a, ll b) {
    return (a * b) % mod;
}

const int MAXN = 3e5 + 120;

void solve() {

    ll n, x, t;
    cin >> n >> x >> t;

    ll cnt = (n + x - 1) / x;

    ll answr = t * cnt;
    cout << answr << "\n";

}


#endif

clock_t timestamp_start = clock();
void time_calc()
{
    cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << "\n";
}


void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
        solve();
        i++;
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifndef ONLINE_JUDGE

#else

#endif
#ifdef multi
    multisolve();
#else
    solve();
//    gen();
#endif
}


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

int main() {
    int K, S;
    cin >> K >> S;

    int ans = 0;
    for (int x = 0; x <= K; x++) {
        for (int y = 0; y <= K; y++) {
            int z = S - x - y;
            if (0 <= z && z <= K) {
                ans++;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int maxn=8e2+10;
using namespace std;
char a[maxn][maxn];
int n,m,k;
int stmp[maxn][maxn];
int posi[4][2]={1,0,-1,0,0,1,0,-1};
bool check(int x,int y)
{
    if(x>=0&&x<n&&y>=0&&y<m&&stmp[x][y]==0&&a[x][y]=='.')
    {
       return 1;
    }
    return 0;
}
queue<pair<int,int> >po;
int main()
{
    int ans=99999999;
    cin>>n>>m>>k;
    for(int i=0;i<n;i++)
    {
        scanf("%s",&a[i]);
    }
    int sx,sy;
    for(int i=0;i<n;i++)
    {
       for(int j=0;j<m;j++)
       {
          if(a[i][j]=='S')
          {
             sx=i;
             sy=j;
          }
       }
    }
    stmp[sx][sy]=1;
    po.push(make_pair(sx,sy));
    while(!po.empty())
    {
        int x=po.front().first;
        int y=po.front().second;
        ans=min(ans,min(min(x,n-x-1),min(y,m-y-1)));
        po.pop();
        for(int i=0;i<4;i++)
        {
            int xx=x+posi[i][0];
            int yy=y+posi[i][1];
            if(check(xx,yy)&&stmp[x][y]<=k)
            {
               stmp[xx][yy]=stmp[x][y]+1;
               po.push(make_pair(xx,yy));
            }
        }
    }
    int anss;
    if(ans%k==0)
    {
        anss=1+ans/k;
    }
    else
    {
        anss=2+ans/k;
    }
    cout<<anss<<endl;
    return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "YES" : "NO") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

vector<string> split(string,string);

//template<typename T>
//void swap(T*,T*);
//char ToUpper (char cX) { return toupper(cX); }

int main()
{
    string N;
    cin >> N;
    cout << "ABC" << N ;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;

int main()
{
    ll a,b,i,j,n,t;
    string s;
    cin>>s;
    ll ans;
    if(s=="RRR") ans=3;
    else if((s[0]=='R' && s[1]=='R') || (s[1]=='R' && s[2]=='R')) ans=2;
    else if(s[0]=='R' || s[1]=='R' || s[2]=='R') ans=1;
    else ans=0;
    cout<<ans;
}

Measured memory_bytes: 3624
n = int(input())
w = [input() for _ in range(n)]
w_l = [w[0]]
w_ = w[0][-1]
for wi in w[1:]:
    if w_ != wi[0] or wi in w_l:
        print("No")
        exit()
    w_ = wi[-1]
    w_l.append(wi)
print("Yes")

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

int main() {
	int n,a[100100]; cin>>n; for(int i=0;i<n;i++)cin>>a[i];
	int fr=0,two=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]%4==0)fr++;
		else if(a[i]%2==0)two++;
	}
	if((fr+two/2)>=(n)/2)cout<<"Yes";
	else cout<<"No";
	}

Measured memory_bytes: 640
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');

while (line = lines.shift()) {
    const numbers = line.split(' ').map(Number);

    // Edit from here
    let a = numbers[0];
    let b = numbers[1];

    if ( a === 0 && b === 0 ) { break; }

    if ( a > b ) {
        const tmp = a;
        a = b;
        b = tmp;
    } 

    const output = a + ' ' + b;
    // to here
    
    console.log(output);
    

}


Measured memory_bytes: 19092
#include <bits/stdc++.h>
#define INF 1e18
#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 all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int n;
    cin >> n;
    map<string, int> mp;
    vector<string> s(n);
    rep(i, n)
    {
        cin >> s[i];
        mp[s[i]]++;
    }
    int m;
    cin >> m;
    rep(i, m)
    {
        string t;
        cin >> t;
        mp[t]--;
    }
    int ans = 0;
    rep(i, n) ans = max(ans, mp[s[i]]);
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

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

		String line1 = sc.nextLine();
		List<String> lines1 = Arrays.asList(line1.split(" "));

		if (lines1.get(0).equals(lines1.get(1))) {
			System.out.println("Draw");
			return;
		}else if (lines1.get(0).equals("1")) {
			System.out.println("Alice");
			return;
		}else if (lines1.get(1).equals("1")) {
			System.out.println("Bob");
			return;
		}else {
			Integer a = Integer.parseInt(lines1.get(0));
			Integer b = Integer.parseInt(lines1.get(1));
			if(a > b) {
				System.out.println("Alice");
				return;
			}else {
				System.out.println("Bob");
				return;
			}
		}
	}

}

Measured memory_bytes: 23764
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Text.Parsec
import Text.Parsec.String
import Test.HUnit


main :: IO ()
-- main = runTestTT (TestList tests) >> return ()
main = do
  n <- getl toInt
  xs <- replicateM n getLine
  mapM_ putStrLn $ solve xs

solve :: [String] -> [String]
solve = map snake

snake :: String -> String
snake s
  | a = "A"
  | b = "B"
  | otherwise = "NA"
  where
    a = either (\_ -> False) id (parse snakeA "" s)
    b = either (\_ -> False) id (parse snakeB "" s)

snakeA :: Parser Bool
snakeA = do
  string ">'"
  a <- many1 (char '=')
  char '#'
  b <- many1 (char '=')
  char '~'
  return $ length a == length b
  
snakeB :: Parser Bool
snakeB = do
  string ">^"
  many1 (string "Q=")
  string "~~"
  return True
  
toInt :: String -> Int
toInt s = read s

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 9428
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define pb(x) push_back(x)
#define int long long

int N;
vector<int> A;

signed main(void){
	cin >> N;
	int sum = 0;
	rep(i, N){
		int a;
		cin >> a;
		sum += a;
		A.pb(a);
	}

	cout << sum-N << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iterator>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <string>
#include <vector>
#include <limits>
#include <queue>
#include <cmath>
#include <map>
#include <set>

using namespace std;

using ll = long long;

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

    string s;
    cin >> s;

    int cnt = 0;
    for(int i = 1; i < n; ++i)
        if(s[i - 1] != s[i])
            ++cnt;

    int good = n - 1 - cnt;
    int pairs = min(cnt / 2, k);
    good += 2 * pairs;
    k -= pairs;
    if(k != 0 && good != n - 1)
        ++good;

    cout << good << endl;

    /*
    cout << "cnt = " << cnt << endl;
    cout << "good = " << n - 1 - cnt << endl;
    */

    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    int A, B, K;
    scanf("%d %d %d", &A, &B, &K);
    vector<int> ans;
    int c = 1;
    while(c <= A && c <= B){
        if(A % c == 0 && B % c == 0) {
            ans.push_back(c);
        }
        c++;
    }
    printf("%d", ans[ans.size() - K]);
    return 0;
}

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

int main() {
    //input
  int n, m;
  scanf("%d%d",&n,&m);
  vector<int> a(m);
  rep(i, m) cin >> a[i];
  for (int i = n;;++i) { //n, n+1, n+2, ...
    bool ok = true;
    int x = i;
    while (x) { //1の位の数字が0になったら停止
      rep(j,m) if (x%10 == a[j]) ok = false; //xの1,10,100,...の位の数が嫌いな数字だったらfalse
      x /= 10; //10で割って切り捨てるごとに一つ上の位の数字を1の位に持ってくる
    }
    if (ok) { //嫌いな数字が来たら表示できない
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%s %s", $a, $b);
if($a == 'H' && $b == 'H'){
  echo 'H';
}elseif($a == 'H' && $b == 'D'){
  echo 'D';
}elseif($a == 'D' && $b == 'H'){
  echo 'D';
}elseif($a == 'D' && $b == 'D'){
  echo 'H';
}
?>

Measured memory_bytes: 4604
#include <cstdio>
#include <algorithm>
#include <functional>

int main()
{
  int n;
  long long a, b;
  scanf("%d%lld%lld", &n, &a, &b);
  long long h[100000];
  for (int i = 0; i < n; ++i)
  {
    scanf("%lld", h + i);
  }
  std::sort(h, h + n, std::greater<long long>());
  long long l = 0, r = 1e10;
  while (r - l > 1)
  {
    long long t = l + (r - l) / 2;
    long long ex = 0;
    for (long long i = 0; i < n; ++i)
    {
      if (h[i] < b * t) break;
      ex += (h[i] - b * t + a - b - 1) / (a - b);
    }
    if (ex > t)
    {
      l = t;
    }
    else
    {
      r = t;
    }
  }
  printf("%lld\n", r);
  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
ll a[100000];
int main()
{
	int n;
	ll ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	if(a[n-1]!=2)
	{
		cout<<-1<<endl;
		return 0;
	}
	ll l=1;ll r=1;
	for(int i=n-2;i>-1;i--)
	{
		ll tmpl,tmpr;
		tmpl=a[i+1]*l/a[i];
		if((a[i+1]*l)%a[i]!=0)
			tmpl++;
		tmpr=(a[i+1]*(r+1)-1)/a[i];
		if(tmpl>tmpr)
		{
			cout<<-1<<endl;
			return 0;
		}
		l=tmpl;r=tmpr;
	}
	l=l*a[0];
	r=r*a[0]+a[0]-1;
	cout<<l<<" "<<r<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
  int w, h, x, y, r;
  scanf("%d%d%d%d%d", &w, &h, &x, &y, &r);
  if(x - r >= 0 && y - r >= 0 && x + r <= w && y + r <= h) printf("Yes\n");
  else printf("No\n");
}



Measured memory_bytes: 2688
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n, x;
    scan(n, x);
    auto a = readln.split.to!(int[]);

    auto sg = SegmentTree!(int, min, inf3)(a ~ a);

    long ans = inf6;

    foreach (k ; 0 .. n) {
        long t;
        foreach (i ; 0 .. n) {
            t += sg.query(n + i - k, n + i + 1);
        }
        t += 1L * k * x;
        ans = min(ans, t);
    }

    writeln(ans);
}




struct SegmentTree(T, alias op, T initValue = 0) {
    import std.functional : binaryFun;

    alias f = binaryFun!(op);

    T[] _data;
    int _treeSize, _lineSize = 1;

    // 配列の要素数 n だけ与えて初期化
    this(int n) {
        while (_lineSize < n) {
            _lineSize *= 2;
        }
        _treeSize = 2 * _lineSize - 1;
        _data = new T[](_treeSize);
        _data[] = initValue;
    }

    // 配列 a を与えて初期化
    this(T[] a) {
        auto n = a.length;
        while (_lineSize < n) {
            _lineSize *= 2;
        }
        _treeSize = 2 * _lineSize - 1;
        _data = new T[](_treeSize);
        _data[] = initValue;

        _data[_lineSize - 1 .. _lineSize - 1 + n] = a[];

        foreach_reverse (i; 0 .. _lineSize - 1) {
            _data[i] = f(_data[2 * i + 1], _data[2 * i + 2]);
        }
    }

    // a[i] = x
    void assign(int i, T x) {
        i += _lineSize - 1;
        _data[i] = x;

        while (i > 0) {
            i = (i - 1) / 2;
            _data[i] = f(_data[2 * i + 1], _data[2 * i + 2]);
        }
    }

    // a[i] = f(a[i], x)
    void act(int i, T x) {
        i += _lineSize - 1;
        _data[i] = f(_data[i], x);

        while (i > 0) {
            i = (i - 1) / 2;
            _data[i] = f(_data[2 * i + 1], _data[2 * i + 2]);
        }
    }

    alias add = act;

    // 要求区間 [a, b) に対して、対象区間 [l, r) の値を返す
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r == -1) {
            r = _lineSize;
        }
        if (a >= b) { // 要求区間が空である場合
            return initValue;
        }
        if (b <= l || r <= a) { // 要求区間が対象区間外の場合
            return initValue;
        }
        if (a <= l && r <= b) { // 要求区間が対象区間に含まれている場合
            return _data[k];
        }

        // どちらでもない場合は対象区間を２つに分けて再帰する

        auto leftValue = query(a, b, 2 * k + 1, l, l + (r - l) / 2);
        auto rightValue = query(a, b, 2 * k + 2, l + (r - l) / 2, r);

        return f(leftValue, rightValue);
    }
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 2428
#if 0
date +%Y.%m.%d

O(n^2m) 可过，我惊了。。。
#endif
#include <cstdio>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

const int maxn = 404, maxm = 100005;
int a[maxm], b[maxm];
bool f[maxn][maxn], g[maxn];

int main() {
	int n = read, m = read;

	for(int i = 1; i <= m; i ++)
		read(a[i], b[i]);

	for(int i = 1; i <= n; i ++) {
		f[i][i] = 1;
		for(int j = m; j; j --) {
			if(f[i][a[j]] and f[i][b[j]]) {
				g[i] = 1;
				break;
			}
			if(f[i][a[j]] or f[i][b[j]])
				f[i][a[j]] = f[i][b[j]] = 1;
		}
	}

	int ans = 0;
	for(int i = 1; i < n; i ++)
		if(!g[i])
			for(int j = i + 1; j <= n; j ++)
				if(!g[j]) {
					for(int k = 1; k <= n; k ++)
						if(f[i][k] and f[j][k])
							goto FAIL;
					++ ans;
FAIL:;
				}

	printf("%d\n", ans);
}


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

int main(){
int a, b, c;
  cin >> a >> b >> c;
  
  if((a != b) && (b != c) && (c != a)){
  cout << 3 << endl;
  }
  else if(((a == b) && (b != c) && (c != a)) || ((a != b) && (b == c) && (c != a)) || ((a != b) && (b != c) && (c == a))){
  cout << 2 << endl;
  }
  else{
  cout << 1 << endl;
  }
}

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

using namespace std;

int main() {
    int N;
    int A[210];

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

    while(true) {
        bool exist_odd = false;
        for(int i = 0; i < N; ++i) {
            if(A[i] % 2 != 0) exist_odd = true;
        }

        if(exist_odd) break;

        for(int i = 0; i < N; ++i) {
            A[i] /= 2;
        }
        ++res;
    }

    cout << res << endl;


    return 0;
}

Measured memory_bytes: 256
A, B, C, D, E, F = map(int, input().split())

water_cand = []
for i in range(F):
    for j in range(F):
        tmp = 100 * A * i + 100 * B * j
        if tmp > F:
            break
        water_cand.append(tmp)

ws_cand = []
for x in water_cand:
    for i in range(F-x+1):
        for j in range(F-x+1):
            tmp = C * i + D * j
            if x + tmp == 0:
                ws_cand.append((x, tmp))
                continue
            if x + tmp <= F and (tmp / (x+tmp)) <= (E / (100+E)):
                ws_cand.append((x, tmp))
            elif x + tmp > F:
                break
if len(ws_cand) == 1 and ws_cand[0] == (0, 0):
    print(0, 0)
    exit()
ws_cand.remove((0, 0))
ans = max(ws_cand, key=lambda x: x[1] / (x[0]+x[1]))
print(ans[0]+ans[1], ans[1])

Measured memory_bytes: 63532
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<pair<int, long long int> > > v(100000);
	for(int i = 0; i < m; i++){
		int l, r;
		long long int d;
		cin >> l >> r >> d;
		v[l].push_back(make_pair(r, d));
		v[r].push_back(make_pair(-l, d));
	}
	vector<long long int> x(100001, -mod);
	for(int i = 1; i <= n; i++){
		if(x[i] != -mod) continue;
		x[i] = 0;
		queue<int> qu;
		qu.push(i);
		while(!qu.empty()){
			int now = qu.front();
			qu.pop();
			for(int j = 0; j < v[now].size(); j++){
				int lr = v[now][j].first;
				long long int d = v[now][j].second;
				if(x[abs(lr)] == -mod){
					if(lr > 0) x[lr] = x[now] + d;
					else x[-lr] = x[now] - d;
					qu.push(abs(lr));
				} else if(abs(x[abs(lr)] - x[now]) != d){
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
 }

Measured memory_bytes: 13824
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll n;
  cin >> n;
  ll res = 0;
  map<string, ll> table;
  rep(i, n) {
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    auto it = table.find(s);
    if (it != table.end()) {
      it->second++;
    } else {
      table[s] = 1;
    }
  }
  for (auto it = table.begin(); it != table.end(); it++) {
    res += it->second * (it->second - 1) / 2;
  }

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

Measured memory_bytes: 11136
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll pow(ll x,ll y){
  if(y==0) return 1;
  ll res=pow(x,y/2);
  res*=res;
  res%=mod;
  if(y%2==1) res*=x;
  return res%mod;
}
ll gyaku(ll x){
  return pow(x,mod-2);
}
vector<ll> frac,gfrac;
void set_frac(ll n){
  frac.push_back(1);
  gfrac.push_back(1);
  for(ll i=1;i<=n;i++){
    frac.push_back(frac[i-1]*i%mod);
    gfrac.push_back(gyaku(frac[i]));
  }
}
ll nCr(ll n,ll r){
  ll res=frac[n]*gfrac[r]%mod;
  res*=gfrac[n-r];
  return res%mod;
}
ll read(){
  ll res;
  cin>>res;
  return res;
}
int main(){
  ll n;
  cin>>n;
  vector<ll> vec;
  for(int i=0;i<n;i++) vec.push_back(read());
  ll ans=0,gsum=0;
  for(int i=0;i<n-1;i++){
    gsum+=gyaku(i+1);
    gsum%=mod;
    ans+=(gsum*(vec[i+1]-vec[i]))%mod;
    ans%=mod;
  }
  for(ll i=1;i<n;i++){
    ans*=i;
    ans%=mod;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1400
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    int x=s.length();
    for(int i=0;i<x;i++)
    {
        if(s[i]==',')
            s[i]=' ';
    }
    for(int i=0;i<x;i++)
    {
        cout<<s[i];
    }
    return 0;
}

Measured memory_bytes: 256
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort(all(x), greater<>())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
#define INF 1e9;
#define LINF 1e18;
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;}
// clang-format on

void solve(std::string S) {
  if (S == "zyxwvutsrqponmlkjihgfedcba") {
    ANS(-1);
    return;
  }
  if (S.size() < 26) {
    string chars;
    rep(i, 26) {
      chars += 'a' + i;
    }
    rep(i, S.size()) {
      chars.erase(remove(all(chars), S[i]), chars.end());
    }
    ANS(S << chars[0]);
  } else {
    rrep(i, S.size() - 1) {
      if (S[i + 1] > S[i]) {
        string s = S.substr(0, i);
        for (char r = S[i] + 1; r <= 'z'; r = (char)(r + 1)) {
          int pos = s.find(r);
          if (pos == string::npos) {
            ANS(s << r);
            return;
          }
        }
      }
    }
  }
}

// clang-format off
int main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printYesNo(b) \
  if (b)              \
  {                   \
    printYes();       \
  }                   \
  else                \
  {                   \
    printNo();        \
  }

#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  string w;
  cin >> w;
  vector<int> alphabet_count(30, 0);
  rep(i, w.size())
  {
    alphabet_count[w[i] - 'a']++;
  }
  bool is_ok = true;
  rep(i, alphabet_count.size())
  {
    if (alphabet_count[i] % 2 == 1)
      is_ok = false;
  }
  printYesNo(is_ok);
  return 0;
}

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

int SelectionSort(int a[], int n){
  int count = 0;

  for(int i=0; i<n; i++){
    int minj=i;
    for(int j=i; j<n; j++){
      if(a[j]<a[minj]) minj = j;
    }
    if(i!=minj){
        swap(a[i], a[minj]);
        count++;
    }
  }
  return count;
}

int main(void){
  int n;
  cin >> n;
  int a[n];
  for (int i=0; i<n; i++){
    cin >> a[i];
  }
  int count = SelectionSort(a, n);
  for(int i=0; i<n; i++){
    if(i) cout << " ";
    cout << a[i];
  }
  cout << endl;
  cout << count << endl;
  return 0;
}



Measured memory_bytes: 3104
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stdio.h>

using namespace std;




int main()
{
    int sum=0,ans=0;
    int n;
    cin>>n;
    ans=n;
    while(n)
    {
    sum+=n%10;
    n=n/10;
    }
    if(ans%sum==0)cout<<"Yes";
    else cout<<"No";
    //ystem("pause");
    return 0;
}

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

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

  

  int x=2*n;
  vector<int> a(x);

  for(int i=0;i<x;i++){
    cin >> a.at(i);
  }
  int ans =0;
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    ans += a.at(i*2);
  }
  cout <<ans <<endl;
}

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

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

    return gcd(b, a%b);
}

int main(){

    int n;
    cin >> n;

    int a;
    cin >> a;
    
    for (int i = 0; i<n; i++){
        int b;
        cin >> b;

        a = gcd(a, b);
    }

    cout << a << endl;
}

Measured memory_bytes: 3608
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

vector<int> prime(int n){
    vector<int> t;
    vector<bool> x(n+1, true);
    t.push_back(2);

    int i;
    for(i = 3; i * i <= n; i += 2){
        if(!x[i]){
            continue;
        }
        t.push_back(i);
        for(int j = i; j <= n; j += i){
            x[j] = false;
        }
    }
    for(; i <= n; i += 2){
        if(x[i]){
            t.push_back(i);
        }
    }
    return t;
}

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

    int n, p;
    cin >> n >> p;

    if(n == 1){
        cout << p << endl;
        return 0;
    }

    vector<int> vp = prime(1000000);
    vector<int> a(SZ(vp));

    int m = p;
    rep(i, SZ(vp)){
        if(m % vp[i] == 0){
            while(m % vp[i] == 0){
                m /= vp[i];
                a[i]++;
            }
        }
    }

    int ans = 1;
    rep(i, SZ(vp)){
        if(a[i] >= n){
            while(a[i] >= n){
                ans *= vp[i];
                a[i] -= n;
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2412