akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

// bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
//     return arg1.first > arg2.first;
// }

int main(void) {
    int a, b;
    cin >> a >> b;

    if(b%a==0) cout << a+ b << endl;
    else cout << b-a << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main()
{
  char s[100001],ans;
  int n;
  int i;
  int a[26];
  int b=0;
  scanf("%s",s);
  n=strlen(s);
  for(i=0;i<26;i++){
    a[i]=0;
  }
  for(i=0;i<strlen(s);i++){
    if(a[s[i]-'a']==0) b++;
    a[s[i]-'a']++;
    if(b>=26){
      printf("None");
      return 0;
    }
  }
  for(i=0;i<26;i++){
    if(a[i]==0){
      ans='a'+i;
      printf("%c",ans);
      return 0;
    }
  }
  printf("None");
  return 0;
}


Measured memory_bytes: 1708
#include<iostream>
#include<iomanip>
using namespace std;
int n,arr[4];
double dp[305][305][305];
double dfs(int a,int b,int c)
{
	if(a==0&&b==0&&c==0)	return 0;
	if(dp[a][b][c]>0) return dp[a][b][c];
	double ans=1.0*n/(a+b+c);
	if(a) ans+=1.0*a/(a+b+c)*dfs(a-1,b,c);
	if(b) ans+=1.0*b/(a+b+c)*dfs(a+1,b-1,c);
	if(c) ans+=1.0*c/(a+b+c)*dfs(a,b+1,c-1);
	return dp[a][b][c]=ans;
}
int main()
{
	int d;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		{
			scanf("%d",&d);
			arr[d]++;
		}
	cout<<fixed<<setprecision(10)<<dfs(arr[1],arr[2],arr[3]);	
		
	return 0;
}

Measured memory_bytes: 217344
#include<stdio.h>
int main(){
  char c;
  int w,h,k,i;
  scanf("%d %d",&h,&w);
  while(h--){
    k=-1;
    for(i=0;i<w;i++){
      scanf(" %c",&c);
      if(c=='c')k=0;
      else if(k+1)k++;
      if(i)printf(" ");
      printf("%d",k);
    }
    printf("\n");
  }
  return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

int n;
ll a[200000], sum;

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

    cin >> n;
    REP(i, n) {
        cin >> a[i];
        a[i] -= (i + 1);
    }
    sort(a, a + n);
    ll mid = a[n / 2];
    REP(i, n) {
        sum += abs(a[i] - mid);
    }
    if (n % 2 == 0) {
        int idx = n / 2 - 1;
        ll tmp = 0;
        REP(i, n) {
            tmp += abs(a[i] - a[idx]);
        }
        sum = min(sum, tmp);
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
typedef long long ll;

int n,k;
string s,t;

int main() {
  cin >> n >> s >> t;
  int l=0;
  rep(i,n)
  if(s.substr(n-1-i)==t.substr(0,i+1)) l=i+1;
  cout << n+(n-l) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);

	int n,k;
	cin >> n >> k;
	vector<int>height(n);
	for(int& i:height) cin >> i;

	vector<int>dp(n,INT_MAX);

	dp[0] = 0;
	for(int i=0;i<n;i++){
		for(int j=1;j<=k;j++){
			if(j+i < n) dp[j+i] = min(dp[j+i],dp[i] + abs(height[i]-height[i+j]));
		}
	}

	cout << dp[n-1] << endl ;

	return 0;
}


Measured memory_bytes: 4036
import core.bitop, std.bitmanip;
import core.checkedint;
import std.algorithm, std.functional;
import std.array, std.container;
import std.bigint;
import std.conv;
import std.math, std.numeric;
import std.range, std.range.interfaces;
import std.stdio, std.string;
import std.typecons;

void main()
{
    int n, m;
    readf("%s %s", &n, &m);
    readln;
    
    auto arr = readln.chomp.split.map!(to!int).array;
    
    auto rbt = make!(RedBlackTree!(int, "a > b", true))(arr);
    
    while (m--) {
        auto x = rbt.front;
        
        rbt.removeFront();
        
        rbt.insert(x / 2);
    }
    
    long ans = 0;
    foreach (e; rbt) { ans += e; }
    
    ans.writeln;
}

Measured memory_bytes: 11464
#include<iostream>
using namespace std;
int main() {
	long n;
	cin >> n;
	int rest = n % 10;
	if (rest == 2 || rest == 4 || rest == 5 || rest == 7 || rest == 9) {
		cout << "hon"<<endl;
	}
	else if(rest==3){
		cout << "bon"<< endl;
	}
	else {
		cout << "pon" << endl;
	}
	return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val N, Q = Integer.parseInt(sc.next)
    val G = Array.fill(N + 1)(ArrayBuffer[Int]())
    (0 until N - 1) foreach { _ =>
      val a, b = sc.nextInt()
      G(a).append(b)
      G(b).append(a)
    }

    val PtoX = Array.fill(N + 1)(0)
    (0 until Q).foreach(_ => PtoX(sc.nextInt) += sc.nextInt)

    val Counter = new Array[Long](N + 1)
    val visited = new Array[Boolean](N + 1)

    val stack = new scala.collection.mutable.Stack[Int]
    stack.push(1)
    while (stack.nonEmpty) {
      val u = stack.pop()
      visited(u) = true
      Counter(u) += PtoX(u)
      G(u).foreach { v =>
        if (!visited(v)) {
          stack.push(v)
          Counter(v) += Counter(u)
        }
      }
    }

    println(Counter.tail.mkString(" "))
  }
}


Measured memory_bytes: 159748
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;
const int N = (int)1e3 + 123;
const int W = (int)1e4 + 123;
 
int dp[W], can[W];
int a[N], b[N];
int ans = mod;

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();   
	int h, n;
	cin >> h >> n;
	for(int i = 1; i <= n; i++) cin >> a[i] >> b[i];
	for(int i = 0; i < h; i++) dp[i] = mod;
	can[h] = 1;
	for(int j = h; j >= 1; j--)
	{
		if(can[j])	
		{
			for(int i = 1; i <= n; i++)
			{
				if(j - a[i] <= 0) 
				{
					ans = min(ans, dp[j] + b[i]);
					continue;
				}
				can[j - a[i]] = 1;
				dp[j - a[i]] = min(dp[j] + b[i], dp[j - a[i]]);
			}
		}
	}
	cout << ans;
}                                

Measured memory_bytes: 384
import std.stdio, std.conv;

void main(){
	int l, m, n;
	string ans;
	while (readf("%d\n", &l), l) {
		ans = "NA";
		foreach (i; 1..13) {
			readf("%d %d\n", &m, &n);
			l -= m-n;
			if (l <= 0 && ans == "NA") ans = text(i);
		}
		writeln(ans);
	}
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
const ll mod = 1e9 + 7;
const int maxn = 1e5 + 5;
int n , k;
ll a[maxn] , inv[maxn] , f[maxn] , c[maxn];
ll fpow(ll x , ll k) {
	ll ret = 1 , base = x;
	while(k) {
		if(k & 1) ret = ret * base % mod;
		base = base * base % mod;
		k >>= 1;
	}
	return ret;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> k;
	for(register int i = 1; i <= n; ++i)
		cin >> a[i];
	sort(a + 1 , a + n + 1);
	for(register int i = 1; i <= n; ++i)
		inv[i] = fpow(i , mod - 2);
	f[k] = k , f[k - 1] = 1;
	for(register int i = k + 1; i <= n; ++i)
		f[i] = i * f[i - 1] % mod;
	c[0] = 1;
	for(register int i = 1; i <= n - k + 1; ++i)
		c[i] = inv[i] * c[i - 1] % mod;
	ll ans = 0 , p;
	for(register int i = k; i <= n; ++i)
		ans = (ans + a[i]*(f[i-1]*c[i-k]%mod)%mod)%mod;
	for(register int i = k; i <= n; ++i)
		ans = (ans - a[n-i+1]*(f[i-1]*c[i-k]%mod)%mod)%mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi


def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

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


def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y


for _ in range(int(input()) if not True else 1):
    #n = int(input())
    d, t, s = map(int, input().split())
    #a, b = map(int, input().split())
    #c, d = map(int, input().split())
    #a = list(map(int, input().split()))
    #b = list(map(int, input().split()))
    #s = input()
    print("Yes" if s*t >= d else "No")

Measured memory_bytes: 62960
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
	FastIO
	lld n, i;
	cin >> n;
	lld A[n];
	foi(i,n){
		cin >> A[i];
	}
	lld c = 0;
	lld max = MIN;
	for(i = 1; i < n; i+=1){
		if (A[i]<=A[i-1]){
			c +=1;
		}
		else{
			if (c > max){
				max = c;
			}
			c = 0;
		}
	}
	if (c > max){
		max = c;
	}
	cout << max;
	return 0;
}

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

int main() {
    int n, k, s;
    cin >> n >> k >> s;
    int a = s > 2 ? s - 1 : 3;
    for(int i = 0; i < k; i++)
        cout << s << ' ';
    for(int i = k; i < n; i++)
        cout << a << ' ';
    cout << endl;
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second

vector<ll> par(1000001);//親（一つ上のノード）を持つ
vector<ll> ran(1000001,0);
vector<ll> gm(1000001,1);

void ini(int x){
    for(int i=0;i < x;i++)
    {
        par.at(i)=i;
    }
}
//-----------↑初期化↑--------------

ll findroot(ll x){
    if(par.at(x)==x){
        return x;
    }else{
        return findroot(par.at(x));
    }
}//根を見つける

//-----------↑親を見つける↑---------------

bool same(ll x,ll y){
    return par.at(x)==par.at(y);
}

//-----------↑同じグループかどうか判定↑----------

void unite(ll x,ll y){
    x=findroot(x);
    y=findroot(y);
    if(x==y){
        return ;
    }//二要素の根が同じならおわり

    if(ran.at(x)<ran.at(y)){
        par.at(x)=y;
    }else if(ran.at(x)>ran.at(y)){
        par.at(y)=x;
    }else{
        par.at(x)=y;
        ran.at(y)++;//ランクの低い方の木の根を高い方の根につなげる
    }
}
//-----------↑二つの要素をつなげる↑------------

int main(){
    ll n,m;
    cin >> n >> m;
    ini(n);
    vector<ll> h(m+1);
    vector<pair<ll,ll>> v(m);
    for(int i=0;i < m;i++)
    {
        cin >> v.at(i).fi >> v.at(i).se;
    }

    h.at(m)=0;

    for(int i=m-1; 0<=i;i--)
    {
        bool flag = false;
        ll t=gm.at(findroot(v.at(i).fi)),s=gm.at(findroot(v.at(i).se));
        if(same(findroot(v.at(i).fi),findroot(v.at(i).se))){
             h.at(i)=h.at(i+1);
        }else{
            h.at(i)=h.at(i+1)-s*t;
            flag = true;
        }
        unite(v.at(i).fi,v.at(i).se);
        if(flag){
            gm.at(findroot(v.at(i).fi))=s+t;
        }
    }

    for(int i=1;i < m+1;i++)//
    {
        h.at(i) += abs(h.at(0));
    }

    for(int i=1;i < m+1;i++)
    {
        cout << h.at(i) << endl;
    }
}

Measured memory_bytes: 27136
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(int n,i,a[]=new int[100],v,c,x;(n=s.nextInt())>0;System.out.println(c)){for(i=x=c=0;i<n;++i)a[i]=s.nextInt();for(v=s.nextInt();x<n&&++c>0&&a[i=(x+n-1)/2]!=v;)if(a[i]<v)x=i+1;else n=i;}}}

Measured memory_bytes: 12000
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = Integer.parseInt(scanner.next());
        }
        int min = A[0];
        int ans = 1;
        for (int i = 1; i < N; i++) {
            if (A[i] <= min) {
                ans++;
            }
            min = Math.min(min, A[i]);
        }

        System.out.println(ans);
    }

}



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

int main() {
  int n;
  cin >> n;
  vector<pair<long long,long long>>data(n);
  vector<long long>ans(n);
  for(int i = 0;i < n;i++){
    cin >> data[i].first;
    data[i].second = i;
  }
  sort(data.begin(),data.end());
  for(int i = 0;i < n;i++){
    if(i <= n/2-1){
      ans.at(data.at(i).second) = data.at(n/2).first;
    }
    else{
      ans.at(data.at(i).second) = data.at(n/2-1).first;
    }
  }
  for(int i = 0;i < n;i++){
    cout << ans.at(i) << endl;
  }
}


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

int main(){
  int n;
  cin >> n;
  
  if(n%10 == 3)
    cout << "bon" << endl;
  else if(n%10 == 0)
    cout << "pon" << endl;
  else if(n%10 == 1)
    cout << "pon" << endl;
  else if(n%10 == 6)
    cout << "pon" << endl;
  else if(n%10 == 8)
    cout << "pon" << endl;
  else
    cout << "hon" << endl;
}
    

Measured memory_bytes: 3636
# import math
# from functools import lru_cache

# @lru_cache(maxsize=100000)
# def gcd_list(a, b, c):
#     return gcd(gcd(a, b), c)

# @lru_cache(maxsize=100000)
# def gcd(x, y):
#     return math.gcd(x, y)


# for k in range (1, 201):
#     ans = 0
#     for a in range(1, k+1):
#         for b in range(1, k+1):
#             for c in range(1, k+1):
#                 ans += gcd_list(a,b,c)
#     print("%d:%d," % (k, ans))


a = {
1:1,
2:9,
3:30,
4:76,
5:141,
6:267,
7:400,
8:624,
9:885,
10:1249,
11:1590,
12:2208,
13:2689,
14:3411,
15:4248,
16:5248,
17:6081,
18:7485,
19:8530,
20:10248,
21:11889,
22:13687,
23:15228,
24:17988,
25:20053,
26:22569,
27:25242,
28:28588,
29:31053,
30:35463,
31:38284,
32:42540,
33:46581,
34:50893,
35:55362,
36:61824,
37:65857,
38:71247,
39:76884,
40:84388,
41:89349,
42:97881,
43:103342,
44:111528,
45:120141,
46:128047,
47:134580,
48:146316,
49:154177,
50:164817,
51:174438,
52:185836,
53:194157,
54:207927,
55:218812,
56:233268,
57:245277,
58:257857,
59:268182,
60:288216,
61:299257,
62:313635,
63:330204,
64:347836,
65:362973,
66:383709,
67:397042,
68:416448,
69:434025,
70:456967,
71:471948,
72:499740,
73:515581,
74:536073,
75:559758,
76:583960,
77:604833,
78:633651,
79:652216,
80:683712,
81:709065,
82:734233,
83:754734,
84:793188,
85:818917,
86:846603,
87:874512,
88:909496,
89:933081,
90:977145,
91:1006126,
92:1041504,
93:1073385,
94:1106467,
95:1138536,
96:1187112,
97:1215145,
98:1255101,
99:1295142,
100:1342852,
101:1373253,
102:1422195,
103:1453816,
104:1502376,
105:1553361,
106:1595437,
107:1629570,
108:1691292,
109:1726717,
110:1782111,
111:1827492,
112:1887772,
113:1925853,
114:1986837,
115:2033674,
116:2089776,
117:2145333,
118:2197483,
119:2246640,
120:2332104,
121:2379085,
122:2434833,
123:2490534,
124:2554600,
125:2609625,
126:2693919,
127:2742052,
128:2813988,
129:2875245,
130:2952085,
131:3003306,
132:3096024,
133:3157249,
134:3224511,
135:3306240,
136:3388576,
137:3444609,
138:3533637,
139:3591322,
140:3693924,
141:3767085,
142:3842623,
143:3912324,
144:4027884,
145:4102093,
146:4181949,
147:4270422,
148:4361548,
149:4427853,
150:4548003,
151:4616104,
152:4718640,
153:4812789,
154:4918561,
155:5003286,
156:5131848,
157:5205481,
158:5299011,
159:5392008,
160:5521384,
161:5610705,
162:5739009,
163:5818390,
164:5930196,
165:6052893,
166:6156139,
167:6239472,
168:6402720,
169:6493681,
170:6623853,
171:6741078,
172:6864016,
173:6953457,
174:7094451,
175:7215016,
176:7359936,
177:7475145,
178:7593865,
179:7689630,
180:7886244,
181:7984165,
182:8130747,
183:8253888,
184:8403448,
185:8523897,
186:8684853,
187:8802826,
188:8949612,
189:9105537,
190:9267595,
191:9376656,
192:9574704,
193:9686065,
194:9827097,
195:9997134,
196:10174780,
197:10290813,
198:10493367,
199:10611772,
200:10813692
}

k = int(input())
print(a[k])


Measured memory_bytes: 9392
import java.io.*;

class Main{
 public static void main(String[] args)throws IOException{
   BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
   String[] strAry; 
   int H,W,i,j;
      
   while(true){
     strAry = br.readLine().split(" ");
     H = Integer.parseInt(strAry[0]);  
     W = Integer.parseInt(strAry[1]);
     if(H==0&&W==0) break;
     for(j=0;j<H;j++){
       for(i=0;i<W;i++){
        if(j==0||j==H-1||i==0||i==W-1){
         System.out.print("#");
        }else{
         System.out.print(".");
        }
       }
       System.out.print("\n");  
     }     
     System.out.print("\n");  
     
    }  
      


  }
}

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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

// const value
// const ll MOD = 1e9 + 7;
// const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
// const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll k, n;
  cin >> k >> n;
  VLL a(n);
  rep(i, n) cin >> a[i];

  ll ans = (a.back() - a[0]);
  rep(i, n - 1) { chmin(ans, k - (a[i + 1] - a[i])); }
  cout << ans << endl;
  return 0;
}


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


typedef long long ll;
typedef long double ld;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;


#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define asd cout << "ok" << endl;


#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define trav(it, m) for(auto it = m.begin(); it!= m.end(); it++)

const int MOD = 1e9 + 7;
const ll INF = 1e19;
const ld PI = acos((ld)-1);
const int MX = 2e5 +5;
const char nl = '\n';


int main(){

  int n; cin >> n;
  int a[n];
  for(int i= 0; i < n; i++){
    cin >> a[i];
  }
  int ans  = 0;
  for(int i = 0 ; i < n -1; i++){
    for(int j = i+1; j < n; j++)
    {
      ans = max(ans, abs(a[j] - a[i]));
    }
  }
  cout << ans << nl;




  return 0;
}



















Measured memory_bytes: 3648
import java.util.*;
import java.io.PrintWriter;
public class Main{
	static int[][] xd;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long mod=998244353;
		xd=new int[n][2];
		SegTree st=new SegTree(n);
		for(int i=0; i<n; i++){
			xd[i][0]=sc.nextInt();
			xd[i][1]=sc.nextInt();
		}
		Arrays.sort(xd,(x,y)->(x[0]-y[0]));
		int[] max=new int[n];
		for(int i=n-1; i>=0; i--){
			int idx=bs(i,n,xd[i][0]+xd[i][1]-1);
          if(idx==i){
            max[i]=i;
          }else{
			max[i]=st.query(i+1,idx+1);
          }
          st.set(i,max[i]);
		}
		long[] dp=new long[n+1];
		dp[n]=1;
		dp[n-1]=2;
		for(int i=n-2; i>=0; i--){
			dp[i]+=dp[i+1]+dp[max[i]+1];
			dp[i]%=mod;
		}
		System.out.println(dp[0]);
	}
	static int bs(int left,int right,int dis){
		int l=left;
		int r=right;
		while(r-l>1){
			int m=(r+l)/2;
			if(xd[m][0]<=dis){
				l=m;
			}else{
				r=m;
			}
		}
		return l;
	}
	static class SegTree{
		int n=1;
		int[] v;
		
		public SegTree(int n) {
			while(this.n<n)this.n*=2;
			v=new int[2*this.n-1];
		}
		
		void set(int k,int val) {
			k+=n-1;
			v[k]=val;
			while(k>0) {
				k=(k-1)/2;
				v[k]=Math.max(v[2*k+1],v[2*k+2]);
			}
		}
		
		int query(int a,int b) {
			return query(0,n,a,b,0);
		}
		
		int query(int l,int r,int a,int b,int k) {
			if(r<=a||b<=l)return 0;
			else if(a<=l&&r<=b)return v[k];
			else {
				int vl=query(l,(l+r)/2,a,b,2*k+1);
				int vr=query((l+r)/2,r,a,b,2*k+2);
				return Math.max(vl,vr);
			}
		}
	}
}


Measured memory_bytes: 123180
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
 
#define sPRINT(str) printf(#str "\n")
#define yOUT sPRINT(Yes)
#define nOUT sPRINT(No)
#define YOUT sPRINT(YES)
#define NOUT sPRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
 
using namespace std;

int main(void)
{   
    int n, k, sum=0, inp;
    cin >> n >> k;
    REP(i, n){
        cin >> inp;
        sum += 2*min(inp,(k-inp));
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

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

    int n;
    cin >> n;

    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }

    int maxi = 0;
    rep(i, n){
        if(maxi < a[i]){
            cout << -1 << endl;
            return 0;
        }
        chmin(maxi, a[i]);
        ++maxi;
    }

    lint ans = 0;
    rep(i, n - 1){
        if(a[i] < a[i + 1]){
            ++ans;
        }else{
            ans += a[i + 1];
        }
    }

    cout << ans << endl;

    cout << flush;

    return 0;
}

Measured memory_bytes: 1024
# coding: utf-8
import time
import re
import math

def main():
    N,X=map(int,input().split())
    L=list(map(int,input().split()))
    count=0
    num=0
    for a in range(N+1):
        if a>0:
            num=num+L[a-1]
        if num<=X:
            count+=1
    print(count)
start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#"YNeos"[True::2]
#A=list(map(int,input().split()))
#n=int(input())
# global n,A,s,memo,mx,mn,L,B


Measured memory_bytes: 3184
#include<iostream>

using namespace std;
int main(){
    int R, G, B, N;
    cin >> R >> G >> B >> N;

    int r,g,b,count=0;
    for(r=0; r*R<=N; r++){
        for(g=0; r*R+g*G<=N; g++){
            if((N-r*R-g*G)%B==0){
                count++;
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    a=list(map(int,readline().split()))
    ans=1

    flag_zero=False
    for i in range(n):
        if a[i]==0:
            flag_zero=True

    if flag_zero:
        print(0)
    else:
        flag=True
        for i in range(n):
            ans*=a[i]
            if ans>10**18:
                flag=False
                break

        if flag:
            print(ans)
        else:
            print(-1)

if __name__=="__main__":
    main()

Measured memory_bytes: 21908
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }.sorted()

    var sum = 0
    for (i in 0..(n-2)) {
        sum += a[i]
    }

    println(if(sum > a[n-1]) "Yes" else "No")
}

Measured memory_bytes: 37992
# Integer Cards

cards = []
rewrite_source = []

N, M = gets.chomp.split(" ").map(&:to_i)

cards = gets.chomp.split(" ").map(&:to_i)

for i in 0...M do
  bnum, cnum = gets.chomp.split(" ").map(&:to_i)
  rewrite_source[i] = [bnum, cnum]
end

cards.sort!

rewrite_source.sort_by!{|a| a[1]}.reverse!


i = 0
j = 0

check = 0

while i < M

  while j < N
    if j >= rewrite_source[i][0] + check then
      break
    elsif cards[j] <= rewrite_source[i][1] then
      cards[j] = rewrite_source[i][1]
      j += 1
    else
      break
    end
  end

  check = j
  i += 1
end

answer = 0

cards.each{|a|
  answer += a
}

puts answer


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

int main(){
	int N, K;
	
	int num[200000] = { 0 };
	int numa;
	int numb = 0;
	int count = 0; int m = 0;
	cin >> N >> K;
	int K1=0;
	for (int i = 0;i < N;i++) {
		cin >> numa;
		num[numa-1]++;
	}
	for (int i = 0;i < N;i++) {
		if (num[i] != 0) K1++;
	}
	sort(num, num + N);
	if (K1 - K >= 1) {
		while (count != K1- K) {
			m++;
			if (num[m] != 0) {
			numb += num[m];
			count++;
		}
		}
		
	}
	cout << numb;
}

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

int main(){
    int n;
    cin >> n;
    map<int,int> cnt;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        cnt[a]++;
    }
    ll ans=0;
    for(auto p: cnt){
        int x,num;
        x = p.first;
        num= p.second;
        if(num>=x) ans+=(ll)(num-x);
        else ans+=(ll)num;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

int main() {
    int m,k,z,y,ans;
    ans = 0;
    cin >> m >> k;
    for(int i = 0;i < m;i++){
        cin >> z;
        y = min(abs(z-k),z);
        ans += y * 2;
    }
    cout << ans << endl;
    
}



Measured memory_bytes: 256
//
//  main.cpp
//  Exercise
//
//

#include <algorithm>
#include <iostream>
#include <limits>
#include <math.h>
#include <tuple>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include "string.h"
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <set>

using namespace std;

using intll_t = long long;

int main() {
    int N;
    scanf("%d", &N);
    vector<pair<int, int>> idxAndXns; // (idx in (1..N), Xn)
    idxAndXns.reserve(N);
    for (int n = 0; n < N; n++) {
        int xn;
        scanf("%d", &xn);
        idxAndXns.push_back(make_pair(n + 1, xn));
    }
    sort(idxAndXns.begin(), idxAndXns.end(),
         [](pair<int, int> idxAndXn1, pair<int, int> idxAndXn2) -> bool { return idxAndXn1.second < idxAndXn2.second; });
    unordered_map<int, int> idxToOrderMap;
    idxToOrderMap.reserve(N); // order : 1..N
    for (int n = 0; n < N; n++) {
        int idx = idxAndXns[n].first;
        idxToOrderMap.insert(make_pair(idx, n+1));
    }
    int meanFormer = idxAndXns[N/2 - 1].second;
    int meanLatter = idxAndXns[N/2].second;
    for (int idx = 1; idx <= N; idx++) {
        int order = idxToOrderMap.at(idx);
        if (order > N/2) {
            printf("%d\n", meanFormer);
        } else {
            printf("%d\n", meanLatter);
        }
    }
    // printf("\n");
    return 0;
}

Measured memory_bytes: 11648
#include<stdio.h>

int main()
{

int n;
scanf("%d",&n);
int r;
int a,b,c;
a=n%10;
n=n/10;
b=n%10;
n=n/10;
c=n%10;
//printf("%d %d %d",a,b,c);
if(c==1){
c=9;
printf("%d",c);
}
else{
c=1;
printf("%d",c);
}

if(b==1){
b=9;
printf("%d",b);
}
else{
b=1;
printf("%d",b);
}
if(a==1){
a=9;
printf("%d",a);
}
else{
a=1;
printf("%d",a);
}



return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const *argv[])
{
    string input;
    int ans = 0;
    cin >> input;
    for (int i = 0; i < 4; i++)
    {
        if (input.at(i) == '2')
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'

using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef long long LL;

static const int INF = INT_MAX;
static const LL L_INF = LLONG_MAX;

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

    int n;
    cin >> n;
    int a[n];
    int ans = 0;
    for(int i = 0; i < n; ++i) { cin >> a[i]; ans += a[i]; }
    sort(a, a + n);

    int i = 0;
    if( !(ans % 10) ) {
        while(i < n && !((ans - a[i]) % 10)) {
            ++i;
        }

        if( i == n ) cout << 0 << endl;
        else cout << ans - a[i] << endl;
    } else cout << ans << endl;

    return 0;
}




Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000000;

/* typedef */

typedef long long ll;

/* global variables */

int phis[MAX_N + 1];
ll fs[MAX_N + 1];

/* subroutines */

/* main */

int main() {
  for (int i = 0; i <= MAX_N; i++) phis[i] = i;
  for (int i = 1; i <= MAX_N; i++)
    for (int j = i + i; j <= MAX_N; j += i) phis[j] -= phis[i];

  fs[1] = 2;
  for (int i = 2; i <= MAX_N; i++) fs[i] = fs[i - 1] + phis[i];

  int tn;
  cin >> tn;

  while (tn--) {
    int n;
    cin >> n;

    cout << fs[n] << endl;
  }

  return 0;
}

Measured memory_bytes: 12876
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
	int N; cin >> N;
	vector<long long>A(N);
	long long B, C, ans = 0, sum = 0;

	for (int i = 0; i < N; i++) {
		cin >> B >> C;
		A.at(i) = B + C;
		ans += C;
	}
	sort(A.begin(), A.end(), greater<long long>());
	for (int i = 0; i < N; i += 2) {
		sum += A.at(i);
	}
	cout << sum - ans << endl;
}

Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		Main m = new Main();
		m.run();
	}
	
	void run(){
		int n = sc.nextInt();
		int x = sc.nextInt();
		int a[] = new int[n];
		for(int i =0 ; i < n ; i++){
			a[i] = sc.nextInt();
		}
		
		Arrays.sort(a);
		int count = 0;
		long sum = 0;
		for(;count < n;){
			if( x >= sum + a[count]){
				sum = sum + a[count];
				count++;
			}else{
				break;
			}
		}
		if(count == n && sum != x ){
			count --;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define N 500005
int X=2e5,n,l,r;bool fl;char a[N],ans[N];
int main()
{
	scanf("%s %d",a+1,&n);l=X+1;r=X+strlen(a+1);
	for(int i=1;i<=strlen(a+1);++i) ans[X+i]=a[i];
	for(int i=1,F[2];i<=n;++i)
	{
		scanf("%d",&F[0]);
		if(F[0]==1) fl^=1;
		if(F[0]==2)
		{
			char c[2];scanf("%d %s",&F[1],c);
			if(F[1]==1) {if(fl) ans[++r]=c[0];else ans[--l]=c[0];}
			if(F[1]==2) {if(fl) ans[--l]=c[0];else ans[++r]=c[0];}
		}
	}
	if(fl) for(int i=r;i>=l;--i) printf("%c",ans[i]);
	else for(int i=l;i<=r;++i) printf("%c",ans[i]);return 0;
}

Measured memory_bytes: 896
n, m = map(int, input().split())
py = [list(map(int, (input() + " 0 " + str(i)).split())) for i in range(m)]
py = sorted(py, key=lambda x: (x[0], x[1]))
d = {}
for i, v in enumerate(py):
    if v[0] not in d:
        d[v[0]] = 1
    else:
        d[v[0]] += 1
    v[2] = d[v[0]]
py = sorted(py, key=lambda x: x[3])
for i in py:
    print(("000000" + str(i[0]))[-6:] + ("000000" + str(i[2]))[-6:])


Measured memory_bytes: 82132
# セグメント木。区間における要素の取得をO(logN)で行うことが可能である。
class SegTree():
    def __init__(self, lists, function, basement):
        self.n = len(lists)
        self.K = (self.n-1).bit_length()
        self.func = function
        self.basement = basement
        self.seg = [basement]*2**(self.K+1)

        for i in range(self.n):
            self.seg[i+2**self.K-1] = lists[i]

        for i in range(2**(self.K)-2, -1, -1):
            self.seg[i] = self.func(self.seg[2*i+1], self.seg[2*i+2])

    def update(self, k, value):
        # 0-indexでa[k]の値をvalueに変更
        k += 2**self.K-1
        self.seg[k] = value
        while k:
            k = (k-1)//2
            self.seg[k] = self.func(self.seg[k*2+1], self.seg[k*2+2])

    def query(self, p, q):
        # 0-indexで[p,q)の値を取得する
        if q <= p:
            return self.basement
        num = 2**self.K
        p += num-1
        q += num-2
        res = self.basement
        while q-p > 1:
            if p & 1 == 0:
                res = self.func(res, self.seg[p])
            if q & 1 == 1:
                res = self.func(res, self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.func(res, self.seg[p])
        else:
            res = self.func(self.func(res, self.seg[p]), self.seg[q])
        return res


#gcd on blackboard
#セグ木（区間gcd) verify
from fractions import gcd
N=int(input())
A=list(map(int,input().split()))
seg=SegTree(A,gcd,0)
ans=1
for i in range(-1,N):
    v=gcd(seg.query(0,i),seg.query(i+1,N))
    ans=max(v,ans)
print(ans)


Measured memory_bytes: 92008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main()
{
    int X, Y, Z, K; cin >> X >> Y >> Z >> K;
    priority_queue<tuple<ll, int, int, int>> p;
    vector<ll> A, B, C;
    map<tuple<int, int, int>, bool> m; 
    ll a;
    rep(i, X + Y + Z)
    {
        cin >> a;
        if (i < X) A.push_back(a);
        else if (i < X + Y) B.push_back(a);
        else C.push_back(a);
    }
    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());

    p.push(make_tuple(A[0] + B[0] + C[0], 0, 0, 0));
    m[make_tuple(0, 0, 0)] = 1;

    ll ans;
    int i, j, k;
    rep(l, K)
    {
        ans = get<0>(p.top());
        i = get<1>(p.top()); j = get<2>(p.top()); k = get<3>(p.top());
        p.pop();
        cout << ans << endl;
        if (!m[make_tuple(i + 1, j, k)] && i + 1 < X) p.push(make_tuple(A[i + 1] + B[j] + C[k], i + 1, j, k));
        if (!m[make_tuple(i, j + 1, k)] && j + 1 < Y) p.push(make_tuple(A[i] + B[j + 1] + C[k], i, j + 1, k));
        if (!m[make_tuple(i, j, k + 1)] && k + 1 < Z) p.push(make_tuple(A[i] + B[j] + C[k + 1], i, j, k + 1));

        m[make_tuple(i + 1, j, k)] = 1;
        m[make_tuple(i, j + 1, k)] = 1;
        m[make_tuple(i, j, k + 1)] = 1;
    }
    
}

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

#define int long long

void solve(int tt)
{
    int n,m,x;
    cin>>n>>m>>x;
    int a[n+5][m+5],c[n+5];
    for(int i=0;i<n;i++)
    {
        cin>>c[i];
        for(int j=0;j<m;j++)
            cin>>a[i][j];
    }
    int ans=1e18;
    for(int i=0;i<(1<<n);i++)
    {
        int temp[m+5]={0},tp=0;
        for(int j=0;j<n;j++)
        {
            if(i&(1<<j))
            {
                tp+=c[j];
                for(int k=0;k<m;k++)
                    temp[k]+=a[j][k];
            }
        }
        bool flag=true;
        for(int j=0;j<m;j++)
        {
            if(temp[j]<x)
                flag=false;
        }
        if(flag)
            ans=min(ans,tp);
    }
    if(ans==1e18)
        ans=-1;
    cout<<ans;
}

int32_t main()
{
    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)
        solve(i);
}

Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);

        System.out.println(a[n - 1] - a[0]);
    }
}


Measured memory_bytes: 23252
#include <stdio.h>

void func(int,int* volume,int);

int main(void) {
	int r, d, x;
	int i;
	scanf("%d%d%d", & r, &d, &x);

	for (i = 0;i < 10;i++) {
		func(r, &x, d);
	
	}
	return 0;

}

void func(int r,int* volume,int d) {
	*volume = r * (*volume) - d;
	printf("%d\n", *volume);

		return;
}

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

int main(){
    int a, five=0, seven=0;
    for(int i=0;i<3;i++){
        cin >> a;
        if(a == 5) five++;
        if(a == 7) seven++;
    }
    if(five == 2 && seven == 1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const double EPS=1e-10;
const ll INF=1000000000;
int main(){
    int n,m,a;
    while(cin>>n>>m>>a,n+m+a){
        vector<P> v[110];
        for(int i=0;i<m;i++){
            int h,p,q;
            cin>>h>>p>>q;
            v[p].push_back(P(h,q));
            v[q].push_back(P(h,p));
        }
        for(int i=1;i<=n;i++){
            sort(v[i].begin(),v[i].end(),greater<P>());
        }
        int hi=INF;
        while(1){
            bool f=true;
            for(int i=0;i<v[a].size();i++){
                P p=v[a][i];
                if(p.first<hi){
                    f=false;
                    a=p.second;
                    hi=p.first;
                    break;
                }
            }
            if(f){
                break;
            }
        }
        cout<<a<<endl;
    }
    return 0;
}


Measured memory_bytes: 3124
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

#define INF 1001001001
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;


int main(){
    int n; cin >> n;
    vector<pair<int, int>> tasks(n);
    
    rep(i,n){
        int a,b; cin >> a >> b;
        tasks[i].first = b;
        tasks[i].second = a;
        

    }
    sort(tasks.begin(), tasks.end());
    int sum = 0;
    
    rep(i,n){
        sum += tasks[i].second;
        if(sum > tasks[i].first){
            cout <<"No"<< endl;
            return 0;
        }
    }
    
    cout <<"Yes"<< endl;



}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;
 
int main(){
  int n;
  cin >> n;
  ll ans;
  rep(i, n){
    ll t;
    cin >> t;
    if(i == 0) ans = t;
    else{
      ll g = __gcd(ans, t);
      ans = t / g * ans;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
#define N 200010
using namespace std;
int n,k;
double p,sum[N],ans=0;
int main(){
	int i,j;
	double x;
	cin>>n>>k;
	memset(sum,0,sizeof(sum));
	for(i=0;i<n;i++)
	{
		cin>>x;
		p=(x+1)/2;
		sum[i+1]=sum[i]+p;
	}
	for(i=0;i+k<=n;i++)
	{
		ans=max(ans,sum[i+k]-sum[i]);
	}
	printf("%.15f\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;


int main() {
        vector<int> P = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        int k;
        cin >> k;
        cout << P.at(k-1) << endl;
        
        return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int,int>ma;
vector<int>vec;
int main()
{
    int n,x,a;
    long long ans=0,sum=0,mod;
    scanf("%d%lld",&n,&mod);
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a);
        sum+=a;
        x=sum%mod;
        if(ma[x]==0)vec.push_back(x);
        ma[x]++;
    }
    int len=vec.size();
    for(int i=0; i<len; i++)
    {
        sum=ma[vec[i]];
        if(vec[i])sum--;
        ans+=sum*(sum+1)/2;
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 3452
def count_four(lst):
    counter = 0
    for i in lst:
        if i%4 == 0:
            counter += 1
    return counter

def count_two(lst):
    counter = 0
    for i in lst:
        if i%2 == 0:
            counter += 1
    return counter

n = int(input())
lst = list(map(int,input().split()))

def solve(lst):
    four = count_four(lst)
    two = count_two(lst) - four
    others = n - four - two

    if two == 0:
        if four + 1 - others >= 0:
            return "Yes"
        else:
            return "No"

    if two > 0:
        two = 1
        if four + 1 - others - two >= 0:
            return "Yes"
        else:
            return "No"


print(solve(lst))

Measured memory_bytes: 14252
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Numerics;

public class Program
{
    public static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = new int[n];

        string[] line = Console.ReadLine().Split(' ');
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = int.Parse(line[i]);
        }


        int v = a[0];
        for (int i = 1; i < a.Length; i++)
        {
            v = Gcd(v, a[i]);
        }

        Console.WriteLine(v);
        Console.ReadLine();
    }

    public static int Gcd(int a, int b)
    {
        if (a < b) return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }

}


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

int main(){

int cnt=0;
int n, d;
vector<int> x(200010), y(200010);
cin >> n >> d;
for(int i=0;i<n; i++) cin >> x[i] >> y[i];
/*
pair<int, int> p[200010];
rep(i,n) cin >> p[i].first >> p[i].second;
sort(p, p+n, greater<pair<int, int>>());
for(int i=0; i<n; i++){
    if(!(i>=1 && p[i].first==p[i-1].first && p[i].second==p[i-1].second)){
    if( p[i].first*p[i].first+p[i].second*p[i].second<=d*d) cnt++;
    }
}
*/
for(int i=0;i<n; i++) {
    ll p=pow(x[i],2)+pow(y[i],2);
    ll q=pow(d,2);
   // cout << p << endl;
    if(p<=q) cnt++;
}
cout << cnt << endl;

}

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

const ll mod = 1e9 + 7;
char s[3005];
int main()
{
    int n;
    scanf("%d",&n);
    scanf("%s",&s);
    vector < ll > dp(2);
    vector < ll > new_dp;
    dp[1] = 1;
    for(int len = 2 ; len <= n; len++)
    {
        new_dp.resize(len+1);
        for(int last = 1 ; last <= len ; last++)
            new_dp[last] = (new_dp[last-1] + (s[len-2] == '<' ? dp[last-1] : (dp[len-1] + mod - dp[last-1])%mod))%mod;
        dp = new_dp;
    }
    printf("%lld\n",dp[n]);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;

int modd=1e9+7;

int main(){
  int n,k; cin>>n>>k;
  int ans[k+1];
  for(int i=0; i<=k; i++)  ans[i]=0;
  int arr[n];
  for(int i=0; i<n; i++) cin>>arr[i];

  int key;
  for(int i=1; i<n; i++){
    key=arr[i]; int j=i-1;
    for( ; j>=0; j--){
        if(arr[j]>arr[j+1]) arr[j+1]=arr[j];
        else {  break; }
    }
    arr[j+1]=key;
  }

  int r; 
  for(int i=1; i<=k; i++){
    for(int j=0; j<n; j++){
      r=arr[j];
      if(i<r) break;
      if(ans[i-r]==0) { ans[i]=1; break; }
    }
  }

  if(ans[k]==1) cout<<"First"<<endl;
  else cout<<"Second"<<endl;
}


Measured memory_bytes: 640