akhauriyash/Code-Regression huggingface dataset:
# Verified: https://atcoder.jp/contests/atc001/submissions/16154602
class UnionFind
	Node = Struct.new(:p, :h)
	def initialize(size)
		@p, @r = size.times.to_a, [0]*size
	end
	def unite(i, j)
		k, l = parent(i), parent(j); if @r[k] < @r[l]; @p[k] = l; @r[l] += 1 if @r[k] == @r[l]; else; @p[l] = k; end
	end
	def united?(i, j)
		parent(i) == parent(j)
	end
	def parent(i)
		j = i; until i == @p[i]; j, i = i, @p[j] = @p[i]; end; i
	end
end

n, m = gets.split.map &:to_i
uf = UnionFind.new n
m.times do
	a, b = gets.split.map &:to_i
	uf.unite a-1, b-1
end

parents = [0] * n
n.times do |i|
	parents[uf.parent i] += 1
end

p parents.max

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

using namespace std;

bool isValid(int n, unordered_set<int> digits) {
	while (n > 0) {
		if (digits.find(n % 10) != digits.end()) {
			return false;
		}

		n /= 10;
	}

	return true;
}

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

	unordered_set<int> digits;

	for (int i = 0; i < k; i++) {
		int temp;
		cin >> temp;
		digits.insert(temp);
	}

	for (int i = n; i <= 100000; i++)
	{
		if (isValid(i, digits)) {
			cout << i;
			return 0;
		}
	}
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        if (sc.nextInt() + sc.nextInt() + sc.nextInt() <= 21) {
            System.out.println("win");
        }
        else {
            System.out.println("bust");
        }
    }
}


Measured memory_bytes: 22228
#include<bits/stdc++.h>
using namespace std;
#define INFTY 10000000000
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
using ipair = pair<ll,ll>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
#define rep(i,n) for (int i = 0; i < (n); ++i)
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(){

    int x,n;cin>>x>>n;
    if(n==0){
        cout<<x<<endl;
        return 0;
    }
    vector<int> p(n);
    rep(i,n){
        cin>>p[i];
    }
    rep(i,104){
        if(find(p.begin(), p.end(), x-i) == p.end()){
            cout<<x-i<<endl;
            return 0;
        }
        else if (find(p.begin(), p.end(), x+i) == p.end()){
            cout<<x+i<<endl;
            return 0;
        }
    }
    return 0;
}

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

int main(){
int k,a,b;
  cin>>k>>a>>b;
  bool x=false;
  for(int i=a;i<=b;i++){
if(i%k==0){
x=true;
break;
}
  }
if(x==true){
cout<<"OK"<<endl;
}
  else{
cout<<"NG"<<endl;
  }
}

Measured memory_bytes: 3608
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n::Int32,k::Int32=parseMap(split(readline()))
    a::Vector{Int32}=parseMap(split(readline()))
    m::Vector{Int32}=zeros(Int32,n)
    # if sum(a)==0
    #     println(join(m," "))
    #     return
    # end
    for _ in 1:k
        flag::Bool=true
        s_m::Vector{Int32}=zeros(Int,n)
        e_m::Vector{Int32}=zeros(Int,n)
        ans::Int=0
        for i in 1:n
            s_m[max(1,i-a[i])]+=1
            e_m[min(n,i+a[i])]+=1
        end
        for i in 1:n
            ans+=s_m[i]
            m[i]=ans
            if m[i]<n
                flag=false
            end
            ans-=e_m[i]
        end
        a=m
        if flag
            break
        end
    end
    println(join(m," "))
end
main()

Measured memory_bytes: 257452
<?php
fscanf(STDIN, "%d %d %d %d", $n, $m, $x, $y);
$p = max(explode(' ', trim(fgets(STDIN))));
$z = min(explode(' ', trim(fgets(STDIN))));
echo $x < $z && $z <= $y && $p < $z ? 'No War' : 'War';

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1004;
const ll mod = 1000000007;
char mat[N][N];
ll dp[N][N];
bool vis[N][N];
int n,m;


bool valid(int a,int b) {
    if(a>=0 and a < n and b >= 0 and b < m){
        if(mat[a][b] == '.')return 1;
        else return 0;
    }
    return 0;
}


ll take(int x,int y){
    if(!valid(x,y))return 0;
    return dp[x][y];
}

int main(int argc, char const *argv[])
{
    scanf("%d %d",&n,&m);
    for(int i = 0; i < n;i++){
        scanf("%s",mat[i]);
    }
    dp[0][0] = 1;
    for(int i = 0; i < n;i++){
        for(int j = 0; j < m;j++){
            if(i == j and i == 0)continue;
            dp[i][j] = (take(i-1,j)+take(i,j-1))%mod;
        }
    }
    printf("%lld\n",dp[n-1][m-1]);
    
    return 0;
}

Measured memory_bytes: 9088
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int a,b,c,d,res;
	cin >> a >> b >> c >> d;
	int ac_max = max(a,c);
	int bd_min = min(b,d);
	res = bd_min - ac_max;
	if(res < 0) res = 0;
	cout << res << endl;
	return 0;
}

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

int main(void)
{
	string str;
	int i;

	getline(cin, str);

	for (i=0; str[i]!='\0'; i++) {
		if ((str[i] >= 'A') && (str[i] <= 'Z')) {
			str[i] += ' ';
		}
		else if ((str[i] >= 'a') && (str[i] <= 'z')) {
			str[i] -= ' ';
		}
		else {
			;
		}
	}

	cout << str << endl;

	return 0;
}




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

const int MAXN = 1.1e5;
const int MAXM = 1.1e5;
int N, M;
vector<int> B[MAXM];

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    int a, b; cin >> a >> b;
    if (a <= M) B[a].push_back(b);
  }
  long long ans = 0;
  priority_queue<int> pq;
  for (int i = 0; i <= M; i++) {
    for (int b : B[i]) pq.push(b);
    if (!pq.empty()) { ans += pq.top(); pq.pop(); }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int n; cin >> n;
  vi arr(n);
  rep(i,n) cin >> arr[i];

  ll sum = arr[0];
  ll l = 0, r = 0;
  int pre = -1;
  ll ans = 0;
  bool skip = false;

  while (r < n-1) {
    if (sum & arr[r+1]) {
      if (skip) {
        sum -= arr[l];
        ++l;
        if (l == r) skip = false;
        continue;
      }

      ans += (r-l+1) * (r-l+2) / 2;
      if (l <= pre) ans -= (pre-l+1) * (pre-l+2) / 2;
      
      if (l == r) {
        ++l; ++r;
        sum = arr[l];
        continue;
      }

      skip = true;
      pre = r;
      sum -= arr[l];
      ++l;
    }

    else {
      skip = false;
      sum += arr[r+1];
      ++r;
    }
  }

  ans += (r-l+1) * (r-l+2) / 2;
  if (l <= pre) ans -= (pre-l+1) * (pre-l+2) / 2;

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


Measured memory_bytes: 1024
#include<stdio.h>
typedef struct{
  int a;
  int b;
}P;
main(){
  int i,j,k,n,m;
  P set[100];
  P tmp;
  for(i=0;;i++){
    scanf("%d,%d",&n,&m);
    if(n==0&&m==0)break;
    set[i].a=n;
    set[i].b=m;
  }
  n=i;
  for(j=0;j<n-1;j++){
    for(k=n-1;k>j;k--){
      if(set[k].b>set[k-1].b){
	tmp=set[k];
	set[k]=set[k-1];
	set[k-1]=tmp;
      }
    }
  }
      
  while(scanf("%d",&m)!=EOF){
    for(i=0,j=1;;i++,j++){
      if(i!=0){
	if(set[i].b==set[i-1].b)j--;
      }
      if(set[i].a==m){
	printf("%d\n",j);
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 600
/* 142b */
#include<stdio.h>
int main(void)
{
  int n,k,h[100000],i,f;
 scanf("%d %d",&n,&k);
 f=0;
 for(i=0;i<n;i++){
   scanf("%d",&h[i]);
   if(h[i]>=k){
     f++;
   }
 }
 printf("%d\n",f);
 return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
 
int main(){
    float x,y,a,b,c,d,e,f;
    
    while(scanf("%f %f %f %f %f %f",&a,&b,&c,&d,&e,&f)!=EOF){
        x=(b*f-c*e)/(b*d-a*e);
        y=(c*d-a*f)/(b*d-a*e);
        if(x==0)x=0;
        if(y==0)y=0;
        printf("%.3f %.3f\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;
 
int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for(int i = a; i <= b; ++i) {
        stringstream ss;
        ss<<i;
        string s;
        ss>>s;
        string r = s;
        reverse(all(r));
        if(s==r) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <functional>
#include <map>
#include <cmath>
using namespace std;

vector<int>group[100009]; long long G[100009], val[100009]; bool flag = false;

void unite(int a, int b, int c) {
	if (G[a] == G[b]) {
		if (val[b] - val[a] != c) { flag = true; }
		return;
	}
	long long SA = (val[b] - val[a]) - c; SA *= -1;
	a = G[a]; b = G[b];
	if (group[a].size() < group[b].size()) { swap(a, b); SA *= -1; }

	for (int i = 0; i < group[b].size(); i++) {
		int to = group[b][i];
		G[to] = a; val[to] += SA; group[a].push_back(to);
	}
	group[b].clear();
}

long long n, m, l, r, x;

int main() {
	cin >> n >> m;
	for (int i = 0; i <= n; i++) { G[i] = i; group[i].push_back(i); }
	for (int i = 0; i < m; i++) {
		cin >> l >> r >> x;
		unite(l, r, x);
	}
	if (flag == true) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 11004
# by the authority of GOD   author: manhar singh sachdev #

import os,sys
from io import BytesIO, IOBase
from collections import defaultdict,deque

def main():
    n,m = map(int,input().split())
    path = defaultdict(set)
    se = set(range(1,n+1))
    for _ in range(m):
        a,b = map(int,input().split())
        path[a].add(b)
        path[b].add(a)
    lst = []
    while len(se):
        ans = 0
        x = se.pop()
        curr = deque([x])
        while len(curr):
            y = curr.popleft()
            ans += 1
            while len(path[y]):
                i = path[y].pop()
                if i in se:
                    curr.append(i)
                    se.remove(i)
                path[i].remove(y)
        lst.append(ans)
    lst.sort()
    fin = 0
    a = 0
    for i in lst:
        fin += max(0,i-a)
        a += (i-a)
    print(fin)

#Fast IO Region
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == '__main__':
    main()

Measured memory_bytes: 175372
n,k=map(int,input().split())

ans1=0

if n>=k:
	ans1=(n-k+1)/n
	
	ans2=0
	ans=0
	for i in range(k-1):
		j=1
		while (i+1)*2**j<k:
			j=j+1
	
		ans2=(1/2)**j
		#print(j)
		#print(ans2)
		ans=ans+ans2

	ans=ans1+1/n*ans

if n<k:
	ans2=0
	ans=0
	for i in range(n):
		j=1
		while (i+1)*2**j<k:
			j=j+1
	
		ans2=(1/2)**j
		#print(j)
		#print(ans2)
		ans=ans+ans2

	ans=+1/n*ans
	
print(ans)

Measured memory_bytes: 38768
N, A, B = map(int, input().split())
diff = B - A

if N == 1:
    if diff != 0:
        print(0)
    else:
        print(1)
else:
    if diff < 0:
        print(0)
    elif diff == 0:
        print(1)
    else:
        max_val = B * (N-1) + A
        min_val = A * (N-1) + B
        print(max_val - min_val + 1)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    string a;
    cin>>a;
    int l,r;
    for(int i=0;i<a.size();i++)
    {
        if(a[i]=='A')
        {
            l=i;
            break;
        }       
    } 
    for(int i=a.size()-1;i>=0;i--)
    {
        if(a[i]=='Z')
        {
            r=i;
            break;
        }
    }
    cout<<r-l+1<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int n,m,s1,s2,i,j;
int main()
{
cin>>n>>m;
 for(i=n-1,j=m-1;i>=1||j>=1;i--,j--)
 {
   if(i>=1)s1+=i;
   if(j>=1)s2+=j;
 }
  cout<<s1+s2<<endl;
}

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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 k;
    cin >> k;
    vector<i64> a(k);
    for (auto& e : a) cin >> e;
    reverse(all(a));

    i64 nmin = 2, nmax = 2;
    for (auto& e : a) {
        nmin = (nmin + e - 1) / e * e, nmax = nmax / e * e + e - 1;
        if (nmin > nmax) {
            cout << -1 << endl;
            return;
        }
    }

    cout << nmin << " " << nmax << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 1024
def dfs(c, l, d):
    if c == r:
        if ans[0] > d: ans[0] = d
        return
    for i in range(r):
        if seen[i]: continue
        seen[i] = True
        if l == -1:
            dfs(c + 1, R[i], 0)
        else:
            dfs(c + 1, R[i], d + dp[l][R[i]])
        seen[i] = False

n, m, r = map(int, input().split())
R = [i - 1 for i in map(int, input().split())]
dp = [[float("Inf") if i != j else 0 for i in range(n)] for j in range(n)]
for i in range(m):
    x, y, z = map(int, input().split())
    dp[x - 1][y - 1] = z
    dp[y - 1][x - 1] = z
for k in range(n):
    for j in range(n):
        for i in range(n):
            if dp[i][j] > dp[i][k] + dp[k][j]:
                dp[i][j] = dp[i][k] + dp[k][j]
seen = [False] * r
ans = [float("Inf")]
dfs(0, -1, 0)
print(*ans)

Measured memory_bytes: 57048
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
 
    UnionFind(int n = 1) {
        init(n);
    }
 
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }
 
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
 
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
 
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

    
  
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  COMinit();
  
  ll n,a,b;
  cin >> n >> a >> b;
  cout << max(0ll,-b-(n-1)*a+a+(n-1)*b+1) << endl;
}


Measured memory_bytes: 12160
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef vector<pii>vip;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _
        int n; cin >> n;
        int k; cin >> k;
        vi a(n);
        rep(i,n)cin >> a[i];
        sort(all(a));
        ll su = 0;
        rep(i,k)su+=a[i];
        cout<<su<<endl;

return 0;
}




Measured memory_bytes: 3656
#include<iostream>
using namespace std;
#define S 100
#define INF 2001
#define WHITE 0;
#define GRAY 1;
#define BLACK 2
int n,a[S][S];

int prim(){
    int u,mina;
    int d[S],p[S],cnd[S];

    for(int i=0;i<n;i++){
        d[i]=INF;
        p[i]=-1;
        cnd[i]=WHITE;
    }

    d[0]=0;
    while(1){
        mina=INF;
        u=-1;
        for(int i=0;i<n;i++){
            if(mina>d[i]&&cnd[i]!=BLACK){
                u=i;
                mina=d[i];
            }
        }
        if(u==-1)break;
        cnd[u]=BLACK;
        for(int v=0;v<n;v++){
            if(cnd[v]!=BLACK&&a[u][v]!=INF){
                if(d[v]>a[u][v]){
                    d[v]=a[u][v];
                    p[v]=u;
                    cnd[v]=GRAY;
                }
            }
        }
    }
            int sum=0;
        for(int i=0;i<n;i++){
            if(p[i]!=-1)sum+=a[i][p[i]];
        }
    return sum;
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int e;
            cin>>e;
            if(e==-1)a[i][j]=INF;
            else a[i][j]=e;
        }
    }
    cout<<prim()<<endl;
    return 0;

}


Measured memory_bytes: 3124
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

struct Town {
    int p, y, i;
};
bool cmp1(const Town &a, const Town &b) {
    if (a.p == b.p) return (a.y < b.y);
    else return (a.p < b.p);
}
bool cmp2(const Town &a, const Town &b) {
    return (a.i < b.i);
}
int main() {
    int n, m, p, y;
    vector<Town> towns;

    scanf("%d%d", &n, &m);

    for (int i = 0; i < m; i++) {
        scanf("%d%d", &p, &y);
        towns.push_back((Town){p,y,i});
    }


    sort(towns.begin(), towns.end(), cmp1);

    int p_cur = 0;
    int x = 1;
    for (int i = 0; i < m; i++) {
        if (towns[i].p == p_cur) {
            x++;
        } else {
            x = 1;
            p_cur = towns[i].p;
        }
        towns[i].y = x;
    }

    sort(towns.begin(), towns.end(), cmp2);
    for (int i = 0; i < m; i++) {
        printf("%06d%06d\n", towns[i].p, towns[i].y);
    }
    return 0;
}


Measured memory_bytes: 2804
#include<stdio.h>
int main() {
	int N, K, ans, i,a;
	ans = 0;
	a = 0;
	int A[100000];
	//printf("aaa");
	scanf("%d %d", &N, &K);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	do{
		if (a == 0) {
			N = N - K;
			ans++;
			a++;
		}else{
			N = N - (K - 1);
			ans++;
		}
	} while (N >= 1);
	printf("%d\n", ans);

}

Measured memory_bytes: 512
var
  n,a,t,c,i,x:longint;
  h:array[1..1000]of real;
  min:real;
begin
  readln(n,t,a);
  for i:=1 to n do 
  begin 
    read(c);
	h[i]:=abs(a-(t-0.006*c));
  end;
  min:=h[1];x:=1;
  for i:=2 to n do
	if h[i]<min then begin min:=h[i];x:=i;end;
  writeln(x);
  readln(i);
end.

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<queue>
using namespace std;

vector< vector<int> > ch(vector< vector<int> > a, int x, int y){
  for(int i=0; i<a.size(); i++){
    for(int j=0; j<a[i].size(); j++){
      if( a[i][j] == x ) a[i][j] = y;
    }
  }
  return a;
}
bool cl(int l, int r){ return l > r;}
int main(void) {

  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  for(int i=0; i<h; i++) cin >> a[i];
  bool f = true;

  vector<int> alp(26, 0);
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      alp[ a[i][j]-'a' ]++;
    }
  }
  priority_queue<int> pq;
  for(int i=0; i<26; i++){
    if( alp[i] != 0 ) pq.push(alp[i]);
    if( alp[i] != 0 ) cerr << alp[i] << endl;
  }

  vector< vector<int> > b(h, vector<int> (w, -1));
  int cnt = 1;
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if( b[i][j] == -1 ){
        b[i][j] = cnt;
        if( b[i][w-j-1] == -1 ) b[i][w-j-1] = cnt;
        else b = ch(b, max(cnt, b[i][w-j-1]), min(cnt, b[i][w-j-1]));
        if( b[h-i-1][j] == -1 ) b[h-i-1][j] = cnt;
        else b = ch(b, max(cnt, b[h-i-1][j]), min(cnt, b[h-i-1][j]));;
        cnt++;
      }
    }
  }

  vector<int> x(10001, 0);
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      x[ b[i][j] ]++;
    }
  }
  vector<int> y;
  for(int i=1; i<x.size(); i++){
    if( x[i] != 0 ) y.push_back(x[i]);
  }

  sort(y.begin(), y.end(), cl);

  cerr << endl;
  for(int i=0; i<y.size(); i++) cerr << y[i] << endl;

  int pos = 0;
  int lp = 0;
  while( !pq.empty() ){
    int tmp = pq.top();
    pq.pop();
    if( tmp >= y[pos] ){
      tmp -= y[pos];
      pos++;
      if( tmp != 0 ) pq.push(tmp);
    }else{
      pq.push(tmp);
    }
    lp++;
    if( lp > 10000 ){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;


  return 0;
}







// EOF


Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int a, b, c, tmp;
  scanf("%d %d %d", &a, &b, &c);
  if(b<a){
    tmp=a;
    a=b;
    b=tmp;
  }
 
   
  if(c<b){
    tmp=b;
    b=c;
    c=tmp;
 
  }
if(b<a){
    tmp=a;
    a=b;
    b=tmp;
  }
    
  printf("%d %d %d\n", a, b, c);
 
 
 
  return 0;
}
 

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define mp make_pair
#define pb push_back
#define EB emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr double eps = 1e-14; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int N;
string s;
vector<char> ans;

bool solve(char zero,char one,char last){
    ans.assign(N,'-');
    ans[0] = zero;
    ans[1] = one;
    for(int i=1;i<N-1;i++){
        char tc = s[i];
        if(ans[i]=='W'){
            if(s[i]=='o') tc = 'x';
            else tc = 'o';
        }

        if(tc=='o'){
            ans[i+1] = ans[i-1];
        }else{
            if(ans[i-1]=='W'){
                ans[i+1] = 'S';
            }else{
                ans[i+1] = 'W';
            }
        }
    }
    //cout << zero << " " << one << " " << last << " " << (ans[N-1] == last) << endl;
    if(ans[N-1]!=last) return false;

    if(ans[N-1]=='S'){
        if(s[N-1]=='o' and ans[0]!=ans[N-2]) return false;
        if(s[N-1]=='x' and ans[0]==ans[N-2]) return false;
    }else{
        if(s[N-1]=='x' and ans[0]!=ans[N-2]) return false;
        if(s[N-1]=='o' and ans[0]==ans[N-2]) return false;
    }
    return true;
}

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

    if(s[0] == 'o'){
        if(solve('S','S','S') or solve('S','W','W') or solve('W','S','W') or solve('W','W','S')){
            rep(i,N) cout << ans[i];
            cout << endl;
            return 0;
        }
    }else{
        if(solve('S','S','W') or solve('S','W','S') or solve('W','W','W') or solve('W','S','S')){
            rep(i,N) cout << ans[i];
            cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
  int a;cin >> a;
  if(a==10 || a==100 || a==1000 || a==10000 ||a==100000) cout << 10 << endl;
  else{
    int ans = 0;
    while(a){
      ans += a%10;a /= 10;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		//文字列を入力
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str=br.readLine();
		//文字列をカウント
		int n=str.length();
		//繰り返し
		for(int i=0;i<n;i++) {
			//strからi個目の文字を切り出す
			char a;
			a=str.charAt(i);
			//それぞれをif文にかけ、n文字目が大文字か小文字かを判断
			if(Character.isUpperCase(a)) {
				String c=String.valueOf(a);
				c=c.toLowerCase();
				System.out.print(c);
			}else {
				String c=String.valueOf(a);
				c=c.toUpperCase();
				System.out.print(c);
			}
		}
		System.out.println();
	}

}



Measured memory_bytes: 25232
import java.util.Arrays

const val MOD: Long = (1e9+7).toLong()

fun main(args: Array<String>) {
    val (n, a) = readLine()!!.split(" ").map{it.toInt()}
    val x = readLine()!!.split(" ").map{it.toInt()}
    val max = 50*n

    val dp = Array(n+1, {Array(n+1, {Array(max+1, {0L})})})
    dp[0][0][0] = 1L
    for (i in 1..n) {
        for (j in 0..n) {
            for (k in 0..max) {
                if ((k < x[i-1]) or (j == 0)) {
                    dp[i][j][k] += dp[i-1][j][k]
                } else {
                    dp[i][j][k] += dp[i-1][j][k] + dp[i-1][j-1][k-x[i-1]]
                }
            }
        }
    }

    var res = 0L
    for (j in 1..n) {
        res += dp[n][j][a*j]
    }
    println(res)
}


Measured memory_bytes: 92252
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scan =new Scanner(System.in);
        int h,w;
        while(true){
            h=scan.nextInt();
            w=scan.nextInt();
            if(h==0 && w==0)break;
            int a=0;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(a==0){
                        System.out.printf("#");
                        a=1;
                    }else if(a==1){
                        System.out.printf(".");
                        a=0;
                    }
                }
                if(w%2==0){
                    if(a==1)a=0;
                else a=1;
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
    }
}


Measured memory_bytes: 64156
#include <stdio.h>

int main(void){
	int N;
	int P[20];
	int i;
	int count;

	scanf("%d",&N);
	for(i=0; i<N; i++){
		scanf("%d",&P[i]);
	}

	count = 0;
	for(i=1; i+1<N; i++){
		if((P[i]<P[i-1] && P[i]>P[i+1]) || (P[i]>P[i-1] && P[i]<P[i+1])){
			count++;
		}
	}

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

Measured memory_bytes: 128
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNextDouble()){
			double x = sc.nextDouble();
			double t = x / 9.8;
			double y = 4.9 * Math.pow(t, 2);
			int N = 0;
			while(5 * N -5 < y){
				N++;
			}
			System.out.println(N);
		}
	}
}

Measured memory_bytes: 18864
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		try (Scanner sc = new Scanner(System.in);) {

			String n = sc.next();
			String l = sc.next();

			List<String> list = new ArrayList<>();
			Matcher m = Pattern.compile("[\\s\\S]{1," + l + "}").matcher(n);
			while (m.find()) {
				list.add(m.group());
			}

			StringBuilder sb = new StringBuilder();
			for (String st : list) {
				sb.append(String.valueOf(st.charAt(0)));
			}

			System.out.println(sb.toString());
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

int main() {
  int n;
  cin >> n;
  double x, sum = 0, btc = 380000.0;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> x >> s;
    if (s == "JPY") {
      sum += x;
    } else {
      sum += btc * x;
    }
  }
  cout << setprecision(8) << sum << endl;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
a = []
for _ in range(h):
    l = input()
    if l != '.'*w:
        a.append(l)
col = []
h = len(a)
for i in range(w):
    if a[0][i] == '.':
        for j in range(1,h):
            if a[j][i] != '.':
                col.append(i)
                break
    else:
        col.append(i)
for l in a:
    ll = ''
    for i in col:
        ll += l[i]
    print(ll)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

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

  sort(A, A + N, greater<int>());

  long long comfortability = A[0];
  int wait = 1;
  
  for (int j = 1; j < N; j++) { // temp N / 2
    if (N - j - 1 >= wait + 1) { // 2 inputs will be connected
      comfortability += 2 * A[j];
    } else if (N - j - 1 >= wait) { // 1 input will be connected
      comfortability += A[j];
    } else {
      break;
      // else no input will connect - subsequent inputs add no value
    }
    wait++;
  }

  cout << comfortability << endl;

}

Measured memory_bytes: 4428
#include<stdio.h>
#include<algorithm>
using namespace std;
int d[400];
int p[800];
int q[800];
int r[800];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		scanf("%d%d%d",p+i,q+i,r+i);
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++)
			d[q[j]]=max(d[q[j]],d[p[j]]+r[j]);
	}
	printf("%d\n",d[a-1]);
}

Measured memory_bytes: 1040
s=str(input())
while len(s)>=1:
    if s[-5:]=="erase":
        s=s[:-5]
    elif s[-5:]=="dream":
        s=s[:-5]
    elif s[-6:]=="eraser":
        s=s[:-6]
    elif s[-7:]=="dreamer":
        s=s[:-7]
    else:
        break

print("YNEOS"[len(s)>0::2])


Measured memory_bytes: 3188
def solve(string):
    n, m, *ab = map(int, string.split())
    ab = sorted([(a, b) for a, b in zip(ab[::2], ab[1::2])])
    ans = 0
    for a, b in ab:
        if m <= b:
            ans += a * m
            break
        ans += a * b
        m -= b
    return str(ans)


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 26748
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


string buf,line,pattern;
vector<int> LOC[128];


bool check(int start,int end){

	bool FLG;

	int left,right,m,tmp_start,tmp_end;

	for(int i = 0; i < pattern.length(); i++){
		int ch = pattern[i];

		left = 0,right = LOC[ch].size()-1,m = (left+right)/2;
		tmp_start = BIG_NUM;

		while(left <= right){
			if(LOC[ch][m] >= start){
				tmp_start = m;
				right = m-1;
			}else{
				left = m+1;
			}
			m = (left+right)/2;
		}
		if(tmp_start == BIG_NUM)return false;

		left = tmp_start,right = LOC[ch].size()-1,m = (left+right)/2;
		tmp_end = BIG_NUM;

		while(left <= right){
			if(LOC[ch][m] <= end){
				tmp_end = m;
				left = m+1;
			}else{
				right = m-1;
			}
			m = (left+right)/2;
		}
		if(tmp_end == BIG_NUM)return false;
	}
	return true;
}

void func(){

	for(int i = 0; i < 128; i++)LOC[i].clear();

	line += buf;
	while(true){
		getline(cin,buf);
		if(buf == "")break;
		line += buf;
	}
	getline(cin,pattern);
	getline(cin,buf);

	for(int i = 0; i < line.length(); i++){
		LOC[line[i]].push_back(i);
	}

	for(int i = 0; i < pattern.length(); i++){
		if(LOC[pattern[i]].size() == 0){
			printf("0\n\n");
			return;
		}
	}

	bool FLG;
	int left,right,m,minimum = BIG_NUM,ans_count = 1,tmp_end;
	int ans_start,ans_end;

	for(int start = 0; start < line.length(); start++){

		left = start,right = line.length()-1,m = (left+right)/2;
		tmp_end = BIG_NUM;

		while(left <= right){
			if(check(start,m)){
				tmp_end = m;
				right = m-1;
			}else{
				left = m+1;
			}
			m = (left+right)/2;
		}
		if(tmp_end == BIG_NUM)continue;

		if(tmp_end-start+1 < minimum){

			minimum = tmp_end-start+1;
			ans_count = 1;
			ans_start = start;
			ans_end = tmp_end;

		}else if(tmp_end-start+1 == minimum){
			ans_count++;
		}
	}

	printf("%d\n\n",ans_count);
	for(int i = ans_start; i <= ans_end; i += 72){
		for(int k = i; k <= min(ans_end,i+71); k++){
			printf("%c",line[k]);
		}
		printf("\n");
	}
	printf("\n");

	line.clear();
	pattern.clear();
}


int main(){

	while(true){
		getline(cin,buf);
		if(buf == "")break;

		func();
	}

	return 0;
}



Measured memory_bytes: 6068
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	class Edge {
		int to, dis, cost;
		Edge(int to, int dis, int cost) {
			this.to = to;
			this.dis = dis;
			this.cost = cost;
		}
	}
	
	class Pair implements Comparable<Pair>{
		int index;
		int distance;
		int cost;
		Pair(int i, int d, int c) {
			this.index = i;
			this.distance = d;
			this.cost = c;
		}
		@Override
		public int compareTo(Pair o) {
			return (distance != o.distance) ? distance - o.distance : cost - o.cost;
		}
	}
	
	final int INF = Integer.MAX_VALUE/2;
	List<Edge>[] list;
	int[] d;
	
	int res;
	
	void dijkstra(int s) {
		res = 0;
		int n = list.length;
		d = new int[n];
		boolean[] used = new boolean[n];
		Arrays.fill(d, INF);
		d[s] = 0;
		
		PriorityQueue<Pair> queue = new PriorityQueue<Pair>();
		queue.add(new Pair(s, 0, 0));
		
		while (!queue.isEmpty()) {
			Pair p = queue.poll();
			int v = p.index, c = p.cost;
			if (used[v]) continue;
			used[v] = true;
			res += c;
			for (Edge e : list[v]) {
				if (d[v]+e.dis <= d[e.to]) {
					d[e.to] = d[v] + e.dis;
					queue.add(new Pair(e.to, d[e.to], e.cost));
				}
			}
		}
	}
	
	void addEdge(int u, int v, int d, int c) {
		list[u].add(new Edge(v, d, c));
		list[v].add(new Edge(u, d, c));
	}
	
	@SuppressWarnings("unchecked")
	void run() {
		while (true) {
			int n = sc.nextInt(), m = sc.nextInt();
			if (n == 0 && m == 0) break;
			list = new ArrayList[n];
			for (int i = 0; i < n; i++)
				list[i] = new ArrayList<Edge>();
			
			for (int i = 0; i < m; i++) {
				addEdge(sc.nextInt()-1, sc.nextInt()-1, sc.nextInt(), sc.nextInt());
			}
			dijkstra(0);
			out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

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

int main() {
  int n;
  cin >> n;
  vector<int> hs(n);
  for (int& h : hs)
    cin >> h;

  int ret = 0;
  int current = -1;
  int count = 0;
  for (int h : hs) {
    if (h > current) {
      count = 0;
    } else {
      ret = max(ret, ++count);
    }
    current = h;
  }
  cout << ret << "\n";
  return 0;
}


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

mod = 10**9+7
n = int(input())
a = list(map(int, input().split()))
s = 0
ss = 0
for ai in a:
    s += ai
    ss += ai*ai
    s %=mod
    ss %=mod

x = pow(2,mod-2,mod)
ret = (s*s-ss)%mod
ret = ret*x
ret %=mod

print(ret)


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	ll n;cin >> n;
	vector<ll> a(n);REP(i, n)cin >> a[i];
	vector<ll> b(n);REP(i, n)cin >> b[i];

	priority_queue<P> pq;
	REP(i, n)if(b[i] > a[i])pq.push(MP(b[i], i));
	ll ans = 0;

	while(!pq.empty()){
		auto now = pq.top();pq.pop();
		ll id = now.SE;
		ll num = now.FI - a[id];
		ll mai = b[(id+1)%n] + b[(id+n-1)%n];
		ans += num / mai;
		num %= mai;
		if(b[id] == a[id] + num){
			cout << -1 << endl;
			return 0;
		}
		b[id] = a[id] + num;
		if(num != 0){
			pq.push(MP(a[id]+num, id));
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 9584
#include <stdio.h>
#include <math.h>
int main(){
  int n,i,j,x,count=0;
  scanf("%d", &n);
  int A[n], B[n];
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    B[i]=0;
  }
  for(i=0;i<n;i++){
    if(A[i]==2)continue;
    if(A[i]<1 || A[i]%2==0)B[i]=1;
    for(j=3;j<=sqrt(A[i]);j+=2)if(A[i]%j==0)B[i]=1;
  }
  for(i=0;i<n;i++){
    if(B[i]==0)count++;
  }
  printf("%d", count);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2072
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

int main(void)
{
  int a[4];
  for(int i=0;i<3;i++)cin>>a[i];
  sort(a,a+3);
  cout<<(a[2]-a[1])+(a[1]-a[0])<<endl; 
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define MAX_N 2000000
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int> vec(MAX_N+10);
	vector<int> A(MAX_N+10, 0);
	int idx = 0;
	rep(i, n)
	{
		cin >> vec[i];
		A[vec[i]]++;
	}
	for(int i=1; i<10000; i++)
	{
		A[i] += A[i-1];
		if(A[i] > idx) idx = A[i];
	}
	//rep(i,15) cout << A[i] << " ";
	//cout << endl;
	vector<int> B(idx+1, 0);
	for(int i=0; i<=idx; i++)
	{
		B[A[vec[i]]] = vec[i];
		A[vec[i]]--;
	}
	for(int i=1; i<=idx; i++)	
	{
		if(i == 1) cout << B[i];
		else cout << " " << B[i];
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 26328
n = int(input())

testimonies = []
for i in range(n):
    a = int(input())
    t = []
    for j in range(a):
        x, y = map(int, input().split())
        t.append((x, y))
    testimonies.append(t)

MAX = 0
for i in range(2 ** n):
    for index, t in enumerate(testimonies):
        if (i >> index) & 1:
            contradict = False
            for x, y in t:
                if (i >> (x - 1)) % 2 == y:
                    continue
                else:
                    contradict = True
                    break
            if contradict:
                break
    else:
        honest = 0
        while i:
            i = i & (i - 1)
            honest += 1
        MAX = max(MAX, honest)
print(MAX)

Measured memory_bytes: 42864
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

int main(){    
  string S,T,U;
  cin >> S >> T;
  int a,b;
  cin >> a >> b;
  cin >>U;
  
  if(S==U){
    a--;
  }else{
    b--;
  }
  
  cout << a << " " << b << endl;
  
}

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

using namespace std;

using ll = long long;
using ld = long double;

#define st first
#define nd second

const int MAXN = 1e6 + 5, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18, MOD = 1e15 + 37;
const ld PI = acos(-1);

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << setprecision(13) << fixed;

    //////////////////////////////////////////
    //////////////////////////////////////////

    int n;
    cin >> n;
    int sum = 0, sum_squares = 0;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        sum = (sum + a) % mod;
        sum_squares = (0LL + sum_squares + 1LL * a * a) % mod;
    }

    int square_sum = 1LL * sum * sum % mod;
    int double_res = ((square_sum - sum_squares) % mod + mod) % mod;
    cout << 500000004LL * double_res % mod << "\n";
}


Measured memory_bytes: 3652
#include <iostream>
#include <string>
using namespace std;
#define N 2020
string s[N];
int L[N][N];
int R[N][N];
int U[N][N];
int D[N][N];
int h, w;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> h >> w;
    for (int i = 0; i < h; i++)
    {
        cin >> s[i];
    }
    for (int i = 0; i < h; i++)
    {
        int cur = 0;
        for (int j = 0; j < w; j++)
        {
            if (s[i][j] == '#')
                cur = 0;
            else
                cur++;
            L[i][j] = cur;
        }
    }
    for (int i = 0; i < h; i++)
    {
        int cur = 0;
        for (int j = w - 1; j >= 0; j--)
        {
            if (s[i][j] == '#')
                cur = 0;
            else
                cur++;
            R[i][j] = cur;
        }
    }
    for (int j = 0; j < w; j++)
    {
        int cur = 0;
        for (int i = 0; i < h; i++)
        {
            if (s[i][j] == '#')
                cur = 0;
            else
                cur++;
            U[i][j] = cur;
        }
    }
    for (int j = 0; j < w; j++)
    {
        int cur = 0;
        for (int i = h - 1; i >= 0; i--)
        {
            if (s[i][j] == '#')
                cur = 0;
            else
                cur++;
            D[i][j] = cur;
        }
    }

    int ans = 0;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (s[i][j] == '.')
                ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3);
        }
    }
    cout << ans << endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 68096
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>


int main(){
  int n;
  scanf("%d",&n);
  if(n<1000){
    printf("ABC");
  }else{
    printf("ABD");
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        int max = 1;

        for(int i=n; i<40000; i++) {
            if(m % i == 0) {
                max = Math.max(max, m / i);
                break;
            }
        }

        for(int i=n-1; i>1; i--) {
            if(m % i == 0) {
                if(m / i >= n) {
                    max = Math.max(max, i);
                    break;
                }
            }
        }

        System.out.println(max);
    }

}


Measured memory_bytes: 23380
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#include <sstream>
#include <iterator>
#include <sstream>
#include <iomanip>
#include <istream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main()
{
    string ans;
    string a, b, c;
    cin >> a >> b >> c;
    ans = a[0];
    ans += b[0];
    ans += c[0];
    transform(ans.begin(),ans.end(),ans.begin(),::toupper);

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision


#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

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



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

	string s; cin >> s;
	int n = s.size();
	bool a = true;
	rep(i,n) a = a && s[i] == s[n-i-1];
	rep(i,n/2) {
	  a = a && s[i] == s[n/2 - i -1];
		a = a && s[i+(n+1)/2] == s[n/2 - i - 1 + (n+1) / 2];
	}
	if (a) cout << "Yes" << endl;
	else cout << "No" << endl;
} 


Measured memory_bytes: 256
from fractions import gcd
from functools import reduce


def lcm(x, y):
    return x // gcd(x, y) * y


def lcm_list(L):
    return reduce(lcm, L)


N = int(input())
T = [int(input()) for _ in range(N)]
ans = lcm_list(T)
print(ans)


Measured memory_bytes: 5076