akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let mut vec = vec![];
    for _ in 0..N {
        let x: f64 = read();
        let y: f64 = read();
        vec.push((x, y));
    }
    let mut sum = 0.0;
    for &(x1, y1) in &vec {
        for &(x2, y2) in &vec {
            sum += ((x1 - x2).powf(2.0) + (y1 - y2).powf(2.0)).sqrt();
        }
    }
    let ans = sum * factorial(N as i64 - 1) as f64 / factorial(N as i64) as f64;
    println!("{}", ans);
}

fn factorial(n: i64) -> i64 {
    let mut ans = 1;
    for i in 1..n + 1 {
        ans *= i;
    }
    ans
}


Measured memory_bytes: 4352
N = int(input())
S = [list(map(int, input().split())) for _ in range(N)]  # N日間の夏休み

dp = [[0]*3 for _ in range(N)]  # i日目の状態, (幸福度の合計, 前日の遊んだ内容3種類のテーブル)

# print(S)
# print(dp)

# 初期値
dp[0][0] = (S[0][0], 'a')
dp[0][1] = (S[0][1], 'b')
dp[0][2] = (S[0][2], 'c')

# print(dp)
for i in range(1, N):  # N日間の遷移
    # aの予定を実行する場合
    if dp[i-1][1][0]+S[i][0] > dp[i-1][2][0]+S[i][0]:
        dp[i][0] = (dp[i-1][1][0]+S[i][0], 'a')
    else:
        dp[i][0] = (dp[i-1][2][0]+S[i][0], 'a')

    # bの予定を実行する場合
    if dp[i-1][0][0]+S[i][1] > dp[i-1][2][0]+S[i][1]:
        dp[i][1] = (dp[i-1][0][0]+S[i][1], 'b')
    else:
        dp[i][1] = (dp[i-1][2][0]+S[i][1], 'b')

    # cの予定を実行する場合
    if dp[i-1][0][0]+S[i][2] > dp[i-1][1][0]+S[i][2]:
        dp[i][2] = (dp[i-1][0][0]+S[i][2], 'c')
    else:
        dp[i][2] = (dp[i-1][1][0]+S[i][2], 'c')

# print(dp)
print(max(dp[N-1])[0])


Measured memory_bytes: 66416
import java.util.Scanner;

public class Main {
	char[][] a;
	char[][] b;
	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int count = 0;
		a = new char[N][N];
		b = new char[M][M];
		for(int i = 0; i < N; i++) {
			String tmp = sc.next();
			a[i] = tmp.toCharArray();
		}
		for(int i = 0; i < M; i++) {
			String tmp = sc.next();
			b[i] = tmp.toCharArray();
		}
		for(int i = 0; i <= N - M; i++) {
			for(int j = 0; j <= N - M; j++) {
				for(int k = 0; k < M; k++) {
					for(int l = 0; l < M; l++) {
						if(b[k][l] == a[i+k][j+l]) {
							count++;
						}
					}
					if(count == M * M) {
						System.out.println("Yes");
						sc.close();
						return;
					}
				}
				count = 0;
			}
		}
		System.out.println("No");
		sc.close();
	}

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

Measured memory_bytes: 22100
import * as fs from 'fs';
// main
function main(input: string[]) {
    // param
    let s: number = 0;
    let ans: number = 0;
    // init
    s = Number(input.shift());
    // solve
    var m = new Array(s + 1).fill(0);
    for (var mx = 1; mx <= s; mx++) {
        if (mx < 3) m[mx] = 0;
        else if (mx < 6) m[mx] = 1;
        else {
            var w = 1;
            for (var nx = 3; nx <= mx - 3; nx++) {
                w += m[mx - nx];
            }
            m[mx] = w % 1000000007;
        }
    }
    ans = m[s];
    // answer
    console.log(ans);
}
// entrypoint
function entrypoint() {
    try {
        // linux
        let input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            let input = lines;
            main(input);
        });
    }
}
entrypoint();


Measured memory_bytes: 33144
n, m = map(int, input().split())

a = list(map(int, input().split()))

a.sort()

operate = []

for i in range(m):

    b, c = map(int, input().split())

    operate.append((b, c))

operate.sort(key = lambda x: x[1], reverse = True)

index = 0

for i in range(m):

    b, c = operate[i]

    j = index

    while j < n and j - index < b and a[j] < c:

        a[j] = c

        j += 1

    index = j

print(sum(a))

Measured memory_bytes: 22524
#include <stdio.h>

inline void gc(int* x){
    *x = 0;
    for(;;){
        int c=getchar_unlocked();
        if('0'<= c && c <='9'){
            *x = *x*10 + c-'0';
        }else{
            break;
        }
    }
}

int main(void){
    using namespace std;
    constexpr int KMAX = 1000;
    static int s[KMAX+1][2*KMAX+1];
    char c;
    int n, k, x, y;
    scanf("%d %d\n", &n, &k);
    for(int i=0; i<n; i++){
        gc(&x);
        gc(&y);
        c=getchar_unlocked();
        getchar_unlocked();
        y %= 2*k;
        if(c=='W'){
            if(y>=k){
                y-=k;
            }else{
                x+=k;
            }
        }else{
            if(y>=k){
                y-=k;
                x+=k;
            }
        }
        x %= 2*k;
        s[y+1][x+1]++;
    }
    for(int y=0; y<k; y++){
        for(int x=0; x<2*k; x++){
            s[y+1][x+1] += s[y][x+1] + s[y+1][x] - s[y][x];
        }
    }
    int max = 0;
    int v = s[0][0] - s[0][2*k];
    for(int y=0; y<k; y++){
        int u = v - s[y][0] + s[y][2*k];
        for(int x=0; x<k; x++){
            int t = u - s[0][x] - s[k][x] + s[0][x+k] + s[k][x+k] + 2*s[y][x] - 2*s[y][x+k];
            t = t<n/2 ? n-t : t;
            max = t>max ? t : max;
        }
    }
    printf("%d", max);
    return 0;
}


Measured memory_bytes: 7936
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)

tmp = []
tree = []

def dfs(node, depth, fr):
    global tmp, tree
    tree[node] = (fr, depth)
    for i, c in tmp[node]:
        if i != fr:
            dfs(i, depth+c, node)

def main():
    global tmp, tree
    n = int(input().strip())
    tmp = [[] for _ in range(n)]
    tree = [0] * n
    for _ in range(n-1):
        a, b, c = map(int, input().strip().split())
        a -= 1
        b -= 1

        if b > a:
            a, b = b, a
        tmp[a].append((b, c))
        tmp[b].append((a, c))

    q, k = map(int, input().strip().split())
    k -= 1
    dfs(k, 0, -1)
    # print(tmp)
    # print(tree)
    for _ in range(q):
        x, y = map(lambda x: x-1, map(int, input().strip().split()))
        print(tree[x][1] + tree[y][1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 196144
#include<iostream>
#include<vector>
#include<map>
#include<tuple>
#include<string>
#include<cmath>
#include<climits>

using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV 1000000007
ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if(n&1==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
using namespace std;

int main(){
  ll n; cin >> n;
  rep(i,3501)
    rep(k,3501)
      if(i == 0 || k == 0)  continue;
      else if(4*i*k-n*i-n*k != 0 && n*k*i % (4*i*k-n*i-n*k) == 0){
        if(n*k*i / (4*i*k-n*i-n*k) > 0){
          cout << i << " " << k << " " << n*k*i / (4*i*k-n*i-n*k) << endl;
          return 0;
        }
      }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<int(n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;

int main(){
	ll K, N; cin >> K >> N;
	ll A[N], ma = 0;
	rep(i, N){
		cin >> A[i];
		
	}
	rep(i, N){
		if(i==0){
			if(ma < A[i] + K - A[N-1]) ma = A[i] + K - A[N-1];
		}else{
			if(ma < A[i] - A[i-1]) ma = A[i] - A[i-1];
		}
	}
	cout << K - ma << endl;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int Inf = (1<<30);
ll inf = (1LL<<60);
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 n;
	cin >> n;
	vector<int> a(n);
	int i;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	sort(a.begin(), a.end());
	for (i = 0; i < n - 2; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			auto itr = lower_bound(a.begin(), a.end(), a[i] + a[j]);
			int Not = distance(itr, a.end()); // デカ過ぎて使えないものの個数
			ans += n - Not - j - 1;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
import math

a, b = map(int, input().split())

price_a_min = math.ceil(a * 12.5)
price_a_max = math.ceil((a + 1) * 12.5) - 1
price_b_min = math.ceil(b * 10)
price_b_max = math.ceil((b + 1) * 10) - 1

if price_a_min > price_b_max or price_b_min > price_a_max:
  print(-1)
else:
  print(max(price_a_min, price_b_min))



Measured memory_bytes: 3060
#include<iostream>
#include<string>
using namespace std;
int main(){
  int a, b , c, n;
  cin >> a >> b >> c;
  n = c / a + 1;
  for(int i = 1; i < n; i++){
    int s = 0;
    s = a * i;
    if(b <= s){
      cout <<"OK\n";
      return 0;
    }
  }
  cout << "NG\n";
}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main(){
  char a[1000];
  int i=0,n,k;
  cin>>n>>k;
  while(1){
    scanf("%c",&a[i]);
    if(i!=0 && a[i]=='\n')break;
    i++;
  }
  a[k]-='A'-'a';
  for(i=1;i<=n;++i)cout<<a[i];
  cout<<endl;
  return 0;
}



Measured memory_bytes: 256
n, t = [int(i) for i in input().split()]
list_route = [list(map(int, input().split())) for list_route in range(n)]
ans = 1001
for i in range(0, n):
    if list_route[i][1] <= t and ans >= list_route[i][0]:
        ans = list_route[i][0]
if ans != 1001: print(ans)
else: print("TLE")

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

#define ll long int 

int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
 
ll findlcm(int arr[], int n) 
{ 
   
    ll ans = arr[0]; 
  
  
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 


int main(){
    
    long int n,i;
    cin>>n;
    int arr[n];
    for(i=0;i<n;i++) cin>>arr[i];
    
    double s=0;
    double lcm  = findlcm(arr,n);
    
    for(i=0;i<n;i++){
        s = s+(double)(lcm/arr[i]);
    }
   cout<<setprecision(9)<<lcm/s; 
    
    
    return 0;
}




Measured memory_bytes: 256
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys,collections

D,T,S = map(int,sys.stdin.readline().split())

if D <= T * S:
    print("Yes")
    exit()
print("No")


Measured memory_bytes: 9464
#include "bits/stdc++.h"
using namespace std;

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979323846

template<class T>bool ch1000000(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}


ll gcd(ll a, ll b){
  ll resi, g, l;
  if(a > b){
    g = a; l = b;
  }else if(b > a){
    g = b; l = a;
  }else{
    return a;
  }
  resi = g % l;
  if(resi != 0){
    return gcd(l, resi);
  }else{
    return l;
  } 
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int ans = 0;
int N, M, Q;

template<typename T>
void showall(vector<T> v){
  rep(i, 0, v.size()){
    cout << v[i] << " ";
  }
  cout << endl;
}

template<typename T>
ll com(T n, T m, T mod){
  ll a = 1, b = 1, ans;
  if(n == m || m == 0){
    ans = 1;
  }else{
    for(ll i = 0;i < m; i++){
      a *= n-i;
      a %= mod;
      b *= i+1;
      b %= mod;
    }
    ans = (a * powmod(b, mod-2, mod)) % mod;
  }
  
  return ans;
}



int main() {
  int N, S = 0;
  cin >> N;

  vector<int> a(N);

  rep(i, 0, N){
    cin >> a[i];
    S ^= a[i];
  }

  rep(i, 0, N){
    cout << (S^a[i]) << endl;
  }

  



  
  
  

  
  // cout << setprecision(8) << ans << endl;  // For double
}



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

int main() {
  string s,t;

  cin >> s >> t;

  int flag = 0;

  rep(i,s.size()){
    if(s.at(i) != t.at(i))
    flag ++ ;
  }

  cout << flag;



}

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

using namespace std;
using ll = long long int;

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

  vector<pair<int, int>> vec;
  int cnt_1 = 0;
  for (int i = 0; i < n; i++)
  {
    if (s[i] == '0')
    {
      int cnt_0 = 0;
      while (i < n && s[i] == '0')
      {
        cnt_0++;
        i++;
      }
      i--;
      vec.push_back({cnt_1, cnt_0});
      cnt_1 = 0;
    } else 
      cnt_1++;
    
  }

  int len = vec.size();

  int ans = cnt_1;
  for (int i = 0; i < len; i++) 
  {
    int sum = 0;
    int j = 0;
    for (j = 0; j < k && i + j < len; j++) 
    {
      sum += vec[i + j].first;
      sum += vec[i + j].second;
    }
    int last = i + j;
    if (last >= len)
      sum += cnt_1;
    else
      sum += vec[last].first;
    ans = max(ans, sum);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+10;
bool isprime[MAXN];
vector<int> v;

void sieve(int n)
{
    memset(isprime,true,sizeof(isprime));
    isprime[0]=isprime[1]=false;
    for(int i=2;i<=n;i++)
    {
        if(isprime[i])
        {
            for(int j=2*i;j<=n;j+=i)
                isprime[j]=false;
        }
    }
    for(int i=1;i<=n;i++)
    {
        if((i&1)&&isprime[i]&&isprime[(i+1)/2])
            v.push_back(i);
    }
}

int main()
{
    sieve(1e5+5);
    int q;
    while(scanf("%d",&q)!=EOF)
    {
        int L,R;
        for(int i=1;i<=q;i++)
        {
            scanf("%d%d",&L,&R);
            int t1=upper_bound(v.begin(),v.end(),R)-v.begin();
            int t2=upper_bound(v.begin(),v.end(),L-1)-v.begin();
            int res=t1-t2;
            printf("%d",res);
            if(i!=q) printf(" ");
            else printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 768
#include <iostream>
using namespace std;


int main(){
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int dx = x2 - x1;
    int dy = y2 - y1;
    int x3 = x2 - dy;
    int y3 = y2 + dx;
    int x4 = x3 - dx;
    int y4 = y3 - dy;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;

    return 0;
}

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

int main(void)
{
    int N, M;
    cin >> N >> M;

    int ans = 0;
    if (N >= 2)
        ans += N * (N - 1) / 2;
    if (M >= 2)
        ans += M * (M - 1) / 2;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
cost = 0  # 支払うお金
numofdrink = 0  # 手に入れたドリンクの数
price = [0] * N
for i in range(N):
    price[i] = [0] * 2
    price[i][0], price[i][1] = map(int, input().split())
price = sorted(price)

ite = 0
while (numofdrink < M):
    if numofdrink + price[ite][1] >= M:
        cost += (M - numofdrink) * price[ite][0]
    else:
        cost += price[ite][0] * price[ite][1]

    numofdrink += price[ite][1]
    ite += 1

print(cost)


Measured memory_bytes: 20776
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    string s;
    cin >> s;
    int n = 0;
    for (char c : s) {
        if (c == 'o') {
            n++;
        }
    }
    cout << 700 + n * 100;
}


Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		
		int ans = 700;
		
		if (s.charAt(0) == 'o') ans += 100;
		if (s.charAt(1) == 'o') ans += 100;
		if (s.charAt(2) == 'o') ans += 100;
		
		System.out.println(ans);
	}
	
}

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

ll fun(ll b, ll n){
  ll ans = 0;
  while(n > 0){
    ans += n % b;
    n /= b;
  }

  return ans;
}

int main(){
  ll n,s;

  scanf("%lld", &n);
  scanf("%lld", &s);

  ll i = 2;
  int f = 0;
  ll ans;

  if(s > n){
    printf("-1\n");
    return 0;
  }

  if(s == n){
    printf("%lld", n + 1);
    return 0;
  }

  for(i = 2;i*i <= n;i++){
    if(fun(i,n) == s){
      printf("%lld\n", i);
      return 0;
    }
  }

  ll t = n - s;
  ans = -1;

  for(i = 1;i*i < n;i++){
    ll b = t/i + 1;

    if(b >= 2 && fun(b,n) == s) ans = b;
  }

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


  return 0;
}

Measured memory_bytes: 256
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def bs(ar,eq,n) en=(eq==1 ? :>= : :>); ar.bsearch_index{|x|x.send(en,n)} end
def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
d=gsmi

sum=0
n.times do |i|
  (i+1).upto(n-1) do |j|
    sum+=d[i]*d[j]
  end
end

puts sum

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	int n; cin >> n;
	vector<ll> a(n),b(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		cin >> b[i];
	}
	ll sum=0;
	ll cnt=0;
	for(int i=0;i<n;i++){
		if(a[i]<b[i]){
			cnt+=(b[i]-a[i])/2;
		}
		else if(a[i]>b[i]){
			sum+=(a[i]-b[i]);
		}
	}
	if(sum<=cnt){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}


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

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int A = sc.nextInt();
        int B = sc.nextInt();
        System.out.println(Math.max(Math.max(A+B,A-B),A*B));
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 20692
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int mat[][] = new int[n][m];
		int vec[] = new int[m];
		int res;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				mat[i][j] = scan.nextInt();
			}
		}
		for(int i = 0; i < m; i++){
			vec[i] = scan.nextInt();
		}
		scan.close();
		for(int i = 0; i < n; i++){
			res = 0;
			for(int j = 0; j < m; j++){
				res += mat[i][j] * vec[j];
			}
			System.out.println(res);
		}
	}
}

Measured memory_bytes: 40608
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <sstream>
#include <string>
#include <climits>
#include <set>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <numeric>
#include <map>
using namespace std;

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

	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		double x, y;
		cin >> x >> y;

		if (sqrt(x * x + y * y) <= d)
			cnt++;
	}

	cout << cnt;
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,z=0;
	cin>>a>>b;
	z=a+b;
	if(a>=0&&b>=0){
	if(z>=24)
	z=z-24;
	else 
	z=a+b;
}
	cout<<z;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

int main(void) {
  int N;
  scanf("%d", &N);

  int bad = 1;
  REP(i, N) {
    int x;
    scanf("%d", &x);
    if (x % 2 == 0) bad *= 2;
  }

  int all = 1;
  REP(i, N) all *= 3;

  int ans = all - bad;
  printf("%d\n", ans);
  return 0;
}


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

int main()
{
  int H, W;
  cin >> H >> W;

  while( H != 0 and W != 0 ) {
    string block = "#.";
    int flag = 0;
    for( int i = 0; i < H; i++ ) {
      for( int j = 0; j < W; j++ ) {
        cout << block[ flag++ % 2 ];
      }

      if( W % 2 == 0 ) {
        flag++;
      }
      cout << endl;
    }
    cout << endl;
    cin >> H >> W;
  }

  return 0;
}

Measured memory_bytes: 3148
// abc066_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    deque<int> ans;
    REP(i, N){
        if (i % 2 == 0){
            ans.emplace_back(A[i]);
        } else{
            ans.emplace_front(A[i]);
        }
    }

    if (N % 2 == 1){
        reverse(ALL(ans));
    }

    print_line(ans, N);

    return 0;
}


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

const int MOD = 1000000007;

int main(void){
    int N, K, Abuf;
    vector<int> Aplus;
    vector<int> Aminus;
    int numAzero = 0;
    cin >> N >> K;
    for(int i=0; i<N; i++){
        cin >> Abuf;
        if(Abuf >= 0)Aplus.push_back(Abuf);
        if(Abuf < 0)Aminus.push_back(Abuf);
    }
    if(Aminus.size() > 1)sort(Aminus.begin(), Aminus.end());
    if(Aplus.size() > 1)sort(Aplus.begin(), Aplus.end(), greater<int>());
    if(K == N){
        long long res = 1LL;
        for(int i=0; i<Aplus.size(); i++){
            res = res * Aplus[i] % MOD;
        }
        for(int i=0; i<Aminus.size(); i++){
            res = res * (MOD + Aminus[i]) % MOD;
        }
        cout << res << endl;
    }else if((Aminus.size() == N)&&(K%2 == 1)){
        long long resMinus = 1LL;
        for(int i=0; i<K; i++){
            resMinus = resMinus * abs(Aminus[N-i-1]) % MOD;
        }
        cout << (MOD - resMinus) % MOD << endl;
    }else{
        long long resPlus = 1LL;
        int countminus = 0;
        int countplus = 0;
        while(countminus + countplus < K){
            if((countminus < (int)Aminus.size()-1)&&(countplus < (int)Aplus.size()-1)&&(countminus + countplus < K-1)){
                if((long long)Aminus[countminus]*Aminus[countminus+1] >= (long long)Aplus[countplus]*Aplus[countplus+1]){
                    resPlus = resPlus * abs(Aminus[countminus]) % MOD;
                    resPlus = resPlus * abs(Aminus[countminus+1]) % MOD;
                    countminus += 2;
                }else{
                    resPlus = resPlus * abs(Aplus[countplus]) % MOD;
                    resPlus = resPlus * abs(Aplus[countplus+1]) % MOD;
                    countplus += 2;
                }
            }else if((countminus < (int)Aminus.size()-1)&&(countminus + countplus < K-1)){
                resPlus = resPlus * abs(Aminus[countminus]) % MOD;
                resPlus = resPlus * abs(Aminus[countminus+1]) % MOD;
                countminus += 2;
            }else{
                resPlus = resPlus * abs(Aplus[countplus]) % MOD;
                countplus += 1;
            }
        }
        cout << resPlus << endl;
    }
    return 0;
}

Measured memory_bytes: 4256
#include <iostream>
using namespace std;
int main() {
  long s, c;
  long n=0;
  cin >> s >> c;
  while(s>=1 && c>=2){
      s--;
      c-=2;
      n++;
  }

  while(c>=4){
      c-=4;
      n++;
  }

  cout << n << endl;

  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = input()
    if "9" in N:
        print(Yes)
    else:
        print(No)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <sstream>

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> a(H);
    for (int h = 0; h < H; ++h) {
        a[h].resize(W);
        for (int w = 0; w < W; ++w) {
            cin >> a[h][w];
        }
    }
    vector<vector<int>> operations;
    for (int h = 0; h < H; ++h) {
        for (int w = 0; w < W-1; ++w) {
            if (a[h][w] % 2 != 0) {
                --a[h][w];
                ++a[h][w+1];
                operations.push_back({h, w, h, w+1});
            }
        }
    }
    for (int h = 0; h < H-1; ++h) {
        if (a[h][W-1] % 2 != 0) {
            --a[h][W-1];
            ++a[h+1][W-1];
            operations.push_back({h, W-1, h+1, W-1});
        }
    }
    cout << operations.size() << endl;
    for (auto op: operations) {
        cout << op[0]+1 << " " << op[1]+1 << " " << op[2]+1 << " " << op[3]+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 9904
#include<iostream>
using namespace std;

int count=0; 
int BubbleSort(int A[],int N){
   
    bool flag=1;
    while(flag){
        flag=0;
        for(int j=N-1;j>=1;j--){
            if(A[j]<A[j-1]){
                swap(A[j],A[j-1]);
                count++;
                flag=1;
            }
        }
    }
    return count;
}

int main(){
    int n=0;
    cin >> n;
    int array[n];
    for(int i=0;i<n;i++){
        cin >> array[i];
    }
    int i = BubbleSort(array,n);
    for(int i=0;i<n-1;i++){
        cout << array[i] << " ";
    }
    cout << array[n-1] << endl << count << endl;
    return 0;
     
}

Measured memory_bytes: 3100
#include <iostream>
using namespace std;

int n;
int a[101];

void show_elements(){
  for(int i=0; i<n-1; i++){
    cout << a[i] << " ";
  }
  cout << a[n-1] << endl;
  return ;
}

void solve(){
  show_elements();
  for(int i=1; i < n; i++){
    int key = a[i];
    int j = i-1;
    while (j >= 0 && a[j] > key){
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = key;
    show_elements();
  }
  return ;
}
int main(){
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  solve();
  return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 1e9 + 7;
const int maxn = 500007;

void go() {
    int n;
    cin >> n;
    vector<int>v1,v2;
    f(n) {
        int x;
        cin >> x;
        v1.pb(x);
    }
    f(n) {
        int x;
        cin >> x;
        v2.pb(x);
    }
    reverse(all(v2));
    int val = 74751;
    f(n) {
        if (v1[i] == v2[i]) {
            val = v1[i];
        }
    }
    if (val == 74751) {
        cout << "Yes\n";
        for (auto &i : v2) {
            cout << i <<' ';
        }
        cout << '\n';
        return;
    }
    vector<int>ok;
    f(n) {
        if (v1[i] != val && v2[i] != val) {
            ok.pb(i);
        }
    }
    f(n) {
        if (v1[i] == v2[i]) {
            if (!ok.size()) {
                cout << "No\n";
                return;
            }
            swap(v2[i],v2[ok.back()]);
            ok.pop_back();
        }
    }
    cout << "Yes\n";
        for (auto &i : v2) {
            cout << i <<' ';
        }
        cout << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }
}


Measured memory_bytes: 6348
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

typedef complex<double> C;
typedef pair<C,C> pp;
typedef vector<C> VP;
typedef vector<pp> VPP;
#define eq(a,b) (fabs(a-b)<eps)
#define veq(a,b) (eq(a.real(),b.real())&&eq(a.imag(),b.imag()))
const C O{0,0};

void In(C& p){
	double x,y;
	cin>>x>>y;
	p=C(x,y);
}

void Out(C p){
	cout<<(int)p.real()<<' '<<(int)p.imag()<<endl;
}

double Dot(C p,C q){
	return p.real()*q.real()+p.imag()*q.imag();
}

double Det(C p,C q){
	return p.real()*q.imag()-q.real()*p.imag();
}

int Clock(C a,C b,C c){
	double t=Det(b-a,c-a);
	if(t>eps) return 1;
	if(t<-eps) return -1;
	if(Dot(b-a,c-a)<-eps) return 2;
	if(Dot(a-b,c-b)<-eps) return -2;
	return 0;
}

bool is_Containment(VP p,C x){
	bool B=0;
	p.push_back(p[0]);
	int n=p.size();
	for(int i=0;i<n-1;i++){
		C a=p[i]-x,b=p[i+1]-x;
		if(a.imag()>b.imag()) swap(a,b);
		if(a.imag()<=0&&b.imag()>0&&Det(a,b)<0) B=!B;
	}
	return B;
}

int n,q;
VP a;
C x;

int main(){
	cin>>n;
	a=VP(n);
	for(auto &i:a) In(i);
	cin>>q;
	for(int i=0;i<q;i++){
		bool B=0;
		In(x);
		for(int i=0;i<n;i++) if(!Clock(a[i],a[(i+1)%n],x)) B=1;
		if(B) cout<<1<<endl;
		else cout<<(is_Containment(a,x)?2:0)<<endl;
	}
}


Measured memory_bytes: 3184
#include <iostream>
using namespace std;

int main(void){
  int a;
  int n,ans;
  
  cin >> n;
  ans = 0;
  for (int i=0; i<n; i++){
    for (cin >> a; a%2==0; a/=2) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <regex>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    long w, h;
    cin >> w >> h;
    
    vector<P> v;
    REP(i,w) {
        long a;
        cin >> a;
        v.push_back(P(a,0));
    }
    REP(i,h) {
        long a;
        cin >> a;
        v.push_back(P(a,1));
    }
    
    sort(v.begin(), v.end());
    
    long ans = 0;
    long vc = 0, cc = 0;
    long ec = 0;
    REP(i,v.size()) {
        if (ec == (w + 1) * (h + 1) - 1) {
            break;
        }
        if (v[i].second == 0) {
            cc++;
            ans += v[i].first * (h + 1 - vc);
            ec += h + 1 - vc;
        } else {
            vc++;
            ans += v[i].first * (w + 1 - cc);
            ec += w + 1 - cc;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6384
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;

int main() {
    int N,K;
    std::cin>>N;
    std::cin>>K;
    int a[N];
    for(int i=0;i<N;i++){
        cin>>a[i];
    }


    sort(a,a+N);
    int min=1e9;
    for(int i=0;i<N-K+1;i++){
        if(min > a[i+K-1]-a[i]) min = a[i+K-1]-a[i];
    }

    cout << min << endl;
}


Measured memory_bytes: 640
from collections import defaultdict
dic = defaultdict(int)
n,m = map(int, input().split())
for _ in range(m):
  a, b = map(int, input().split())
  dic[a] += 1
  dic[b] += 1
flag = True
for k,v in dic.items():
  if v % 2 == 1:
    flag = False
    break
if flag:
  print("YES")
else:
  print("NO")


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

int main() {
    ll x, a = 100, year = 0;
    cin >> x;
    while (a < x) {
        a += a / 100;
        year++;
    }
    cout << year << endl;
    return 0;
}

Measured memory_bytes: 3608
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        static final int mod = 1000000007;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int N = Integer.parseInt(in.next());
            int M = Integer.parseInt(in.next());
            int[] a = new int[N];
            boolean[] broken = new boolean[N + 1];
            for (int i = 0; i < M; i++) {
                a[i] = Integer.parseInt(in.next());
                broken[a[i]] = true;
            }
            int[] dp = new int[N + 1];
//        Arrays.fill(dp,0);

            //dp[x]=dp[x-1]+dp[x-2]
            dp[0] = 1;
            if (broken[1]) {
                dp[1] = 0;
            } else {
                dp[1] = 1;
            }
            for (int i = 2; i <= N; i++) {
                if (!broken[i - 1]) dp[i] += dp[i - 1];
                if (!broken[i - 2]) dp[i] += dp[i - 2];
                dp[i] %= mod;
            }

            out.println(dp[N]);

        }

    }
}



Measured memory_bytes: 47136
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)


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

if k == 10:
    print(len(str(n)))
else:
    print(len(Base_10_to_n(n,k)))

Measured memory_bytes: 3060
import itertools
N=int(input())
S=list(input())
SS=set(S)
SS=list(SS)
num = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
num=[x for x in num if x in SS]
number=["".join(i) for i in itertools.product(num,repeat=3)]

ans=0
for i in number:
    count=0

    for s in range(N):
        if i[count]==S[s]:
            count+=1
            if count==2:
                if i[2] in S[s+1:]:
                    ans+=1
                break


print(ans)




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

int main(){
    long long n,k;
    cin>>n>>k;
    if(n<k){
        cout<<min(n,(k-n))<<"\n";
    }else if(n%k==0){
        cout<<"0\n";
    }else{
        long long x=n%k;
        long long y=abs(x-k);
        long long z=abs(y-k);
        long long a=abs(z-k);
        cout<<min(x,min(y,min(z,a)))<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using ll=long long;
using namespace std;
const auto mod=1e9+7;

template <typename T>
using GPQ=priority_queue<T,vector<T>,greater<T>>;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int n; cin >> n;
  double p=(double)(n-n/2)/(double)n;
  cout << p << endl;
}

Measured memory_bytes: 256
Day_Week_S = input()

if Day_Week_S == 'SUN':
    print(7)
elif Day_Week_S == 'MON':
    print(6)
elif Day_Week_S == 'TUE':
    print(5)
elif Day_Week_S == 'WED':
    print(4)
elif Day_Week_S == 'THU':
    print(3)
elif Day_Week_S == 'FRI':
    print(2)
elif Day_Week_S == 'SAT':
    print(1)

Measured memory_bytes: 8980
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████   
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
const double EPS = 1e-9;
#define INF (1LL<<60)
#define fs first
#define sc second
#define pb push_back
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  vec a(5);
  REP(i,5) cin >> a[i];
  
  int k;
  cin >> k;

  REP(i,5){
    REP(j,5){
      if(abs(a[i]-a[j] > k)){
        cout << ":(" << endl;
        return 0;
      }
    }
  }

  cout << "Yay!" << endl;

  return 0;
}

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


int main() {
    const int MAX_N = 20;
    const int MAX_D = 20;
	int N, D, p[MAX_N][MAX_D];
    cin >> N >> D;
    for (int i = 0; i < N; ++i){
        for (int j = 0; j < D; ++j){
            cin >> p[i][j];
        }
    }

    int ans = 0;
    for (int i = 0; i < N - 1; ++i){
        for (int j = i+1; j < N; ++j){
            int dis = 0;
            for (int k = 0; k < D; ++k){
                int a = p[i][k];
                int b = p[j][k];
                dis += (a-b)*(a-b);
            }
            int c = (int) sqrt( (float)dis );
            if ( dis == c*c ) ans++;
        }
    }

    cout << ans << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  map<string, int> m;

  for (int i=0; i<N; i++) {
    cin >> S.at(i);
  }

  // sort(S.begin(), S.end());
  // cout << "===sorted===" << endl;
  // for (auto x : S) cout << x <<endl;

  for (int i=0; i<N; i++) {
    m[S.at(i)]++;
  }
  // cout << "===map===" << endl;
  // for (auto iter = m.begin(); iter != m.end(); iter++) {
  //     // first: key, second: value
  //     cout << iter->first << ":" << iter->second << endl;
  // }
  // cout << "=== ans ===" << endl;
  int maxv=0;
  for (const auto &x : m) {
    int v = x.second;
    if (v > maxv) maxv = v;
  }
  for (auto i=m.begin(); i!=m.end(); i++) {
    if (i->second == maxv) {
      cout << i->first << endl;
    }
  }

}

Measured memory_bytes: 26752
void main() {
	auto N = rl;
	dchar[] res;
	while(N != 0) {
		N--;
		res ~= ('a' + N % 26);
		N /= 26;
	}
	res.reverse.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

long rl() {
	return readAs!long;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 2764
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <cmath>

using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

int main() {
	string s;

	cin >> s;
	int n = s.size();
	int front_x = 0;
	int back_x = n - 1;
	int ans = 0;

	while(front_x < back_x) {
		if (s.at(front_x) == s.at(back_x)) {
			front_x++;
			back_x--;
			continue;
		}
		if (s.at(front_x) == 'x') {
			ans ++;
			front_x++;
			continue;
		}
		if (s.at(back_x) == 'x') {
			ans ++;
			back_x--;
			continue;
		}
		cout << -1 << endl;
		return 0;


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

Measured memory_bytes: 512
int b[5];main(i,s,w){while(1){for(s=i=0;i-5&&scanf("%d",b+i);s|=1<<--b[i++]);if(i=*b<0)return 0;for(w=s-5?s-6?0:1:2;printf("%d\n",s-1&&s-2&&s-4&&s-7?b[i]-w?2:1:3)&&++i-5;);}}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    int n;
    cin >> n;
    vector<int> ans(n * n, 0);
    vector<pair<int, int>> p;
    rep(i, n) {
        int x;
        cin >> x;
        x--;
        ans[x] = i + 1;
        p.push_back({x, i + 1});
    }
    sort(ALL(p));
    int x = 0;
    for(auto q : p) {
        rep(i, q.second - 1) {
            while(ans[x])
                x++;
            if(x > q.first) {
                cout << "No" << endl;
                return 0;
            }
            ans[x] = q.second;
        }
    }
    sort(ALL(p), greater<pair<int, int>>());
    x = n * n - 1;
    for(auto q : p) {
        rep(i, n - q.second) {
            while(ans[x])
                x--;
            if(x < q.first) {
                cout << "No" << endl;
                return 0;
            }
            ans[x] = q.second;
        }
    }
    cout << "Yes" << endl;
    rep(i, n * n) cout << ans[i] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 2176