akhauriyash/Code-Regression huggingface dataset:
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << "debug " <<"LINE:"<<__LINE__<<"  "<< #i <<":"<< i << std::endl

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if ((a == 0)||(mod!=-1&&a%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<ll, ll>;

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

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

  ll n,m;
  std::cin>>n>>m;

  std::vector<std::vector<ll>> graph(n);
  rep(i,0,m){
    ll a,b;
    std::cin>>a>>b;
    a--;b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  std::vector<ll> per;
  rep(i,1,n)per.push_back(i);

  ll ans=0;

  do{
    bool isok=true;
    ll now=0;

    rep(i,0,n-1){
      if(std::find(all(graph[now]),per[i])==graph[now].end()){
        isok=false;
        break;
      }
      now=per[i];
    }

    if(isok)ans++;
  }while(std::next_permutation(all(per)));

  std::cout<<ans<<"\n";

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	ll l, r, res=2020;
	cin>>l>>r;
	if(r-l>=2019) return cout<<0, 0;
	for(ll j=l;j<=r;j++){
		for(ll i=l;i<j;i++)
			res=min(res,(i*j)%2019);
	}
	cout<<res;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define INF 1e+17
#define int long long
using namespace std;

int seg,segMin[2][600000],segMax[2][600000];

int getMin(int a,int b,int k,int l,int r,int num){
	if(b <= l || r <= a) return INF;
	if(a <= l && r <= b) return segMin[num][k];
	return min(getMin(a,b,k * 2 + 1,l,(l + r) / 2,num),getMin(a,b,k * 2 + 2,(l + r) / 2,r,num));
}

int getMax(int a,int b,int k,int l,int r,int num){
	if(b <= l || r <= a) return 0;
	if(a <= l && r <= b) return segMax[num][k];
	return max(getMax(a,b,k * 2 + 1,l,(l + r) / 2,num),getMax(a,b,k * 2 + 2,(l + r) / 2,r,num));
}

void updMin(int i,int x,int num){
	i += seg - 1;
	segMin[num][i] = min(x,segMin[num][i]);
	while(i){
		i = (i - 1) / 2;
		segMin[num][i] = min(segMin[num][i * 2 + 1],segMin[num][i * 2 + 2]);
	}
}

void updMax(int i,int x,int num){
	i += seg - 1;
	segMax[num][i] = max(x,segMax[num][i]);
	while(i){
		i = (i - 1) / 2;
		segMax[num][i] = max(segMax[num][i * 2 + 1],segMax[num][i * 2 + 2]);
	}
}

signed main(){
	int n,d,x[200000],y[200000],b[200000];
	cin >> n >> d;
	seg = 1;
	while(seg < n) seg *= 2;
	for(int i = 0;i < seg * 2 - 1;i++){
		segMin[0][i] = INF;
		segMin[1][i] = INF;
	}
	vector<int> vec;
	for(int i = 0;i < n;i++){
		cin >> x[i] >> y[i] >> b[i];
		vec.push_back(b[i]);
	}
	sort(vec.begin(),vec.end());
	vec.erase(unique(vec.begin(),vec.end()),vec.end());
	for(int i = 0;i < n;i++){
		int pos = lower_bound(vec.begin(),vec.end(),b[i]) - vec.begin();
		updMin(pos,x[i],0);
		updMax(pos,x[i],0);
		updMin(pos,y[i],1);
		updMax(pos,y[i],1);
	}
	int ma = 0;
	for(int i = 0;i < vec.size();i++){
		int low = lower_bound(vec.begin(),vec.end(),vec[i]) - vec.begin();
		int up = upper_bound(vec.begin(),vec.end(),vec[i] + d) - vec.begin() - 1;
		//cout << getMax(low,up + 1,0,0,seg,0) << " " << getMin(low,up + 1,0,0,seg,0) << " " << getMax(low,up + 1,0,0,seg,1) << " " << getMin(low,up + 1,0,0,seg,1) << endl;
		ma = max(ma,(getMax(low,up + 1,0,0,seg,0) - getMin(low,up + 1,0,0,seg,0)) * (getMax(low,up + 1,0,0,seg,1) - getMin(low,up + 1,0,0,seg,1)));
	}
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 23764
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    
    # https://atcoder.jp/contests/abc005/tasks/abc005_4
    # https://qiita.com/drken/items/56a6b68edef8fc605821#4-%E4%BA%8C%E6%AC%A1%E5%85%83%E7%B4%AF%E7%A9%8D%E5%92%8C
    # https://upura.hatenablog.com/entry/2019/04/01/212701
    N,M,Q=map(int,input().split())
    D=[[0]*N for _ in range(N)]
    for i in range(M):
        l,r=map(int,input().split())
        l-=1
        r-=1
        D[l][r]+=1

    
    # 2次元累積和
    # S[x][y]:= [0:x] * [0:y]の長方形区間の和
    S = [[0] * (N + 1) for _ in range(N + 1)]
    for i in range(N):
        for j in range(N):
            S[i + 1][j + 1] = S[i][j + 1] + S[i + 1][j] - S[i][j] + D[i][j]
    
    for i in range(Q):
        p,q=map(int,input().split())
        x1,y1=p-1,p-1
        x2,y2=q,q
        ans=S[x2][y2] - S[x1][y2] - S[x2][y1] + S[x1][y1]
        print(ans)
    
    
    
    
resolve()

Measured memory_bytes: 80768
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char ch;
    bool f=0;
    while(scanf("%c",&ch) != EOF) if(f) if(ch=='F') return 0*printf("Yes\n"); else f=1; else if(ch=='C') f=1;
    return 0*printf("No\n");
}

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

S = int(input())
lis = []
for item in range(0,int(S)):
    tmp = input()
    lis.append(int(tmp))
ls = sorted(lis)
lsb = sorted(lis)

center = ls[int(S/2-0.5)]
ans1 = ls[-1] - center
ls.remove(center)
for k in range(0,int(S/2)):
    try:
        
        ans1 = ans1 + ls.pop(-1) - ls[0]
        ans1 = ans1 + ls[-1] -ls.pop(0)
    except:
        break
    
if S % 2 ==0:
    print(ans1)
    exit()

center = lsb[int(S/2)]
ans2 = center - lsb[0] 

lsb.remove(center)

for k in range(0,int(S/2)):
    try:
        ans2 = ans2 + lsb[-1] - lsb.pop(0) 
        ans2 = ans2 + lsb.pop(-1) - lsb[0] 

    except:
        break
print(max(ans1,ans2))
    

Measured memory_bytes: 8928
n=int(input())
d=0
x=[0 for i in range(n)]
y=[0 for i in range(n)]
for i in range(n):
    x[i],y[i]=map(int,input().split())

for i in range(n-2):
    if(x[i]==y[i] and x[i+1]==y[i+1] and x[i+2]==y[i+2]):
        d=d+1
    else:
        d=d
if(d>0):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9200
#include<iostream>
#include<cmath>
#include<string>
#include<map>
#include<queue>
#define N 3
#define N2 9
using namespace std;
 
struct Puz{
  int f[N2];
  int space;
  string path;
  
  bool operator < (const Puz &p) const{
    for(int i = 0; i < N2; i++){
      if(f[i]==p.f[i]) continue;
      
      return f[i]>p.f[i];
      
    }
    
    return false;
    
  }
};
 
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
 
bool check(Puz p){
  for(int i = 0; i < N2; i++){
    if(p.f[i] != (i+1)) return false;
  }
  
  return true;

}
 
string bfs(Puz s){
  queue<Puz> Q;
  map<Puz,bool> V;
  Puz u, v;
  
  s.path="";
  Q.push(s);
  V[s]=true;
   
  while(!Q.empty()){
    u = Q.front();
    Q.pop();
    
    if(check(u)) return u.path;
    
    int sx = u.space / N;
    int sy = u.space % N;
    
    for(int i = 0; i < 4; i++){
      int tx = sx + dx[i];
      int ty = sy + dy[i];
      
      if(tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
      
      v=u;
      swap(v.f[u.space], v.f[tx*N+ty]);
      
      v.space = tx * N + ty;
      
      if(!V[v]){
	V[v] = true;
	v.path += dir[i];
	Q.push(v);
      }
    }
  }
  
  return "unsolvable";
  
}
 
int main(){
  Puz in;
  for(int i = 0; i < N2; i++){
    cin >> in.f[i];
    
    if(in.f[i] == 0){
      in.f[i]=N2;
      in.space=i;
    }
  }
  
  string ans = bfs(in);
  
  cout << ans.size() << endl;
  
  return 0;
}



Measured memory_bytes: 30488
def main():
    n = int(input())
    A = [int(a) for a in input().split()]
    min_count = float('inf')
    if A[0] != 0:
        tot = A[0]
        count = 0
        for a in A[1:]:
            if tot > 0 and tot + a >= 0:
                count += tot+a+1
                tot = -1
            elif tot < 0 and tot + a <= 0:
                count += -(tot+a)+1
                tot = 1
            else:
                tot += a
        min_count = min(min_count, count)
    for i in [1, -1]:
        count = abs(i - A[0])
        tot = i
        for a in A[1:]:
            if tot > 0 and tot + a >= 0:
                count += tot+a+1
                tot = -1
            elif tot < 0 and tot + a <= 0:
                count += -(tot+a)+1
                tot = 1
            else:
                tot += a
        min_count = min(min_count, count)
    return min_count

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

Measured memory_bytes: 14468
# soundhound2018-summer-qualC - Ordinary Beauty
def main():
    N, M, D = map(int, open(0).read().split())
    x = 2 if D else 1
    ans = x * (N - D) * (M - 1) / N ** 2
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  string t;
  cin >> t;

  string ans = "";

  for(int i = 0;i < n;i++){
    ans += s[i];
    ans += t[i];
  }

  cout << ans << endl;
}

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

using namespace std;

int main()
{
	int n;
	cin>>n;
	long long ans=1;
	for(int i=0;i<n;i++)
		ans=ans*(i+1)%1000000007;
	cout<< ans<< endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<=(b);++(i))
#define rep(i, n)  FOR(i,0,n-1)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define int long long
#define double long double
#define mod 1000000007LL
#define INF 123456789012345
typedef pair<ll, ll> P;
typedef pair<int, P> PP;

const int maxn =1e5 + 10;


signed main(){

	string s,t;cin>>s>>t;

	rep(i,s.size()) 
	{
		bool ok = true;
		
		rep(j,s.size())
		{
			if(s[j] != t[(i+j)%s.size()]) 
			{
				ok=false;
				break;
			}
		}
		if(!ok)continue;
		cout << "Yes"<<endl;;
		return 0;
	}

	cout << "No"<<endl;

	

}

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

using namespace std;


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

    string s;
    cin >> s;
    int count = 0;
    for(int i = 0 ; i < s.length(); ++i)
    {
        if(s[0] == '1')
        {
            if(i % 2 == 0 && s[i] !='1')
                count++;
            else if(i % 2 != 0 && s[i] !='0')
                count++;
        } else
        {
            if(i % 2 == 0 && s[i] !='0')
                count++;
            else if(i % 2 != 0 && s[i] !='1')
                count++;
        }
    }


    cout << count << endl;

    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int A = sc.nextInt();
		int waru = H / A;
		int amari = H % A;
		if (amari != 0) {
			int kasan = waru + 1;
			waru = kasan;
		}
		System.out.println(waru);
		sc.close();
	}
}

Measured memory_bytes: 35612
#include <iostream>
#include <string>
using namespace std;
 
int main(int argc, char const *argv[]) {
  string S;
  cin >> S;
  int ans = 0;
 
  int length = S.length();
  if (length == 1) {
    cout << 0 << "\n";
    return 0;
  }
 
  for (int i = 0; i < length - 1; i++) {
    if (S[i] == S[i + 1]) {
      ans++;
      S[i + 1] = S[i + 1] == '0' ? '1' : '0';
    }
  }
 
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 512
import heapq
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]

heapq.heapify(ab)

sm = 0
for _ in range(n):
    a, b = heapq.heappop(ab)
    if m >= b:
        m -= b
        sm += a * b
    else:
        sm += a * m
        break

print(sm)


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

int main() {
    int n,max=0,flag,sum=0;
    cin >> n;
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l.at(i);

    }
    for (int i = 0; i < n; i++) {
        if (max < l.at(i)) {
            max = l.at(i);
            flag = i;
        }
    }
    for (int i = 0; i < n; i++) {
        if (i != flag) {
            sum += l.at(i);
        }
    }
    if (sum > max) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;
int main() {
  int64_t N;
  cin>>N;
  cout<<(N-1)*N/2<<endl;
  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <sstream> // std::stringstream
#include <bitset>  // std::bitset<N>
#include <map>

using namespace std;

int main(void){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,m;
    cin >> n >> m;

    vector<int> vec;

    for(int i = 0;i<n;i++){
        vec.push_back(-1);
    }

    std::map<int, int> mp;

    int inp;
    int inp_;

    for(int i = 0;i<m;i++){
        cin >> inp;
        cin >> inp_;

        if(inp == 1 && inp_==0 && n != 1){
            cout << "-1";
            return 0;
        }

        auto itr = mp.find(inp);
        if( itr != mp.end() ) {
            //設定されている場合の処理
            if(mp[inp] != inp_){
                cout << "-1";
                return 0;
            }
        } else {
            //設定されていない場合の処理
            mp[inp] = inp_;
            vec[inp-1] = inp_;
        }
    }


    if(n == 1){
        if(vec[0]==-1)vec[0]=0;
    }else{
        if(vec[0]==-1)vec[0]=1;
    }

    if(n >1){
        for(int i = 1;i<n;i++){
            if(vec[i]==-1)vec[i]=0;
        }
    }

    

    for(int i: vec){
        cout << i;
    }


    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cctype>
#include <cstring>
#define fi first
#define se second
#define N 600005

using namespace std;
typedef long long ll;

template <class T> inline void read(T &x) {
	char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	if (flag) x = -x;
}

inline int input() {
	int x; char ch; bool flag = false;
	while (!isdigit(ch = getchar())) flag |= ch == '-';
	for (x = ch ^ 48; isdigit(ch = getchar()); x = x * 10 + (ch ^ 48));
	return flag ? -x : x;
}

const int mod = 1e9 + 7;
inline int add(int x, int y) { x += y; return x >= mod ? x - mod : x; }
inline void inc(int &x, int y) { x += y; x -= x >= mod ? mod : 0; }

inline int Power(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) res = (ll) res * x % mod;
		x = (ll) x * x % mod, y >>= 1;
	} return res;
}

template <class T> void chkmax(T &x, T y) { x = x > y ? x : y; }
template <class T> void chkmin(T &x, T y) { x = x < y ? x : y; }
template <class T> T gcd(T x, T y) { return !y ? x : gcd(x % y, y); }

int n;
int a[N], b[N];

bool check(int l, int r) {
	int A = 0, B = 0;
	for (int i = l; i <= r; ++i) {
		if (a[i] < l || a[i] > r) return false;
		if (a[i] > i) {
			if (a[i] < A) return false;
			A = a[i];
		}
		if (a[i] < i) {
			if (a[i] < B) return false;
			B = a[i];
		}
	} return true;
}

int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i], b[i] = a[i] == i;
	for (int i = 2; i < n; ++i) if (!b[i] && !b[i - 1] && !b[i + 1]) return puts("No"), 0;
	for (int l = 1, r; l <= n; l = r + 1) {
		r = l;
		if (!b[l]) {
			while (r < n && b[r + 1] ^ b[r]) ++r;
			if (b[r]) --r;
		}
		if (!check(l, r)) return puts("No"), 0;
	}
	puts("Yes");
	return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-originか1-originでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    string s; cin >> s;
    ll answer = 0;
    ll cnt, a;
    for(int bit = 0; bit < (1<<s.size()); ++bit) {
        if(bit & (1<<s.size()-1)) break;
        cnt = 0;
        a = 0;
        for(int i = 0; i < s.size(); ++i) {
            cnt = cnt*10 + (s[i]-'0');
            //debug(cnt);
            if(bit & (1<<i)) {
                a += cnt;
                //debug(cnt);
                cnt = 0;
            }
        }
        a += cnt;
        //debug(a);
        answer += a;
    }
    cout << answer << '\n';
}

Measured memory_bytes: 256
from collections import deque

N = int(input())
edges = [[] for _ in range(N+1)]
for _ in range(N-1):
    ai, bi, ci = map(int, input().split())
    edges[ai].append((bi, ci))
    edges[bi].append((ai, ci))
Q, K = map(int, input().split())

distance = [-1]*(N+1)
# def add_weight(k, pre):
#     for v in edges[k]:
#         d, w = v
#         if d != pre:
#             distance[d] = w + distance[k]
#             add_weight(d, k)
# add_weight(K, -1)
que = deque()
que.append(K); distance[K] = 0
while len(que):
    a = que.popleft()
    for b, c in edges[a]:
        if distance[b] == -1:
            distance[b] = c + distance[a]
            que.append(b)

# print(distance)

for _ in range(Q):
    s, e = map(int, input().split())
    print(distance[s] + distance[e])

Measured memory_bytes: 44568
#include<stdio.h>
#define FOR(S,F) for(int i=S;i<=F;i++)
#define FOR2(S,F) for(int j=S;j<=F;j++)
int main() {
	int n, m,t;
	scanf("%d%d%d",&n,&m,&t);
	printf("%d\n",(n/m+(n%m?1:0))*t);
	return 0;
}

Measured memory_bytes: 1736
#include<stdio.h>
int main()
{
	int n,m,a[3],i,j,max;
	scanf("%d",&m);
	for(i=0;i<m;i++)
	{
		scanf("%d %d %d",&a[0],&a[1],&a[2]);
		max=0;
		for(j=0;j<3;j++)
		{
			if(max<a[j]){ max = a[j]; n=j;}
		}
			if(a[n]*a[n] == a[(n+2)%3]*a[(n+2)%3]+a[(n+1)%3]*a[(n+1)%3]) printf("YES\n");
			else printf("NO\n");
			
	}
	return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;


#define mk make_pair
#define pb push_back

typedef long long lld;
typedef pair<lld,lld> pr;
typedef priority_queue <lld> max_heap;
typedef priority_queue <lld, vector<lld>, greater<lld> > min_heap;
lld const mod = 1e9+7;
lld const N = 1e5+5;
#define ordered_set tree<lld, null_type,less<lld>, rb_tree_tag,tree_order_statistics_node_update>

lld fact[N], ifact[N];

lld power(lld x, lld y)
{
    lld res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}

lld power_mod(lld base, lld y)
{
    lld t = 1;
    while (y > 0)
    {

        if (y % 2 != 0)
            t = (t * base) % mod;
        base = (base * base) % mod;
        y /= 2;
    }
    return t % mod;
}

void findFact() {
    fact[0] = 1;
    for(lld i = 1; i <= N; i++)
        fact[i] = 1ll * fact[i - 1] * i % mod;
    ifact[N] = power_mod(fact[N], mod - 2);
    for(lld i = N - 1; i >= 0; i--)
        ifact[i] = 1ll * ifact[i + 1] * (i + 1) % mod;
}

lld comb(lld n, lld r) {
    return 1ll * fact[n] * ifact[r] % mod * ifact[n - r] % mod;
}


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

vector<lld> ad[lld(2e5+5)];
lld visited[lld(2e5+5)]={0};




int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lld n,m;
  cin>>n>>m;
  lld x,y;
  lld i;
  for(i=0;i<m;i++)
  {
    cin>>x>>y;
    ad[x].pb(y);
    ad[y].pb(x);
  }

  lld cnt=0;
  lld ans = 0;
  // map <lld,lld> hsh;
  queue <lld> q;
  for(i=1;i<=n;i++)
  {
    if(visited[i]==0)
    {
      cnt=1;
      // hsh[cnt]=1;
      visited[i]=1;
      q.push(i);
      while(!q.empty())
      {
        lld cur = q.front();
        q.pop();
        for(auto x: ad[cur])
        {
          if(visited[x]==0)
          {
            cnt++;
            // hsh[cnt]++;
            visited[x]=1;
            q.push(x);
          }
        }
      }
      ans = max(ans,cnt);
      // q.pop()
    }
  }
  cout<<ans<<endl;
}


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

template<class T> struct WeightedUnionFind {
    int sz;
    vector<int> data;
    vector<T> potential;

    WeightedUnionFind (int sz, T id = 0)
        : sz(sz), data(sz, -1), potential(sz, id) { }

    // potential[y] = potential[x] + w
    bool unite (int x, int y, T w) {
        w += (weight(x) - weight(y));
        x = root(x); y = root(y);
        if (x == y) return false;
        if (data[x] > data[y]) { swap(x, y); w = -w; }
        data[x] += data[y];
        data[y] = x;
        potential[y]= w;
        sz--;
        return true;
    }

    bool is_same (int x, int y) { return root(x) == root(y); }

    int root (int x) {
        if (data[x] < 0) return x;
        int r = root(data[x]);
        potential[x] += potential[data[x]];
        return data[x] = r;
    }

    T weight (int x) { root(x); return potential[x]; }

    T diff (int x, int y) { return weight(y) - weight(x); }

    size_t size () { return (size_t)sz; }

    size_t size (int x) { return (size_t)-data[root(x)]; }

};



int main() {
    int n, q;
    cin >> n >> q;
    WeightedUnionFind<int> uf(n);
    
    while (q--) {
        int t;
        cin >> t;
        if (t == 0) {
            int x, y, w;
            cin >> x >> y >> w;
            uf.unite(y, x, w);
        } else {
            int x, y;
            cin >> x >> y;
            if (uf.is_same(x, y)) {
                cout << uf.diff(y, x) << '\n';
            } else {
                cout << '?' << '\n';
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3568
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    int n, m;
    std::cin >> n >> m;
    std::vector<int> a(n, -1);
    bool isOK = true;
    rep(i, m) {
        int s, c;
        std::cin >> s >> c;
        s--;
        if(a[s] != -1 and a[s] != c) {
            isOK = false;
            break;
        } else {
            a[s] = c;
        }
    }
    if(a[0] == -1) {
        if(n == 1)
            a[0] = 0;
        else
            a[0] = 1;
    } else if(a[0] == 0) {
        if(n == 1 and isOK) {
            std::cout << 0 << std::endl;
            return;
        } else {
            isOK = false;
        }
    }
    if(isOK) {
        rep(i, n) std::cout << (a[i] == -1 ? 0 : a[i]);
        std::cout << std::endl;
    } else {
        std::cout << -1 << std::endl;
    }
}

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

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;
  vector<Int> cnt(26,0);
  for(char c:s) cnt[c-'a']++;
  for(Int i=0;i<26;i++){
    if(!cnt[i]){
      cout<<char('a'+i)<<endl;
      return 0;
    }
  }
  cout<<"None"<<endl;
  return 0;
}


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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second

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

    ll a,b;
    cin >> a >> b;
    for(ll i=1; i<=10000; i++)
    {
        ll tmp = (i*8)/100 , tmp2 = (i*10)/100;
        if (tmp == a && tmp2 == b) return cout << i << "\n" , 0;
    }
    cout << "-1\n";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;

namespace Contest
{
    class Program
    {
        private Scanner sc;
        public void Solve()
        {
            sc = new Scanner();
            int A = sc.NextInt();
            int B = sc.NextInt();
            if ((A + B) % 2 == 0)
            {
                Console.WriteLine((A + B) / 2);
            }
            else
            {
                Console.WriteLine("IMPOSSIBLE");
            }
        }

        static void Main() => new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
        _separator = ' ';
    }
    private readonly char _separator;
    private readonly StreamReader _stream;
    private int _pos;
    private string[] _line;
    #region get a element
    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(_separator);
            _pos = 0;
        }
        return _line[_pos++];
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    #endregion
    #region convert array
    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }
    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }
    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }
    #endregion
    #region get array
    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(_separator);
        _pos = _line.Length;
        return _line;
    }
    public int[] IntArray()
    {
        return ToIntArray(Array());
    }
    public long[] LongArray()
    {
        return ToLongArray(Array());
    }
    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }
    #endregion
}

Measured memory_bytes: 13140
n,h=int(input()),list(map(int,input().split()));dp=[0]*n;dp[1]=abs(h[1]-h[0])
for i in range(2,n):dp[i]=min(dp[i-2]+abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i]))
print(dp[-1])

Measured memory_bytes: 13980
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define mp(a,b) make_pair((a),(b))
#define eq ==

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> pii;

// →↑←↓
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};


const double EPS = 1e-9;

int main(){
    vector<int> W(10);
    vector<int> K(10);
    for(int i=0;i<10;i++) cin >> W[i];
    for(int i=0;i<10;i++) cin >> K[i];
    sort(rall(W));
    sort(rall(K));

    int ws = W[0] + W[1] + W[2];
    int ks = K[0] + K[1] + K[2];

    cout << ws << " " << ks << endl;
    return 0;
}

Measured memory_bytes: 1200
/*  ex4_2
    yy8332  */

#include <stdio.h>
#include <math.h>


int main(void){
  double lengthA, lengthB, hour, minute, theta, ans;

  //入力読み取り
  scanf("%lf %lf %lf %lf", &lengthA, &lengthB, &hour, &minute);

  //角度計算
  theta = (((hour + minute / 60) * 30 - minute * 6) / 180) * M_PI;

  //長さ計算
  ans = pow(lengthA, 2.0) + pow(lengthB, 2.0) - 2 * lengthA * lengthB * cos(theta);

  ans = sqrt(ans);


  //出力
  printf("%.10f",ans);


  return 0;
}


Measured memory_bytes: 2560
/* Author: topcoderme123
   Date: 21st june 2020 */

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define F first
#define S second
#define all(v) (v).begin(),v.end()
#define np next_permutation
using namespace std;
using vi=vector<int>;
#define lp(i,n) for(int i=0;i<n;i++)
#define reps(i,j,n) for(int i=j;i<=n;i++)
#define vii vector<vi>
#define vb vector<bool>
#define pr pair<int,int>
#define vl vector<ll>
#define vs vector<string>
#define us unordered_map<int,int>
#define Mpq priority_queue<int>
#define mpq priority_queue<int,vi,greater<int>> 
#define eb emplace_back
#define prl pair<ll,ll>
#define vp vector<pr>

const int N=2000007;
ll dp[N],ans,k;
string s;

ll fpow(ll x,ll y){
  ll ans=1;
  while(y>0){
     if(y&1) ans=(ans*x)%mod;
     x=(x*x)%mod;
     y>>=1;
  }
  return ans;
}

void slv(){  
   dp[0]=dp[1]=1; 
   for(int i=2;i<N;i++)
      dp[i]=(dp[i-1]*1LL*i)%mod;
}

void solve(){
   slv();
   cin>>k>>s;
   ll n=s.size();
   
   for(ll i=n+k;i>=n;i--){
      ll r=(n+k-i),l=(k-r);
      ll x=fpow(25,l),y,z;
      y=fpow(26,r);
      z=((dp[i-1]*fpow(dp[i-n],mod-2))%mod*fpow(dp[n-1],mod-2))%mod;
      ans=(ans+((x*y)%mod*z)%mod)%mod;
   }
   cout<<ans<<"\n";
}
int main(int argc,char *argv[]){
   ios_base::sync_with_stdio(0);
   cin.tie(nullptr);
   solve();
   return 0;
}


Measured memory_bytes: 19884
#pragma GCC optimize(2,3,"Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define in inline
namespace fast_io
{
	char buf[1<<12],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int C=-1,Z=0,Bi=0,ny;
	in char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
	in int read()
	{
		int x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;Bi=1;if(nc<0)return nc;
		x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48),Bi++;return x*ny;
	}
	in db gf() {int a=read(),y=ny,b=(nc!='.')?0:read();return (b?a+(db)b/pow(10,Bi)*y:a);}
	in int gs(char *s) {char c,*t=s;while(c=gc(),c<32);*s++=c;while(c=gc(),c>32)*s++=c;return s-t;}
	in void ot() {fwrite(sr,1,C+1,stdout);C=-1;}
	in void flush() {if(C>1<<22) ot();}
	template <typename T>
	in void write(T x,char t)
	{
		int y=0;if(x<0)y=1,x=-x;while(z[++Z]=x%10+48,x/=10);
		if(y)z[++Z]='-';while(sr[++C]=z[Z],--Z);sr[++C]=t;flush();
	}
	in void write(char *s) {int l=strlen(s);for(int i=0;i<l;i++)sr[++C]=*s++;sr[++C]='\n';flush();}
};
using namespace fast_io;
int n,m,h;
int main()
{
	n=read(),m=read(),h=read();
	cout<<ceil(1.0*h/max(n,m));
	return ot(),0;
}
//Author: disangan233
//In my dream's scene,I can see the everything that in Cyaegha.


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

int N,K;
vector<bool> v;

int main(){
  cin >> N >> K;
  v = vector<bool>(N);
  for(int i = 0; i < K;i++){
    int d;
    cin >> d;
    for(int j = 0; j < d; j++){
      int a;
      cin >> a;
      v.at(a-1) = true;
    }
  }
  int ans = 0;
  for(int i = 0; i < N; i++) if(!v.at(i)) ans++;
  cout << ans << endl;
      
}

Measured memory_bytes: 3632
use std::io;
pub trait ExRead {
    fn read_line(&mut self) -> io::Result<String>;
    fn read_to_string(&mut self) -> io::Result<String>;
}

impl<'a> ExRead for io::StdinLock<'a> {
    fn read_line(&mut self) -> io::Result<String> {
        let mut buf = String::new();
        io::BufRead::read_line(self, &mut buf).map(|_| buf)
    }

    fn read_to_string(&mut self) -> io::Result<String> {
        self.read_line().map(|s| s.trim().to_string())
    }
}

fn main() {
    let n: usize;
    let a: Vec<usize>;
    let mut ans = Vec::new();

    {
        let stdin = std::io::stdin();
        let mut lkin = stdin.lock();
        let mut input = lkin.read_line().unwrap()
            .split_whitespace()
            .map(|e| e.parse().ok().unwrap()).collect::<Vec<_>>().into_iter();
        n = input.next().unwrap();
        a = lkin.read_line().unwrap()
            .split_whitespace()
            .map(|e| e.parse().ok().unwrap()).collect::<Vec<_>>();
    }

    ans.resize(n, 0);
    a.iter().for_each(|e|
        *ans.get_mut(e-1).unwrap() += 1
    );

    ans.iter().for_each(|a| println!("{}", a));
}


Measured memory_bytes: 5048
const main = (standardInput) => {
    const lengthList = standardInput.split(' ');
    const a = Number.parseInt(lengthList[0]);
    const b = Number.parseInt(lengthList[1]);

    console.log(a*b,a*2+b*2);
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));



Measured memory_bytes: 15384
//Compiler optimization
#pragma GCC optimize("Ofast")

//include
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;

//typedef
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vl> mat;

//macro
#define reverse(a) reverse(a.begin(),a.end())
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define each(x, v) for (auto &x : v)
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 (a>b) { a=b; return 1; } return 0; }
ll pow(ll a,ll n, ll m){
    ll ret=1;
    for(;n>0;n>>=1,a=a*a%m){
        if(n%2==1){
        ret=ret*a%m;
        }
    }
    return ret;
}

//abbreviation
#define pb push_back
#define elif else if
#define mp make_pair
#define endl '\n'

//debug
#define debug(x) cerr << #x << ": " << x << endl
#define v_debug(v) cerr << #v << endl;fr(i,v.size()) cerr << i << ": " << v[i] << endl

//const
const  ll INF = 1e18;

using namespace atcoder;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(20);
    int k;cin >> k;
    string ans = "";
    fr(i,k)ans += "ACL";
    cout << ans << endl;
    return 0;
}

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

int main()
{
  string s;
  int a,b;
  a=0;
  b=0;
  cin>>s;
  for(int i=0;i<s.size();i++)
  {
    if(i%2==0)
    {
      if(s.at(i)=='1')
        a++;
    }
    else
    {
      if(s.at(i)=='0')
        a++;
    }
  }
  for(int i=0;i<s.size();i++)
  {
    if(i%2==0)
    {
      if(s.at(i)=='0')
        b++;
    }
    else
    {
      if(s.at(i)=='1')
        b++;
    }
  }
  cout<<min(a,b)<<endl;
}

Measured memory_bytes: 3740
#include<stdio.h>
int main(void)
{
	int n,x,y,z;
	int x1[101],y1[101],z1[101],a[101][4];
	int i,j,cnt,flg;
	
	scanf("%d",&n);
	
	scanf("%d",&x);
	for(i=0;i<x;i++) scanf("%d",&x1[i]);
	scanf("%d",&y);
	for(i=0;i<y;i++) scanf("%d",&y1[i]);
	scanf("%d",&z);
	for(i=0;i<z;i++) scanf("%d",&z1[i]);
	
	for(i=1;i<=n;i++){
		for(j=0;j<3;j++) a[i][j]=0;
	}
	
	for(i=0;i<x;i++){
		for(j=1;j<=n;j++){
			if(x1[i]==j) a[j][0]=1;
		}
	}
	for(i=0;i<y;i++){
		for(j=1;j<=n;j++){
			if(y1[i]==j) a[j][1]=1;
		}
	}
	for(i=0;i<z;i++){
		for(j=1;j<=n;j++){
			if(z1[i]==j) a[j][2]=1;
		}
	}
	cnt=0;
	for(i=1;i<=n;i++){
		if(a[i][0]==0&&a[i][2]==1
			||a[i][1]==1&&a[i][2]==1)
			cnt++;
	}
	
	printf("%d\n",cnt);
	
}	


Measured memory_bytes: 2736
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
using namespace std;
vector <int> ans;
int n,x,y;
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    cin >> n >> x >> y;
    x--;y--;
    ans.resize(n);
    for(int i = 0; i < n-1; i++)
    {
        for(int g = i+1; g < n; g++)
            ans[min(abs(max(x,y)-g)+abs(min(x,y)-i),g-i-1)]++;
    }
    for(int i = 0; i < n-1; i++)
        cout << ans[i] << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  char a;
  cin>>a;
  if(a=='A')cout<<"T"<<endl;
  else if(a=='T')cout<<"A"<<endl;
  else if(a=='C')cout<<"G"<<endl;
  else if(a=='G')cout<<"C"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
using namespace std;
const int tINF = (int)INT_MAX;
const long long lINF = (long long)LLONG_MAX;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef DEBUG
			assert(freopen("inp", "r", stdin));
			assert(freopen("out", "w",stdout));
	#else
			#define cerr if(false)cerr
	#endif
        int n;
        cin >> n;
    vector <int> ar(n);
    for(auto &i : ar)
        cin >> i;
    sort(all(ar));
    bool res = 1;
    for(int i =0 ; i < n - 1; ++i){
        if(ar[i] == ar[i + 1])
            res = 0;
    }
    if(res)cout << "YES\n";
    else
        cout << "NO\n";

    cerr << "Time execute: " << (double)clock() / (double)CLOCKS_PER_SEC 
    << " sec" << endl;
}

Measured memory_bytes: 1024
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("-1"),0;
#define mod 1000000007
#define N 1000055
//#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,f[N],sum[N],ans;
inline int get_s(int x){
	return (x>=0)?sum[x]:0;
}
inline void add(int &x,int k){
	x+=k;x-=(x>=mod)?mod:0;
}
signed main(){
	n=read();
	f[0]=1;sum[0]=1;
	F(i,1,n){
		f[i]=(f[i-1]+get_s(i-3))%mod;
		sum[i]=(sum[i-1]+f[i])%mod;
	}
	F(i,0,n-2){
		add(ans,1LL*f[i]*(n-1)%mod*(n-1)%mod);
		add(ans,1LL*f[i]*(i+1)%mod);
	}
	add(ans,1LL*f[n-1]*(n-1)%mod);add(ans,f[n]);
	wrn(ans);
	return 0;
}

Measured memory_bytes: 8064
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
    int n;
    double x1, y1, x2, y2, x3, y3, det2, A, B, X, Y, R;
    scanf("%d", &n);
    while(n--){
        scanf("%lf %lf %lf %lf %lf %lf",
               &x1, &y1, &x2, &y2, &x3, &y3);
        det2 = 2*((x1-x2)*(y1-y3)-(y1-y2)*(x1-x3));
        A = x1*x1-x2*x2+y1*y1-y2*y2;
        B = x1*x1-x3*x3+y1*y1-y3*y3;
        X = ((y1-y3)*A-(y1-y2)*B)/det2;
        Y = ((x1-x2)*B-(x1-x3)*A)/det2;
        R = sqrt((X-x1)*(X-x1)+(Y-y1)*(Y-y1));
        printf("%.3lf %.3lf %.3lf\n", 
                X, Y, R);
    }
    return 0;
}

Measured memory_bytes: 1092
def main():
    N, M, K = map(int, input().split())

    MAX_N = 2000000

    s = [0] * MAX_N
    t = [0] * MAX_N
    for i, c in zip(range(N - 1, -1, -1), input()):
        s[i] = int(c)
    for i, c in zip(range(M - 1, -1, -1), input()):
        t[i] = int(c)

    len_max = max(N, M) - 1
    st = []
    for i in range(len_max, -1, -1):
        m = []
        if s[i] and t[i]:
            s[i] = t[i] = 0
            xs = xt = 1
            z = K - 1
            j = i + 1

            while xs or xt:
                if not s[j] and not t[j]:
                    if xs and not xt:
                        s[j] = 1
                        st.append(j)
                        len_max = max(len_max, j)
                        break
                    elif not xs and xt:
                        t[j] = 1
                        st.append(j)
                        len_max = max(len_max, j)
                        break

                if not st or st[-1] - j > z:
                    s[j + z] = t[j + z] = 1
                    len_max = max(len_max, j + z)
                    break

                p = st.pop()
                z -= p - j
                j = p

                if s[j] == xs and t[j] == xt:
                    s[j] = t[j] = 0
                    j += 1
                    continue

                if xs and xt:
                    xs = s[j]
                    xt = t[j]
                    s[j] ^= 1
                    t[j] ^= 1
                    m.append(j)
                    j += 1
                    continue

                if s[j] != xs and t[j] != xt:
                    if not z:
                        s[j] = t[j] = 1
                        break
                    else:
                        s[j] = t[j] = 0
                        j += 1
                        z -= 1
                        xs = xt = 1
                        continue

            st += reversed(m)

        elif s[i] or t[i]:
            st.append(i)

    s = s[:len_max + 1]
    t = t[:len_max + 1]

    while not s[-1]:
        s.pop()
    while not t[-1]:
        t.pop()

    print(*reversed(s), sep='')
    print(*reversed(t), sep='')


main()

Measured memory_bytes: 213368
#include <iostream>
#include <algorithm>
#include <numeric>
using namespace std;

int W, N;
int X[50010];
int f[50010], s[50010];

void read();
void soups_on();
bool yee_haw(int);

int main() {
  while (cin >> W >> N, W + N)
    read(), soups_on();

  return 0;
}

void read() {
  X[0] = W, X[N + 1] = W;
  for (int i = 1; i <= N; ++i)
    cin >> X[i];
  partial_sum(X, X + (N + 2), X);
}

void soups_on() {
  int low = 1, up = W, mid;

  while (low < up) {
    mid = (low + up) / 2;
    if (yee_haw(mid))
      up = mid;
    else
      low = mid + 1;
  }

  cout << low << "\n";
}

bool yee_haw(int lm) {
  int lb, ub, low, up, mid, sum = 0, p;

  fill(&f[0], &f[N + 2], 0);
  for (int i = 0; i <= N; ++i) {
    sum += f[i], s[i] = sum;
    if (i == 0 || sum > 0) {
      low = i + 1, up = N + 1;
      while (low < up) {
        mid = (low + up) / 2;
        if ((X[mid] - X[i]) + lm * (mid - i - 1) < W)
          low = mid + 1;
        else
          up = mid;
      }
      lb = low;

      low = i + 1, up = N + 1;
      while (low < up) {
        mid = (low + up) / 2;
        if ((X[mid] - X[i]) + (mid - i - 1) <= W)
          low = mid + 1;
        else
          up = mid;
      }
      ub = low;
      ++f[lb], --f[ub];
    }
  }

  p = 0, s[0] = 1;
  for (int i = N; i >= 0 && p <= W; --i) {
    if (s[i] > 0)
      return true;
    p = (X[N] - X[i - 1]) + (N - i);
  }

  return false;
}

Measured memory_bytes: 1744
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = scan.nextInt();
		}
		Arrays.sort(a);
		int ans = Math.abs(a[0] - a[n-1]);
		System.out.println(ans);
	}
}


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

typedef long long ll;
const ll MAX_N = 1e9;

bool ques(ll n){
    cout<<"? "<<n<<endl<<flush;
    string ans;
    cin>>ans;
    return (ans=="Y");
}

void bin(ll l,ll r){
    if(l+1==r){
        cout<<"! "<<r<<endl;
        return;        
    }
    ll m = (l+r)/2;
    bool yes = ques(m*10);
    if(yes) bin(l,m);
    else bin(m,r);
}

int main(void){
    if(ques(MAX_N)){
        int d=MAX_N;
        while(d>1 && ques(d-1)) d/=10;
        cout<<"! "<<d<<endl;
    }else{
        int d=MAX_N;
        while(d/=10,!ques(d));
        bin(d,d*10);
    }
    return 0;
}


Measured memory_bytes: 596
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int A, B;	cin >> A >> B;
	int num = 0;
	int answer = 0;
	for (int i = A; i <= B; ++i) {
		num = i;
		if (num / 10000 == num % 10) {
			num -= (num / 10000) * 10000;
			num /= 10;
			if (num / 100 == num % 10) {
				++answer;
			}
		}
	}
	cout << answer << endl;
	cin >> A;
	return 0;
}

Measured memory_bytes: 256