akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
//using namespace __gnu_pbds;
#define rep(i,a,b) for(i=(a);i<=(b);i++)
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e18
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define ps(x,y) fixed<<setprecision(y)<<x
//template<typename T>
//using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out <<  "(" << a.F << ", " << a.S << ")";
}
 
template<class A> ostream& operator << (ostream& out, const vector<A> &a) {
	out << "[";
	for (auto it = a.begin(); it != a.end(); ++it) {
		if (it != a.begin())
			out << ", ";
		out << *it;
	}
	return out << "]";
}
int main()
{
    boost;
    ll n,i,j,x,t,y,p;
	cin>>p>>n;
	ll a[n];
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	ll ans=inf;
	for(i=0;i<n-1;i++){
		if(i==0) {
			ans=min(ans,a[n-1]-a[0]);
			ans=min(ans,p-(a[1]-a[0]));
		}
		else{
			ans=min(ans,p-(a[i+1]-a[i]));
			ans=min(ans,p-(a[i]-a[i-1]));
		}
	}
	cout<<ans;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int r = sc.nextInt();
        int D = sc.nextInt();
        int x = sc.nextInt();
        
        for(int i=0;i<10;i++){
            x = r * x - D;
            System.out.println(x);
        }
        
    }
}


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

int main() {
  int n;
  cin >> n;
  vector<double> v(n);
  for(int i=0;i<n;i++){
    cin >> v.at(i);
  }
  sort(v.begin(),v.end());
  double ans = 0;
  for(int i=0;i<n-1;i++){
    ans = (v.at(i) + v.at(i+1))/2;
    v.at(i+1) = ans;
  }
  cout << ans << endl;

  
    
  
  return 0;
}
  


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

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

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

constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int N;
    cin >> N;
    vector<pair<int, int>> points(N);
    for (int i=0; i<N; ++i) cin >> points[i].first >> points[i].second;

    sort(points.begin(), points.end());
    int res = -1;
    int minx = -1, miny = -1, maxx = -1, maxy = -1;
    for (auto p : points) {
        int x = p.first, y = p.second;
        if (minx == -1) {
            minx = x;
            miny = y;
        } else {
            chmax(res, abs(x - minx) + abs(y - miny));
            if (x + y < minx + miny) {
                minx = x;
                miny = y;
            }
        }
        if (maxx == -1) {
            maxx = x;
            maxy = y;
        } else {
            chmax(res, abs(x - maxx) + abs(y - maxy));
            if (y - x > maxy - maxx) {
                maxx = x;
                maxy = y;
            }
        }
    }
    cout << res << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 4768
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const int MINF = -1e9;;


int main() {
	int n;
	vector<int> a;
	cin >> n;
	a.resize(n);
	rep(i, n) {
		cin >> a[i];
	}
	int max_num, second_num;
	vector<int> x(n);
	copy(a.begin(), a.end(), x.begin());
	sort(x.begin(), x.end());
	max_num = x.at(n-1);
	second_num = x.at(n - 2);

	rep(i, n) {
		if (a[i] == max_num) cout << second_num << endl;
		else cout << max_num << endl;
	}

	return 0;
}


Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int car = in.nextInt();
		int max = 0;
		for (int i = 0; i < n; i++) {
			car += in.nextInt();
			car -= in.nextInt();
			max = Math.max(max, car);
			if (car < 0) {
				max = 0;
				break;
			}
		}
		System.out.println(max);
	}
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define All(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   string o,e;
   cin >> o >> e;
   int s = o.size() + e.size();
   int on = 0,en = 0;
   for(int i=0;i<s;i++){
      if(i%2 == 0){
         cout << o[on++];
      }else{
         cout << e[en++];
      }
   }
   return 0;
}

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

using namespace std;

const int N = 1e5 + 3;
int a[N], l[N], r[N], n;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	l[0] = r[n + 1] = 0;
	r[n] = a[n];
	l[1] = a[1];
	for (int i = 2; i <= n; ++i)
		l[i] = __gcd(l[i - 1], a[i]);
	for (int i = n - 1; i >= 1; --i)
		r[i] = __gcd(r[i + 1], a[i]);
	int res = 0;
	for (int i = 1; i <= n; ++i)
		res = max(res, __gcd(l[i - 1], r[i + 1]));
	printf("%d", res);
	return 0;
}


Measured memory_bytes: 1408
import Data.List

main :: IO ()
main = do
  n <- readLn
  s <- getLine
  putStrLn $ ans n s

ans :: Int -> String -> String
ans n = map shiftS where
  alf = ['A'..'Z']
  shiftS c = alf !! ((`mod` 26) . (+n) . (\(Just a) -> a) $ elemIndex c alf)

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

int main() {
  long n, x = 0;
  cin >> n;
  vector<long> num(n);
  for (int i = 0; i < n; i++) {
    cin >> num.at(i);
  }
  sort(num.begin(), num.end());
  for (int i = 0; i < (n - 1); i++) {
    if (num.at(i) == num.at(i + 1)) {
      x = 1;
      break;
    }
  }
  string ans = x == 0 ? "YES" : "NO";
  cout << ans;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main()
{
	int a, b = 0, i;
	for (i = 0; i < 5; i++){
		scanf("%d", &a);
		if (a <= 40)
			a = 40;
		b+=a;
	}
	printf("%d\n", b/5);
	return 0;
}

Measured memory_bytes: 1028
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N;

	public static void main(String[] args) throws Exception {
		while (true) {
			N = sc.nextInt();
			if (N == 0) break;
			boolean[][] t = new boolean[31][N];
			for (int i = 0; i < N; ++i) {
				int F = sc.nextInt();
				for (int j = 0; j < F; ++j) {
					int d = sc.nextInt();
					t[d][i] = true;
				}
			}
			int ans = -1;
			for (int i = 1; i <= 30; ++i) {
				if (ok(t, i)) {
					ans = i;
					break;
				}
			}
			System.out.println(ans);
		}
	}

	static boolean ok(boolean[][] t, int d) {
		boolean[] v = new boolean[N];
		for (int i = 0; i < N; ++i) {
			if (t[d][i]) v[i] = true;
		}
		for (int i = d - 1; i >= 1; --i) {
			boolean ok = false;
			for (int j = 0; j < N; ++j) {
				if (t[i][j] && v[j]) ok = true;
			}
			if (ok) {
				for (int j = 0; j < N; ++j) {
					if (t[i][j]) v[j] = true;
				}
			}
		}
		for (int i = 0; i < N; ++i) {
			if (!v[i]) return false;
		}
		return true;
	}
}

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

int main() {
  int a,b;
  cin >> a >> b;
  if(a<=5){
    cout << 0 << endl;
  }else if(a<=12){
    cout << b/2 << endl;
  }else{
    cout << b << endl;
  }
}


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

int main()
{
  string S;
  cin >> S;
  S.pop_back();
  S.pop_back();

  while (true)
  {
    int num = S.size() / 2;
    string first_S(S.begin(), S.begin() + num);
    string last_S(S.begin() + num, S.end());

    if (first_S == last_S)
      break;
    S.pop_back();
    S.pop_back();
  }

  cout << S.size() << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){
  string a,b;cin>>a>>b;
  int an=a.size(),bn=b.size();

  if(an>bn){
    out("GREATER");
    return 0;
  }
  else if(an<bn){
    out("LESS");
    return 0;
  }
  else{
    rep(i,an){
      if(a[i]-'0'>b[i]-'0'){
        out("GREATER");
        return 0;
      }else if(a[i]-'0'<b[i]-'0'){
        out("LESS");
        return 0;
      }
    }
  }
  out("EQUAL");

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs

const int MAXN = 100500;

int n, m;
vector<int> g[MAXN];
int dp[MAXN];

int calc(int v) {
  if (dp[v] != -1) {
    return dp[v];
  }
  dp[v] = 0;
  for (int to : g[v]) {
    dp[v] = max(dp[v], 1 + calc(to));
  }
  return dp[v];
}

int main() { 

  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int from, to;
    scanf("%d %d", &from, &to);
    from--; to--;
    g[from].push_back(to);
  }

  memset(dp, -1, sizeof(dp));

  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = max(ans, calc(i));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 7424
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;


int calc_num(long long n){
  if (n == 0)
    return 3;
  if (n == 1)
    return 5;
  if (n == 2)
    return 7;
  return -1;
}

int main(){
  long long n, count=0;
  cin >> n;
  for (int i = 3; i <= ceil(log10(n)); i++){
    for (int j = 0; j < pow(3, i); j++){
      long long this_num = 0, tmp = j;
      long long multiple = 1;
      vector<bool> valid(3, false);
      for (int k = 0; k < i; k++){
        this_num += calc_num(tmp % 3) * multiple;
        valid[tmp % 3] = true;
        tmp /= 3;
        multiple *= 10;
      }
      if ((valid[0] && valid[1] &&valid[2]) &&
          (i < ceil(log10(n)) || (i == ceil(log10(n)) && this_num <= n)))
        count += 1;
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll                 long long int
#define mod                1000000007
#define pi                 3.14159265358979323846264338327950288419716939937510
#define setbit(x)          __builtin_popcountll(x)
#define db                 long double
#define pp(x)              pair<x,x>
#define ff                 first
#define ss                 second
#define FIO                ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc                 ll tc; cin>>tc; for(ll number = 1 ; number <= tc ; number ++ )
#define vv(x)              vector<x>
#define pb                 push_back
#define pob                pop_back
#define pf                 push_front
#define pof                pop_front
#define endl               "\n"
#define pq                 priority_queue
#define dbg(x)             { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)          { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define bp                 ll kkk; cin >>kkk;
#define dbgArr(a,n)        cout<<"Array "<<#a<<endl; for(ll i=0 ; i<n ; i++) cout<<a[i]<<" "; cout<<endl;
#define maxE(a,n)          *max_element(a,a+n);
#define minE(a,n)          *min_element(a,a+n);
#define forn(i,s,n)        for(ll i=s ; i<n ; i++)
#define fornr(i,e,s)       for(ll i=e-1 ; i>=s ; i--)
#define arr(a,n)           for(ll i=0;i<n;i++){ cin>>a[i]; }
#define arr1(a,n)          for(ll i=1;i<=n;i++){ cin>>a[i]; }
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define print cout<<"Case #"<<number<<": "
#define all(x) x.begin(), x.end()
ll power(ll x, ll b,ll m) {ll p = 1;while (b > 0) {if(b&1) {p = p * x; p %= m;} b >>= 1; x *= x; x %= m;} return p % m;}
using namespace std;
# define INF 1e15
struct lex_compare {
    bool operator() (pp(ll) p1, pp(ll) p2){
        return p1.ff >= p2.ff;
    }
};


int main(){
    FIO;
    ll n,k; cin >> n >> k;
    ll arr[n]; forn(i,0,n) cin >> arr[i];
    for(ll i = k;i<n;i++){
        if(arr[i] > arr[i-k]){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;

        }
    }
    return 0;
}


Measured memory_bytes: 5212
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 100000;

int main(void){
    ll a,b,c,d;
    string s,t;

    cin >> a >> b;//>> c >> d;
    //cin >> s >> t;
    cout << max(a-b,ll(0)) << endl;


    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
n, k = map(int,input().split())
a = list(map(int,input().split()))

cnt = defaultdict(lambda :0)
num = defaultdict(lambda :0)
cnt[1] = 1
num[1] = 1
trans = 1
for i in range(k):
    temp = a[trans - 1]
    #print(temp)
    if cnt[temp] != 0:
        roop = - cnt[temp] + cnt[trans] + 1
        omit = (k - cnt[temp] + 1) % roop

        ans = num[cnt[temp] + omit]
        print(ans)
        exit()
    cnt[temp] = cnt[trans] + 1
    num[cnt[temp]] = temp
    trans = temp

print(trans)

Measured memory_bytes: 129076
# ABC070 C Multiple Clocks

from functools import reduce
from fractions import gcd #python3.5より前
# from math import gcd      #python3,5以降

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

def multi_lcm(numbers):
    return reduce(lcm_base, numbers)

n = int(input())
t_list = [int(input()) for i in range(n)]

print(multi_lcm(t_list))

Measured memory_bytes: 5256
#include <iostream>
#include <set>
using namespace std;
int main(){
    set<int> s;
    set<int>::iterator itr;
    int N, d;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> d;
        itr = s.find(d);
        if (itr == s.end()) s.insert(d);
    }
    cout << s.size() << endl;
}

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

int main(int argc, char const *argv[])
{
    int N, R;
    cin >> N >> R;
    if (N <= 10)
    {
        cout << (R + 100 * (10 - N)) << endl;
    }
    else
    {
        cout << R << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N=int(input())
D,X=list(map(int,input().split(" ")))
A=[]

for i in range(N):
  A.append(int(input()))

S=0
  
for i in range(N):
  for j in range(1000):
    if (1+j*A[i])>D:
      S+=j
      break
  
print(S+X)

Measured memory_bytes: 3060
S = input()
if not S[0] == 'A':
    print('WA')
    exit()
if not S[2:-1].count('C') == 1:
    print('WA')
    exit()
if not (S[1] + S[2:-1].replace('C', '') + S[-1]).islower():
    print('WA')
    exit()
print('AC')


Measured memory_bytes: 2940
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect


class Scanner():
    def int():
        return int(sys.stdin.readline().rstrip())

    def string():
        return sys.stdin.readline().rstrip()

    def map_int():
        return [int(x) for x in Scanner.string().split()]

    def string_list(n):
        return [input() for i in range(n)]

    def int_list_list(n):
        return [Scanner.mapInt() for i in range(n)]

    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    def roundUp(a, b):
        return -(-a // b)

    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    def toLowerMultiple(a, x):
        return (a // x) * x

    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7


def main():
    # sys.stdin = open("sample.txt")
    X, Y = Scanner.map_int()
    ans = 1
    while X <= Y:
        if X * 2 <= Y:
            X *= 2
            ans += 1
        else:
            break
    print(ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 38640
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
#include <stdio.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(a) (a).begin(),(a).end()
#define vecin(a) rep(i,a.size())cin >> a[i]
#define vecout(a) rep(i,a.size()){cout << a[i];cout << (i == a.size() - 1 ? "\n":" ");}
#define rep(i,x) for(ll i = 0;i<x;i++)
#define REP(i,x) for(ll i = 1;i<=x;i++)
#define mp make_pair
#define debug(x) cerr << #x << ": " << x << "\n"
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const dou pi = 3.14159265358;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T, class U> inline bool chmin(T& a, const U& b){ if(a > b){ a = b; return 1; } return 0; }
template<class T, class U> inline bool chmax(T& a, const U& b){ if(a < b){ a = b; return 1; } return 0; }
template<class T, class U> inline bool change(T& a,U& b){if(a > b){swap(a,b);return 1;}return 0;}
//0の場合のアレンジに注意
template<class T>
T gcd(T a,T b){
    if(a == 0)return b;
    else if(b == 0)return a;
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
template<class T>
T lcm(T a,T b){
    return a / gcd(a,b) * b;
}

//素数判定O(sqrt(N))
template<class T>
inline bool isp(T n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const ll cmax = 1000000;
vector<ll> fac(cmax),finv(cmax),inv(cmax);

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < cmax; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if(fac[0] == 0)COMinit();
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logm)
ll modpow(ll n,ll m,ll MOD){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}
ll mypow(ll n,ll m){
    if(m == 0)return 1;
    if(m < 0)return -1;
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n);
        m >>= 1;
        n *= n;
    }
    return res;
}
template<class T = ll>
T in(){T x;cin >> x;return x;}
ll dist_to_a(char c){
    if(c == 'a')return 0;
    else return 26 + 'a' - c;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    string S = in<string>();
    ll N = in();
    ll s = S.size();
    rep(i,s){
        if(dist_to_a(S[i]) <= N){
            N -= dist_to_a(S[i]);
            S[i] = 'a';
        }
    }
    if(N){
        N %= 26;
        S[s - 1] += N;
    }
    cout << S << "\n";
}

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

int main()
{
	int n,k;
	cin>>n>>k;
	vector<int> h(n);
	for(int &x: h) cin>>x;
	vector<int> dp(n,1e9+5);
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		int p=i;
		for(int j=p+1;j<=p+k;j++)
		{
			if(j<n)
			{
				dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
			}
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 3988
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const int MOD = 100000007;

int main()
{
    int h, w;
    cin >> h >> w;

    vector<string> s(h);
    for(int i=0; i<h; ++i)
        cin >> s[i];

    map<string, int> curr;
    curr[string(w, '0')] = 1;

    for(int y=0; y<h; ++y){
        for(int x=0; x<w; ++x){
            map<string, int> next;

            if(s[y][x] == '.'){
                for(map<string, int>::iterator it=curr.begin(); it!=curr.end(); ++it){
                    string t = it->first;
                    rotate(t.begin(), t.begin()+1, t.end());
                    (next[t] += it->second) %= MOD;
                }
            }else{
                for(map<string, int>::iterator it=curr.begin(); it!=curr.end(); ++it){
                    string t = it->first;
                    if(t[0] > '2' || t[0] > s[y][x])
                        continue;

                    t = t.substr(1) + (char)(s[y][x] - (t[0] - '0'));
                    if(*max_element(t.begin(), t.end()-1) <= '2')
                        (next[t] += it->second) %= MOD;

                    bool ng = false;
                    int k = x - 1;
                    while(k >= 0 && s[y][k] == '.'){
                        if(t[k+w-x-1] != '0')
                            ng = true;
                        -- k;
                    }

                    if(k >= 0 && !ng){
                        k += w - x - 1;
                        if(t[w-1] != '0' && t[k] != '0'){
                            -- t[w-1];
                            -- t[k];
                            if(*max_element(t.begin(), t.end()-1) <= '2')
                                (next[t] += it->second) %= MOD;
                        }
                        if(t[w-1] != '0' && t[k] != '0'){
                            -- t[w-1];
                            -- t[k];
                            if(*max_element(t.begin(), t.end()-1) <= '2')
                                (next[t] += it->second) %= MOD;
                        }
                    }
                }
            }

            curr.swap(next);
        }
    }

    cout << curr[string(w, '0')] << endl;

    return 0;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> V(N);

  for (int i = 0; i < N; i++) {
       cin >> V.at(i);
  }
  
  sort(V.begin(), V.end());
  reverse(V.begin(), V.end());
  
  int Alice = 0;
  int Bob = 0;
  
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0){
      Alice = Alice + V.at(i);
    }
    else{
      Bob = Bob + V.at(i);
    }
  }
  cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
 string s;
 cin >> s;
 if(s[5] == '0' && s[6] == '1' || s[5] == '0' && s[6] == '2' || s[6] == '3' || s[6] == '4'){
     cout << "Heisei" << endl;
 }
 else cout << "TBD" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n,s;
	while(cin>>n>>s,n){
		vi in(n);
		rep(i,n)cin>>in[i];
		int m1=inf,m2=inf,out;
		bool h=false;
		rep(i,n){
			int t=s/in[i]*in[i];
			if(m1>t){
				m1=t;
				m2=in[i];
				out=i+1;
				h=false;
			}else if(m1==t){
				if(m2==in[i])h=true;
				if(m2>in[i]){
					m2=in[i];
					out=i+1;
					h=false;
				}
			}
		}
		if(h)cout<<n<<endl;
		else cout<<out<<endl;
	}
}

Measured memory_bytes: 1196
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
using namespace std;

int main(){
    int n, k, ans = 1;
    cin >> n >> k;
    for(int i=0; i<n; i++) {
        if(ans * 2 < ans + k) {
            ans *= 2;
        } else {
            ans += k;
        }
    }
    cout << ans << endl;
}

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

int d[]={0,1,2,3,5,7,8,9};

void solve(int n){
  if(8<=n){
    solve(n/8);
  }
  cout<<d[n%8];
  return;
}

int main(void){
  int  n;
  while(cin>>n&&n!=0){
    solve(n);
    cout<<endl;
  }
  return 0;
}

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

int main(void){
    int n;
    cin >> n;
    map<int,int> mp;
    rep(i,n) {
        int x;
        cin >> x;
        mp[x]++;
    }
    if (mp.count(1) && mp[1] > 1) {
        cout << 0 << endl;
        return 0;
    }
    if (mp.count(1) && mp[1] == 1) {
        cout << 1 << endl;
        return 0;
    }
    
    vector<int> v;
    for (auto itr : mp){
        v.push_back(itr.first);
    }
    sort(all(v));
    
    int cnt = 0;
    int SIZE = 1000010;
    vector<bool> multi(SIZE);
    for(int x : v){
        if (multi[x]) continue;
        for(int j=x; j<SIZE; j+=x){
            multi[j] = true;
        }
        if (mp[x] == 1) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 13556
#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 <class T> using oset = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

void usaco(string name = "")
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(name.size())
    {
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

int main()
{
    usaco();
    int n;
    cin >> n;
    vector <int> a(n), b(n), c(n);
    vector <vector<int>> dp(n, vector <int> (3));
    for (int i = 0; i < n; ++i) cin >> a[i] >> b[i] >> c[i];
    dp[0][0] = a[0], dp[0][1] = b[0], dp[0][2] = c[0];
    for (int i = 1; i < n; ++i)
    {
        dp[i][0] = a[i]+max(dp[i-1][1], dp[i-1][2]);
        dp[i][1] = b[i]+max(dp[i-1][0], dp[i-1][2]);
        dp[i][2] = c[i]+max(dp[i-1][0], dp[i-1][1]);
    }
    cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << '\n';
}


Measured memory_bytes: 9804
#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))

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

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	int N, K;
	string S;
	cin >> N >> S >> K;

	char replace_char = S[K - 1];

	for (int i = 0; i < N; i++) {
		if (S[i] != replace_char) {
			S[i] = '*';
		}
	}
	cout << S;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int x,n;
int a[105];
bool Find(int p)
{
	for(int i=1;i<=n;i++)
		if(a[i]==p) return true;
	return false;
}
int main()
{
	cin>>x>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	int i=x,j=x;
	while(true){
		if(!Find(i)) break;
		if(!Find(j)) break;
		i--;j++;
	}
	if(!Find(i))
		cout<<i<<endl;
	else
		cout<<j<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
    int n,p[101];
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        scanf("%d",&p[i]);
    }
    int max=-1,count=0;
    for(int i=0;i<n;++i){
        if(max<p[i]){
            max=p[i];
        }
    }
    if(max>n)max=n;
    while(1){
        count=0;
        for(int i=0;i<n;++i){
            if(p[i]>=max){
                count++;
            }
        }
        if(count>=max)break;
        max--;
        count=0;
    }
    cout<<max<<endl;
    return 0;
}


Measured memory_bytes: 3220
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <numeric>
#include <cassert>

#define endl '\n'
#define sp ' '

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll dp[105][100005];

ll val[105],weight[105];

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

    int n,w;cin>>n>>w;
    
    for(int i=1;i<=n;i++){
        cin>>weight[i]>>val[i];
    }

    for(int item=1;item<=n;item++){
        for(int we=1;we<=w;we++){
            if(weight[item] <= we)
                dp[item][we] = max(dp[item-1][we], val[item] + dp[item-1][we-weight[item]]);
            else
                dp[item][we] = dp[item-1][we];
        }
    }

    cout<<dp[n][w]<<endl;

}













Measured memory_bytes: 79360
import java.util.Scanner;

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

        if((y%2)!=0||y>(x*4)||y<(x*2)){
            System.out.println("No");
            return;
        }else{
            System.out.println("Yes");
        }

        scn.close();

    }

}

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

using Graph = vector<vector<int>>;

int main(){
    string s;
    cin >> s;
    int n;
    cin >>n;
  
    bool rev =false;
    int t;
    int f;
    char c;
    
    //vector<int>q;
    rep(i,n){
        cin >>t;
        //q.push_back(t);
        if(t == 1){
            rev  = !rev;
        }
        else{
            cin >>f >> c;
            if(f==1){
                if(rev)
                    s.push_back(c);
                else
                    s.insert(s.begin(), c);
            }
            else{//f==2
                if(rev)
                     s.insert(s.begin(), c);
                else
                    s.push_back(c);
            }
        }
        
    }
    
    if(rev)
        reverse(s.begin(), s.end());
    
    cout << s <<endl;
    
    return 0;
}




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

int main() {
  
  int a;
  cin >> a;
  int b;
  cin >> b;
  
  string s;
  cin >> s;
  
  int ss=1;
  for (int i=0; i<s.size(); i++) {
    if (i==a) continue;
    else if (s.at(i)=='-') ss*=0;
  }
  
  if (ss==1 && s.at(a)=='-') cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
def factorial_mod(n, mod=10**9+7):
    ret = 1
    for i in range(1, n+1):
        ret = (ret * i) % mod
    return ret

N, M = map(int, input().split())
mod = 10**9 + 7
if N == M:
    print((2 * factorial_mod(N) * factorial_mod(M)) % mod)
elif abs(N - M) == 1:
    print((factorial_mod(N) * factorial_mod(M)) % mod)
else:
    print(0)

Measured memory_bytes: 3064
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


import math


X = int(input())
ans = 0
t = 100.0

while t < X:
    t = math.floor(t * 1.01)
    ans += 1

print(ans)


Measured memory_bytes: 9172
from sys import stdin

s = stdin.readline().rstrip()
point = 0

li = ["0","1"]

start = li.pop(li.index(s[0]))
last = li[-1]

for i in range(len(s)):
    if i % 2 == 0:
        if s[i] != start:
            point += 1
    else:
        if s[i] != last:
            point += 1

print(point)

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

int main() {
  int N , D ; 
  cin >> N >> D ; 
  int cnt = 0 ; 
  
  vector<vector<int>> X(N , vector<int>(D)) ; 
  
  for( int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < D ; j++){
      cin >> X.at(i).at(j) ; 
    }
  }
  
  for(int i = 0 ; i < N ; i++){
    for(int j = i+1 ; j < N ; j++){
      int norm = 0 ; 
      
      for( int k = 0 ; k < D ; k++){
        int dist = abs( X.at(i).at(k) - X.at(j).at(k) ); 
        norm = norm + dist*dist ; 
      }
      
      for(int k = 0 ; k <= norm ; k++){
        if(k * k  == norm){
          cnt++ ; 
        }
      }
      
    }
  }
  
  cout << cnt << endl ; 
  
}

Measured memory_bytes: 3620
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let s: String = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    };
    let t: String = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    };

    let ans = 2 * N - (0..N + 1).rev().find(|&k| s[N - k..] == t[..k]).unwrap();

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


Measured memory_bytes: 4352
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    for i in 1..10 {
        for j in 1..10 {
            if i * j == n {
                return "Yes".to_string();
            }
        }
    }

    return "No".to_string();
}


Measured memory_bytes: 4352
#include<iostream>
#include <ctype.h>

using namespace std;

int main(){
	
	int counter[26] = { 0 };
	char c;
	while (cin >> c) {

		c = tolower(c);

		int num = c - 'a';  

		if (0 <= num && num < 26) {

			counter[num]++;
		}
	}
	for (int i = 0; i < 26; i++) {

		cout << char(i + 'a') << " : " << counter[i] << endl;

	}
	return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<stack>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
using ll = long long;
using namespace std;
int main() {
	int k, x;
	cin >> k >> x;
	REP(i, k - 1)cout << x + i - k + 1 << " ";
	cout << x << " ";
	REP(i, k - 1) {
		cout << x + i + 1;
		if (i != k - 2)cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env ruby
require 'set'

n = gets.chomp.to_i

dict = SortedSet.new
n.times do
  action, str = gets.chomp.split
  str = str.tr('ACTG', '1234').to_i
  case action
  when 'insert'
    dict << str
  when 'find'
    puts dict.include?(str) ? 'yes' : 'no'
  end
end

Measured memory_bytes: 26428
N, W = map(int, input().split())

dp = [[0]*(W+1) for _ in range(N+1)]
dp[0][0] = 0

for i in range(N):
    v, w = map(int, input().split())
    for sum_w in range(W+1):
        if w <= sum_w:
            dp[i + 1][sum_w] = max(dp[i][sum_w], dp[i+1][sum_w - w] + v)
        else:
            dp[i + 1][sum_w] = dp[i][sum_w]

print(dp[N][W])


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

#define min(a, b) a < b ? a : b
#define max(a, b) a > b ? a : b

#define MAXN 100000

int main(void)
{
	long long i;
	long long N;
	int ok = 1;
	long long sumn = 0, suma = 0, k;
	long long A[MAXN];
	long long d[MAXN];

	scanf("%lld", &N);

	for (i = 0; i < N; i++) {
		scanf("%lld", &A[i]);
		suma += A[i];
	}

	sumn = N * (N + 1) / 2;
	if ((suma % sumn) != 0) {
		printf("NO\n");
	} else {
		k = suma / sumn;
		for (i = 0; i < N; i++) {
			d[i] = A[(i + 1) % N] - A[i] - k;
		}
		for (i = 0; i < N; i++) {
			if (d[i] % N == 0 && d[i] <= 0) {
				//ok = 1;
			} else {
				ok = 0;
				break;
			}
			/*if (d[i] % N != 0 || d[i] > 0) {
				ok = 0;
				break;
			}*/
		}
		//printf("YES\n");
		if (ok) {
			printf("YES\n");
		} else {
			printf("NO\n");
		}
	}
	/*if (ok) {
		printf("YES\n");
	} else {
		printf("NO\n");
	}*/
	return (0);
}

Measured memory_bytes: 1664
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
typedef struct edge {
    int u,v;
    ll w;
} edge;
int n,m;
ll x;
edge E[2020];
int mark[2020];
int p[1010];
int find(int a){
    return p[a] == a ? a : p[a] = find(p[a]);
}
void unify(int a,int b){
    p[find(a)] = find(b);
}

void init_uf(){
    for(int i=1;i<=n;i++){
        p[i] = i;
    }
}
ll pow2(int a){
    ll r = 1;
    ll x = 2;
    while(a){
        if(a&1)r = r*x%mod;
        x = x*x%mod;
        a>>=1;
    }
    return r;
}
int main(){
    scanf("%d%d%lld",&n,&m,&x);
    for(int i=0;i<m;i++){
        scanf("%d%d%lld",&E[i].u,&E[i].v,&E[i].w);
    }
    sort(E, E+m, [](edge &a, edge &b){return a.w < b.w;});
    for(int i=0;i<m;i++){
        init_uf();
        unify(E[i].u, E[i].v);
        vector<int> v;
        v.push_back(i);
        ll sum = E[i].w;
        for(int j=0;j<m;j++){
            edge &e = E[j];
            if (find(e.u) != find(e.v)){
                v.push_back(j);
                unify(e.u, e.v);
                sum += e.w;
            }
        }
        if (sum < x){
            for(auto j : v){
                mark[j] = 1;
            }
        }
        else if (sum == x){
            if(mark[i] == 0)mark[i] = 2;
        }
    }

    int s[3] = {};
    for(int i=0;i<m;i++){
        s[mark[i]]++;
    }
    //printf("%d %d %d\n", s[0], s[1], s[2]);
    ll ans;
    if (s[2] == 0){
        ans = 0;
    }
    else if (s[1] == 0){
        ans = (pow2(s[2]) - 2) % mod * pow2(s[0]) % mod;
    }
    else {
        ans = 2 * (pow2(s[2]) - 1) % mod * pow2(s[0]) % mod;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 256
data class Point(val x: Int, val y: Int) {
    operator fun minus(that: Point): Point = Point(x - that.x, y - that.y)
}
fun dot(a: Point, b: Point): Int {
    return a.x * b.y - a.y * b.x
}

fun main(args:Array<String>?): Unit {

    val (n, k) = readLine()!!.trim().split(' ').map(String::toInt)
    val points = Array(n) {
        val (x, y) = readLine()!!.trim().split(' ').map(String::toInt)
        Point(x, y)
    }.sortedBy { it.x }
    println(
            if (points.indices.drop(1).any { o ->
                val origin = points[o - 1]
                val sorted = (o until n).sortedWith(
                        kotlin.Comparator { o1, o2 ->
                        dot(points[o1] - origin, points[o2] - origin).compareTo(0)
                    }).map{i -> points[i]}
                (0 .. sorted.size - k + 1).any { i ->
                    ((i == 0 || dot(sorted[i] - origin, sorted[i - 1] - origin) != 0) && (i + 1 until i + k - 1).all{j -> dot(sorted[i] - origin, sorted[j] - origin) == 0})
                }
            }) 1 else 0
    )
}


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

template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}

int main(){
  long long m,n;
  cin>>m>>n;
  cout<<mod_pow(m,n,(long long)1000000007)<<'\n';
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int X, Maxlog, Maxbeki, ANSWER;
  ANSWER =1;
  Maxbeki=0;
  cin >> X;
  for (int i = 2; i<32; i++){
	  Maxlog = log(X)/log(i)+0.0001;
	  if (Maxlog>1){
		  Maxbeki = pow(i, Maxlog);
	  }
	  if (Maxbeki > ANSWER){
	  ANSWER = Maxbeki;
	}
	Maxbeki=0;
  }

  cout << ANSWER << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    string s;
    cin >> s;
    int cnt=0;
    for (int i = 0; i < s.size(); i++)
    {
        if(s[i]=='p') cnt++;
    }
   // cerr<<cnt;
    cout<<(int)s.size()/2-cnt<<endl;
    
    return 0;
}

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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
#define MP make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;
typedef pair < ll , ll > pll;

const double PI = acos(-1);
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int INF = 1e9;
	

ll addMod(ll a, ll b){
	if(a + b >= MOD) return a + b - MOD;
	return a + b;
}

ll mulMod(ll a, ll b){
	return (a*b)%MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b%2 == 1) tmp = mulMod(tmp,a);
	return tmp;
}

ll GCD(ll a, ll b){
	if(a > b) return GCD(b,a);
	if(a == 0) return b;
	return GCD(b%a,a);
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

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

const int N = 2000;

int n;
int a[N + 5];

int f(int lt, int x){
	int l = lt, r = n-1, m, ret = lt-1;
	while(l <= r){
		m = (l + r) / 2;
		if(a[m] >= x){
			r = m - 1;
		}
		else{
			l = m + 1;
			ret = m;
		}
	}
	return ret - lt + 1;
}

int solve(){
	sort(a,a+n);
	int ret = 0;
	FOR(i,n){
		REP(j,i+1,n-1){
			ret += f(j+1, a[i] + a[j]);
		}
	}
	return ret;
}

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	FOR(i,n) cin >> a[i];
	cout << solve() << endl;
	return 0;
}

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

using namespace std;

int grid[3][3] = {};

int main() {
    int maxC = -1;
    for (int i = 0; i < 3; ++i) for (int j = 0; j < 3; ++j) {
        int c; cin >> c;
        maxC = max(maxC, c);
        grid[i][j] = c;
    }

    bool ok = false;
    for (int i = 0; i <= maxC; ++i) {
        for (int j = 0; j <= maxC; ++j) {
            for (int k = 0; k <= maxC; ++k) {
                bool b1, b2, b3;
                b1 = b2 = b3 = false;
                b1 = grid[0][0] - i == grid[1][0] - j && grid[1][0] - j == grid[2][0] - k;
                b2 = grid[0][1] - i == grid[1][1] - j && grid[1][1] - j == grid[2][1] - k;
                b3 = grid[0][2] - i == grid[1][2] - j && grid[1][2] - j == grid[2][2] - k;
                ok = b1 && b2 && b3;
                if (ok) break;
            }
            if (ok) break;
        }
        if (ok) break;
    }

    cout << (ok ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
    "bufio"
    "fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var N,M int
	fmt.Scan(&N,&M)
	height := make([]int, N)
	flag := make([]int, N)
	for i := 0; i < N; i++ {
		var H int
		fmt.Scan(&H)
		height[i] = H
	}
	for j := 0; j < M; j++{
		var A,B int
		fmt.Scan(&A,&B)
		if height[A-1] > height[B-1]{
			flag[B-1] = 1
		}else if height[A-1] < height[B-1]{
			flag[A-1] = 1
		}else {
			flag[B-1] = 1
			flag[A-1] = 1
		}
	}
	count := 0
	for _,v := range flag {
		if v == 0 {
			count += 1
		}
	}
	fmt.Println(count)

}

Measured memory_bytes: 6504