akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;

int main(){
  int a, b, q;
  string str, str1, str2, str3, g, p;

  cin >> str >> q;

  for( int i = 0; i < q; i++){
    cin >> g;
    if(g == "print"){
      cin >> a >> b;
      cout << str.substr(a, b - a + 1) << endl;
    } else if(g == "reverse"){
      cin >> a >> b;
      str1 = str.substr(a, b - a + 1);
      int n;
      n = str1.size();
      for( int j = 0; j < n; j++){
        str[j + a] = str1[n - 1 - j];
      }
      str.insert(a, str2);
    } else if(g == "replace"){
      cin >> a >> b >> p;
      str.erase(a, b - a + 1);
      str.insert(a, p);
    }
  }

  return 0;
}

Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

const int INF = 1e8;
const int H = 10;
const int W = 5;


int checkLine(int x, int m[W]){
	if(m[x] == INF) return 0;

	int cnt = 0;
	range(i,x,W){
		if(m[i] == m[x]) cnt++;
		else break;
	}
	assert(cnt >= 0 and cnt <= 5);
	return cnt;
}

void drop(int h, int m[H][W], int y, int x){
	if(y + 1 >= h or m[y][x] == INF) return;

	if(m[y + 1][x] == INF){
		m[y + 1][x] = m[y][x];
		m[y][x] = INF;
	}
}

int deleteLine(int h, int m[H][W]){
	int res = 0;
	rep(i,h){
		rep(j,W){
			int cnt = checkLine(j, m[i]);
			if(cnt >= 3){
				rep(k,cnt){
					res += m[i][j + k];
					m[i][j + k] = INF;
				}
			}
		}
	}

	rep(_,10){
		rep(i,h){
			rep(j,W){
				drop(h,m,i,j);
			}
		}
	}

	return res;
}

int main(){
	int h;
	while(cin >> h,h){
		int m[H][W];
		rep(i,h) rep(j,W) cin >> m[i][j];

		int ans = 0;
		while(true){
			int cnt = deleteLine(h, m);
			if(cnt == 0) break;
			ans += cnt;
		}

		cout << ans << endl;
	}
}



Measured memory_bytes: 3028
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;typedef vector<int> ivec;typedef vector<string> svec;

int main(){
	int N,A,B,H,W,ans=0;
	scanf("%d%d%d",&N,&H,&W);
	for(int i=0;i<N;++i){
		cin >> A >> B;
		if(A<H||B<W) continue;
		else ++ans;
	}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long X,Y,Z,K,i,x,y,z;
vector<long>A,B,C,ABC;
int main(){
  cin>>X>>Y>>Z>>K;
  A.resize(X);
  B.resize(Y);
  C.resize(Z);
  for(i=0;i<X;i++)cin>>A[i];
  for(i=0;i<Y;i++)cin>>B[i];
  for(i=0;i<Z;i++)cin>>C[i];
  sort(A.rbegin(),A.rend());
  sort(B.rbegin(),B.rend());
  sort(C.rbegin(),C.rend());
  for(x=0;x<X;x++){
    for(y=0;y<Y;y++){
      if((x+1)*(y+1)>K)break;
      for(z=0;z<Z;z++){
        if((x+1)*(y+1)*(z+1)>K)break;
        ABC.push_back(A[x]+B[y]+C[z]);
      }
    }
  }
  sort(ABC.rbegin(),ABC.rend());
  for(i=0;i<K;i++)cout<<ABC[i]<<endl;
}


Measured memory_bytes: 1404
N, M = map(int, input().split())
X = []
for i in range(N):
    x = list(map(int, input().split()))
    X.append(x)
Y = []
for i in range(M):
    y = list(map(int, input().split()))
    Y.append(y)


for i in X:
    len = []
    for j in Y:
        len.append(abs(i[0]-j[0])+abs(i[1]-j[1]))
    print(len.index(min(len))+1)


Measured memory_bytes: 9152
#include <stdio.h>

int main() {
  double  min, max, height;

  scanf("%lf", &height);
  min = height;
  max = min;

  while (scanf("%lf", &height) != EOF) {
    if (height < min) {
      min = height;
    } else if (max < height) {
      max = height;
    } else {
    }
  }

  printf("%f\n", max - min);

  return 0;
}

Measured memory_bytes: 648
def input_int_list():
    return [int(thing) for thing in input().split(" ")]

def int_input():
    return int(input())


def print_ans(string):
    print(string)
    exit()

def yes():
    print("Yes")
    exit()

def no():
    print("No")
    exit()


if __name__ == '__main__':
    X=int_input()
    yokin=100
    for i in range(5000):
        yokin=yokin*1.01//1
        if yokin>=X:
            print_ans(i+1)


Measured memory_bytes: 9252
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}

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



int main(){
    int n,m;
    cin >> n >> m;
    vector<P> p;

    rep(i, m){
        int a,b;
        cin >> a >> b;
        p.emplace_back(b, a);
    }

    sort( ALL(p) );
    int res = 0;
    int now = -1;

    rep(i, m){
        if(now < p[i].second){
            res++;
            now = p[i].first - 1;
        }
    }
    
    cout << res << endl;
    
}

Measured memory_bytes: 1400
n,t = map(int,input().split())
a = list(map(int,input().split()))

max_now = 0
max_idx = 0
max_gap = 0
dat = []
for i in range(n-1,-1,-1):
    if i == n-1:
        max_now = a[i]
        max_idx = i
        max_gap = 0
    else:
        if a[i]>max_now:
            max_idx = i
            max_now = a[i]
            dat.append((a[i],i,max_now,max_idx,0))
        else:
            dat.append((a[i],i,max_now,max_idx,max_now-a[i]))
dat.sort(key = lambda x:x[4],reverse=True)
max_gap = dat[0][4]

res = 0
for _,_,_,_,gap in dat:
    if gap == max_gap:
        res+=1
    else:
        break
print(res)


Measured memory_bytes: 24680
inf = float("inf") 
n,k=map(int ,input().split())
a=list(map(int ,input().split()))
dp=[inf]*n
dp[0]=0
for i in range(1,n):
    for j in range(i-1,max(0,i-k)-1,-1):
        dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]))
print(dp[n-1])
    

Measured memory_bytes: 54880
package main

import "fmt"

func main() {
	var (
		n int
		s string
	)
	fmt.Scan(&n, &s)

	ans := 1
	for i := 1; i < len(s); i++ {
		if s[i-1] != s[i] {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1280
N,A,B,K=map(int,input().split())
mod=998244353

INV=[None]*(N+1)
for i in range(1,N+1):
    INV[i]=pow(i,mod-2,mod)

Combi=[None]*(N+1)
Combi[0]=1
Combi[1]=N
for i in range(2,N//2+2):
    Combi[i]=Combi[i-1]*(N-i+1)*INV[i] %mod
for i in range(N//2+2,N+1):
    Combi[i]=Combi[N-i]


ANS=0

if B>A:
    (A,B)=(B,A)

ran=K//A

for i in range(min(ran,N)+1):
    q, r = divmod(K-(A*i), B)
    if r==0 and q<=N:
        ANS = (ANS+(Combi[i]*Combi[q])%mod)%mod

print(ANS)



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

public class Main {
	
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		int a = fs.nextInt();
		int b = fs.nextInt();
		
		int[] hitPointArr = new int[n];
		int maxHitPoint = 0;
		for(int i = 0; i < n ; i++) {
			int hitPoint = fs.nextInt();
			hitPointArr[i] =hitPoint;
			maxHitPoint = Math.max(maxHitPoint, hitPoint);
		}
		
		int left = 0;
		int right = maxHitPoint / b + 1;
		int minVal = 1001001001;
		
		while(left <= right) {
			int mid = (left + right) / 2;
			if(canBeatAllMonster(mid, a,b, hitPointArr)) {
				minVal = Math.min(minVal, mid);
				right = mid - 1;
			}else {
				left = mid + 1;
			}
		}
		
		System.out.println(minVal);
	}

	boolean canBeatAllMonster(int time, int a, int b, int[] hitPointArr) {
		
		int restTime = time;
		
		for(int i = 0; i < hitPointArr.length; i++) {
			int hitPoint = hitPointArr[i];
			hitPoint -= b*time;
			if(hitPoint > 0) {
				if(hitPoint % (a-b) == 0) {
					restTime -= (hitPoint / (a-b));
				}else {
					restTime -= (hitPoint / (a-b)  + 1);
				}
			}
			if(restTime < 0) {
				return false;
			}
		}
		return true;
	}
	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}


}


Measured memory_bytes: 36864
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD =1e9+7;
using ll=long long;
int n, A;
set<int> memo;
int main(){
  cin >> n;
  rep(i,n) {
    cin >> A;
    if(!memo.count(A)) memo.insert(A);
    else memo.erase(A);
  }
  cout << memo.size() << endl;
}


Measured memory_bytes: 4864
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
  int A,B,C,X;
  cin>>A;
  cin>>B;
  cin>>C;
  cin>>X;

  int ans=0;

  for(int i=0;i<=A;++i){
    for(int j=0;j<=B;++j){
      for(int k=0;k<=C;++k){
      if(500*i+100*j+50*k==X){++ans;}
      }
    }
  }

cout<<ans<<endl;

}

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

int main() {
    long long A;
    long long B;
    long long C;
    cin >> A >> B >> C;
    if (A == B && B != C) {
            cout << "Yes" << endl;
    }
    else if (B == C && C != A) {
        cout << "Yes" << endl;
    }
    else if (C == A && A != B) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    x = []
    l = []
    for i in range(n):
        tmp = list(map(int, input().split()))
        x.append(tmp[0] - tmp[1])
        l.append(tmp[0] + tmp[1])
    x, l = zip(*sorted(zip(x, l)))
    maxcount = 0
    preve = 0
    idx = 0
    while idx < n:
        tmps = x[idx]
        tmpe = l[idx]
        if preve == 0:
            maxcount += 1
            preve = tmpe
        elif tmps >= preve:
            maxcount += 1
            preve = tmpe
        elif tmpe < preve:
            preve = tmpe
        idx += 1
    print(maxcount)
    return

if __name__ == "__main__":
    main()

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

int main(){
    int n, m; cin >> n >> m;
    vector<vector<int>> g(n);
    rep(i, n) g[i].resize(n);
    rep(i, m){
        int a, b; cin >> a >> b; a--; b--;
        g[a][b] ++; g[b][a] ++;
    }
    rep(i, n){
        int cnt = 0;
        for (auto gi:g[i]){
            if (gi != 0) cnt += gi;
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 3624
while 1 :
	x, y, s = map(int,raw_input().split(" "))
	if (x, y, s) == (0,0,0):
		break
	max_sum_price = 0
	for priceA in range(1, s / 2 + 1):
		priceB = s - priceA
		tmp_priceA_free = priceA * 100 / (100 + x)
		tmp_priceB_free = priceB * 100 / (100 + x)
		while (tmp_priceA_free * (100+x) / 100 <= priceA):
			priceA_free = tmp_priceA_free
			tmp_priceA_free += 1
		while (tmp_priceB_free * (100+x) / 100 <= s - priceA):
			priceB_free = tmp_priceB_free
			tmp_priceB_free += 1
		if priceA_free * (100+x) / 100 != priceA or priceB_free * (100+x) / 100 != priceB:
			continue
		max_sum_price = max(max_sum_price, priceA_free*(100+y)/100 + priceB_free*(100+y)/100)
	print max_sum_price

Measured memory_bytes: 4240
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        N: usize,
        D: usize,
        Xss: [[f64; D]; N],
    }

    let mut ans = 0;
    for i in 0..N {
        for j in i + 1..N {
            let mut distance: f64 = 0.0;
            for d in 0..D {
                distance += (Xss[i][d] - Xss[j][d]) * (Xss[i][d] - Xss[j][d]);
            }
            distance = distance.sqrt();

            if distance == distance.floor() {
                ans += 1;
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2592
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
char s[100001],s2[100001],s3[100001];
int main(){
	cin>>s;
	int flag=1,len=strlen(s);
	for(int i=len-1;i>=0;i--){
	    int L=i,R=len-i-1; 
		if (L>R)
		break;
		if(s[L]==s[R])
		flag=0;
		else {
			flag=1;
			break;
		}
	}
	if(!flag){
		cout<<"Yes"<<endl;
		return 0;
	}
	int cnt=0;
	for(int i=0;i<len;i++)
		s2[i]=s[i];
	for(int i=0;i<len;i++){
		if(s2[i]=='b')
		s2[i]='d';
		else if(s2[i]=='d')
		s2[i]='b';
		else if(s2[i]=='p')
		s2[i]='q';
		else if(s2[i]=='q')
		s2[i]='p';
		if(s2[i]==s[i])
		 cnt=1;
		 else{
		 		cnt=0;
		 		break;
			 }
	}
	if(cnt==1){
		cout<<"Yes"<<endl;
		return 0; 
	}
	
	for(int i=0;i<len;i++)
		s2[len-i-1]=s[i];
		
		for(int i=len-1;i>=0;i--){
	    if(s2[len-i-1]==s[len-i-1])
		 flag=0;
		else 
		{
			flag=1;
			break;
		}
	}
	if(!flag)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	for(int i=0;i<len;i++){
		if(s2[len-i-1]=='b')
		s2[len-i-1]='d';
		else if(s2[len-i-1]=='d')
		s2[len-i-1]='b';
		else if(s2[len-i-1]=='p')
		s2[len-i-1]='q';
		else if(s2[len-i-1]=='q')
		s2[len-i-1]='p';
		if(s2[len-i-1]==s[len-i-1])
		 cnt=1;
		 else
		 	{
		 		cnt=0;
		 		break;
			 }
	}
	if(cnt==1)
	{
		cout<<"Yes"<<endl;
		return 0; 
	}
	cout<<"No"<<endl;
	return 0;
}

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

int main(){
  
  int x2;
  
  double a,b,x1,x3;
  
  cin >> a >> b;
  
  x1=(a+b)/2;
  
  x3=x1+0.9;
  
  x2=x3;
  

cout << x2 << endl; 

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 998244353;


template <ll mod>
struct ModCombination{
    ll N;
    vector<ll> fact,inv,finv;

    ModCombination(ll n):N(n){
        fact.assign(n+1, 1);
        inv.assign(n+1, 1);
        finv.assign(n+1,1);
        for(int i=1;i<n;i++){
            fact[i+1] = fact[i]*(i+1)%mod;
            inv[i+1] = inv[mod%(i+1)]*(mod-mod/(i+1))%mod;
            finv[i+1] = finv[i]*inv[i+1]%mod;
        }
    }

    ll Comb(ll n,ll k){
        return (fact[n]*finv[k]%mod)*finv[n-k]%mod;
    }
};


int main(){
  int K,N;cin>>K>>N;
  ModCombination<MOD> C(K+N);
  for(int i=2;i<=2*K;i++){
    ll ans=0;
    int p=0;
    for(int j=1;j*2<i&&j<=K;j++){
      if(1<=i-j&&i-j<=K)p++;
    }
    debug(p);
    int left = K-2*p+N-1;
    if(!(i&1)) left--;
    debug(left);
    ll pow2=1;
    repeat(q,min(p+1,N+1)){
      if(left>=N-q)ans = (ans+pow2*C.Comb(p,q)%MOD*C.Comb(left,N-q)%MOD)%MOD;
      pow2 = pow2*2%MOD;
    }

    if(!(i&1)){
      pow2=1;
      repeat(q,min(p+1,N)){
        if(left>=N-q)ans = (ans+pow2*C.Comb(p,q)%MOD*C.Comb(left-1,N-q-1)%MOD)%MOD;
        pow2 = pow2*2%MOD;
      }
    }

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


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        int ans;
        if(a+b > 2*c) {
            if (x > y && a < 2*c) {
                ans = 2*y*c + (x-y)*a;
            } else if (y > x && b < 2*c) {
                ans = 2*x*c + (y-x)*b;
            } else {
                ans = 2*c*Math.max(x,y);
            }
        } else {
            ans = x*a + y*b;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
n=int(input())
w=[]
flag=True
for i in range(n):
    w.append(input())
    
for i in range(n-1):
    if w[i][-1]!=w[i+1][0]:
        #print(i,"out1")
        flag=False

for i in range(n-1):
    for j in range(i+1,n):
        if(w[i]==w[j]):
            #print(i,j,"out2")
            flag=False

if flag==True:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    ll N;
    cin >> N;
    cout << N * (N-1) / 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>

int
main ()
{
    int a, b;
    std::cin >> a >> b;

    std::ostringstream ab, ba;
    for (int i = 0; i < a; ++i) ab << b;
    for (int i = 0; i < b; ++i) ba << a;

    std::cout << std::min(ab.str(), ba.str()) << std::endl;
}


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

## Library

from fractions import gcd
import math
from math import ceil,floor
import collections

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# list = list(map(int, input().split()))

A,B=map(int, input().split())

## Logic

if (A*B)%2 == 0:
    print("Even")
else:
    print("Odd")

## output



Measured memory_bytes: 64620
# -*- coding: utf-8 -*-
import sys
from collections import deque

N,M,P=map(int, sys.stdin.readline().split())

al=[ [] for i in range(N+1) ]		#隣接リスト
rev_al=[ [] for i in range(N+1) ]	#reverse隣接リスト
#辺のリスト
edge=[]

for i in range(M):
	a,b,c=map(int, sys.stdin.readline().split())
	al[a].append(b)
	rev_al[b].append(a)
	edge.append((a,b,c-P))


#ゴールからBFS
#訪問した頂点
Visit=[ 0 for _ in range(N+1) ]
q=deque()
q.append(N)
Visit[N]=1
while q:
	fro=q.popleft()
	for to in rev_al[fro]:
		if Visit[to]==0:
			Visit[to]=1
			q.append(to)
			
Visit1=Visit

#スタートからBFS
#訪問した頂点
Visit=[ 0 for _ in range(N+1) ]
q=deque()
q.append(1)
Visit[1]=1
while q:
	fro=q.popleft()
	for to in al[fro]:
		if Visit[to]==0:
			Visit[to]=1
			q.append(to)

Visit2=Visit

#1からもNからも到達可能な頂点の集合
V=[]
for v1,v2 in zip(Visit1,Visit2):
	V.append(v1&v2)

new_N=sum(V)

fedge=[]	#必要な要素だけをフィルターした辺集合
for a,b,c in edge:
	if V[a]==1 and V[b]==1:
		fedge.append((a,b,c))


D=[ float("-inf") ]*(N+1)	#頂点１からの距離 1-indexed
D[1]=0

#ベルマンフォード
for i in range(new_N):
	for a,b,c in fedge:
		if D[a]==float("-inf"): continue
		alt=D[a]+c
		if D[b]<alt:
			D[b]=alt
			if i==new_N-1:
				print -1
				quit()

print max(0,D[N])

Measured memory_bytes: 35688
// 基本テンプレート
#define _GLIBCXX_DEBUG // for STL debug
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int imos[100010];

const int SIZE = 1 << 18;
struct segtree {
    int node[2 * SIZE];
    segtree() {
        memset(node, 0, sizeof(node));
    }
    void add(int x, int val) {
        x += SIZE - 1;
        node[x] += val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = node[2*x+1] + node[2*x+2];
        }
    }
    int query(int a, int b, int l=0, int r=SIZE, int k=0) {
        if(b <= l or r <= a) return 0;
        if(a <= l and r <= b) return node[k];
        int mid = (l + r) / 2;
        int vl = query(a, b, l, mid, 2*k+1);
        int vr = query(a, b, mid, r, 2*k+2);
        return vl + vr;
    }
};

int rp[100010], lp[100010];

struct segment {
    int l, r;
    segment() {}
    segment(int a, int b) : l(a), r(b) {}
};

segtree treeone;
signed main() {
    int N; cin >> N;
    vector<segment> segs;
    for(int i=0; i<N; i++) {
        int a, b; cin >> a >> b;
        segs.push_back(segment(a, b));
    }

    // sort(segs.begin(), segs.end());
    int ans1 = 0, ans2 = 0;
    for(int i=0; i<N; i++) {
        int l = segs[i].l, r = segs[i].r;
        imos[l]++;
        imos[r]--;

        rp[r]++;
        lp[l]++;
    }

    for(int i=0; i<100005; i++) {
        imos[i+1] += imos[i];
        rp[i+1] += rp[i];
        chmax(ans2, imos[i]);
    }
    for(int i=100005; i>0; i--) {
        lp[i-1] += lp[i];
    }

    for(int i=0; i<N; i++) {
        int l = segs[i].l, r = segs[i].r;
        int cand = rp[l] + lp[r];
        chmax(ans1, N - cand);
    }

    cout << ans1 << " " << ans2 << endl;
    return 0;
}



Measured memory_bytes: 12688
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};
int dx2[]={1, 1, 0, -1, -1, -1, 0, 1};
int dy2[]={0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    while(1){
        int n; cin>>n;
        if(n==0) return 0;

        vector<int> cx(n, 0);
        vector<int> cy(n, 0);
        int wmin=0, wmax=0;
        int hmin=0, hmax=0;

        for(int i=1; i<n; i++){
            int m, d; cin>>m>>d;
            cy[i]=cy[m]+dy[d], cx[i]=cx[m]+dx[d];

            chmin(wmin, cx[i]);
            chmax(wmax, cx[i]);
            chmin(hmin, cy[i]);
            chmax(hmax, cy[i]);
        }

        cout << (wmax-wmin)+1 << " " << (hmax-hmin)+1 << endl;
    }
}


Measured memory_bytes: 3132
#include<stdio.h>
#include<string.h>
int main()
{
    char a[11], b[11], c[11];
    int length1=0, length2=0, length3=0;
    scanf("%s", a);
    scanf("%s", b);
    scanf("%s", c);
    length1=strlen(a);
    length2=strlen(b);
    length3=strlen(c);
    if(a[length1-1]==b[0]&&b[length2-1]==c[0])printf("YES");
    else printf("NO");
    return 0;
}


Measured memory_bytes: 128
fun main(args: Array<String>) {
  val N = readLine()!!.toInt()
  val a = readLine()!!.split(" ").map(String::toInt)
  val ave = Math.round(a.average())
  var total = 0.0
  for (A in a) {
    total += Math.pow((A.toDouble()-ave),2.0)
  }
  println(total.toInt())
}

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

#define ll long long
#define t() int t;cin>>t;while(t--)
#define ff first
#define ss second
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>b;i--)
#define pb push_back
#define mp make_pair

 
//ll solveb(int n){

//}

void solvea(){
 
 int n;
 ll ans=0;
 cin>>n;

 ans+=n/2;
 if(n&1){
 for(int i=1;i<=n/2;i++){
 	if(n%i==0){
 		ans+=(n/i-1);
 	}
 	else ans+=n/i;
 }
}
else {
	 for(int i=1;i<n/2;i++){
 	if(n%i==0){
 		ans+=(n/i-1);
 	}
 	else ans+=n/i;
 }
}
 cout<<ans<<endl;

 }

	
	
 

int main()
{
	#ifndef ONLINE_JUDGE
		//for getting input from input1.txt
		freopen("input1.txt","r",stdin);
		//for getting output from output.txt
		freopen("output.txt","w",stdout);
		#endif

		solvea();
return 0;
}

Measured memory_bytes: 3604
a[]={2,3,5,10,12,15},b[]={380,550,850,1520,1870,2244},m[51];main(n,d,T){for(n=1;n<51;n++)for(m[n]=9999,d=5;~d;d--)if(a[d]<=n&&m[n]>(T=m[n-a[d]]+b[d]))m[n]=T;for(;scanf("%d",&n),n;)printf("%d\n",m[n/100]);exit(0);}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll A, B, C;
	cin >> A >> B >> C;
	bool flag = false;
	REP(i, B+2){
		if((A*(i+1))%B==C) flag = true;
	}
	cout << (flag?"YES":"NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[105][100005];
ll N,W;
ll v[1001],w[1001];

ll knapsack(ll W,ll i){
    if(i>N-1){
        return 0;
    }
    if(W-w[i]<0){
        return knapsack(W,i+1);
    }
    //cout<<v[i]<<w[i];

    if(dp[i][W]!=-1){
        return dp[i][W];
    }

    ll op1=knapsack(W-w[i],i+1)+v[i];
    ll op2=knapsack(W,i+1);
    return dp[i][W]=max(op1,op2);
    

    

}
int main()
{
    
    cin>>N>>W;
    for(ll i=0;i<N;i++){
        cin>>w[i]>>v[i];
    }
    
    memset(dp,-1,sizeof(dp));
    cout<<knapsack(W,0);
    
}

Measured memory_bytes: 85672
import math
xs,ys,xg,yg= map(int,input().split())
n = int(input())
c = [[-1,xs,ys,0]]
for i in range(n):
    x,y,r = map(int,input().split())
    c.append([max(math.sqrt(abs(xs-x)**2+abs(ys-y)**2)-r,0),x,y,r])
dp  = [float("inf")]*(n+1)
dp[0] = 0
used = [0]*(n+1)
for i in range(n+1):
    a = float("inf");b=-1
    for j in range(n+1):
        if used[j]:continue
        if a > dp[j]:
            a = dp[j];b = j
    used[b] = 1
    g = b
    _,x,y,r = c[b]
    for j in range(n+1):
        if used[j]:
            continue
        _,x2,y2,r2 = c[j]
        ima = dp[g]+max(0,math.sqrt(abs(x2-x)**2+abs(y2-y)**2)-r-r2)
        if ima < dp[j]:
            dp[j] = ima
ans = float("inf")
for i in range(n+1):
    _,x,y,r = c[i]
    ans = min(dp[i]+max(0,math.sqrt(abs(xg-x)**2+abs(yg-y)**2)-r),ans)
print(ans)

Measured memory_bytes: 3316
#pragma comment(linker, "/STACK:512000000")
#include <bits/stdc++.h>
using namespace std;

#define all(a) a.begin(), a.end()
typedef long long li;
typedef long double ld;
void solve(__attribute__((unused)) bool);
void precalc();
clock_t start;
#define FILENAME ""

int main() {
#ifdef AIM
    string s = FILENAME;
//    assert(!s.empty());
    freopen("/home/alexandero/ClionProjects/cryptozoology/input.txt", "r", stdin);
#else
//    freopen(FILENAME ".in", "r", stdin);
//    freopen(FILENAME ".out", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    start = clock();
    int t = 1;
#ifndef AIM
    cout.sync_with_stdio(0);
    cin.tie(0);
#endif
    precalc();
    cout.precision(10);
    cout << fixed;
    //cin >> t;
    int testNum = 1;
    while (t--) {
        //cout << "Case #" << testNum++ << ": ";
        solve(true);
    }
    cout.flush();
#ifdef AIM1
    while (true) {
      solve(false);
  }
#endif

#ifdef AIM
    cout.flush();
    auto end = clock();

    usleep(10000);
    print_stats(end - start);
    usleep(10000);
#endif

    return 0;
}

void precalc() {
}

template<typename T>
inline T nxt() {
    T cur;
    cin >> cur;
    return cur;
}

//#define int li
//const int mod = 1000000007;

void solve(__attribute__((unused)) bool read) {
    int n;
    cin >> n;
    vector<int> res(n);
    for (int i = 0; i < n; ++i) {
        int cur;
        cin >> cur;
        --cur;
        if (cur) {
            res[cur] = res[cur - 1] + 1;
        } else {
            res[cur] = 1;
        }
    }
    cout << n - *max_element(all(res)) << "\n";
}

Measured memory_bytes: 1024
while True:
    H,W=map(int, input().split())
    if W == H == 0: break
    for i in range(H):
        if i%2==0 :
                if W%2==0:
                    print(W//2*"#.")
                else:
                    print(W//2*"#."+"#")
        else :
                if W%2==0:
                    print(W//2*".#")
                else:
                    print(W//2*".#"+".")
    print()


Measured memory_bytes: 5608
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define all(a)  (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  string s,t; cin >> s >> t;
  string ans = "Yes";

  vvi sg(26), tg(26);
  for (int i = 0; i < s.size(); i++) {
    int num = s[i] - 'a';
    sg[num].push_back(i);// 文字 s[i] が s の何文字目にあるかを記録
    num = t[i] - 'a';
    tg[num].push_back(i);
  }
  rep(i, 26){
    if(sg[i].size() > 1){// 文字 i が s に複数含まれていたら
      for (int j = 1; j < sg[i].size(); j++) {
        // s中 の i に対応する t の文字は全て同じ文字の必要がある
        if(t[sg[i][j]] != t[sg[i][j-1]]) ans = "No";
      }
    }

    if(tg[i].size() > 1){
      for (int k = 1; k < tg[i].size(); k++) {
        if(s[tg[i][k]] != s[tg[i][k-1]]) ans = "No";
      }
    }
  }
  std::cout << ans << '\n';
}


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

int main() {
    map<string, int> count;
    int N;
    cin >> N;

    rep(i, N){
        string S;
        cin >> S;
        count[S] += 1;
    }

    int max = 0;
    queue<string> q;

    for (auto p : count){
        if (p.second > max){
            while (!q.empty()){
                q.pop();
            }

            q.push(p.first);
            max = p.second;
        } else if (p.second == max){
            q.push(p.first);
        } else continue;
    }

    while (!q.empty()){
        cout << q.front() << endl;
        q.pop();
    }

}

Measured memory_bytes: 26880
#include <bits/stdc++.h>
using namespace  std;
#define f(i,n) 		for(i=0;i<n;i++)
#define fr(i,n,a) 	for(i=n;i>=a;i--)
#define fa(i,a,n) 	for(i=a;i<n;i++)
#define deb(x)		cout<<#x<<" "<<x<<endl;
#define deb2(x,y)	cout<<#x<<","<<#y<<" "<<x<<","<<y<<endl;
#define buf(x)		cout<<"Check"<<x<<endl;
#define ll			long long int 
#define ft			first
#define s			second
#define pb			push_back
#define mp			make_pair
#define d			double
#define all(v)		v.begin(),v.end()	
#define et(v)		for(auto itr:v)
inline void p(int x[],int n)	{	int i;f(i,n)cout<<x[i]<<" ";cout<<endl; }
void solve()
{  	
	ll N,K,i;
	cin>>N;

	if(N>=30)
		cout<<"Yes";
	else
		cout<<"No";
	
}
int main()
{	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
		cout<<endl;
		
	}
	return 0;
}
		


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    vector<int> antenna (5);
    REP(i,5){
        cin >> antenna[i];
    }
    int k;
    cin >> k;
    REP(i,4){
        FOR(j,i,5){
            if (antenna[j] - antenna[i] > k){
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b;
    cin>>a>>b;
    int i;
    for(i=1;i<=100000;i++)
    {
        int eight=int(i*0.08);
        int ten=int (i*0.1);
        if(eight==a && ten==b)
            {
                cout<<i<<endl;
                return 0;
            }
    }
    cout<<"-1"<<endl;
    return 0;
}


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

const size_t MAX_N = 1e5 + 5;

vector<int> list[MAX_N];
int N, M, cols[2];
bool color[MAX_N], used[MAX_N];

bool dfs(int v, int cl) {
    for (int& x: list[v]) if (used[x] && color[x] == cl) return false; 
    color[v] = cl;
    ++cols[cl];
    bool flag = used[v] = true;
    for (int& x: list[v]) if (!used[x] && !dfs(x, !cl)) {
        flag = false;
        break;
    }
    return flag;
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        int a,b;
        cin >> a >> b;
        a--; b--;
        list[a].emplace_back(b);
        list[b].emplace_back(a);
    }
    if (!dfs(0,0)){ 
        cout << 1LL * N * (N - 1) / 2 - M << endl;
        return 0;
    }else{
        cout << 1LL * cols[0] * cols[1] - M << endl;
        return 0;
    }
}

Measured memory_bytes: 6272
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int n,m,x;
int ans=0;
int c[12]={0};
int a[12][12]={{0}};
int ability[12]={0};
int sel[12]={0};
int tmp;

void sum(int p[])
{
  tmp=0;
  for(int j=0;j<m;j++) ability[j]=0;
  for(int i=0;i<n;i++)
  {
    if(p[i]==1)
    {
      tmp+=c[i];
      for(int j=0;j<m;j++)
      {
        ability[j]+=a[i][j];
      }
    }
  }
}

void search(int i)
{
  for(int k=0;k<=1;k++)
  {
    sel[i]=k;
    if(i==n-1)
    {
      sum(sel);
      int flag=0;
      for(int j=0;j<m;j++)
      {
        if(ability[j]<x)
        {
          flag=1;
          break;
        }
      }
      if(flag==0 && ans>tmp) ans=tmp;
    }
    else search(i+1);
  }
}

int main(void)
{
  scanf("%d %d %d",&n,&m,&x);
  for(int i=0;i<n;i++)
  {
    scanf("%d",&c[i]);
    ans+=c[i];
    for(int j=0;j<m;j++)
    {
      scanf("%d",&a[i][j]);
      ability[j]+=a[i][j];
    }
  }

  for(int j=0;j<m;j++)
  {
    if(ability[j]<x)
    {
      printf("-1\n");
      return 0;
    }
  }

  search(0);
  printf("%d\n",ans);

  return 0;
}

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

int N,M;
int tb[40];
int main (){
    cin >> N >> M;
    for(int i=0; i<N; i++) {
        int k;
        cin >> k;
        for(int j=0; j<k; j++) {
            int a;
            cin >> a;
            tb[a]++;
        }
    }
    int cnt = 0;
    for(int i=0; i<=M; i++) if( tb[i] == N ) cnt++;
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    char S[5];
    int i=0;
  
    scanf("%s",S);
    
    if(S[0]==S[1]) i++;
    if(S[0]==S[2]) i++;
    if(S[0]==S[3]) i++;
    
    if(i!=1) { printf("No\n"); return 0; }
    else i=0;
  
    if(S[1]==S[0]) i++;
    if(S[1]==S[2]) i++;
    if(S[1]==S[3]) i++;
  
    if(i!=1) { printf("No\n"); return 0; }
    else i=0;
  
    if(S[2]==S[0]) i++;
    if(S[2]==S[1]) i++;
    if(S[2]==S[3]) i++;
    
    if(i!=1) { printf("No\n"); return 0; }
    else i=0;
  
    if(S[3]==S[0]) i++;
    if(S[3]==S[1]) i++;
    if(S[3]==S[2]) i++;
    
    if(i!=1) printf("No\n");
    else printf("Yes\n");
  
    return 0;
}

Measured memory_bytes: 1628
#include <iostream>
using namespace std;
int main (void) {
    int A, B;

    cin >> A >> B;

    int ans = 0;
    for (int i = A; i <= B; i++) {
        string s = std::to_string(i);
        if (s[0] == s[4] && s[1] == s[3]) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n,m,x,y = map(int,input().split())
x_list = list(map(int,input().split()))
y_list = list(map(int,input().split()))

isWar = True
z = min(y_list)
if (x<z<=y) and (max(x_list)<z):
    isWar = False

if isWar:
    print('War')
else:
    print('No War')

Measured memory_bytes: 9188
//love yjl forever
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF=0x3f3f3f3f;
int n;
int main()
{
/*	freopen("","r",stdin);
	freopen("","w",stdout);*/
	int i;
	string s;
	cin>>s;
	cout<<s[0]<<s[1]<<s[2];
}

Measured memory_bytes: 3628
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut l: [usize; n],
    }

    if n < 3 {
        println!("{}", 0);
        return;
    }

    l.sort();

    let mut ans = 0;
    for i in 0..(n - 2) {
        for j in (i + 1)..(n - 1) {
            for k in (j + 1)..n {
                // if l[i] + l[j] > l[k] && l[i] != l[j] && l[j] != l[k] && l[k] != l[i] {
                //     ans += 1;
                // }
                if l[i] == l[j] || l[j] == l[k] || l[k] == l[i] {
                    continue;
                }
                if l[k] < l[i] + l[j] && l[i] < l[j] + l[k] && l[j] < l[k] + l[i] {
                    ans += 1;
                }
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2100
N = int(input())
ans = ''
if N == 0:
    print('0')
    exit()

while N != 0:
    if abs(N) % 2 == 0:
        ans += '0'
        N = int(N / (-2))
    else:
        ans += '1'
        N = int((N-1)/(-2))

ans = ans[::-1]
print(ans)

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2> 
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	int n;
	cin >>n;
	ll mx = -1LL<<60, mn = 1LL<<60;
	rep(i, n){
		ll a; cin >>a;
		mx = max(mx, a - mn);
		mn = min(a, mn);
		//dbg(mx,mn,a);
	}
	cout << mx <<"\n";
	return 0;
}




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

using namespace std;

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n, m;
    cin >> n >> m;
    vector <vector <int>> d(n, vector <int> (m, Inf));
    queue <pair <int, int>> q;
    for (int i = 0; i < n; ++i) {
    	for (int j = 0; j < m; ++j) {
    		char c;
    		cin >> c;
    		if (c == '#') {
    			d[i][j] = 0;
    			q.push({i, j});
    		}
    	}
    }
    while (!q.empty()) {
    	auto p = q.front();
    	int x = p.first, y = p.second;
    	q.pop();
    	for (int dx = -1; dx <= 1; ++dx) {
    		for (int dy = -1; dy <= 1; ++dy) {
    			if (abs(dx) + abs(dy) == 1 && 0 <= x + dx && x + dx < n && 0 <= y + dy && y + dy < m) {
    				if (d[x + dx][y + dy] > d[x][y] + 1) {
    					d[x + dx][y + dy] = d[x][y] + 1;
    					q.push({x + dx, y + dy});
    				}
    			}
    		}
    	}
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
    	for (int j = 0; j < m; ++j) {
    		ans = max(ans, d[i][j]);
    	}
    }
    cout << ans << '\n';
}

Measured memory_bytes: 12432
n = int(input())
l = [[int(i) for i in input().split()] for _ in range(n)]
import math
distance = 0
for i in l:
    for j in l:
        distance += ((i[0] - j[0])**2 + (i[1] - j[1])**2)**0.5*math.factorial(n-1)
        
print(distance/math.factorial(n))


Measured memory_bytes: 38256
import Control.Applicative
import Text.Printf

main :: IO ()
main = do
  xs <- words <$> getLine
  if (xs !! 1) == "?" then return ()
    else do {
    putStrLn $ solve xs;
    main
    }
         
solve :: [String] -> String
solve ss
  | ope == "+" = show (a + b)
  | ope == "-" = show (a - b)
  | ope == "*" = show (a * b)
  | ope == "/" = show (a `div` b)
  where ope = ss !! 1
        a = read (ss !! 0)
        b = read (ss !! 2)

Measured memory_bytes: 3964
#include <stdio.h>

int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};

int main()
{
	int mon,day;
	int ans;
	scanf("%d %d",&mon,&day);
	while(mon != 0 || day != 0){
		ans = 0;
		for(int i = 0; i < mon - 1; i++){
			ans += month[i];
		}
		ans += day;
		ans = ans % 7;
		if(ans == 1){
			printf("Thursday\n");
		}
		if(ans == 2){
			printf("Friday\n");
		}
		if(ans == 3){
			printf("Saturday\n");
		}
		if(ans == 4){
			printf("Sunday\n");
		}
		if(ans == 5){
			printf("Monday\n");
		}
		if(ans == 6){
			printf("Tuesday\n");
		}
		if(ans == 0){
			printf("Wednesday\n");
		}
		scanf("%d %d",&mon,&day);

	}
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    int card[4][13]={};
    for(int i=1;i<=n;i++){
        string suit;
        int num;
        cin>>suit>>num;
        if(suit=="S")card[0][num-1]=1;
        if(suit=="H")card[1][num-1]=1;
        if(suit=="C")card[2][num-1]=1;
        if(suit=="D")card[3][num-1]=1;
    }
    string str[4]={"S","H","C","D"};
    for(int i=0;i<4;i++){
        for(int j=0;j<13;j++){
            if(card[i][j]==1)continue;
            cout<<str[i]<<" "<<j+1<<endl;
        }
    }
    return 0;
}
        
    
        
        
        
        
    



Measured memory_bytes: 3168
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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; }
int main()
{
    int64_t N;
    cin >> N;
    int64_t INF = INT64_MAX;
    vector<int64_t>dp(N+1, INF);
    dp[0] = 0;
    dp[1] = 1;
    int64_t j = 1;
    vector<int64_t> six_pow_vec;
    while (pow(6, j) <= N) {
        six_pow_vec.emplace_back(pow(6, j));;
        j++;
    }

    j = 1;
    vector<int64_t> nine_pow_vec;
    while (pow(9, j) <= N) {
        nine_pow_vec.emplace_back(pow(9, j));
        j++;
    }

    for (int64_t i=2;i<=N;i++) {
        chmin(dp[i], dp[i-1] + 1);
        for (int64_t j=0; j<six_pow_vec.size(); j++) {
            if (0 > i - six_pow_vec[j]) {
                break;
            }

            chmin(dp[i], dp[i-six_pow_vec[j]] + 1);
        }

        for (int64_t j=0; j<nine_pow_vec.size(); j++) {
            if (0 > i - nine_pow_vec[j]) {
                break;
            }

            chmin(dp[i], dp[i-nine_pow_vec[j]] + 1);
        }
    }

    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 4024
N=int(input())
num=list(map(int,input().split()))
num.sort()
flag=0
for i in range(len(num)):
  if(i!=0):
    if(num[i-1]==num[i]):
      flag=1
      break
    else:
      pass
if(flag==0):
  print("YES")
else:
  print("NO")

Measured memory_bytes: 86356