akhauriyash/Code-Regression huggingface dataset:
import sys
import itertools
import math
input = lambda: sys.stdin.readline().rstrip()

def main():
    n, d = map(int, input().split())
    x = []
    for _ in range(n):
        x.append(list(map(int, input().split())))
    ans = 0
    for comb in itertools.combinations(range(n), 2):
        dis = 0
        for i, j in zip(x[comb[0]], x[comb[1]]):
            dis += (i - j)**2
        if str(math.sqrt(dis)).split('.')[-1] == '0':
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9200
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.Math;
import java.math.*;

public class Main {
    public final static long MOD = 1000000007;

    public static void main(String[] args) {
        FS reader = new FS();
        // write reader
        int H = reader.nextInt();
        int A = reader.nextInt();
        int ans = 0;
        while (H > 0) {
            H -= A;
            ans++;
        }
        System.out.println(ans);
    }

    // Read Class
    static class FS {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
    
        private int readByte() { return hasNextByte() ? buffer[ptr++] : -1;}
        private boolean isPrintableChar(int c) {return 33 <= c && c <= 126;}
        private void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public int nextInt() {
            return (int)nextLong();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if(b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
    }
}



Measured memory_bytes: 23124
r, c = map(int, input().split())
mat = [input() for _ in range(r)]
dp = [[0]*c for _ in range(r)]
for i in range(c):
    if mat[0][i] == '#':
        break
    dp[0][i] = 1
for i in range(r):
    if mat[i][0] == '#':
        break
    dp[i][0] = 1
for i in range(1, r):
    for j in range(1, c):
        if mat[i][j] != '#':
            dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % (10**9 + 7)
print(dp[-1][-1])

Measured memory_bytes: 51568
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int main()
{
	long long h, w;	
	
	scanf("%lld%lld", &h, &w);
	
	if ((h == 1) || (w == 1)) {
		printf("1\n");
		return 0;
	}
	
	long long s = h * w;
	
	long long ans;
	
	if (s % 2 == 0)
		ans = s / 2;
	else
		ans = s / 2 + 1;
		
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	char word[1201];
	int i;

	scanf("%[^\n]", word);

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

	printf("%s\n", word);

	return 0;
}

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

int main(){
    int N,K;
    cin >> N >> K;
    long long mod = 1000000007;
    long long res[K+1];
    long long C[N+1][N+1];

    for(int i = 0; i <= N; i++){
        C[i][0] = 1;
        C[i][i] = 1;
        for(int j = 1; j < i; j++){
            C[i][j] = (C[i-1][j-1] + C[i-1][j]) % mod;
        }
    }

    for(int i = 1; i <= K; i++){
        if(N-K+1 >= i){
            res[i] = (C[N-K+1][i] * C[K-1][i-1]) % mod;
        }
        else{
            res[i] = 0;
        }
    }

    for(int i = 1; i <= K; i++){
        cout << res[i] << endl;
    }
}

Measured memory_bytes: 31232
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int countA = 1;
		int countB = 1;

		char a;
		char b;

		a = s.charAt(0);
		for (int j = 1; j < s.length(); j++) {
			b = s.charAt(j);
			if (a == b ) {
				countA++;
			}
		}
//		System.out.println(countA);

		if (countA == 2) {
			if (s.charAt(0) != (s.charAt(1))) {
				a = s.charAt(1);
				for (int j = 2; j < s.length(); j++) {
					b = s.charAt(j);
					if (a ==  b) {
						countB++;
					}
				}
			} else {
				a = s.charAt(2);
				b = s.charAt(3);
				if (a == b) {
					countB++;
				}
			}
		}
//		System.out.println(countB);

		if (countA == 2 & countB == 2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 22612
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
from fractions import gcd

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(A, B, C, D):
    ac = (A-1)//C
    ad = (A-1)//D
    acd = (A-1)//(C * D // gcd(C, D))
    bc = B//C
    bd = B//D
    bcd = B//(C * D // gcd(C, D))
    R = B - (bc + bd - bcd)
    L = (A-1 - (ac + ad - acd))
    return  R - L


def main():
    A, B, C, D = read_int_n()
    print(slv(A, B, C, D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6460
using System;
using System.Linq;
namespace Myatcoder
{
    public class Program
    {
        public static void Main()
        {
            string str = Console.ReadLine();
            int n = int.Parse(str);
            int a = 0;
            for (int i = 0; i < str.Length; i++) {
                a += int.Parse(str[i].ToString());
            }
            if (n % a == 0) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 11092
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
		//System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		double x1 =scan.nextDouble();
		double y1 =scan.nextDouble();
		double x2 =scan.nextDouble();
		double y2 =scan.nextDouble();
		double keisan =0.0;
		keisan = Math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
		System.out.println(keisan);
	}
}

Measured memory_bytes: 27920
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main() {
    int n,k,q;cin >> n >> k >> q;
    vector<lli> a(n);
    rep(i,n)cin >> a[i];
    lli ans = 1e18;
    rep(i,n){
        vector<vector<lli>> tmps;
        vector<lli> tmp;
        for(int j = 0;j<n;j++){
            if(a[j] < a[i]){
                tmps.push_back(tmp);
                tmp.clear();
            }else {
                tmp.push_back(a[j]);
            }
        }
        tmps.push_back(tmp);
        tmp.clear();
        int q_ = q;
        vector<lli> cand;
        for(auto &s:tmps){
            if(s.size() < k){
                continue;
            }
            else {
                sort(s.begin(),s.end());
                reverse(s.begin(),s.end());
                for(int l = k-1;l < s.size();l++){
                    cand.push_back(s[l]);
                }
            }
        }
        if(cand.size() < q){
            continue;
        }
        sort(cand.begin(),cand.end());
        ans = min(ans,cand[q-1] - cand[0]);
    }
    cout << ans << endl;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

int main() {
  ll N, M;
  scanf("%lld %lld", &N, &M);

  ll sum = 0;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    A[i] = v;

    sum += v;
  }

  ll num = 0;
  for (ll i = 0; i < N; i++) {
    ll v = A[i];

    if ((4 * M) * v < sum) {
    } else {
      num++;
    }
  }

  if (num >= M) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))

using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;

int main(void){
    ll res;
    for(int n; cin >> n, n; cout << res << endl){
        res = 0;
        vi c(n);
        rep(i, n) cin >> c[i];

        sort(ALL(c));
        rep(i, n) res += c[i] * (n - i - 1);
    }

    return 0;
}

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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long long int n,i,j,k,x,y,z;
    cin>>n;
    pair<long long int,long long int>A[n+1];
    for(i=1;i<=n;i++){
        cin>>A[i].first>>A[i].second;
    }
    bool ok=false;
    for(i=2;i<n;i++){
        if(A[i-1].first==A[i-1].second&&A[i].first==A[i].second&&A[i+1].first==A[i+1].second)
            ok=true;
    }
    if(ok==true)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 3604
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

H, W = MAP()
S = [input() for _ in range(H)]
dy = (1, 0, -1, 0)
dx = (0, -1, 0, 1)

def diff_max(start_y, start_x):
	check = [[-1]*W for _ in range(H)]
	check[start_y][start_x] = 0
	q = deque([(start_y, start_x)])

	while q:
		y, x = q.popleft()
		for i in range(4):
			ny = y + dy[i]
			nx = x + dx[i]
			if 0 <= ny < H and 0 <= nx < W:
				if check[ny][nx] == -1 and S[ny][nx] == ".":
					check[ny][nx] = check[y][x] + 1
					q.append((ny, nx))

	return max([max(x) for x in check])



ans = -INF
for i in range(H):
	for j in range(W):
		if S[i][j] == ".":
			ans = max(ans, diff_max(i, j))

print(ans)


Measured memory_bytes: 67544
/*
	*	Created By: 'Present_Sir'
	*	Created On: Friday 04 September 2020 11:30:23 AM IST
*/

#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define sz(v) ((int)v.size())
#define lgt(s) ((int)s.length())
#define int long long
using namespace std;

class Solver{
    private:
        set < string > s;
    public:
        void test(){
            //int t; cin>>t; for(int i=1; i<=t; ++i)
            {
                //cout<<"Case #"<<i<<": ";
                this->solve();
            }
        }
        
        void solve(){
            int n;
            cin>>n;
            
            helper(0, n, 0, "");

            for(auto i:s) cout<<i<<endl;
        }

        void helper(int cur, int n, int prev, string k){
            if(n == cur){
                cout<<k<<endl;
                //s.insert(k);
                return;
            }
            
            for(int i=0; i<=prev; ++i){
                if(i==prev)helper( cur+1, n, prev+1, k+(char)(i+'a') );
                else helper(cur+1, n, prev, k+ (char)(i+'a'));
            }
        }
};


int32_t main(){
    IOS;
    Solver S;
    S.test();
    return 0;
}



Measured memory_bytes: 3656
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;
#define ll int64_t
const long mod = 1e9 + 7;


const long LINF = 1e13;
const long LLINF = 1e18;
const long ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


// 最大公約数
long euclid_gcd(long a, long b) {
  if (a < b) euclid_gcd(b, a);//aを大きい数にする.

  // rをaをbで割った剰余とする
  // r=0になるまで繰り返す
  // bはr=0になる直前のr
  long r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }

  return b;
}





int main() {

  long n;

  cin >> n;

  vector<long> a(n);
  cin >> a;


  long ans = a[0];

  for (int i = 1; i < n; ++i){
    ans = euclid_gcd(ans,a[i]);
  }



  cout << ans;


}




















Measured memory_bytes: 1024
# include<bits/stdc++.h>
using namespace std;
int main(){
string n;
cin >> n;
for(int i = 0; i < 3; i++){
	if(n[i]=='1')
    	n[i] = '9';
    else if (n[i]=='9')
    	n[i] = '1';
}
cout << n << '\n';

	return 0;
}

Measured memory_bytes: 256
x, y = map(int, input().split())

if x == 1 or x == 3 or x == 5 or x == 7 or x == 8 or x == 10 or x == 12:
    if y == 1 or y == 3 or y == 5 or y == 7 or y == 8 or y == 10 or y == 12:
        print('Yes')
    else:
        print('No')

if x == 4 or x == 6 or x == 9 or x == 11:
    if y == 4 or y == 6 or y == 9 or y == 11:
        print('Yes')
    else:
        print('No')

if x == 2:
    if y == 2:
        print('Yes')
    else:
        print('No')

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

#define int long long

int n;
string s;
vector<int> v; // sを数値に変換した配列。#は1で.は0
int dp[222222][5]; // dp[i][j]: 直前の要素がjで、i番目の要素まで見た時の最小の操作回数

int dfs(int idx, int old) {
  if (idx >= v.size()) {
    return 0;
  }

  if (dp[idx][old] != -1) {
    return dp[idx][old];
  }

  int ret = 0;

  int a = dfs(idx+1, 1) + (v[idx] == 0); // 現在の要素を'#'にする
  int b = (old == 1 ? 1e18 : dfs(idx+1, 0) + (v[idx] == 1)); // 現在の要素を'.'にする
  ret += min(a, b);

  return dp[idx][old] = ret;
}

signed main() {
  cin >> n >> s;
  v.push_back(-1); // つじつま合わせ的なやつ
  for (int i = 0; i < n; i++) {
    int val = s[i] == '#' ? 1 : 0; // ここから先では「#」を1、「.」を0として扱う
    v.push_back(val);
  }

  // dpテーブルを初期化
  for (int i = 0; i < 222222; i++) { for (int j = 0; j < 5; j++) { dp[i][j] = -1; } }

  int ans = dfs(0, 3); // 3は0番目の要素の前の要素がどの記号化を表す。-1番目の要素は存在しないので適当に3と置いた

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 20212
#include <iostream>

using namespace std;

int gcd(int a, int b){ return a%b ? gcd(b, a%b) : b; }

int main(){
    int N, K;
    while(cin >> N >> K){
        int g = 0;
        cin >> g;
        int m = g;
        for(int i=1;i<N;i++){
            int t; cin >> t;
            m = max(t, m);
            g = gcd(g, t);
        }
        if(K <= m && K%g == 0){
            cout << "POSSIBLE" << endl;
        } else {
            cout << "IMPOSSIBLE" << endl;
        }
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N; cin >> N;
  int hate[N][N] = {};
  bool exist[N][N]; rep(i,N) fill_n(exist[i],N,true);
  rep(i,N) rep(j,N) hate[i][j] = min(min(i,(N-1)-i),min(j,(N-1)-j));

  int result = 0;
  rep(i,N*N) {
    int P; cin >> P; P--;
    int pi = P/N, pj = P%N;
    exist[pi][pj] = false;

    queue<pair<int, int>> q; q.push(make_pair(pi,pj));
    while (q.size()) {
      int ni = q.front().first, nj = q.front().second; q.pop();
      if (ni!=0  &&hate[ni-1][nj]>hate[ni][nj]+exist[ni][nj]) { hate[ni-1][nj] = hate[ni][nj]+exist[ni][nj]; q.push(make_pair(ni-1,nj)); }
      if (ni!=N-1&&hate[ni+1][nj]>hate[ni][nj]+exist[ni][nj]) { hate[ni+1][nj] = hate[ni][nj]+exist[ni][nj]; q.push(make_pair(ni+1,nj)); }
      if (nj!=0  &&hate[ni][nj-1]>hate[ni][nj]+exist[ni][nj]) { hate[ni][nj-1] = hate[ni][nj]+exist[ni][nj]; q.push(make_pair(ni,nj-1)); }
      if (nj!=N-1&&hate[ni][nj+1]>hate[ni][nj]+exist[ni][nj]) { hate[ni][nj+1] = hate[ni][nj]+exist[ni][nj]; q.push(make_pair(ni,nj+1)); }
    }

    result += hate[pi][pj];
    // rep(i,N) debug(hate[i],hate[i]+N); cout << endl;
  }

  cout << result << endl;
  return 0;
}

Measured memory_bytes: 4852
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
n = ip()                                     #入力整数1つ
#n,q= (int(i) for i in input().split())       #入力整数横2つ以上
a = [int(i) for i in input().split()]        #入力整数配列
#b = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
a.sort()
pos = [0]
p = a[0]
for i in range(n):
    if a[i] != p:
        p = a[i]
        pos.append(i)
s = [1]
if n == 2:
    if a[1]-a[0]==1:s.append(2)
for i in range(len(pos)):
    p = a[pos[i]]
    position = pos[i]
    score = 0
    while p +  2 >= a[position]:
        position+=1
        score+=1
        if position == n: break
  #      print(position,end='')
    s.append(score)
 #   print()
print(max(s))

Measured memory_bytes: 24464
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
ll f1(ll x)
{
    if(x==0)
        return 1;
    ll ans=(expo(2,x,hell)+(x*expo(2,x-1,hell))%hell)%hell;
    return ans;
}

ll f2(ll x)
{
    return expo(2,x,hell);
}
void solve()
{
    ll n,x;
    cin>>n;
    vi v;
    rep(i,0,n)
    {
        cin>>x;
        v.pb(x);
    }
    ll ans=0,res;
    sort(all(v));
    reverse(all(v));
    rep(i,0,n)
    {
        res=(f1(i)*f2(n-i-1))%hell;
        res=(res*v[i])%hell;
        ans=(ans+res)%hell;
    }
    // cout<<ans<<endl;
    ans=(ans*expo(2,n,hell))%hell;
    cout<<ans<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

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

using namespace std;

typedef long long LL;

const int N = 1010;

int n, a[N];
int maxa, mina = 0x3f3f3f3f;

int main()
{
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < n; i++)
    {
        mina = min(mina, a[i]);
        maxa = max(maxa, a[i]);
    }
    
    cout << abs(maxa - mina) << endl;
    return 0;
}


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

typedef long long ll;

ll mod = 1000000007;

int main(){
    int a, b;
    cin >> a >> b;
    if(b == 1) cout << 0 << endl;
    else{
        if(a >= b) cout << 1 << endl;
        else{
            b = b - a;
            int rem = b % (a - 1);
            int cnt = b / (a - 1);
            if(rem > 0) cout << cnt + 2 << endl;
            else cout << cnt+1 << endl;
        }
    }
}

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

using namespace std;

#ifdef SG
	#include <debug.h>
#else
	#define show(...)
	#define debug(...)
	#define deepen(...)
	#define timer(...)
#endif

#define ARG4(_1,_2,_3,_4,...) _4

#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)

#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define ve vector
#define pa pair
#define tu tuple
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fs first
#define sc second
#define all(a) (a).begin(), (a).end()
#define sz(a) ((int)(a).size())

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned char uc;
typedef pa<int, int> pii;
typedef pa<int, ll> pil;
typedef pa<ll, int> pli;
typedef pa<ll, ll> pll;
typedef ve<int> vi;

const ld pi = 3.1415926535897932384626433832795l;

template<typename T> inline auto sqr (T x) -> decltype(x * x) {return x * x;}
template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

ll ten[17];

int main () {
	//std::ios::sync_with_stdio(false);
	cout.setf(ios::showpoint | ios::fixed);
	cout.precision(20);
#ifdef SG
	freopen((problemname + ".in").c_str(), "r", stdin);
//	freopen((problemname + ".out").c_str(), "w", stdout);
#endif
	string s;
	getline(cin, s);
	int n = sz(s);
	ten[0] = 1;
	forn(i, 1, 17) {
		ten[i] = ten[i - 1] * 10;
	}
	int ans = 0;
	forn(i, sz(s)) {
	 	ans += (s[i] - '0');
	}
	for (int i = 0; i < n; ++i) {
		int res = 0;
		if (s[i] > '0') {
			forn(j, sz(s)) {
				if (j > i) {
					res += 9;
				} else
					res += (s[j] - '0' - (i == j)); 
			}
		}
		umx(ans, res);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder {
    class _159b {
        static void Main() {
            string s = Console.ReadLine();
            string rev = string.Join("",s.Reverse());
            string pre = s.Substring(0, (s.Length - 1) / 2);
            string prerev = string.Join("",pre.Reverse());
            string post = s.Substring((s.Length + 3) / 2-1, (s.Length-1)/2);
            string postrev = string.Join("" , post.Reverse());
            if(s.CompareTo(rev) == 0 && pre.CompareTo(prerev)==0 && post.CompareTo(postrev) == 0) {
                Console.WriteLine("Yes");
            }
            else {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 13408
use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> 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().expect("failed to parse token")
}
fn main() {
    let h: usize = read();
    let w: usize = read();
    let k: i32 = read();
    let mut grid: Vec<Vec<char>> = vec![vec!['A'; w]; h];
    for i in 0..h {
        let s: String = read();
        grid[i] = s.chars().collect();
    }
    let mut ans = 0;
    for i in 0..(1 << h) {
        for j in 0..(1 << w) {
            let mut black = 0;
            for k in 0..h {
                for l in 0..w {
                    if ((1 << k) & i) == 0 && ((1 << l) & j) == 0 && grid[k][l] == '#' {
                        black += 1;
                    }
                }
            }
            if black == k {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2124
local a,b,h,m=io.read("n","n","n","n")
local angle=h*(2*math.pi/12)+m*(math.pi/360)-m*(2*math.pi/60)
local dist=math.sqrt(a^2+b^2-2*a*b*math.cos(angle))
print(string.format("%.20f",dist))

Measured memory_bytes: 3112
def selectionSort(n, A):
    cnt =0
    for i in range(n):
        minj = i
        for j in range(i,n):
            if A[minj] > A[j]:
                minj = j
        if i != minj:
            A[i],A[minj] = A[minj],A[i]
            cnt += 1
    print(*A)
    print(cnt)

if __name__ == '__main__':
    n = int(input())
    A = list(map(int, input().split()))
    selectionSort(n,A)

Measured memory_bytes: 7736
K=int(input())
A,B=map(int,input().split())
C=B-A
if C>=K-1:
    print("OK")
elif A%K==0:
    print("OK")
elif B%K==0:
    print("OK")
elif A//K != B//K:
    print("OK")
else:
    print("NG")

Measured memory_bytes: 9120
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
using namespace std;


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


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

  
  long long int a=(B/C)-(A-1)/C;
  long long int b=(B/D)-(A-1)/D;
  
  long long int cd=C*D/gcd(C,D);
  long long int c=(B/cd)-(A-1)/cd;
  
  cout<<(B-A+1)-(a+b-c)<<endl;
}


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

int main() {
  int n, m, p = 0, count = 0;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  cin >> m;
  vector<int> b(m);
  for (int i = 0; i < m; i++) cin >> b.at(i);
  bool flag = false;
  for (int i = 0; i < m; i++) {
    for (int j = p; j < n; j++) {
      if (a.at(j) == b.at(i)) {
        p = j + 1;
        count++;
        break;
      }
    }
    if (count != i + 1) {
      flag = true;
      break;
    }
  }
  if (flag) cout << 0 << endl;
  else cout << 1 << endl;
}


Measured memory_bytes: 4404
#include <iostream>
#include <stdio.h>
#include <string>
#define llint long long
#define inf 1e18

using namespace std;

llint n, a, b;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> a >> b;
	n %=12;
	
	for(int i = 1; i <= n; i++){
		if(i % 2) a -= b;
		else b += a;
	}
	cout << a << " " << b << endl;
	
	return 0;
}


Measured memory_bytes: 3200
s = gets.chomp

can = false
# 後ろから調べる
while(true)
  if s.nil? || s.size==0
    can = true
    break
  end

  target = s[([s.size-7,0].max)..-1]
  if !target.match(/eraser/).nil?
    s = s[0, s.size-6]
  elsif !target.match(/dreamer/).nil?
    s = s[0, s.size-7]
  elsif !target.match(/erase|dream/).nil?
    s = s[0, s.size-5]
  else
    break
  end
end

puts can ? 'YES' : 'NO'

Measured memory_bytes: 51112
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }

int main(){
	ll n,k ;
	cin >> n >> k ;
	cout << (k==1?0:n-k) << endl ;
}

Measured memory_bytes: 3628
''' ===========================================
from collections import deque
    appendleft() = push_front(), append = push_back()
    popfleft() = pop_front(), pop() = pop_back()
import heapq #heappush(trgt, val) heappop(trgt) trgt[0] __lt__<
=========================================== '''
##======================================python3
import sys
import collections
sys.setrecursionlimit(10**6)

class gv:
    A, B, M = [0,0,0]
    renzi = []
    reizo = []
    
def build():
    gv.A, gv.B, gv.M = map(int, sys.stdin.readline().split(' '))
    *gv.renzi, = map(int, input().split())
    *gv.reizo, = map(int, input().split())

def solve():
    ans = min(gv.renzi) + min(gv.reizo)
    
    for i in range(gv.M):
        rx, ry, rc = map(int, input().split())
        
        ans_buf = gv.renzi[rx -1] + gv.reizo[ry -1] - rc
        ans = min(ans, ans_buf)
    
    print(ans)

if __name__ == '__main__':
    build()
    solve()


Measured memory_bytes: 18872
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
using namespace std;
using Int = long long;
#define DUMP(range) do{for(auto& x:range){cout<<x<<' ';}cout<<endl;}while(0)
int main()
{
    int a, b, h; cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))
const int mxN = 2e5 + 5;

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

ll n, k;
ll a[mxN];

bool check(ll g){
	ll tot = 0LL;
	rep(i, n) tot += (a[i] - 1) / g;
	return tot <= k;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	cin >> n >> k;
	rep(i, n) cin >> a[i];
	ll l = 1, r = 1e9;
	while(l < r){
		ll mid = (l + r) / 2;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	cout << l << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 5148
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
int main() {
  ll n;
  cin >> n;
  cout << n*(n-1)/2 << endl;
}

Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 998244353;//1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max() / 100;
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, acost, bcost; };
struct edge {
	LL from, to, cost;
};
vector<vector<LL>>g;
vector<edge>ed;
vector<Pll>pv;
map<Pll, LL>ma;
set<LL>st;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, s, t, ans, cnt, sum, a[200000],b[200000];
string str;
bool f;
char c[1100][1100];
int main() {
	cin >> n;
	LL mx;
	rep(i, n) {
		cin >> a[i];
		if (i == 0)mx = a[i];
		else {
			if (mx - 1 > a[i]) {
				f = 1;
			}
			else {
				mx = max(mx, a[i]);
			}
		}
	}
	if (f)cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int N,L;
    cin >> N >> L;
    string S[100];
    for(int i=0;i<N;i++){
        cin >> S[i];
    }
    
    sort(S,S+N);
    
    string ans;
    for(int i=0;i<N;i++){
        ans = ans+S[i];
    }
    
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<iomanip>
using namespace std;
typedef long long ll;
const long long N = 1e9 + 7;
ll h, w, n, x, y;
ll ans[20], a[1000005];
ll fir = 0, cnt = 0;
int main()
{
    ios::sync_with_stdio(false);
    // freopen("D:\\in.txt","r",stdin);
    // freopen("D:\\out.txt","w",stdout);
    cin >> h >> w >> n;
    fir = (h - 2) * (w - 2);
    while(n--)
    {
        cin >> x >> y;
        for(int i = 0; i <= 2; i++)
        {
            for(int j = 0; j <= 2; j++)
            {
                if(x - i >= 1 && x - i <= h - 2 && y - j <= w - 2 && y - j >= 1)
                {
                    a[cnt++] = N * (x - i) + (y - j);
                }
            }
        }
    }
    sort(a, a + cnt);
    ll t = 1;
    for(ll i = 0; i < cnt; i++)
    {
        if(a[i] == a[i + 1])
            t++;
        else
        {
            ans[t]++;
            t = 1;
            fir--;
        }
    }
    cout << fir << endl;
    for(int i = 1; i < 10; i++)
    {
        cout << ans[i] << endl;
    }
    //system("pause");
    return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
    int N;
    int max=0;
    int min=1000000000;
    cin >> N;
    
    vector <int> arr(N);
    
    for(int i=0; i<N; i++){
        cin >> arr.at(i);
        if(max < arr.at(i)) max = arr.at(i);
        if(min > arr.at(i)) min = arr.at(i);   
    }
    
    cout << max - min << endl; 
    
    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String... args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();

		StringBuffer sb1 = new StringBuffer();
		StringBuffer sb2 = new StringBuffer();
		IntStream.range(0, a).forEach(i -> sb1.append(String.valueOf(b)));
		IntStream.range(0, b).forEach(i -> sb2.append(String.valueOf(a)));

		System.out.println(sb1.toString().compareTo(sb2.toString()) > 0 ? sb2.toString() : sb1.toString());
		scan.close();
	}
}

Measured memory_bytes: 26836
//PRZEMYSL ASSERTY

//SPRAWDZ CORNER CASE'Y, MINIMALNE I MAKSYMALNE WEJŚCIE I WYJŚCIE

//MODULO = 1

//while (clock()<=69*CLOCKS_PER_SEC)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  for (auto it = d.b; it != d.e; ++it) 
    *this << ", \0[" + 3 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};

#define imie(x) "[" << #x ": " << (x) << "] "

#define shandom_ruffle random_shuffle

const int nax=1000*1007;

int n;

long long l, t;

long long tab[nax];
int kier[nax];

vector < pair <long long,int> > now;

int roz;

long long myk;

int main()
{
	scanf("%d%lld%lld", &n, &l, &t);
	for (int i=0; i<n; i++)
	{
		scanf("%lld%d", &tab[i], &kier[i]);
		if (kier[i]==1)
		{
			now.push_back({(tab[i]+t)%l, i});
		}
		else
		{
			long long x=tab[i]-t;
			x%=l;
			x+=l;
			x%=l;
			now.push_back({x, i});
		}
	}
	sort(now.begin(), now.end());
	for (int i=0; i<n; i++)
		roz+=(kier[i]!=kier[0]);
	myk+=(t/l)*roz*2;
	t%=l;
	if (kier[0]==1)
	{
		for (int i=0; i<n; i++)
		{
			if (kier[i]==1)
				continue;
			if (tab[0]+t>tab[i]-t)
				myk++;
			if (tab[0]-l+t>tab[i]-t)
				myk++;
		}
		myk%=n;
		for (int i=0; i<n; i++)
		{
			if (!now[i].second)
			{
				for (int j=0; j<n; j++)
					printf("%lld\n", now[(i+j-myk+n)%n].first);
				return 0;
			}
		}
	}
	else
	{
		for (int i=0; i<n; i++)
		{
			if (kier[i]==2)
				continue;
			if (tab[0]+l-t<=tab[i]+t)
				myk++;
			if (tab[0]+l+l-t<=tab[i]+t)
				myk++;
		}
		myk%=n;
		for (int i=0; i<n; i++)
		{
			if (!now[i].second)
			{
				for (int j=0; j<n; j++)
					printf("%lld\n", now[(i+j+myk+n)%n].first);
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 7408
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
  int N; cin >> N;
  string S[N];
  int T[N];
  int i;
  int ans2 = 0;
  rep(i,N){cin >> S[i]; cin >> T[i]; ans2 += T[i];}
  string X; cin >> X;
  int ans1 = 0;

  rep(i,N){
      ans1 += T[i];
      if(S[i]==X){break;}
  }
  cout << ans2 - ans1 << endl;

  return 0;
}


Measured memory_bytes: 256
#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 (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;

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

	long long ans = 1;	
	FOR(i,1,N+1){
		
		ans = ans*i;
		ans =ans%(1000000000+7);

	}		


	cout << ans << endl;
		
		

	return 0;
}


Measured memory_bytes: 256
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    N = INT()
    P = LIST()

    count = 0
    for i in range(1, N - 1):
        if P[i-1] < P[i] and P[i] < P[i+1]:
            count += 1
        elif P[i+1] < P[i] and P[i] < P[i-1]:
            count += 1
    print(count)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define HAIRETU(N,A) for(int i=0;i<N;i++) cin >>A[i]
using namespace std;



void print(int A[], int N)
{
    int i;
    for (i = 0; i < N; i++) {
        if(i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}int main(){
    int N, K;
    cin >> N >> K;
    int tmp, A[200050]={};
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        A[tmp-1]++;
    }

    sort(A, A+N);
    int total=0;
    for (int i = 0; i < N - K; i++) {
        total+=A[i];
    }
    cout << total << endl;

    return 0;
}



Measured memory_bytes: 1024
import numpy as np
import numba
from typing import List


@numba.jit
def solver(N: int, S: int, A: np.array) -> int:
    dp = np.zeros((N+1, S+1), dtype=np.int64)

    dp[0,0] = 1
    MOD = 998244353
    for i in range(N):
        for j in range(S+1):
            dp[i+1, j] += 2 * dp[i, j]
            dp[i+1, j] %= MOD
            if j + A[i] <= S:
                dp[i+1, j+A[i]] += dp[i, j]
                dp[i+1, j+A[i]] %= MOD
    return dp[N,S]


def main():
    N, S = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    ans = solver(N, S, np.array(A))
    print(ans)
 
 
if __name__ == '__main__':
    import sys
    sys.setrecursionlimit(10000)
    main()

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

int main(){
  int n; cin >> n;
  map<int, int> mp;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    mp[a-1]++;
    mp[a]++;
    mp[a+1]++;
  }
  int ans = 0;
  for(auto nv: mp){
    int value = nv.second;
    ans = max(value, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 4736
BIG_NUM = 2000000000

while True:

    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for k in range(W):
            if (i+k)%2 == 0:
                print("#",end = "")
            else:
                print(".",end = "")
        print()

    print() #データセットの区切り


Measured memory_bytes: 7004
from math import radians
from math import cos
def main():
    a, b, h, m = map(int, input().split())
    a_kaku = 30 * (h % 12) + 0.5 * m
    b_kaku = 6 * m
    kakudo = abs(a_kaku - b_kaku)
    coskaku = cos(radians(kakudo))
    r2 = a**2 + b**2 - (2 * a * b * coskaku)
    print(r2 ** 0.5)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9504
$n = gets.to_i

def rec(digits)
  if digits.to_i > $n
    return 0
  end

  combs = 0
  tokens = %w(7 5 3)
  combs += 1 if tokens.all? {|d| digits.count(d) > 0 }

  tokens.each do |d|
    combs += rec(digits + d)
  end

  return combs
end

p rec('')


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N, M;
        N = scan.nextInt();
        M=scan.nextInt();
        if(M==N){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844