akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> A;
    A.resize(N);
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
    }
    int Q;
    cin >> Q;
    vector<int> B, C;
    B.resize(Q);
    C.resize(Q);
    for (int i = 0; i < Q; i++)
    {
        cin >> B[i] >> C[i];
    }
    
    vector<long long> cnt;
    cnt.resize(100010);
    fill(cnt.begin(), cnt.end(), 0);
    for (int n : A)
    {
        cnt[n]++;
    }

    for (int i = 0; i < Q; i++)
    {
        sum = sum + (C[i] - B[i]) * cnt[B[i]];
        cnt[C[i]] += cnt[B[i]];
        cnt[B[i]] = 0;
        cout << sum << endl;
    }
    
    return 0;
}

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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

const int INF = 1e9;


int main(){
    ll N;
    cin >> N;
    ll m=0, a=0, r=0, c=0, h=0;
    string S;
    
    REP(i,N){
        cin >> S;
        if(S[0]=='M') m++;
        if(S[0]=='A') a++;
        if(S[0]=='R') r++;
        if(S[0]=='C') c++;
        if(S[0]=='H') h++;
    }
    
    ll D[5] = {m,a,r,c,h};
    int C_1 [10]= {0,0,0,0,0,0,1,1,1,2};
    int C_2 [10]= {1,1,1,2,2,3,2,2,3,3};
    int C_3 [10]= {2,3,4,3,4,4,3,4,4,4};
    
    ll ans=0;
    REP(i,10){
        ans += D[C_1[i]]*D[C_2[i]]*D[C_3[i]];
    }
    cout << ans << endl;
}


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


int divideNum(int n) {
    int counter = 0;
    while (n > 0) {
        n /= 2;
        counter++;
    }
    return counter;
}


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

    int ans = 0;
    int num = 0;

    rep(i, N+1) {
        int divide_num = divideNum(i);
        if (divide_num > num) {
            ans = i;
            num = divide_num;
        }
    }

    cout << ans << endl;
}


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

int main(){
  int a[3];
  int min=1000;
  int max=0;
  for(int i=0;i<3;i++){
    cin >> a[i];
    if(min>a[i])
      min=a[i];
    if(max<a[i])
      max=a[i];
  }
  cout << max-min << endl;
  return 0;
}


Measured memory_bytes: 256
A,B,C = gets.chomp.split.map(&:to_i)
a,b,c = A,B,C
cnt = 0

if a%2==b%2
	if b%2!=c%2
		a+=1
		b+=1
		cnt+=1
	end
else
	if a%2==c%2
		a+=1
		c+=1
		cnt+=1
	else
		b+=1
		c+=1
		cnt+=1
	end
end
cnt+=[([a,b,c].max-a)/2,0].max
cnt+=[([a,b,c].max-b)/2,0].max
cnt+=[([a,b,c].max-c)/2,0].max
p cnt

Measured memory_bytes: 1788
n, m = map(int, input().split())
v = [0 for i in range(n+1)]
path = [0 for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    if v[b] < a:
        v[b] = a

last = 0

for i in range(n+1):
    if v[i] == 0:
        continue
    m = v[i]

    if last < m:
        path[i - 1] = 1
        last = i - 1


s = 0
for p in path:
    s += p
print(s)

Measured memory_bytes: 6820
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

const int N = 2e5 + 5;

int n;
int arr[N];

int main()
{
  cin >> n;
  for(int i = 0 ; i < n ; i++)
    cin >> arr[i];
  unordered_map<int, int> cnt;
  long long ans = 0;
  for(int i = 0 ; i < n ; i++) {
    int v = i - arr[i];
    ans += cnt[v];
    cnt[i + arr[i]]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 19332
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#define rep(i,a) for( int i = 0; i != (a); ++i )
#define repi(i,a,b) for( int i = (a); i != (b); ++i )
#define all(a) (a).begin(), (a).end()

typedef std::pair<int, int> P;	
const int INF = 1 << 30;

int n, m;
int cost[100][100];
bool used[100];

void dijkstra( std::vector<int> &d, int s )
{
	std::fill( all(d), INF );
	std::fill( used, used+n, false );

	d[s] = 0;

	for( ;; )
	{
		int v = -1;
		rep( u, n )
			if( !used[u] && (v == -1 || d[u] < d[v] ) )
				v = u;

		if( v == -1 )
			break;

		used[v] = true;

		rep( u, n )
			d[u] = std::min( d[u], d[v]+cost[v][u] );
	}
	
	return;
}

int main()
{
	while( scanf( "%d%d", &n, &m ), n|m )
	{
		rep( i, n )
			rep( j, n )
				cost[i][j] = i==j?0:INF;

		rep( i, m )
		{
			int a, b, c;
			scanf( "%d%d%d", &a, &b, &c );
			--a; --b;

			cost[a][b] = cost[b][a] = c;
		}

		std::vector<int> d( n ), rd( n );
		dijkstra( d, 0 );
		dijkstra( rd, n-1 );

		int ans = d[n-1];

		rep( i, n )
		{
			rep( j, n )
			{
				if( i == j )
					continue;

				bool fl = false;
				rep( k, n )
					if( i != k && j != k && cost[i][k] != INF && cost[k][j] != INF )
						fl = true;

				if( !fl )
					continue;

				ans = std::min( ans, d[i]+rd[j] );
			}
		}

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

	return 0;
}

Measured memory_bytes: 1068
K = int(input())

list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

ans = list[K - 1]

print(ans)

Measured memory_bytes: 2940
import Control.Monad
import Data.List

main = do
  [n,c] <- fmap (map read . words) getLine
  text <- getContents
  let xs = map ((\(x:v:_)-> x`seq`v`seq`(x,v)) . map read . words) (lines text)
  print (solve c xs)


-- MaxState, CurrentState, CurrentX
type State = (Int, (Int, Int))

solve :: Int -> [(Int,Int)] -> Int
solve c xs =
  solveTurn roundR roundL
  where
    roundR = scanl f (0,(0,0)) xs
    roundL = scanr (flip f) (0,(0,0)) [(c-x,v)|(x,v)<-xs]

    f (m,(s,y)) (x,v) = let s' = s-(x-y)+v in (max m s', (s', x))

solveTurn :: [State] -> [State] -> Int
solveTurn ss1 ss2 =
  foldl' f 0 (zip ss1 ss2)
  where
    f a (((m1,(s1,x1))),((m2,(s2,x2)))) = max a $! max (s1+m2-x1) $! (s2+m1-x2)


Measured memory_bytes: 61820
#include<bits/stdc++.h>
using namespace std ;
#define Next( i, x ) for( register int i = head[x]; i; i = e[i].next )
#define rep( i, s, t ) for( register int i = (s); i <= (t); ++ i )
#define drep( i, s, t ) for( register int i = (t); i >= (s); -- i )
#define re register
#define int long long
int gi() {
	char cc = getchar() ; int cn = 0, flus = 1 ;
	while( cc < '0' || cc > '9' ) {  if( cc == '-' ) flus = - flus ; cc = getchar() ; }
	while( cc >= '0' && cc <= '9' )  cn = cn * 10 + cc - '0', cc = getchar() ;
	return cn * flus ;
}
int n ; 
const int P = 1e9 + 7 ;
map<int, int> f ; 
int F(int x) {
	if(x == 0) return 1 ;
	if(x == 1) return 2 ; 
	if(f[x]) return f[x] ;
	return f[x] = ( F(x / 2) + F((x - 1) / 2) + F((x - 2) / 2) ) % P ;  
}
signed main()
{
	n = gi() ; 
	cout << F(n) << endl ; 
	return 0 ;
}

Measured memory_bytes: 3656
n,m=map(int,input().split())
a=['-1' for i in range(n)]

if n==1 and m==0:
    print(0)
    exit()
    
for i in range(m):
    s,c=map(int,input().split())
    if a[s-1]=='-1' or str(c)==a[s-1]:
        a[s-1]=str(c)
    else:
        print(-1)
        exit()
    
    if a[0]=='0':
        if n==1:
            print(0)
            exit()
        else:    
            print(-1)
            exit()

if a[0]=='-1':
    a[0]='1'
   
 

for i in range(n):
    if a[i] == '-1':
        a[i]='0'
        
print(''.join(a))   

Measured memory_bytes: 3064
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.8.2)

import math
import statistics
import numpy as np
import queue
import itertools
import functools 

status = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
for _ in range(int(input())):
	s = input()
	status[s] += 1

for st in status:
  print('{} x {}'.format(st, status[st]))


Measured memory_bytes: 27344
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int ret=0,f=1;
	char ch=getchar();
	while(ch>'9'||ch<'0')
	{
		if(ch=='-')
			f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		ret=(ret<<1)+(ret<<3)+ch-'0';
		ch=getchar();
	}
	return ret*f;
}
int n,m,sum,a[105],x,t;
int main()
{
	n=read();
	for(register int i=1;i<=n;i++)
	{
		a[i]=read();
		sum+=a[i];
	}
	m=read();
	for(register int i=1;i<=m;i++)
	{
		x=read();
		t=read();
		printf("%d\n",sum-a[x]+t);
	}
	return 0;
}

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

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

    long long ans = 0;
    int left = 0;
    int right = n - 1;
    int mid;
    if (n % 2 == 0) mid = (n - 1) / 2;
    else mid = n / 2;
    int num = mid;
    for(int i = 0; i < n - 1; i++)
    {
        if (left != mid) {
            ans += abs(a.at(num) - a.at(left));
            num = left;
            left++;
        }
        if (right != mid) {
            ans += abs(a.at(num) - a.at(right));
            num = right;
            right--;
        }
    }
    left = 0;
    right = n - 1;
    num = mid;
    long long ans2 = 0;
    for(int i = 0; i < n - 1; i++)
    {
        if (right != mid) {
            ans2 += abs(a.at(num) - a.at(right));
            num = right;
            right--;
        }
        if (left != mid) {
            ans2 += abs(a.at(num) - a.at(left));
            num = left;
            left++;
        }
    }
    cout << max(ans, ans2) << endl; 
}

Measured memory_bytes: 640
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if ((a*b) % 2 == 0) {
      System.out.println("Even");
    } else {
      System.out.println("Odd");
    }
  }
}


Measured memory_bytes: 21716
import sys
X,N=map(int, sys.stdin.readline().split())
P=map(int, sys.stdin.readline().split())
L=[ 0 for _ in range(102) ]
for p in P:
    L[p]=1

d=float("inf")
ans=None
for i,x in enumerate(L):
    if x==0:
        if abs(X-i)<d:
            d=abs(X-i)
            ans=i
print ans

Measured memory_bytes: 64540
def main():
  s=input()
  k="keyence"
  if len(s)<7:
    print("NO")
    return
  if s[:7]==k or s[-7:]==k:
    print("YES")
    return
  for i in range(1,7):
    if s[:i]==k[:i] and s[i-7:]==k[i-7:]:
      print("YES")
      return
  print("NO")
main()

Measured memory_bytes: 3060
import sys


fin = sys.stdin.readline
N = int(fin())
s_list = [fin().rstrip("\n") for _ in range(N)]
num_AB_in_between = 0
s_Bhoge = 0
s_hogeA = 0
s_BA = 0
for s in s_list:
    if s[0] == "B" and s[-1] == "A":
        s_BA += 1
    elif s[0] == "B":
        s_Bhoge += 1
    elif s[-1] == "A":
        s_hogeA += 1

    for i, char in enumerate(s[:-1]):
        next_char = s[i + 1]
        if char == "A" and next_char == "B":
            num_AB_in_between += 1

# print(s_Bhoge, s_hogeA, s_BA)
if s_BA:
    num_AB_bound = s_BA - 1 + int(s_Bhoge > 0) + int(s_hogeA > 0)
    num_AB_bound += max(0, min(s_Bhoge - 1, s_hogeA - 1))
    # num_AB_bound += min(s_Bhoge - 1, s_hogeA - 1)
else:
    num_AB_bound = min(s_Bhoge, s_hogeA)
print(num_AB_in_between + num_AB_bound)


Measured memory_bytes: 41072
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

class Main {
	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			int H, W;
			ArrayList<int[]> list = new ArrayList<int[]>();
			do {
				int[] ret = new int[2];
				String[] input = br.readLine().split(" ");
				H = Integer.parseInt(input[0]);
				W = Integer.parseInt(input[1]);
				if (H == 0 && W == 0) {
					break;
				} else {
					ret[0] = H;
					ret[1] = W;
					list.add(ret);
				}
			} while (true);

			int x, y;
			for (int[] e : list) {
				H = e[0];
				W = e[1];
				for (x = 0; x < H; x++) {
					for (y = 0; y < W; y++) {
						System.out.print("#");
					}
					System.out.println();
				}
				System.out.println();
			}

		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24224
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define REP(i,a) for(int i=0;i<(a);i++)
#define REPR(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
// using ll = long long;
// using vi = vector<int>;
// using vvi = vector<vi>;
// using vl = vector<long long>;
// using vvl = vector<vl>;
// using vs = vector<string>;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

int main () {
  int n,k;
  cin >> n >> k;
  long bunshi = 0.0;
  int a;
  int time = ceil(log2(k));
  // cout << "time = " << time << endl;
  REP(i,n) {
    if (i+1 >= k) a = 0;
    else a = ceil(log2((double)k/(i+1)));
    // cout << "[i,log2(k/(i+1))] =  [" << i << " , "  << log2((double)k/(i+1)) << "]" << endl;
    bunshi += pow(2, time-a);
  }
  // cout << "bunshi = " << bunshi << endl;
  double result = (double)bunshi/((double)n*(double)pow(2,time));
  printf("%.20lf\n", result);
}


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

int main()
{
	int N;

	while ( cin >> N, N != -1 ) {
		cout << 3130 - min(10, max(0, N - 10)) * 125 - min(10, max(0, N - 20)) * 140 - max(0, N - 30) * 160 << endl;
	}

	return ( 0 );
}



Measured memory_bytes: 3072
#include<iostream>
using namespace std;
long A[100010]={};
long B[100010]={};
long v[100010]={};
int main(){
  long n;
  long ans=0;
  long e1=0,e2=0,o1=0,o2=0;
  long c=0;
  long temp=0;
  long c1=0,c2=0,d1=0,d2=0;
  long tmp1=0,tmp2=0;
  long a=0,b=0;
  long rec1=0,rec2=0;
  cin >> n;
  for(long i=0;i<n;i++){
    cin >> v[i];
  }
  if(n%2==1){
    while(c<=n-1){
      A[v[c]]++;
      c+=2;
    }
    c=1;
    while(c<n){
      B[v[c]]++;
      c+=2;
    }
  }
  else{
    while(c<n){
      A[v[c]]++;
      c+=2;
    }
    c=1;
    while(c<=n-1){
      B[v[c]]++;
      c+=2;
    }
  }
  //E1
  for(long i=0;i<100010;i++){
    //  ans+=A[i];
    a+=A[i];
    temp=e1;
    //cout << ans << endl;
    e1=max(e1,A[i]);
    if(temp!=e1) c1=i;
  }
  //E2
  A[c1]=0;
  for(long i=0;i<100010;i++){
    //ans+=A[i];
    //a+=A[i];
    temp=e2;
    //cout << ans << endl;
    e2=max(e2,A[i]);
    if(temp!=e2) c2=i;
  }
  //O1
  for(long i=0;i<100010;i++){
    //ans+=B[i];
    b+=B[i];
    temp=o1;
    o1=max(o1,B[i]);
    if(temp!=o1) d1=i;
  }
  //O2
  B[d1]=0;
  for(long i=0;i<100010;i++){
    //ans+=B[i];
    //b+=B[i];
    temp=o2;
    o2=max(o2,B[i]);
    if(temp!=o2) d2=i;
  }

  if(c1!=d1){
    cout << a+b-e1-o1 << endl;
    return 0;
  }
  else{
    /*if(c2==d2){
      cout << e1 << endl;
      return 0;
    }*/
    //cout << e1 << e2 << o1 << o2 << endl;
    cout << min(a-e1+b-o2,a-e2+b-o1) << endl;
  }
  /*
  tmp1=s;
  ans=ans-s;
  rec1=ans;
  for(long i=0;i<100010;i++){
    ans+=B[i];
    b+=B[i];
    temp=t;
    t=max(t,B[i]);
    if(temp!=t) c2=i;
  }
  tmp2=t;
  ans=ans-t;
  rec2=ans-rec1;
  //cout <<ans<<endl;
  //cout <<c1 << c2 << endl;
  if(s==t && c1==c2) ans = s;

  //cout << c1 << "q" << c2 << endl;
  else if(c1==c2){
    A[c1]=0;
    B[c2]=0;
    int p=0,q=0;
    //ans+= s+t;
    s=0;
    t=0;
    if(tmp1>tmp2){

      //cout << rec2 << endl;
      ans-=rec2;
      for(long i=0;i<100010;i++){
        q+=B[i];
        temp=t;
        t=max(t,B[i]);
        if(temp!=t) c2=i;
      }
      q-=t;
      ans=ans+b-q;
    }
    else{
      ans-=rec1;
      for(long i=0;i<100010;i++){
        p+=A[i];
        temp=t;
        s=max(s,A[i]);
        if(temp!=s) c1=i;
      }
      p-=s;
      ans=ans+a-p;
    }
  }

  cout << ans << endl;*/
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>

using namespace std;

vector<vector<int>> e;
vector<int> color;

bool check(int v, int c){
	color[v] = c;
	bool res = true;
	for(auto&& i : e[v]){
		if(color[i] == c) return false;
		else if(color[i] == 0) res &= check(i, -c);
	}
	return res;
}

int main(){
	long long n, m, ans = 0;
	cin >> n >> m;
	e = vector<vector<int>>(n + 1);
	for(int i = 0; i < m; i++){
		int x, y;
		cin >> x >> y;
		e[x].emplace_back(y);
		e[y].emplace_back(x);
	}
	color = vector<int>(n + 1);
	bool f = check(1, 1);
	if(f){
		long long b = 0, w = 0;
		for(int i = 1; i <= n; i++){
			if(color[i] == 1) b++;
			else w++;
		}
		cout << b * w - m << endl;
	}else{
		cout << n * (n - 1) / 2 - m << endl;
	}
	return 0;
}


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

string s="CODEFESTIVAL2016";

int main(){
	string t;
	cin >> t;
	int cnt = 0;
	for (int i = 0; i < s.size(); i++){
		if (s[i] != t[i]){
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,sum=0,t1;
	cin>>a>>b;
	if(b>0&&a>0)cout<<"Positive"<<endl;	
	if(b>=0&&a<=0)cout<<"Zero"<<endl;
	if(b<0&&a<0)
	{
		if((b-a+1)%2==0)cout<<"Positive"<<endl;
		else cout<< "Negative"<<endl;
	}	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define PI 3.1415926535897
#define EPS (1e-10)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int N;
int x[100010];
MII d;


void makeD(){
	rep(i, 0, N){
		int a = x[i+1]-x[i];
		repif(i, 1, i*i <= a)
			if(a%i == 0) d[i]++, (a/i != i ? d[a/i]++ : 0);
	}
}


int solve(){
	for(auto it = d.rbegin();it != d.rend();it++)
		if(it->second == N) return it->first;
	return 1;
}


signed main(){
	cin >> N;
	rep(i, 0, N+1) cin >> x[i];

	sort(RNG(x, 0, N+1));

	makeD();

	cout << solve() << endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <int,int>
#define N 300005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;

int main()
{
	int n, ans = 0;
	cin >> n;
	pair <int, int> p[N];
	for (int i = 0; i < n; ++i)
	{
		cin >> p[i].ff;
	}
	for (int i = 0; i < n; ++i)
	{
		cin >> p[i].ss;
		ans += max(0, p[i].ff - p[i].ss);
	}
	cout << ans;
}

Measured memory_bytes: 2560
/* -> Written by <-
   -----------
  |K_A_Z_A_M_A|
  |___________|
  |    _    |
  |   (^_^)   |
  |  /( | )\  |
  |____|_|____|
    H O A N G
*/

#define Task ""
#define F first
#define S second
#define push_back pb
#define bit(x, i) (x >> i) & 1
#define inf 1e9 + 7
#define INF 1e18 + 7

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <string>
#include <sstream>
#include <cstdio>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7;
const int maxn = 2e5 + 5;

int n, m, tr[maxn], cnt, res = 0;
vector <int> a[maxn];

void DFS(int u)
{
    cnt ++;
    for (auto v : a[u])
        if (tr[v] == 0)
        {
            tr[v] = 1;
            DFS(v);
        }
}

void Solve()
{
    cin >> n >> m;
    for (int i = 1; i <= m; i ++)
    {
        int x, y;
        cin >> x >> y;
        a[x].pb(y);
        a[y].pb(x);
    }
    for (int i = 1; i <= n; i ++)
    {
        cnt = 0;
        if (tr[i] == 0)
        {
            tr[i] = 1;
            DFS(i);
        }
        res = max(res, cnt);
    }
    cout << res;
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    if(fopen(Task".inp", "r"))
    {
        freopen(Task".inp","r",stdin);
        freopen(Task".out","w",stdout);
    }
    int test_case = 1;
//    cin >> test_case;
    while (test_case --)
        Solve();
    return 0;
}


Measured memory_bytes: 21524
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
const static int tx[] = {0,1,1,1,0,-1,-1,-1};
const static int ty[] = {-1,-1,0,1,1,1,0,-1};
 
static const double EPS = 1e-8;


int num_of_notes;
int num_of_beauty;
ll force_of_repulsion;
ll sum[200001];
ll dp[2001][2001];
int notes[2001];
ll beauty[100001];

ll compute(int i,int j){
  ll lhs = sum[notes[i]];
  ll rhs = (notes[j] - 1 < 0 ? 0 : sum[notes[j] - 1]);

  return (lhs - rhs) / force_of_repulsion;
}

int main(){
  while(~scanf("%d %d %lld",
               &num_of_notes,
               &num_of_beauty,
               &force_of_repulsion)){

    for(int note_idx = 0; note_idx < num_of_notes; note_idx++){
      scanf("%d",notes + note_idx);
      notes[note_idx]--;
    }

    memset(sum,0,sizeof(sum));

    for(int beauty_idx = 0; beauty_idx < num_of_beauty; beauty_idx++){
      scanf("%d",beauty + beauty_idx);
      sum[beauty_idx] = (beauty_idx - 1 >= 0 ? sum[beauty_idx - 1] : 0) + beauty[beauty_idx];
    }

    sort(notes,notes + num_of_notes);
    reverse(notes,notes + num_of_notes);

    memset(dp,0x3f,sizeof(dp));

    dp[0][0] = 0;
    for(int i=0;i<num_of_notes;i++){
      int next = i + 1;
      if(next >= num_of_notes) break;
      for(int j=0;j<=i;j++){
        dp[next][j]
          = min(dp[next][j],dp[i][j] + compute(i,next));

        dp[next][i]
          = min(dp[next][i],dp[i][j] + compute(j,next));
      }
    }

    ll res = LINF;
    for(int i=0;i<num_of_notes;i++){
      res = min(dp[num_of_notes - 1][i] + compute(i,num_of_notes - 1),res);
    }
    
    printf("%lld\n",res);
  }
}

Measured memory_bytes: 34844
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
    string S; cin >> S;
    int a, b;
    bool c = false;
    rep(i, S.size()) {
        if (c == false && S.at(i) == 'A') {
            a = i - 1;
            c = true;
        }
        if (S.at(i) == 'Z')b = i;
    }
    cout << b - a << endl;
}

Measured memory_bytes: 3764
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int[][] c = new int[3][3];
		for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) c[i][j] = sc.nextInt();
		for(int j = 1; j < 3; j++) {
			for(int i = 0; i < 3; i++) c[j][i] -= c[0][i];
		}
		for(int j = 1; j < 3; j++) {
			for(int i = 0; i < 3; i++) c[i][j] -= c[i][0];
		}
		if(c[1][1] == 0 && c[1][2] == 0 && c[2][1] == 0 && c[2][2] == 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = Integer.parseInt(scanner.next());
        int b = Integer.parseInt(scanner.next());
        int c = Integer.parseInt(scanner.next());

        String answer = (a < b && b < c) ? "Yes" : "No";

        System.out.println(answer);
    }
}

Measured memory_bytes: 26140
#include <cstdio>
#include <cmath>
#include <algorithm>

static const long long  MAX = 100100;
static const long long  INF = 1LL << 31;

int main()
{
    int N; // N : 足場の数
    long long h[MAX]; // h[i]: 足場iの高さ(i = 0,...,N-1) 
    long long dp[MAX];   // DPテーブル...足場iへと移動するのに必要な最小コスト(i = 0,...,N-1)
    scanf("%d", &N);
    for (int i = 0; i < N; i++) scanf("%lld", &h[i]);

    for (int i = 0; i < N; i++) dp[i] = INF;

    dp[0] = 0; // 足場0が初期位置なのでdp[0] = 0

    for (int i = 1; i < N; i++)
    {
        //dp[i-1],dp[i-2]からdp[i]を求める
        dp[i] = std::min(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if (i > 1) dp[i] = std::min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }

    printf("%lld\n", dp[N-1]);

    return 0;
}

Measured memory_bytes: 1664
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,a[30],ans=0;
vector <int> v;

int main()
{
	cin>>n;
	rep(i,n) cin>>a[i];
	repn(i,n-2)
	{
		v.clear();
		v.pb(a[i-1]);
		v.pb(a[i]);
		v.pb(a[i+1]);
		sort(v.begin(),v.end());
		if(v[1]==a[i]) ans++;
	}
	cout<<ans<<endl;
	rt0;
}

Measured memory_bytes: 256
rd(){
	int x=0,k;
	for(;;)
	{
		k=getchar_unlocked();
		if(k<'0'||k>'9')break;
		x=x*10+k-'0';
	}
	return x;
}
sum[3<<17],cnt[3<<17],ans[3<<17];
N,i,acc,t;
main()
{
	N=rd();
	for(i=0;i<N;i++)
	{
		++sum[cnt[rd()]++];
	}
	i=0;
	for(t=N;t>0;t--)
	{
		while(acc>=i*t)acc+=sum[i++];
		ans[t]=i-1;
	}
	for(i=1;i<=N;i++)printf("%d\n",ans[i]);
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
int N;
string s;
int main() {
    cin >> N >> s;
    int max = 0;
    int x = 0;
    for(int i = 0; i < N; ++i) {
        if(s.at(i) == 'I') {
            x++;
        }else {
            x--;
        }

        if(max < x) {
            max = x;
        }
    }

    cout << max << endl;
}

Measured memory_bytes: 256
/*
Author : N_o_o_B
Created : April 11 2020 15:05:15 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;
    int k;
    cin >> k;
    queue<ll> q;
    rep(i,1,9) q.push(i);
    fori(i,k-1){
        ll x = q.front();
        q.pop();
        if(x % 10 != 0){
            q.push(10*x + (x%10) - 1);
        }
        q.push(10*x + x%10);
        if(x % 10 != 9){
            q.push(10*x + (x%10) + 1);
        }
    }
    cout << q.front() << endl;
    time_taken();
    return 0;
}

Measured memory_bytes: 1792
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const double PI=acos(-1);
typedef long long ll;
typedef pair<int,int> pi;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for (int i=(a);i<=(b);i++)
#define per(i,a,b) for (int i=(a);i>=(b);i--)
#define Rep(i,a,b) for (int i=(a);i<(b);i++)
#define Per(i,a,b) for (int i=(a);i>(b);i--)
//debug
#define deb printf("begin\n");
#define dee printf("end\n");
#define def printf("find\n");
#define dey printf("Yes\n");
#define den printf("No\n");
#define dew printf("wrong\n");
void read(int&x){
	x=0;int f=1;char ch=getchar();
	while ((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if (ch=='-')f=-1,ch=getchar();
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=f;
}
//--------------------------head--------------------------//

#define maxn 105
char s[maxn],now[maxn];int n;
bool check(char*s,int len,int num){rep(i,1,len)if (s[i]!=num+'a')return false;return true;}
int work(int num){
	int res=0;
	while (true){
		if (check(now,n-res,num))return res;
		res++;
		rep(i,1,n-res){
			if (now[i]==num+'a')now[i]=num+'a';
			if (now[i+1]==num+'a')now[i]=num+'a';
			now[i]=now[i];
		}
		//rep(i,1,n-res)printf("%c ",now[i]);printf("\n");
	}
}
int ans;
int main(){
	scanf("%s",s+1);n=strlen(s+1);ans=n;
	rep(i,0,25){
		rep(j,1,n)now[j]=s[j];
		ans=min(ans,work(i));
	}
	printf("%d\n",ans);return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

long max (long a, long b)
{
    if (a > b)
        return a;
    return b;
}

int N;
int W;
long dp[110][100010];
long w[110];
long v[110];

int main(int argc, char const *argv[])
{
    scanf("%d%d", &N, &W);
    for (int i = 0; i < N; i++)
        scanf("%ld %ld", w+i, v+i);

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j <= W; j++)
        {
            if (j - w[i] >= 0)
                dp[i+1][j] = max(dp[i+1][j], dp[i][j - w[i]] + v[i]);

            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }
    printf("%ld\n", dp[N][W]);
    return 0;
}


Measured memory_bytes: 79232
n = int(input())
c = list(input())
wc = 0

for i in range(n):
    if c[i] == "W":
        wc += 1

rc = n - wc

winrcount = 0
for i in range(rc):
    if c[i] == "W":
        winrcount += 1

rinwcount = 0
for i in range(rc, n, 1):
    if c[i] == "R":
        rinwcount += 1

if winrcount >= rinwcount:
    print(winrcount)
else:
    print(rinwcount)

Measured memory_bytes: 73396
#include <iostream>
#include <math.h>
#include <string.h>
#include <vector>
#include <algorithm>


using namespace std;

int main() {
    int n,k,h[1000000];
    cin>>n>>k;
    for(int i=0;i<=n-1;i++){
        cin>>h[i];
    }
    sort(h,h+n);
    int ans=1000000000;
    for(int i=0;i<=n-k;i++){
        ans=min(ans,h[i+k-1]-h[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2432
let lower_bound f a =
  let rec loop l r =
    if l >= r then r
    else
      let m = (l+r) / 2 in
      if f a.(m) then loop l m else loop (m+1) r
  in loop 0 (Array.length a)

let comb =
  let memo = Array.make_matrix 55 55 (-1) in
  let rec f n k =
    if memo.(n).(k) >= 0 then memo.(n).(k)
    else
      let v = if k = 0 || n = k then 1 else f (n-1) k + f (n-1) (k-1) in
      memo.(n).(k) <- v; v
  in f

let () =
  Scanf.scanf "%d %d %d" @@ fun n a b ->
  let vs = Array.init n (fun _ -> Scanf.scanf " %f" ((+.) 0.)) in
  Array.sort compare vs;

  let i0 = lower_bound ((<=) vs.(n-a)) vs in
  let i1 = lower_bound ((<) vs.(n-a)) vs in
  let total = Array.init a (fun i -> vs.(n-1-i)) |> Array.fold_left (+.) 0. in

  let lc = i1 - (n-a) in
  let uc = if i1 = n then min b (i1 - i0) else lc in

  Array.init (uc-lc+1) (fun i -> comb (i1-i0) (lc+i))
  |> Array.fold_left (+) 0
  |> Printf.printf "%.10f\n%d\n" (total /. float_of_int a)

Measured memory_bytes: 2560
#include <stdio.h>

#define NIL -1

int Fibonacci(int);

int f[45];

int main() {
  int i, n, ans;

  scanf("%d", &n);
  
  for (i = 0; i < 45; i++) {
    f[i] = NIL;
  }

  ans = Fibonacci(n);

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

  return 0;
}


int Fibonacci(int n) {
  
  if (n == 0 || n == 1) return f[n] = 1;

  else {
    if (f[n-1] != NIL && f[n-2] != NIL) return f[n-1] + f[n-2];

    else if (f[n-1] != NIL) {
      f[n-2] = Fibonacci(n-2);
      return f[n-1] + f[n-1];
    }
    
    else if (f[n-2] != NIL) {
      f[n-1] = Fibonacci(n-1);
      return f[n-1] + f[n-2];
    }
    
    else {
      f[n-1] = Fibonacci(n-1);
      f[n-2] = Fibonacci(n-2);
      return Fibonacci(n-1) + Fibonacci(n-2);
    }
  }
  
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

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

  rep(i, s.size())
    cout << "x";

  cout << endl;

  return 0;
}

Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    double x1, y1, x2, y2;

    x1 = sc.nextDouble();
    y1 = sc.nextDouble();
    x2 = sc.nextDouble();
    y2 = sc.nextDouble();
    System.out.println(Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 18328
#include <list>
#include <cstdio>

using namespace std;

int main(void){
    int n;
    char buf[1026], *p;
    list<char> trains;
    list<char>::iterator it;
    
    scanf("%d", &n);
    for (int i=0; i<n; i++){
        trains.clear();
        scanf("%s", buf);
        p = buf;
        trains.push_front(*p++);
        it = trains.begin();
        while (1){
  //          printf("(deb:%c)\n", *it);
            if (*p=='<'){
                p+=2;
                if (it==trains.begin()){
  //                  puts("deb:pf");
                    trains.push_front(*p);
                }
                p++;
                it--;
            }
            else if(*p=='-'){
                p+=2;
                it++;
                if (it==trains.end()){
  //                  puts("deb:pb");
                    it = trains.insert(it, *p);
                }
                p++;
            }
            else break;
        }
        for (it = trains.begin(); it!=trains.end(); it++){
            putchar(*it);
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 2644
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
int main(void)
{
    int N, T;
    cin >> N >> T;
    vector<lli> t;
    lli tmp;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        t.push_back(tmp);
    }
    lli *x;
    x = new lli[N - 1];
    for (int i = 0; i < N - 1; i++)
    {
        x[i] = t[i + 1] - t[i];
    }
    lli sum = 0;
    for (int i = 0; i < N - 1; i++)
    {
        if (x[i] > T)
        {
            sum += T;
        }
        else
        {
            sum += x[i];
        }
    }
    cout << sum + T << endl;
    return 0;
}

Measured memory_bytes: 3440
#include <iostream>
using namespace std;
 
int main(void)
{
  int a, b, c, d;
  cin.exceptions(ios::failbit);
  
  try
  {
  	cin >> a >> b >> c >> d;
  }
  catch(...)
  {
    return -1;
  }
  
  if((a > 0 && a <= 100) &&
     (b > 0 && b <= 100) &&
     (c > 0 && c <= 100) &&
     (d > 0 && d <= 100) )
  {
    while(1)
    { 
      c -= b;
      if(c <= 0)
      {
        cout << "Yes" << endl;
        break;
      }
      
       a -= d;
 
      if(a <= 0)
      {
        cout << "No" << endl;
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

// 基本的な演算
namespace BasicMath {
    // 二つの値の最大値を求める関数
    static Int Max(const Int a, const Int b);
    Int Max(const Int a, const Int b) {
        if (a >= b) {
            return a;
        } else {
            return b;
        }
    }
}
using namespace BasicMath;

int main(void) {
    Int a, b;
    cin >> a >> b;
    Int sum = a + b;
    Int diff = a - b;
    Int prod = a * b;
    cout << Max(Max(sum, diff), prod) << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<stdio.h>

using namespace std;


int main(){

while(1){
    int n, k;
    cin>> n>> k;
    if(n==0&&k==0) break;
    int a[n];
    for(int i=0; i<n; i++){
        cin>> a[i];
    }
    int s[n+1];
    fill(s, s+n+1, 0);
    for(int i=0; i<n; i++){
        s[i+1]=s[i]+a[i];
    }
    int ans=-100100100;
    for(int i=k; i<=n; i++){
        ans=max(ans, s[i]-s[i-k]);
    }

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

Measured memory_bytes: 3792
#include <cstdio>
#include <cctype>

int main() {
	char c;
	int sum[26] = {0};
	while (scanf("%c", &c) == 1) {
		if (!isalpha(c)) continue;
		c = tolower(c);
		++sum[c - 'a'];
	}
	for (int i = 0; i < 26; i++) {
		printf("%c : %d\n", i+'a', sum[i]);
	}
	return 0;
}

Measured memory_bytes: 980
#include <iostream>

using namespace std;

int main() {

    int N, A;
    cin >> N >> A;

    int i = 500;
    while(i <= 10000){

        if(N % i <= A){
            cout << "Yes" ;
            break;
        }else {
            cout << "No" ;
            break;
        }

        i += 500;
    }

    return 0;
}

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

ll modinv(ll a,ll m){
   ll b=m,u=1,v=0;
   while(b){
      ll t=a/b;
      a-=t*b; 
      swap(a,b);
      u-=t*v; 
      swap(u,v);
   }
   u%=m;
   if(u<0) u+=m;
   return u;
}

ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}



int main(){
  ll x;
  cin>>x;
  ll ans=0;
  ll m=100;
  do{
     m*=1.01;
     ans++;

  }while(m<x);

  cout<<ans;
   return 0;
}



Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;

typedef long long Int;
typedef pair<Int,Int> P;
#define print(x) cout<<(x)<<endl

#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007



int main() {
	string s, t;
	cin >> s >> t;
	string u;
	while (!t.empty()) {
		u += t.back();
		t.pop_back();
	}
	if (s == u)print("YES"); else print("NO");





	return 0;
}

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

using namespace std;

void insertionSort(vector<int> vec)
{
	for (int i = 1; i < vec.size(); ++i)
	{
		int v = vec[i];
		int j = i - 1;
		while (j >= 0 && vec[j] > v)
		{
			vec[j + 1] = vec[j];
			--j;
		}
		vec[j + 1] = v;
		for (int j = 0; j < vec.size() - 1; ++j)
		{
			cout << vec[j] << " ";
		}
		cout << vec[vec.size() - 1] << endl;
	}
}

void solve()
{
	int N;
	cin >> N;
	vector<int> vec(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> vec[i];
	}
	for (int j = 0; j < vec.size() - 1; ++j)
	{
		cout << vec[j] << " ";
	}
	cout << vec[vec.size() - 1] << endl;
	insertionSort(vec);
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1216
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let mut up = vec![];
	let mut down = vec![];
	let mut all = 0;
	for s in s.take(n) {
		let mut min = 0;
		let mut delta = 0;
		for c in s.chars() {
			if c == '(' {
				delta += 1;
			} else {
				delta -= 1;
				if delta < min {
					min = delta;
				}
			}
		}
		if delta > 0 {
			up.push((min, delta));
		} else {
			down.push((min - delta, -delta));
		}
		all += delta;
	}
	if all != 0 {
		println!("No");
		return;
	}
	up.sort_by_key(|a| std::cmp::Reverse(a.0));
	down.sort_by_key(|a| std::cmp::Reverse(a.0));
	let mut cur = 0;
	for (min, delta) in up {
		if cur + min < 0 {
			println!("No");
			return;
		}
		cur += delta;
	}
	let mut cur = 0;
	for (min, delta) in down {
		if cur + min < 0 {
			println!("No");
			return;
		}
		cur += delta;
	}
	println!("Yes");
}


Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int n, m, q;
vector<int> G[MAX];
int v[MAX], d[MAX], c[MAX];
pii dp[11][MAX];

void dfs(int t, int td, int tv, int tc){
    if(dp[td][tv].se > 0) return;
    dp[td][tv] = {t, tc};
    if(td == 0) return;
    for(int nv: G[tv]) dfs(t, td-1, nv, tc);
}

int main(){
    scanf("%d%d", &n, &m);
    rep(i, m){
        int a, b;
        scanf("%d%d", &a, &b);
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    scanf("%d", &q);
    rep(i, q){
        scanf("%d%d%d", &v[i], &d[i], &c[i]);
        --v[i];
    }

    rep(i, 11)rep(j, n) dp[i][j] = {-1, 0};
    rrep(i, q) dfs(i, d[i], v[i], c[i]);
    rep(i, n){
        pii ans = {-1, 0};
        rep(j, 11) chmax(ans, dp[j][i]);
        printf("%d\n", ans.se);
    }
}

Measured memory_bytes: 16248
import sys
import math

nums = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))

r0 = math.floor(nums[0] / nums[1])
r1 = nums[0] % nums[1]
r2 = nums[0] / nums[1]

print(r0, r1, '{:.05f}'.format(r2))


Measured memory_bytes: 5676