akhauriyash/Code-Regression huggingface dataset:
//Making Triangle 

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    nvarep(n,a);
    sort(range(a));
    int ans = 0;
    rep(i,0,n){
        rep(j,i+1,n){
            rep(k,j+1,n){
                if(a[k]<a[i]+a[j]&&a[i]<a[k]+a[j]&&a[j]<a[i]+a[k]){
                    if(a[i]!=a[j]&&a[j]!=a[k]&&a[k]!=a[i]){
                        ans++;
                    }
                }
            }
        }
    }
    cout<<ans<<nnn;
    return 0;
}

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

using namespace std;

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

    if (N % 2 == 0) {
        cout << 0.5 << endl;
    } else {
        cout << std::setprecision(10)
             << (static_cast<double>(N) + 1.0) / 2.0 / static_cast<double>(N) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    int l,r;
    cin >> l >> r;
    int ans = 20000;
    if(r-l > 2019){
        cout << 0 << endl;
        return 0;
    }
    else{
        for(int i = l;i <= r;i++){
            for(int j = i+1;j <= r;j++){
                ans = min(ans,(i*j)%2019);
            }
        }
    }
    cout << ans << endl;

    
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc133.contest.atcoder.jp/tasks/abc133_b

Measured memory_bytes: 256
X = int(input())

if X<600:
	print(8)
elif X<800:
	print(7)
elif X<1000:
	print(6)
elif X<1200:
	print(5)
elif X<1400:
	print(4)
elif X<1600:
	print(3)
elif X<1800:
	print(2)
else:
	print(1)





# 2darray [[0] * 4 for i in range(3)]

Measured memory_bytes: 9176
import copy

MOD = 10 ** 9 + 7

def pow_k(x, n, mod):
  if n == 0:
    return 1

  K = 1
  while n > 1:
    if n % 2 != 0:
      K = (x * K) % mod
        
    x = (x * x) % mod

    n //= 2

  return (x * K) % mod

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

array = [0] * (k+1)
for i in range(1, k+1):
  tmp = k // i
  array[i] = pow_k(tmp, n, MOD)
  
ans = 0
for i in reversed(range(1,k+1)):
  for j in range(i*2,k+1,i):
    array[i] -= array[j]
    
  ans += array[i] * i 
  ans %= MOD
  
print(ans)
  

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

using namespace std;

int main() {
    int n, q;
    string s;

    cin >> n >> q >> s;

    int table[100001] = { 0 };
    for (int i=1; i<n; i++) {
        table[i+1] = (s[i-1]=='A' && s[i]=='C') ? table[i]+1 : table[i];
    }

    int l, r;
    for (int i=0; i<q; i++) {
        cin >> l >> r;
        cout << table[r] - table[l] << endl;
    }


    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdlib>
#include <string>

void alphabetCase(char &moji); 
void change(std::string &str); 

int main(void) {
    std::string target;
    std::getline(std::cin, target);
    change(target);
    std::cout << target << std::endl;

    return EXIT_SUCCESS;
}

void alphabetCase(char &c) {
    int ascii = (int)(c);
    if (ascii >= 65 && ascii <= 90) {
        ascii += 32;
    } else if (ascii >= 97 && ascii <= 122) {
        ascii -= 32;
    }
    c = (char)(ascii);
    return; 
}

void change(std::string &str) {
    int size = (int)(str.size());
    for (int loop = 0; loop < size; loop++) {
        alphabetCase(str[loop]);     
    }
    return;
}

Measured memory_bytes: 3156
import math

N = int(input().rstrip())
A = list(map(int,input().rstrip().split()))
l = [A[0]]
r = [A[-1]]
for i in range(len(A)-1):
    l.append(math.gcd(A[i+1],l[i]))
    r.append(math.gcd(A[-(i+2)],r[i]))
ans = []
ans.append(r[-2])
for i in range(len(A)-2):
    ans.append(math.gcd(l[i],r[-(i+3)]))
ans.append(l[-2])
print(max(*ans))

Measured memory_bytes: 26320
import java.util.Scanner;

public class Main { 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    int[] countTotal = new int[N];
    int countW =0; int countE =0; int countWa =0; int countEa =0;
    int min =300000;
    for (int i =0; i<N; i++) {
      if (S.charAt(i) == 'W') countW++;
      if (S.charAt(i) == 'E') countE++;
    }
    if (S.charAt(0) == 'W') {
      countTotal[0] = countE ;
    } else {
      countTotal[0] = countE -1;
    }
    min = Math.min(countTotal[0],min);
    
    for (int i =0; i<N-1; i++) {
      if (S.charAt(i) == 'W') countWa++;
      if (S.charAt(i) == 'E') countEa++;
      if (S.charAt(i+1) == 'W') {
        countTotal[i+1] =countWa + countE - countEa;
      } else {
        countTotal[i+1] =countWa + countE - countEa - 1;
      }
      min = Math.min(countTotal[i+1],min);
    }
    System.out.println(min);
  }
}    

Measured memory_bytes: 43608
from sys import stdin
n, t = [int(x) for x in stdin.readline().rstrip().split()]
data = [stdin.readline().rstrip().split() for _ in range(n)]
data = [[int(i) for i in l] for l in data]

min_time=t
min_cost=float('inf')
for d in data:
  if d[1]<=t:
    if d[0]<min_cost:
      min_cost=d[0]
if min_cost==float('inf'):
  print('TLE')
else:
  print(min_cost)  

Measured memory_bytes: 3064
#include<stdio.h>

#define MAX 50

int db[MAX];

int fibonacci(int n) {
    if (n == 0 || n == 1) return 1;
    if (db[n] != -1) return db[n];
    return db[n] = fibonacci(n - 1) + fibonacci(n - 2);
}

int main() {
    int n;
    for (int i = 0; i < MAX; ++i) db[i] = -1;

    scanf("%d", &n);
    int result = fibonacci(n);
    printf("%d\n", result);
    return 0;
}

Measured memory_bytes: 2680
#include <bits/stdc++.h>
#define X first
#define Y second

using namespace std;
typedef long long llint;

const int maxn = 210;
const int mod = 1e9+7;

const int logo = 20;
const int off = 1 << logo;
const int treesiz = off << 1;

int n;
char niz[maxn][maxn];
int dis[maxn];
queue<int> q;

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            scanf(" %c", &niz[i][j]);

    int sol = 0;
    for (int i = 0; i < n; i++) {
        memset(dis, -1, sizeof dis);

        dis[i] = 1;
        q.push(i);
        int kol = 0;
        while (!q.empty()) {
            int x = q.front();
            q.pop();
            kol = max(kol, dis[x]);
            for (int j = 0; j < n; j++) {
                if (niz[x][j] == '0') continue;
                else if (dis[j] != -1) continue;

                dis[j] = dis[x] + 1;
                q.push(j);
            }
        }

        bool flag = true;
        for (int x = 0; x < n; x++) {
            for (int y = 0; y < n; y++) {
                if (niz[x][y] == '1' && abs(dis[x] - dis[y]) != 1) {
                    //printf("wrong: %d -> %d %d (%d %d)\n", i, x, y, dis[x], dis[y]);
                    flag = false;
                    break;
                }
            }
        }
        if (flag) sol = max(sol, kol);
    }
    if (sol != 0) printf("%d", sol);
    else printf("-1");
    return 0;
}


Measured memory_bytes: 256
n=input()

if len(n)==1:
    m=int(n)
else:
    m=int(n[-1])

if m==2 or m==4 or m==5 or m==7 or m==9:
    print("hon")
elif m==0 or m==1 or m==6 or m==8:
    print("pon")
elif m==3:
    print("bon")


Measured memory_bytes: 61804
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <map>
#define rep(i,n) for(int i=0; i < (n); i++)
#define INF 1001001
using namespace std;

int main(){
  string s,t;
  cin >> s >> t;
  int s_len, t_len;
  s_len = s.length();
  t_len = t.length();
  //cout << s_len << endl;
  //cout << t_len << endl;
  int count=0,min=INF;
  rep(i,s_len-t_len+1){
    count=t_len;
    rep(j,t_len){
      if(s[j+i]!=t[j]) continue;
      count--;
    }
    //cout << count << endl;
    if(min>count) min=count;
  }
  cout << min << endl;
    
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

signed main(){
	string s=readString();
	string w[4]={
		"dream",
		"dreamer",
		"erase",
		"eraser",
		};
	int n=s.size();
	vector<bool> dp(n+1,false);
	dp[0]=true;
	REP(i,n)if(dp[i]){
		REP(k,4){
			if(i+int(w[k].size())<=n){
				string p=s.substr(i,w[k].size());
				if(p==w[k])
					dp[i+w[k].size()]=true;
			}
		}
	}
	if(dp[n])
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
}


Measured memory_bytes: 512
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_rui = [0]
b_rui = [0]
counta = 0
countb = 0
for i in range(n):

    a_rui.append(a_rui[i]+a[i])
    if a_rui[i+1] <= k:
        counta = i+1

for i in range(m):
    b_rui.append(b_rui[i]+b[i])
    if b_rui[i] <= k:
        countb = i+1

# print(counta, countb)
# print(a_rui, b_rui)
ans = 0
for i in range(counta+1):
    # print("DFGHj")
    # print(i, countb)
    while a_rui[i]+b_rui[countb] > k:
        # print(a_rui[i]+b_rui[countb], i, countb)
        countb -= 1
    # print(i, countb)
    ans = max(ans, i+countb)
print(ans)



Measured memory_bytes: 132584
#include<stdio.h>
#include<iostream>
using namespace std;
int bubbleSort(int A[],int N){
    int sw=0;
    bool flag =1;
    for(int i=0;flag;i++){
        flag=0;
        for(int j=N-1;j>=1+i;j--){
            if(A[j]<A[j-1]){
                swap(A[j],A[j-1]);
                flag=1;
                sw++;
            }
        }
    }
    return sw;
}
int main(){
  int A[100],N,sw;
  cin>>N;
  for(int i=0;i<N;i++)cin>>A[i];
  sw=bubbleSort(A,N);
  for(int i=0;i<N;i++){
    if(i)cout<<" ";
    cout<<A[i];
  }
  cout <<endl;
  cout <<sw<<endl;
return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
typedef long long ll;
typedef long double ld;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main(){
  ll n,m,k,i,j,result=0,d;
  ll x,y;
  string s;
  cin >> n >> d;
  rep(i,n){
    cin >> x >> y;
    
    if(x*x+y*y <= d*d) result++;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;
int par[100000];
int rank_[100000];

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

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

bool exist[100000];

int main(){
    int N,M;
    cin>>N>>M;
    for(int i=0;i<M;i++){
        par[i]=i;
        rank_[i]=0;
    }
    for(int i=0;i<N;i++){
        int Ki;
        cin>>Ki;
        vector<int> L(Ki);
        for(int j=0;j<Ki;j++){
            cin>>L[j];
            L[j]--;
            exist[L[j]]=true;
        }
        for(int j=1;j<Ki;j++){
            unite(L[0],L[j]);
        }
    }
    int p;
    for(int i=0;i<M;i++){
        if(exist[i]){
            p=find(i);
            break;
        }
    }
    for(int i=0;i<M;i++){
        if(!exist[i]) continue;
        if(p!=find(i)){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

Measured memory_bytes: 1152
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

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

   int MIN = max(-1000000, X - K + 1);
   int MAX = min(1000000, X + K - 1);
   for (int i = MIN; i <= MAX; i++) {
      cout << i << " ";
   }
   cout << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int g[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            g[i][j]=0;
        }
    }
    int u;
    int k;
    int p;
    for(int i=0;i<n;i++){
        cin>>u;
        cin>>k;
        for(int j=0;j<k;j++){
            cin>>p;
            g[u-1][p-1]=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n-1;j++){
            cout<<g[i][j]<<" ";
        }
        cout<<g[i][n-1];
        cout<<endl;
    }
    return 0;
}

 


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

def matmul(A, B, mod): # A,B: 行列
    res = [[0] * len(B[0]) for _ in range(len(A))]
    for i in range(len(A)):
        for k, aik in enumerate(A[i]):
            for j,bkj in enumerate(B[k]):
                res[i][j] += aik*bkj
                res[i][j] %= mod
    return res

def matpow(A, p, mod): #A^p
    if p % 2 == 1:
        return matmul(A, matpow(A, p - 1, mod), mod)
    elif p > 0:
        b = matpow(A, p // 2, mod)
        return matmul(b, b, mod)
    else:
        return [[1 if i == j else 0 for j in range(len(A))] for i in range(len(A))]



l,a,d,m = [int(i) for i in input().split()]
r = [(10**(c+1)-1-a)//d for c in range(18)]
MOD=m
#print(r)
ans = 0
flag = 0

for c, rc in enumerate(r):
    if rc < 0: continue
    C=[[pow(10,c+1,MOD),1,0], [0,1,d], [0,0,1]]
    if c==0:
        C = matpow(C,rc+1,MOD)
        ansvec = [[ans],[a],[1]]
    else:
        lc = max(r[c-1]+1,0)
#        print(lc)
        C = matpow(C,min(l-1,rc)-lc+1,MOD)
        ansvec = [[ans],[a+d*(lc)],[1]]
    ans = matmul(C,ansvec,MOD)[0][0]
#    print(ans)
    if rc > l:
        break

print(ans)






Measured memory_bytes: 39920
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,m,y,a,i,j;
  string c;
  cin>>n;
  vector<string> s(n);
  for (i=0;i<n;i++) {
    cin>>s.at(i);
  }
  cin>>m;
  vector<string> t(m);
  for (i=0;i<m;i++) {
    cin>>t.at(i);
  }
  y=0;
  for (i=0;i<n;i++) {
    a=0;
    for (j=0;j<n;j++) {
      if (s.at(j)==s.at(i)) a++;
    }
    for (j=0;j<m;j++) {
      if (t.at(j)==s.at(i)) a--;
      if (a<0) break;
    }
    if (y<a) y=a;
  }
  cout<<y<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        int x[] = new int[num];
        int p = 0;
        for(int i = 0; i<num; i++){
            x[i] = sc.nextInt();
            p = p + x[i];
        }
        int ans1 = 0;
        int ans2 = 0;
        int ans = 0;
        p = p / num;
        
        for(int i = 0; i<num; i++){
            ans1 = ans1 + (x[i] - p) * (x[i] - p);
        }
        
        p++;
        
        for(int i = 0; i<num; i++){
            ans2 = ans2 + (x[i] - p) * (x[i] - p);
        }
        
        if(ans1 < ans2){
            ans = ans1;
        }else{
            ans = ans2;
        }
        
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

ll D = 365;
vec c(26);
mat s(D, vec(26));
vec last(26, 0);

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

    cin >> D;
    Rep (i, 26) {
        cin >> c[i];
    }
    Rep (i, D) {
        Rep (j, 26) {
            cin >> s[i][j];
        }
    }

    vec t(D);
    Rep (i, D) {
        cin >> t[i];
        t[i]--;
    }

    ll tmp = 0;
    Rep (i, D) {
        tmp += s[i][t[i]];
        Rep (j, 26) {
            if (j != t[i]) tmp -= c[j] * (i+1 - last[j]);
        }
        last[t[i]] = i+1;
        cout << tmp << "\n";
    }
}

Measured memory_bytes: 3708
def gi; gets.to_i end
def gs; gets.chomp end
def gli; gets.split(' ').map(&:to_i) end
def d(n); Math.log10(n).to_i + 1 end
class Integer
  # 約数の組み合わせを列挙する
  def divisor_combinations
    (1..Math.sqrt(self).to_i).
      select { |i| self % i == 0 }.
      map { |i| [i, self / i] }
  end
end

N = gi
S = gs

puts S.squeeze.length


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

class DisjointSet {
public:
    vector<int> p;

    DisjointSet() {}
    DisjointSet(int size) {
        p.resize(size, 0);
        for (int i = 0; i < size; i++) {
            makeSet(i);
        }
    }

    void makeSet(int x) {
        p[x] = x;
    }

    bool same(int x, int y) {
        if (findset(x) == findset(y)) {
            return true;
        }
        else {
            return false;
        }
    }

    int findset(int x) {
        if (p[x] != x) {
            p[x] = findset(p[x]);
        }
        return p[x];
    }

    void unite(int x, int y) {
        link(findset(x), findset(y));
    }

    void link(int x, int y) {
        p[y] = x;
    }
};

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

    DisjointSet ds_r = DisjointSet(n + 1);
    DisjointSet ds_t = DisjointSet(n + 1);

    for (int i = 1; i <= k; i++) {
        int p, q;
        cin >> p >> q;
        ds_r.unite(p, q);
    }

    for (int i = 1; i <= l; i++) {
        int r, s;
        cin >> r >> s;
        ds_t.unite(r, s);
    }

    map<pair<int, int>, int> mp;
    for (int i = 1; i <= n; i++) {
        // p[i]を根の値に書き換えるため、もう1度findsetを実施
        mp[make_pair(ds_r.findset(i), ds_t.findset(i))]++;
    }

    for (int i = 1; i <= n; i++) {
        if (i != 1) {
            cout << " ";
        }
        cout << mp[make_pair(ds_r.p[i], ds_t.p[i])];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 13568
#include <stdio.h>
#include <string.h>
int main()
{
    char x[1200];
    char y;
    do
    {
        scanf("%c", &y);
    if (y >= 'A' && y <= 'Z')
    {
        y = y + 32;
    }
    else if (y >= 'a' && y <= 'z')
    {
        y = y - 32;
    }
    printf("%c", y);
    } while (y != '\n');

    return 0;
}


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

int main(){
  int A,B;
  cin >> A >> B;
  
  if(A>12){
    cout << B <<endl;
  }
  if(A>=6 && A<=12){
    cout << B/2 <<endl;
  }
  if(A<6){
    cout << 0 <<endl;
  }
}


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

int main(){
string s;cin>>s;
int l=s.length();
int ans=0;
for(int i=0;i<l/2;i++){
    if(s[i]!=s[l-i-1])ans++;
}
cout<<ans;
}


Measured memory_bytes: 256
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static PrintWriter out;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int total = Integer.parseInt(sc.next());
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int ashikiri = a + b;
        String s = sc.next();
        int passed = 0;
        int foreigner_count = 0;
        for (int i = 0; i < total; i++) {
            if (s.charAt(i) == 'a') {
                if (passed < ashikiri) {
                    passed++;
                    out.println("Yes");
                } else {
                    out.println("No");
                }
            } else if (s.charAt(i) == 'b') {
                foreigner_count++;
                if ((passed < ashikiri) && (foreigner_count <= b)) {
                    passed++;
                    out.println("Yes");
                } else {
                    out.println("No");
                }
            } else {
                out.println("No");
            }
        }
        sc.close();
        out.close();
    }

}

Measured memory_bytes: 40192
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q;
    cin >> n;
    int ans=0;
    rep(i,n){
        int l,r;
        cin>>l>>r;
        ans+=(r-l+1);
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10001

int main(){
  unsigned short *A,*B;
  int C[VMAX];
  int n,i,j;

  scanf("%d",&n);

  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);

  for(i=0;i<VMAX;i++){
    C[i]=0;
  }
  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  for(i=1;i<VMAX;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    if(i>1){
      printf(" ");
    }
    printf("%d",B[i]);
  }
  printf("\n");

  return 0;
}
    



Measured memory_bytes: 9620
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        init(200000);
        int Q = cin.nextInt();
        for (int i = 0; i < Q; i++)
        {
            int l = cin.nextInt();
            int r = cin.nextInt();
            Console.WriteLine(sum[r] - sum[l - 1]);
        }
    }

    bool isPrime(long a)
    {
        if (a < 2) return false;
        long i;
        for (i = 2; i * i <= a; i++)
        {
            if (a % i == 0) return false;
        }
        return true;
    }

    int[] check;
    int[] sum;
    void init(int N)
    {
        check = new int[N];
        sum = new int[N];
        for (int i = 0; i < N; i++)
        {
            check[i] = isPrime(i) ? 1 : 0;
        }

        for (int i = N - 1; i >= 0; i--)
        {
            check[i] = check[i] & check[(i + 1) / 2];
        }

        for (int i = 1; i < N; i++)
        {
            sum[i] = sum[i - 1] + check[i];
        }
    }
    

    

}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 16972
x, y = gets.split.map(&:to_i)

def gcd(x, y)
  if x < y
    swap = x
    x = y
    y = swap
  end
  
  until x % y == 0
    amari = x % y
    x = y
    y = amari
  end
  
  return y
end

puts gcd(x, y)

Measured memory_bytes: 6096
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(a) cout << #a << ": " << a << endl
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define forr(i, st, en) for(int i = st; i < en; i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false)

int32_t main(){ fast;
	
	string s; cin>>s;
	cout<<(s[2] == s[3] && s[4] == s[5] ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
#include<stdio.h>

int main() {
	char s[1100];

	while(true) {
		scanf("%s",s);
		if(s[0] == '0')
			break;
		int sum = 0;

		for(int i = 0;s[i] != '\0';i++) {
			sum += s[i] - '0';
		}
		printf("%d\n",sum);
	}
}


Measured memory_bytes: 2700
#!/usr/bin/env python3

import math

K = int(input())
ans = 0

for i in range(1, K+1):
    for j in range(1, K+1):
        temp = math.gcd(i, j)
        for k in range(1, K+1):
            ans += math.gcd(temp, k)

print(ans)

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

int main() {
    vector<int> clause(3);
    cin >> clause[0] >> clause[1] >> clause[2];

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

    if (clause[0] == 5 && clause[1] == 5 && clause[2] == 7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

using namespace std;

int main()
{
   int N, A;
   scanf("%d %d", &N, &A);
   if(N % 500 <= A) printf("Yes\n");
   else printf("No\n");
   return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
        cin >> a[i];
    map<int, int> mp;
    for (int i = 0; i < N; i++)
        mp[a[i]]++;
    int ans = 0;
    for (auto p : mp)
    {
        int x = p.first;
        int n = p.second;
        if (n < x)
            ans += n;
        else
            ans += (n - x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5120
solve :: Int -> Int -> Int -> Int -> Int
solve a b c k
 | k <= a = k
 | k <= b = a
 | otherwise = a - (k - a - b)

main :: IO ()
main = do
 [a,b,c,k] <- map read . words <$> getLine :: IO [Int]
 print $ solve a b c k

Measured memory_bytes: 3896
import sys
input = sys.stdin.readline
INF = 10**13


def main():
    N = int(input())
    T = [[int(i) for i in input().split()] for j in range(N)]
    X_dist = [[0]*N for _ in range(1 << N)]
    Y_dist = [[0]*N for _ in range(1 << N)]

    for bit in range(1 << N):
        cur_x = [0]
        cur_y = [0]
        for i in range(N):
            if bit & (1 << i):
                cur_x.append(T[i][0])
                cur_y.append(T[i][1])
        for i, (x, y, p) in enumerate(T):
            X_dist[bit][i] = p*min(abs(cx - x) for cx in cur_x)
            Y_dist[bit][i] = p*min(abs(cy - y) for cy in cur_y)

    answer = [INF] * (N+1)
    for i in range(1 << N):
        cnt = bin(i).count("1")
        j = i
        while j >= 0:
            j &= i
            cost = 0
            for k in range(N):
                if not((i >> k) & 1):
                    cost += min(X_dist[j][k], Y_dist[i - j][k])
            answer[cnt] = min(answer[cnt], cost)
            j -= 1

    for ans in answer:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 88632
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
	ios::sync_with_stdio(false);
	int N,H,max=0,ans=0;
	cin>>N>>H;
	vector<int> a(N),b(N);
	for(int i=0;i<N;i++){
		cin>>a[i]>>b[i];
		if(a[i]>=max) max=a[i];
	}
	sort(b.begin(),b.end(),greater<int>());
	for(int i=0;i<N;i++){
		if(b[i]>=max){
			H-=b[i];
			ans++;
		}
		if(H<=0){
			cout<<ans<<endl;
			return 0;
		}
	}
	while(H>0){
		H-=max;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
    
    long n; scanf("%ld",&n);
    int r=0,g=0,b=0,ans=0,ng=0;
    char s[n]; scanf("%s",&s);

    for (int i=0; i<n; i++){
        if (s[i]=='R') r++;
        else if (s[i]=='G') g++;
        else b++;
    }

    int k;
    for (int i=0; i<n; i++){
        for (int j=i+1; j<n; j++){
            k=j+(j-i);
            if (k>=n) continue;
            if ((s[i]!=s[j]) && (s[j]!=s[k]) && (s[k]!=s[i])) ng++;
        }
    }


    printf("%ld\n",r*g*b-ng);
}

Measured memory_bytes: 1732
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <bitset>
using namespace std;
#define LL long long
#define pb push_back
#define mk make_pair
#define pill pair<int, int>
#define mst(a, b)    memset(a, b, sizeof a)
#define REP(i, x, n)    for(int i = x; i <= n; ++i)
#define INF 0x3f3f3f3f
#define ll long long
#define pi acos(-1.0)
int main(){
	int n,k;
	int Min = 2100000000;
	int a[100010];
	scanf("%d %d",&n,&k);
	for(int i = 1 ; i <= n ; i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
	for(int i = k ; i <= n ; i++){
		Min = min(Min,min(abs(a[i]),abs(a[i-k+1]))+a[i]-a[i-k+1]);
	}
	printf("%d\n",Min);
}
/*
10
5 9 5 9 8 9 3 5 4 3
*/

Measured memory_bytes: 640
q, h, s, d = map(int, input().split())
n = int(input())

if n % 2 == 0:
    print((n//2)*min(8*q, 4*h, 2*s, d))
else:
    print((n//2)*min(8*q, 4*h, 2*s, d)+min(4*q, 2*h, s))

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

int main() {
int n;
cin >>n;
vector<int>a(n);
for(int i=0;i<n;i++){
    cin >> a.at(i);
}
sort(a.begin(),a.end());
cout << a.at(n/2)-a.at(n/2-1)<<endl;
}




Measured memory_bytes: 768
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>

#define ll long long
#define ld long double
#define ull unsigned long long
#define endl "\n"
#define MohamedMotaz ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
#define f(a, b, c) for(int a = b; a < c; a++)
#define fr(a, b, c) for(int a = b; a >= c; a--)
#define all(a) a.begin(), a.end()
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pair<ll,ll>>
#define vi vector<int>
#define pi acos(-1)

using namespace std;

const ll mod = 1e9 + 7;

ll fact[1000001]; ll inv[1000001];
//ll primes[100007];
ll arr[1000007];
ll modPower(ll b, ll p) {
	if (p == 0)
		return 1;

	ll halfpow = modPower(b, p / 2);
	ll toReturn = (halfpow * halfpow) % mod;
	if (p % 2)
		toReturn = (toReturn * b) % mod;

	return toReturn;
}
//
//ll fastPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//	ll ans = fastPower(b, p / 2);
//	ans = (ans * ans);
//	if (p % 2 != 0)
//		ans = (ans * b);
//	return ans;
//}
//ll GcdRecursive(ll a, ll b) {
//	if (b == 0) return a;
//	return GcdRecursive(b, a % b);
//}
//ll modLCM(ll a, ll b) {
//	ll val = GcdRecursive(a, b);
//	ll tmp = ((a % mod) * (b % mod)) % mod;
//	ll finalVal = ((tmp % mod) * (arr[val] % mod)) % mod;
//	return finalVal;
//
//}
//ll LCM(ll a, ll b) {
//	return (a * b) / GcdRecursive(a, b);
//}
//void move1step(ll& a, ll& b, ll q) { // a and b by reference
//	ll c = a - q * b;
//	a = b;
//	b = c;
//}
//ll GcdIterative(ll a, ll b) {
//	while (b) move1step(a, b, a / b);
//	return a;
//}
//
void pre(ll n) {

	fact[0] = 1;
	inv[0] = 1;

	for (ll i = 1; i <= n; i++) {
		fact[i] = (i * fact[i - 1]) % mod;
		inv[i] = modPower(fact[i], mod - 2);
		arr[i] = modPower(i, mod - 2);
	}
}
//
//ll npr(ll n, ll r) {
//	return ((fact[n] * inv[n - r]) % mod);
//}
//
ll ncr(ll n, ll r) {
	return ((((fact[n] * inv[n - r]) % mod) * inv[r]) % mod);
}

//void sieve(ll val) {
//	memset(primes, 1, sizeof primes);
//	primes[0] = primes[1] = false;
//	for (int i = 2; i <= val; i++) {
//		if (primes[i]) {
//			for (int j = i * i; j <= val; j += i) {
//				primes[j] = 0;
//			}
//		}
//	}
//
//}

const ll MOD = 998244353;
//const ll mod = 1e9 + 7;
const ll N = 1e3 + 7;
const ll inf = 1e18 + 5;



ll n, k;
int main() {
    MohamedMotaz
    pre(3000);
    cin >> n >> k;
    ll red = n - k, blue = k;
    //val to arrange blue balls & red balls
    ll a, b, ans;
    f(i,1,k + 1){
        a = ncr(red + 1, i);
        b = ncr(blue - 1 , i - 1);
        ans = a * b;
        //cout << a << " " << b << endl;
        cout << ans % mod << endl;
    }
}







Measured memory_bytes: 4480
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	int cnt[];
	int ans[];
	int info[][];
	boolean judge;
	boolean judge2;
	int n, x, m;
	int max = 0;

	void run() {
		n = sc.nextInt();
		x = sc.nextInt();
		m = sc.nextInt();
		cnt = new int[n + 1];
		ans = new int[n + 1];
		info = new int[m][3];
		judge = false;
		for (int i = 0; i < m; i++) {
			info[i][0] = sc.nextInt();
			info[i][1] = sc.nextInt();
			info[i][2] = sc.nextInt();
		}
	
		dfs(0);
		if (!judge2) {
			System.out.println(-1);
		} else {
			for (int j = 1; j < n; j++) {
				System.out.print(ans[j] + " ");
			}
			System.out.println(ans[n]);
		}
	}

	void dfs(int oriCnt) {
		if (oriCnt == n + 1) {
			boolean use[] = new boolean[n + 1];
			judge = false;
			for (int i = 0; i < m; i++) {
				int sum = 0;
				for (int j = info[i][0]; j <= info[i][1]; j++) {
					use[j] = true;
					sum += cnt[j];
				}
				if (sum == info[i][2]) {
					judge = true;
				} else {
					judge = false;
				}
				if (!judge) {
					return;
				}
			}
			if (judge) {
				judge2 = true;
				int sum = 0;
				for (int j = 1; j <= n; j++) {
					if (!use[j]) {
						cnt[j] = x;
					}
					sum += cnt[j];
				}
				if (sum > max) {
					for (int k = 1; k <= n; k++) {
						ans[k] = cnt[k];
					}
				}
			}
			return;
		} else {
			for (int i = 0; i <= x; i++) {
				cnt[oriCnt] = i;
				dfs(oriCnt + 1);
			}
		}
	}

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

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



int main(){
  int N,L;
  cin>>N>>L;
  int mini=abs(L);
  int all=0;
  
  for (int i=0;i<N;i++){
    all+=L+i;
  }
  for (int i=1;i<N;i++){
    mini=min(mini,abs(L+i));
  }
  if(L+N-1<=0)
    mini=(-1)*mini;
  int rest=all-mini;
  cout<<rest<<endl;
}
    

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

using namespace std;

#define INT_MAX 2147483647
typedef long long ll;

ll gcd(ll m, ll n);
ll lcm(ll m, ll n);

int main(void) {

	string ans = "Yes";
	
	int n;
	cin >> n;
	vector<string> v;
	bool flg = true;
	for (int i = 0; i < n; i++) {
		string tmp;
		cin >> tmp;
		if (i == 0) {
			v.push_back(tmp);
			continue;
		}
		if (v[i - 1].back() != tmp[0]) {
			ans = "No";
			break;
		}
		for (auto w : v) {
			if (w == tmp) {
				ans = "No";
				flg = false;
				break;
			}
		}
		v.push_back(tmp);
		if (!flg) break;
	}

	cout << ans << endl;	

	return 0;

}

// 2番目から3要素だけ抜き出した部分文字列を取得する
//std::string result = s.substr(2, 3);  
#if 1
//最大公倍数
ll gcd(ll m, ll n)
{
	ll temp;
	while (m % n != 0)
	{
		temp = n;
		n = m % n;
		m = temp;
	}
	return n;
}

//最小公倍数
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}
#endif

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

using namespace std;


int main()
{
    string S;
    int counter = 700;

    cin >> S;

    for(int i=0; i<3; i++)
    {
        if( S[i] == 'o' )
            counter += 100;
    }

    cout << counter << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var input = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var city = input[0];
        var start = input[1];
        var lo = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var result = Abs(lo[0] - start);
        for(var i = 1; i < city; i++)
            result = Calculation.GCD(result, Abs(lo[i]-start));
        WriteLine(result);
    }
}

public class Calculation
{
  public static int GCD(int num1, int num2)
    {
        return num1 < num2 ? GCD(num2, num1) :
            num2 > 0 ? GCD(num2, num1 % num2) : num1;
    }
}

Measured memory_bytes: 18400
(defun split-string (str)
  (let ((string-position (position #\Space str)))
    (cond
      ((null string-position) (list str))
      (t (cons (subseq str 0 string-position) (split-string (subseq str (1+ string-position))))))))

(defun MaximumDifference (aList)
  (let* ((mini (apply #'min aList)) (maxi (apply #'max aList)))
    (format t "~A~%" (abs (- maxi mini)))))

(read-line)
(MaximumDifference (mapcar #'parse-integer (split-string (read-line))))

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

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

const ll oo = 1e18;
const ll mod = 998244353,maxn = 3030;
const double PI = acos(-1);


int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, ans = 0;
    cin >> n;
    ans += (n/500)*1000;
    n -= (n/500)*500;
    ans += (n/5)*5;

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

Measured memory_bytes: 3608
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ctime>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define N 101
#define mod 1000000007
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define in(i,arr) for(auto &i:arr)cin>>i;
#define all(x) (x).begin(), (x).end()   // sort(all(v)) instead sort(v.begin(),v.end())
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define vi vector<int>
#define vl vector<int>
#define pb push_back
#define eb empalce_back
int pow(int base,int to)
{   int ans=1;
    while(to>0) {
        if (to & 1)
            ans *= base, to--;
        else base *= base, to /= 2;
    }
    return ans;

}
int main()
{ fast;
  float d,t,s;
  cin>>d>>t>>s;
  if(d/s<=t)cout<<"Yes";
  else cout<<"No";



}



Measured memory_bytes: 3740
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define INF 100000000

const int MOD = 1e9+7;
typedef long long ll;
using namespace std;
const ll M = 998244353;

int main(void) {
	ll n, cnt=0, r_cnt=0, g_cnt=0, b_cnt=0;
	string s; char s_i, s_j;
	cin >> n >> s;
	int r_cnt_arr[n], g_cnt_arr[n], b_cnt_arr[n];
	r_cnt_arr[0]=0;g_cnt_arr[0]=0;b_cnt_arr[0]=0;
	for(int i=0;i<n;i++) {
		if(i!=0) {
		    r_cnt_arr[i] = r_cnt_arr[i-1];
		    g_cnt_arr[i] = g_cnt_arr[i-1];
		    b_cnt_arr[i] = b_cnt_arr[i-1];
		}
	    if(s[i]=='R') { r_cnt++; r_cnt_arr[i]++; }
	    else if(s[i]=='G') { g_cnt++; g_cnt_arr[i]++; }
	    else if(s[i]=='B') { b_cnt++; b_cnt_arr[i]++; }
	}
	for(int i=0;i<n-2;i++) {
      s_i = s[i];
      for(int j=i+1;j<n-1;j++) {
      	s_j = s[j];
      	if(s_i==s_j) continue;
      	if(s_i!='R' && s_j!='R') {
      		cnt += r_cnt - r_cnt_arr[j];
      	} else if(s_i!='G' && s_j!='G') {
      		cnt += g_cnt - g_cnt_arr[j];
      	} else if(s_i!='B' && s_j!='B') {
      		cnt += b_cnt - b_cnt_arr[j];
      	}
      	if(j+(j-i) >= n) continue;
      	if(s_i!= s[j+(j-i)] && s_j != s[j+(j-i)]) {
      		cnt--; 
      	}
      }
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int N,M,x=0,g=0,ans=1;
    cin >> N >> M;
    vector<pair<int,int>> v(M);
    for(int i=0;i < M;i++){
        cin >> v.at(i).second>> v.at(i).first;
    }//input 橋の左端と右端

    sort(v.begin(),v.end());//終点でソートした

    for(int i=1;i < v.size();i++){
        if(v.at(x).first <= v.at(i).second){//iは終点ソートしてあることより一番早く終わるとこ
                x=i;//eraseで添え字がずれるの注意,
                ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
/******************
*  Author: BD747  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
#include<bits/stdc++.h>
using namespace std;

int n;
int a,b;
int f,s,t;
int emp;

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n;
	cin>>a>>b;
	for(int i=0;i<n;i++){
		cin>>emp;
		if(emp<=a){
			f++;
		}else{
			if(emp>b){
				t++;
			}else{
				s++;
			}
		}
	}
	cout<<min(min(f,s),t)<<endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int,input().split()))

Odd = []
Even = []

for i in range(n):
    if i%2:
        Even.append(A[i])
    else:
        Odd.append(A[i])

if n%2:
    print(*(list(reversed(Odd))+Even))
else:
    print(*(list(reversed(Even))+Odd))

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

int main() {
  vector<int> v;
  int a;
  REP(i, 3) {
    cin >> a;
    v.push_back(a);
  }

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

  cout << v[2] - v[0] << endl;

  return 0;
}

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

int main(){
  int A,B,C,D,L,R;
  cin >> A >>B>>C>>D;
  L=A+B,R=C+D;
  if(L>R){
    cout << "Left" << endl;
  }
  else if(L==R){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}
    

Measured memory_bytes: 256
n = int(input())
v = list(map(int, input().split()))
even = {}
odd = {}
for i in range(n):
    if i % 2 == 0:
        if v[i] in even:
            even[v[i]] += 1
        else:
            even[v[i]] = 1
    else:
        if v[i] in odd:
            odd[v[i]] += 1
        else:
            odd[v[i]] = 1

def check(dic1, dic2):
    if len(dic1) == 1 and len(dic2) == 1 and list(dic1.keys()) != list(dic2.keys()):
        return True
    else:
        return False

def maxkey(dic):
    maxkey = 0
    maxvalue = 0
    for key in dic:
        value = dic[key]
        if maxvalue < value:
            maxvalue = value
            maxkey = key
    return maxkey

if check(even, odd):
    print(0)
elif len(list(set(v))) == 1:
    print(int(n/2))
else:
    evenlist = sorted(list(even.values()))
    oddlist = sorted(list(odd.values()))
    evenlist.reverse()
    oddlist.reverse()
    if maxkey(even) != maxkey(odd):
        ans = n/2 - evenlist[0] + n/2 - oddlist[0]
        print(int(ans))
    else:
        if len(evenlist) == 1:
            ans = n/2-evenlist[0] + n/2-oddlist[1]
        elif len(oddlist) == 1:
            ans = n/2-evenlist[1] + n/2-oddlist[0]
        else:
            ans = min(n/2-evenlist[0] + n/2-oddlist[1], n/2-evenlist[1] + n/2-oddlist[0])
        print(int(ans))

Measured memory_bytes: 23776
#include <stdio.h>

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

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,inf=0x3f3f3f3f;
#define mst(a) memset(a,0,sizeof a)
int n,d[N],vis[N],sign[N],m;
vector<int>e[N<<1];
void spfa(){
	queue<int>q;
	for(int i=1;i<=n;i++) d[i]=inf;
	q.push(1);vis[1]=1,d[1]=0;
	while(q.size()){
		int u=q.front();q.pop();vis[u]=0;
		for(auto v:e[u]){
			if(d[v]>d[u]+1){
				d[v]=d[u]+1;
				sign[v]=u;
				if(!vis[v]) q.push(v),vis[v]=1; 
			}
		}
	}
	int ok=0;
	for(int i=2;i<=n;i++) 
	if(d[i]==inf){
		 ok=1;
		 break;
	}
	if(ok) puts("No");
	else {
		puts("Yes");
		for(int i=2;i<=n;i++)
			printf("%d\n",sign[i]);
	}
} 
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,u,v;i<=m;i++){
		scanf("%d%d",&u,&v);
		e[u].push_back(v);
		e[v].push_back(u); 
	} 
	spfa();
	return 0;
} 

Measured memory_bytes: 13712