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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef pair<int, int> PII;

const double EPS = 1e-10;

typedef struct edge_def {
  int from;
  int to;
  int cost;

  edge_def(int _from, int _to, int _cost) {
    from = _from;
    to   = _to;
    cost = _cost;
  }
} edge;

const int INF = INT_MAX;
const int V = 100;
int n, t;
vector<edge> es[V];
int d[V];

void dijkstra(int s) {
  int i;
  priority_queue<PII, vector<PII>, greater<PII > > q;
  for (i=0; i<n; i++) d[i] = INF;
  d[s] = 0;
  q.push(PII(0, s));

  while (q.size()) {
    PII p = q.top();
    q.pop();
    int v = p.second;

    if (d[v] < p.first) continue;

    for (i=0; i<(int)es[v].size(); i++) {
      edge e = es[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost; 
        q.push(PII(d[e.to], e.to));
      }
    }
  }
}

int main() {
  int i, j;
  memset(d, 0xff, sizeof(d));
  for (i=0; i<V; i++) es[i].clear();

  scanf("%d ", &n);
  for (i=0; i<n; i++) {
    int u, v, k;
    scanf("%d ", &u);
    scanf("%d ", &k);
    for (j=0; j<k; j++) {
      scanf("%d ", &v);
      es[u-1].psb(edge(u-1, v-1, 1));
    }
  }

  dijkstra(0);

  for (i=0; i<n; i++) {
    if (d[i]==INF) d[i] = -1;
    printf("%d %d\n", i+1, d[i]);
  }

	return 0;
}

Measured memory_bytes: 1200
n = gets.chomp.to_i
def dsum(n)
  sum = 0
  while n > 0 do
    sum += n % 10
    n /= 10
  end
  sum
end
min = 10**12
1.upto(n/2) do |k|
  s = dsum(k) + dsum(n-k)
  min = s if min > s
end
puts min


Measured memory_bytes: 1788
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
    int dice[2][6];
    int vector[3][4]={{0,2,5,3},{0,1,5,4},{1,2,4,3}};
    int i,j,k,l,m,c;
    for(i=0;i<2;i++)
    {
        for(j=0;j<6;j++)
        {
            cin >> dice[i][j];
        }
    }
    for(i=0;i<2;i++)
    {
        for(j=0;j<4;j++)
        {
            int temp = dice[1][vector[i][0]];
            for(k=0;k<3;k++)
            {
                dice[1][vector[i][k]] = dice[1][vector[i][k+1]];
            }
            dice[1][vector[i][3]] = temp;
            c = 0;
            for(k=0;k<6;k++)
            {
                if(dice[0][k]==dice[1][k])c++;
            }
            //printf("First: dice[1] %d %d %d %d %d %d\n",dice[1][0],dice[1][1],dice[1][2],dice[1][3],dice[1][4],dice[1][5]);
            if(c==6)break;
            for(m=0;m<3;m++){
                for(k=0;k<4;k++)
                {
                    int temp = dice[1][vector[m][0]];
                    for(l=0;l<3;l++)
                    {
                        dice[1][vector[m][l]] = dice[1][vector[m][l+1]];
                    }
                    dice[1][vector[m][3]] = temp;
                    c=0;
                    for(l=0;l<6;l++)
                    {
                        if(dice[0][l]==dice[1][l])c++;
                    }
                    //printf("i:0 dice[1] :%d %d %d %d %d %d\n",dice[1][0],dice[1][1],dice[1][2],dice[1][3],dice[1][4],dice[1][5]);
                    if(c==6)break;
                }
                if(c==6)break;
            }
            if(c==6)break;
        }
        if(c==6)break;
    }
    if(c==6){
        cout << "Yes" <<endl;
    }
    else {
        cout << "No" <<endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
char A[110];
char B[110];
char C[110];
int main(){
	scanf("%s%s%s",A,B,C);
	if(A[strlen(A)-1]==B[0]&&B[strlen(B)-1]==C[0])printf("YES\n");
	else printf("NO\n");
}

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

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> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main()
{
    int n;
    cin >> n;
    ll sum = 0;
    map<ll, ll> m;
    rep(i, n) {
        int a;
        cin >> a;
        m[a]++;
        sum += a;
    }
    int q;
    cin >> q;
    rep(i, q) {
        ll b, c;
        cin >> b >> c;
        if(m.find(b) != m.end()) {
            int cnt = m[b];
            sum -= (b*cnt);
            sum += (c*cnt);
            m.erase(b);
            m[c] += cnt;
        }

        cout << sum << endl;
    }

    return 0;
}


Measured memory_bytes: 7580
n = int(input())
a = [int(_) for _ in input().split()]

if n % 2 == 0:
    ind_1 = [2*i for i in range(1, n//2+1)][::-1]
    b_front = [str(a[i-1]) for i in ind_1]
    ind_2 = [2*i-1 for i in range(1, n//2+1)]
    b_back = [str(a[i-1]) for i in ind_2]
    b = b_front + b_back
    print(' '.join(b))
else:
    ind_1 = [2*i-1 for i in range(1, n//2+2)][::-1]
    b_front = [str(a[i-1]) for i in ind_1]
    ind_2 = [2*i for i in range(1, n//2+1)]
    b_back = [str(a[i-1]) for i in ind_2]
    b = b_front + b_back
    print(' '.join(b))


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

template <typename T>
std::tuple<T, T, T> extgcd(T a, T b){
    T s1 = 1, t1 = 0, s2 = 0, t2 = 1;
    while(b != 0){
        std::tie(s1, t1, s2, t2) = std::make_tuple(s2, t2, s1 - (a / b) * s2, t1 - (a / b) * t2);
        std::tie(a, b) = std::make_tuple(b, a % b);
    }
    return std::make_tuple(s1, t1, a);
}

// 注意: a と mod が互いに素である必要がある
template <typename T>
T mod_inverse(T a, T mod){
    T b;
    std::tie(b, std::ignore, std::ignore) = extgcd(a, mod);
    if(b < 0){b += mod;}
    return b;
}

template <typename T>
struct Combinatorics{
    T modulo;
    std::vector<T> fact, inv_fact;

    Combinatorics(T max, T modulo) : modulo(modulo), fact(max + 1), inv_fact(max + 1) {
        fact[0] = 1;
        for(T i=1;i<=max;++i){
            fact[i] = i * fact[i - 1] % modulo;
        }

        inv_fact[max] = mod_inverse(fact[max], modulo);
        for(T i=max;i>0;--i){
            inv_fact[i - 1] = i * inv_fact[i] % modulo;
        }
    }

    T nPk(T n, T k){
        if(n < k){return 0;}
        return fact[n] * inv_fact[n - k] % modulo;
    }

    T nCk(T n, T k){
        if(n < k){return 0;}
        return fact[n] * inv_fact[k] % modulo * inv_fact[n - k] % modulo;
    }

    T nHk(T n, T k){
        if(n == 0 && k == 0){return 1;}
        return nCk(n + k - 1, k);
    }
};

constexpr ll MOD = 1'000'000'007;
Combinatorics<ll> comb(200100, MOD);

int N, K;
std::vector<int> G[100100];

ll dfs(int v, int p){
    ll used = p == -1 ? 1 : 2,
        n = p == -1 ? G[v].size() : G[v].size() - 1;

    if(K < used){
        return 0;
    }

    ll res = comb.nPk(K - used, n);

    // std::cout << v << ", " << p << ", " << res << std::endl;

    for(int w : G[v]){
        if(w == p){
            continue;
        }

        res = res * dfs(w, v) % MOD;
    }

    return res;
}

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

    std::cin >> N >> K;

    for(int i=0;i<N-1;++i){
        int a, b;
        std::cin >> a >> b;

        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    ll res = dfs(1, -1) * K % MOD;
    std::cout << res << std::endl;
}


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

int main() {
  int N, A;
  cin >> N >> A;
  if ( N%500 > A ){
    cout << "No" <<endl;
  }
  else{
    cout << "Yes" << endl;
  }
  
  // ここにプログラムを追記
}


Measured memory_bytes: 256
# 初期入力
N = int(input())
P = list(map(int, input().split()))

#　右から１つ目と２つ目だけ比較し分岐
count =1 # 一つ目（添え字０）は必ずOK
P_min = P[0]
for i in range(1,N):
    if P[i-1] < P[i]: # 増えていたら×
        #print(P[i],P[:i+1])
        continue
    elif P[i] <= P_min: # 今までのPで最小値ならOK
        #print(P[i],P[:i+1])
        count +=1
        P_min = P[i]
print(count)

Measured memory_bytes: 24744
import random
import math
LI = lambda: list(map(int,input().split()))
MI = lambda: map(int,input().split())
yes = lambda: print("Yes")
no = lambda: print("No")
I = lambda: list(input())
J = lambda x: "".join(x)
II = lambda: int(input())
SI = lambda: input()
#---khan17---template
t = II()
a,b = MI()
boo = False
for i in range(a,b+1):
	if i%t == 0:
		boo = True
		break
print("OK" if boo else "NG")

Measured memory_bytes: 9572
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <cassert>
#include <limits>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

int r[5009][5009];
int s[509][100009];

int gcd(int a, int b) {
	if (b == 0) return a;
	if (a <= 5000 && b <= 5000) return r[a][b];
	if (a <= 100000 && b <= 200) return s[b][a];
	return gcd(b, a % b);
}

void init() {
	for (int i = 1; i <= 5000; i++) {
		for (int j = i; j <= 5000; j += i) {
			for (int k = i; k <= 5000; k += i) r[j][k] = i;
		}
	}
	for (int i = 0; i <= 100000; i++) s[0][i] = i;
	for (int i = 0; i <= 500; i++) s[i][0] = i;
	for (int i = 1; i <= 500; i++) {
		for (int j = i; j <= 500; j += i) {
			for (int k = i; k <= 100000; k += i) s[j][k] = i;
		}
	}
}

long long solve_slow(int W, int H, int K) {
	long long cnt = 0;
	for (int i = 1; i <= W / 2; i++) {
		int a = i, b = W - a, base = 2;
		int V = W * (W - i) / gcd(W - i, W);
		if (i * 2 == W) base = 1;

		// 全探索
		for (int j = 1; j <= H - 1; j++) {
			int r1 = b * j; if (r1 > 2 * K + 2 * W + 2) break;

			for (int k = 1; k <= min(H - 1, V); k++) {
				int r2 = a * k; if (r1 + r2 > 2 * K + 2 * W + 2) break;

				// 求めるパート
				int x = j, y = k;
				int area = a * y + b * x;
				int z1 = s[a][x];
				int z2 = s[b][y];
				int z3 = s[W][abs(x - y)];
				int z = (area - (z1 + z2 + z3)); z += 2;
				if (z <= K * 2) {
					int adds = a * V;
					int rems = (K * 2) - z; rems /= adds; rems++;
					int rem2 = (H - 1 - k); rem2 /= V; rem2++;
					cnt += 1LL * min(rems, rem2) * base;
				}
			}
		}
	}
	return cnt;
}

long long solve(int W, int H, int K) {
	if (W <= 500) return solve_slow(W, H, K);

	long long cnt = 0;
	for (int i = 1; i <= W / 2; i++) {
		int a = i, b = W - a, base = 2;
		if (i * 2 == W) base = 1;

		// 全探索
		for (int j = 1; j <= H - 1; j++) {
			int r1 = b * j; if (r1 > 2 * K + 2 * W + 2) break;

			for (int k = 1; k <= H - 1; k++) {
				int r2 = a * k; if (r1 + r2 > 2 * K + 2 * W + 2) break;

				// 求めるパート
				int area = a * k + b * j;
				int z1 = gcd(a, j);
				int z2 = gcd(b, k);
				int z3 = gcd(W, abs(j - k));
				int z = (area - (z1 + z2 + z3)); z >>= 1; z += 1;
				if (z <= K) {
					cnt += 1LL * base;
				}
			}
		}
	}
	return cnt;
}

int main() {
	init();
	long long W, H, K; init();
	cin >> W >> H >> K;

	long long V1 = solve(W, H, K);
	long long V2 = solve(H, W, K);
	cout << 2LL * (V1 + V2) << endl;
	return 0;
}

Measured memory_bytes: 297180
#include<iostream>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int sumcalc(int tmp){
    int calc = 0;
    int suma = 0;
    for(int i = 1; i<= 5;i++){
        suma += tmp%10;
        tmp /= 10;
    }

    return suma;
}

int main(){
    
    int n;
    cin >> n;
    
    int cnt =0;
    int a=0,b=0;
    int suma =0,sumb =0,sum =0,ans = 1000000;

    for(int i=1;i<=n/2;i++){
            a = i;
            b = n-i;
            sum = 0;
            suma =0;
            sumb =0;
        suma = sumcalc(a);
        sumb = sumcalc(b);
        sum = suma + sumb;
        if(ans > sum) ans = sum;
    }
    cout << ans << endl;
    

    return 0;
};



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <iomanip>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)

#define INF (1e5)
#define MOD 1000000007
typedef long long unsigned int ll;




int main()
{
	int a[5];
	int index = 0;
	int mi = 9;
	REP(i, 5)
	{
		cin >> a[i];
		
		
	}

	REP(i,5){
		int b = a[i] % 10;
		if (b != 0 && b < mi)
		{
			index = i;
			mi = b;
		}
		
	}

	int sum = 0;


	REP(i,5){
		if(i!=index){
			int b = a[i] % 10;

			if(b!=0){
			sum += a[i] + 10-b;
			}else{
				sum += a[i];
			}
		}
	}

	sum += a[index];
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())

a = [0] + list(map(int, input().split()))
a = sorted(a)

# print(f"N:{N} a:{a}", file=sys.stderr)
max_power = 0
for i in range(N):
    max_power += a[(N + 1) + 2 * i]
print(max_power)

Measured memory_bytes: 39492
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;


       cin>>str;

       for(i=0; i<3; i++)
       {
           if(str[i]==str[i+1])
           {
               cout<<"Bad"<<endl;

               return 0;
           }
       }

       cout<<"Good"<<endl;












}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> p[101];
long long dp[100001];

int main() {
	int n, W;
    cin >> n >> W;
    for(int i = 0; i < n; i++)
       cin >> p[i].second >> p[i].first;
     sort(p, p+ n);
    memset(dp, 0x3f3f3f3f , sizeof dp);
    dp[0] = 0;
    int sum = 1;
    for(int j = 0; j < n; j++){
        sum += p[j].first;
       for(int i = sum; i >= 0;  i--){
         if(i - p[j].first >= 0)
           dp[i] = min(dp[i], dp[i - p[j].first] + p[j].second);
       }
    }
        int ans = 0;
    for(int i = 0; i < 100001; i++)
      if(dp[i] <= W) ans = i;
    cout << ans;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {

	public static void main(String[] args) {
		int n;
		int[] a = new int[20000];
		Scanner stdIn = new Scanner(System.in);
		n = stdIn.nextInt();
		while (n!=0){
			double sum=0.0;
			for (int i=0;i<n;i++){
				a[i] = stdIn.nextInt();
				sum+=a[i];
			}
			double ave=sum/n;
			int count=0;
			for (int i=0;i<n;i++) {
				if (a[i]<=ave) {
					count++;
				}
			}
			System.out.println(count);
			n = stdIn.nextInt();
		}

	}

}



Measured memory_bytes: 58512
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define INF 10000000000000000000

int main(){
  ll n;
  cin >> n;
  ll a[n];
  ll s[n+1];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  s[0] = 0;
  for(int i=0;i<n;i++){
    s[i+1] = s[i]+a[i];
  }
  sort(s,s+n+1);
  ll ans = 0;
  ll l=0,r=0;
  ll num;
  while(r < n+1){
    while(r < n+1 && s[l] == s[r]){
      r += 1;
    }
    num = r - l;
    ans += num*(num-1)/2;
    l = r;

  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a==5 && b==5 && c==7) cout << "YES" << endl;
	else if(a==5 && b==7 && c==5) cout << "YES" << endl;
	else if(a==7 && b==5 && c==5) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
// echo $n;
$v = explode(" ",fgets(STDIN));
for($i=0; $i<$n; $i++) {
    $v[$i] = intval($v[$i]);
}
sort($v);
// var_dump($v);
for($i=0;$i<$n-1;$i++){
    $v[$i+1] = ($v[$i]+$v[$i+1])/2;
}
echo $v[$n-1];

Measured memory_bytes: 4728
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
typedef long long int ll;
const int INF = 100000000;

vector<int> to[200000];
int ans[200000];

void dfs(int x, int x_last = -1) {
    rep(i, to[x].size()) {
        if (to[x].at(i) == x_last) continue;
        ans[to[x].at(i)] += ans[x];
        dfs(to[x].at(i), x);
    }
    return;
}

int main()
{
    int n, q;
    cin >> n >> q;
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    rep(i, q) {
        int p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }
    dfs(0);
    rep(i, n) {
        cout << ans[i] << endl;
    }
    return 0;
}

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

int n,m,k;

int main ()
{
	cin >> m >> k;
    
    if ( k >= ( 1 << m ) )
	{
		puts("-1");
		
		return 0;
		
	}
    n = ( 1 << m + 1 );
    if ( m == 1 && k == 1 )
	{
		puts("-1");
		
		return 0;
		
	}
    if ( ! k )
    {
        for ( int i = 1 ; i <= n ; ++ i )
		    cout << ( i - 1 ) / 2 << ' ';
		
        return 0;
        
    }
    
    cout << "0 " << k << " 0";
    
    for ( int i = 1 ; i < ( 1 << m ) ; ++ i )
	    if ( i != k )
		   cout << ' ' << i;
    cout << ' ' << k;
    
    for ( int i = ( 1 << m ) - 1 ; i ; -- i )
	    if ( i != k )
		   cout << ' ' << i;
	
	return 0;
	
}

Measured memory_bytes: 1792
N, M, C = map(int, input().split())
B = list(map(int, input().split()))

A = [ list(map(int, input().split())) for _ in range(N) ]

count = 0
for i in range(N):
    if sum([x*y for x,y in zip(A[i], B)]) + C > 0:
        count += 1

print(count)

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
// #include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
string trans(int N)
{
        string S;
        while (N != 0)
        {
                if (N % 2 == 1)
                {
                        N--;
                        S = '1' + S;
                }
                else
                {
                        S = '0' + S;
                }
                N /= 2;
        }
        return S;
}

int main() //input->compute->output
{
        int N;
        cin >> N;
        vector<int> vec(N);
        int ma = -1;
        int mi = 2000;
        rep(i, N)
        {
                cin >> vec[i];
                ma = max(ma, vec[i]);
                mi = min(mi, vec[i]);
        }
        cout << ma - mi << endl;

        return 0;
}

Measured memory_bytes: 256
def black(x, y):
  for xi in x:
    for yi in y:
      block[yi][xi] = False

W, H, N = map(int, input().split())
coords = [ map(int, input().split()) for _ in range(N) ]

block = [ [True] * W for _ in range(H) ]

for x, y, a in coords:
  if a == 1:
    black(range(x), range(H))
  if a == 2:
    black(range(x, W), range(H))
  if a == 3:
    black(range(W), range(y))
  if a == 4:
    black(range(W), range(y, H))

result = 0
for i in range(H):
  result += block[i].count(True)

print(result)

Measured memory_bytes: 39408
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

#s=input().rstrip()

n,m=MI()
hs=LI()
relate=[[] for i in range(n)]
for i in range(m):
    a,b=MI()
    a-=1
    b-=1
    relate[a].append(hs[b])
    relate[b].append(hs[a])
#print(relate)
for i in range(n):
    if len(relate[i])==0:
        relate[i].append(0)
count=0
for i in range(n):
    if hs[i]>max(relate[i]):
        count+=1
print(count)

Measured memory_bytes: 25300
#include<iostream>
using namespace std;
int main() {
	int a;
	while (cin >> a){
		bool b = false;
		if (a % 2 == 1){
			cout << '1';
			b = true;
			a -= 1;
		}
		if (a % 4 == 2){
			if (b == true) 
				cout << ' ';
			else b = true;
			cout << 2;
			a -= 2;
		}
		if (a % 8 == 4) {
			if (b == true) 
				cout << ' ';
			else b = true;
			cout << 4;
			a -= 4;
		}
		if (a % 16 == 8) {
			if (b == true) 
				cout << ' ';
			else b = true;
			cout << 8;
			a -= 8;
		}
		if (a % 32 == 16) {
			if (b == true) 
				cout << ' ';
			else b = true;
			cout << 16;
			a -= 16;
		}
		if (a % 64 == 32) {
			if (b == true) 
				cout << ' ';
			else b = true;
			cout << 32;
			a -= 32;
		}
		if (a % 128 == 64) {
			if (b == true) 
				cout << ' ';
			else b = true;
			cout << 64;
			a -= 64;
		}
		if (a % 256 == 128) {
			if (b == true) 
				cout << ' ';
			else b = true;
			cout << 128;
			a -= 128;
		}
		if (a % 512 == 256) {
			if (b == true) 
				cout << ' ';
			else b = true;
			cout << 256;
			a -= 256;
		}
		if (a % 1024 == 512) {
			if (b == true) 
				cout << ' ';
			else b = true;
			cout << 512;
			a -= 512;
		}
		cout << endl;
	}
}

Measured memory_bytes: 3072
#include <cstdio>
#include <algorithm>
#include <queue>

using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using u16 = std::uint16_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

char s[1000][1001];
i32 dist[1000][1000];

auto main() -> i32 {
	i32 h, w;
	i32 sy, sx;
	i32 gy, gx;
	scanf("%d%d%d%d%d%d", &h, &w, &sy, &sx, &gy, &gx);
	sy--, sx--, gy--, gx--;
	for (i32 i = 0; i < h; ++i) {
		scanf("%s", s[i]);
	}
	for (i32 i = 0; i < h; ++i) {
		std::fill(dist[i], dist[i] + w, 1 << 30);
	}
	using tuple = std::tuple<i32, i32, i32>;
	std::deque<tuple> q;
	q.push_front(tuple(0, sy, sx));
	dist[sy][sx] = 0;
	while (q.size() > 0) {
		auto [d, y, x] = q.front();
		q.pop_front();

		if (d > dist[y][x]) {
			continue;
		}

		const i32 move[] = {0, 1, 0, -1};
		for (i32 i = 0; i < 4; ++i) {
			i32 ny = y + move[i];
			i32 nx = x + move[i ^ 1];
			if (ny >= 0 && ny < h && nx >= 0 && nx < w && s[ny][nx] == '.' && dist[y][x] < dist[ny][nx]) {
				dist[ny][nx] = dist[y][x];
				q.push_front(tuple(dist[y][x], ny, nx));
			}
		}
		for (i32 dx = -2; dx <= 2; ++dx) {
			for (i32 dy = -2; dy <= 2; ++dy) {
				if (dx == 0 && dy == 0) {
					continue;
				}
				i32 ny = y + dy;
				i32 nx = x + dx;
				if (ny >= 0 && ny < h && nx >= 0 && nx < w && s[ny][nx] == '.' && dist[y][x] + 1 < dist[ny][nx]) {
					dist[ny][nx] = dist[y][x] + 1;
					q.push_back(tuple(dist[ny][nx], ny, nx));
				}
			}
		}
	}
	if (dist[gy][gx] == 1 << 30) {
		puts("-1");
	} else {
		printf("%d\n", dist[gy][gx]);
	}
	return 0;
}


Measured memory_bytes: 8208
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int M = sc.nextInt();
            int[] p = new int[M];
            String[] S = new String[M];
            for (int i = 0; i < M; i++) {
                p[i] = sc.nextInt();
                S[i] = sc.next();
            }

            HashSet<Integer> setAC = new HashSet<Integer>();
            for (int i = 0; i < M; i++) {
                if (S[i].equals("AC")) {
                    setAC.add(p[i]);
                }
            }

            HashSet<Integer> setAC2 = new HashSet<Integer>();
            int countWA = 0;
            for (int i = 0; i < M; i++) {
                if (setAC.contains(p[i]) && !setAC2.contains(p[i])) {
                    if (S[i].equals("WA")) {
                        countWA++;
                    }
                }
                if (S[i].equals("AC")) {
                    setAC2.add(p[i]);
                }
            }

            System.out.println(setAC.size() + " " + countWA);
        }
    }
}

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

int main() {
  int N;
  cin >> N;
  int ans=1;
  bool d =true;
  while(d){
    ans *= 2;
    if(ans>N){
      d =false;
    }
  }
  cout << ans/2 <<endl;

}


Measured memory_bytes: 256
n, m = map(int, input().split())
wars = []
for _ in range(m):
    wars.append(tuple(map(int, input().split())))
wars.sort(key = lambda x: x[1])
last_distruction = -1
distruction = 0
for l, r in wars:
    if l > last_distruction:
        distruction += 1
        last_distruction = r-1
print(distruction)


Measured memory_bytes: 18248
#include <cstdio>

int main(){
	while(true){
		int n, m;
		scanf("%d", &n);
		if(n == 0){ break; }
		scanf("%d", &m);
		char s[1000002];
		scanf("%s", s);
		int answer = 0;
		for(int i = 0; i < m; ++i){
			if(s[i] != 'I'){ continue; }
			int j = 0;
			for(++i; i < m && j < n; i += 2, ++j){
				if(s[i] != 'O' || s[i + 1] != 'I'){ break; }
			}
			if(j < n){ --i; continue; }
			for(++answer; i < m; i += 2, ++answer){
				if(s[i] != 'O' || s[i + 1] != 'I'){ break; }
			}
			--i;
		}
		printf("%d\n", answer);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int t[20001],n,s,g,L,R,M,sum,m;
  t[0]=-1;
  while(1){
    cin>>n>>s;
    if(n==0&&s==0)break;
    for(int i=1;i<=n;i++)cin>>t[i];
    sort(t+1,t+n+1);
    //cout<<"---"<<endl;
    sum=0;
    for(int i=1;i<=n-1;i++){
      g=s-t[i]+1;
      if(g<0)g=0;
      L=1;
      R=n+1;
      M=(L+R)/2;
 
      while(1){
    if(t[M]>=g&&t[M-1]<g){
      if(i<M){
        m=M;
      }else{
        m=i+1;
      }
      sum+=(n-m+1);
      // cout<<t[M]<<" "<<m<<" "<<sum<<endl;
      break;
    }else if(L>=R-1){
      break;
    }else if(t[M]<g){
      L=M;M=(L+R)/2;
    }else{
      R=M;M=(L+R)/2;
    }
      }
    }
    cout<<sum<<endl;
    //for(int i=0;i<=n;i++)cout<<t[i]<< " ";
    //cout<<endl;
     
     
  }
  return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int dp[n]={0};
    for(int i=1;i<n;i++)
    {
        dp[i]=INT_MAX;
        for(int j=1;j<=k;j++)
        {
            if(i>=j)
            {
                dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
            }

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

Measured memory_bytes: 4384
n, x = gets.chomp.split.map(&:to_i)
m = n.times.map { gets.chomp.to_i } # 本当は mi = m[i - 1] だが気にしない

made_count = 0

# 使いきるフェイズ
x -= m.reduce(&:+)
made_count += n

# 小さいのを作りまくるフェイズ
made_count += x / m.min

puts made_count


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

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

  int a;
  cin >> a;

  string s;
  cin >> s;

  if (a < 3200) cout << "red\n";
  else cout << s << endl;

  return (0);
}


Measured memory_bytes: 3596
n,k,*a=map(int,open(0).read().split())

now=1
if k<=n:
  for i in range(k):
    now=a[now-1]
  print(now)
  exit()
# 絶対ループする
visited=[False]*n
visited[now-1]=-1
for i in range(4*10**5):
  now=a[now-1]
  if visited[now-1]==False:
    visited[now-1]=i
  else:
    c,d=visited[now-1],i
    break

k=(k-c)%(d-c)+c
while k<n:
  k+=(d-c)
now=1
for i in range(k):
  now=a[now-1]
print(now)

Measured memory_bytes: 31812
pub trait Gcd {
    /// Determine [greatest common divisor](https://en.wikipedia.org/wiki/Greatest_common_divisor)
    /// using the [Euclidean algorithm](https://en.wikipedia.org/wiki/Euclidean_algorithm)
    ///
    /// # Examples
    ///
    /// ```
    /// use gcd::Gcd;
    ///
    /// assert_eq!(0, 0u8.gcd(0));
    /// assert_eq!(10, 10u8.gcd(0));
    /// assert_eq!(10, 0u8.gcd(10));
    /// assert_eq!(10, 10u8.gcd(20));
    /// assert_eq!(44, 2024u32.gcd(748));
    /// ```
    fn gcd(self, other: Self) -> Self;
    fn lcm(self, other: Self) -> Self;
}

macro_rules! gcd_impl {
    ($($t:ty),*) => ($(
        impl Gcd for $t {
            fn gcd(self, other: Self) -> Self {
                // variable names based off Euclidean divison equation: a = b · q + r
                let (mut a, mut b) = if self > other {
                    (self, other)
                } else {
                    (other, self)
                };

                while b != 0 {
                    let r = a % b;
                    a = b;
                    b = r;
                }

                a
            }
            fn lcm(self, other: Self) -> Self {
                self * (other / self.gcd(other))
            }
        }
    )*)
}

gcd_impl! { u8, u16, u32, u64, usize }

use std::io::{BufRead, Write};
use std::io;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    let n: usize = s.trim().parse().unwrap();
    let t: Vec<usize> = (0..n)
        .map(|_| {
            s.clear();
            input.read_line(&mut s).unwrap();
            s.trim().parse().unwrap()
        })
        .collect();
    writeln!(
        output,
        "{}",
        t.iter().skip(1).fold(t[0], |acc, &x| acc.lcm(x))
    ).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "2
2
3\n",
            "6\n",
        );
    }
    #[test]
    fn case2() {
        test(
            "5
2
5
10
1000000000000000000
1000000000000000000\n",
            "1000000000000000000\n",
        );
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    vector<int> nums{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 << nums[K - 1] << endl;
    return 0;
}

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

int main()
{
	int n,t;
	int ans;
	cin>>n>>t;	
	ans=2000;
	for(int i=0;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		if(a<=ans&&b<=t)
		{		
			ans=a;
		}		
	}
	if(ans>1000)
	{
		cout<<"TLE"<<endl; 
	}
	else
	{
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
'use strict';
(function(stdin) {
  var i = stdin.toString().trim();
  (function(r) {
    var r = (i * i * Math.PI).toFixed(5);
    var g = (2 * Math.PI * i).toFixed(5);
    console.log(r,g);
  }(parseInt(i,10)
      )); 
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 15620
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);	
		
		int k = scan.nextInt();
		int t = scan.nextInt();
		
		int max = 0;
		
		for(int i = 0 ; i < t ; i++){
			
			int a = scan.nextInt();
			if(max < a){
				max = a;
			}
		}
		
		max = max / 2;
		max = max * 2;
		
		if(max > (k / 2)){
			if(t != 1){
				System.out.println(max - (k - max + 1));
			} else {
				System.out.println(max - 1);
			}
		} else {
			System.out.println("0");
		}
		
		
		
	}
}



Measured memory_bytes: 9804
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;

int main(){
    ll a,b,n;
    cin>>a>>b>>n;
    ll x;
    ll ans;
    ll temp;

    if(n>=b){   
        x=b-1;
        ans=floor(a*x/b)-a*floor(x/b);
        cout<<ans<<endl;
        return 0;
    }
    else{
        x=n;
        ans=floor(a*x/b)-a*floor(x/b);
        cout<<ans<<endl;
        return 0;

    }



}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

    if(s[0]=='A'){
        int c_cnt = 0;
        int small_cnt = 0;
        for(int i = 2; i < s.size()-1; i++){
            if(s[i]=='C'){c_cnt++;}
        }
        for(int i = 0; i < s.size(); i++){
            if('a'<=s[i] && s[i]<='z'){small_cnt++;}
        }
        if(c_cnt==1 && small_cnt==s.size()-2){
            cout << "AC" << endl;
        }else{
            cout << "WA" << endl;
        }
    }else{
        cout << "WA" << endl;
    }
}


Measured memory_bytes: 256
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val abc = inputs(0).split(" ").map(_.toInt)
  val a   = abc(0) // 赤
  val b   = abc(1) // 緑
  val c   = abc(2) // 青
  val k   = inputs(1).toInt

  println(solve(a, b, c, k))

  // A < B < C
  def solve(a: Int, b: Int, c: Int, k: Int): String = {
    var tmpA = a
    var tmpB = b
    var tmpC = c

    (0 until k).foreach { i =>
      if(tmpA >= tmpB) {
        tmpB = tmpB * 2
      } else if (tmpB >= tmpC) {
        tmpC = tmpC * 2
      }

      if (tmpA < tmpB && tmpB < tmpC) {
        return "Yes"
      }
    }

    if (tmpA < tmpB && tmpB < tmpC) {
      return "Yes"
    } else {
      return "No"
    }

  }
}

Measured memory_bytes: 54868
#include <iostream>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n, x, cnt;
	while (true) {
		cin >> n >> x;
		if (n == 0 && x == 0) break;
		cnt = 0;
		for (int i = 1; i <= n; i++) {
			for (int j = i + 1; j <= n; j++) {
				for (int k = j + 1; k <= n; k++) {
					if (i + j + k == x) cnt++;
				}
			}
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

bool isPrime(ll n) {
    if (n < 2)return false;
    for (ll i = 2; i * i <= n; i++)if (!(n % i))return false;
    return true;
}
vector<bool> prime_table(int n) {
    vector<bool> prime(n + 1, true);
    if (n >= 0)prime[0] = false;
    if (n >= 1)prime[1] = false;
    for (int i = 2; i * i <= n; i++) {
        if (!prime[i])continue;
        for (int j = i + i; j <= n; j += i) {
            prime[j] = false;
        }
    }
    return prime;
}

ll POW(ll n, ll p) {
    ll ret = 1;
    for (; p > 0; p >>= 1, n = n * n % mod) {
        if (p & 1)ret = ret * n % mod;
    }
    return ret;
}
ll INV(ll n) { return POW(n, mod - 2); }

int main() {
    init();

    int n; cin >> n;
    ll ans = 0;
    eFOR(i, 1, n) {
        if (i % 3 != 0 && i % 5 != 0)ans += i;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
    int x, y;
    while(1){
        cin >> x >> y;
        if (x == 0 && y == 0) break;
        if(x < y) printf("%d %d\n", x, y);
        else printf("%d %d\n", y, x);
    }
    return 0;
}


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

int main() {
  int h, n, a;
  cin >> h >> n;
  bool flag = false;

  for (int i = 0; i < n; i++){
    cin >> a;
    h -= a;
    if(h <= 0){
      flag = true;
      break;
    }
  }

  if(flag) cout << "Yes";
  else cout << "No";
  
}



Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);
		int N = sc.nextInt();
		int[] A = new int[N + 2];

		A[0] = 5000;
		A[N + 1] = 5000;
		int total = 0;
		for (int i = 1; i <= N; i++) {
			A[i] = sc.nextInt() + 5000;
			total += Math.abs(A[i] - A[i - 1]);
		}
		total += Math.abs(A[N + 1] - A[N]);

		sc.close();

		for (int i = 1; i <= N; i++) {
			int diff = 0;
			if (A[i - 1] <= A[i] && A[i] <= A[i + 1]) {

			} else if (A[i - 1] <= A[i + 1] && A[i + 1] <= A[i]) {
				diff = 2 * (A[i] - A[i + 1]);
			} else if (A[i] <= A[i - 1] && A[i - 1] <= A[i + 1]) {
				diff = 2 * (A[i - 1] - A[i]);
			} else if (A[i] <= A[i + 1] && A[i + 1] <= A[i - 1]) {
				diff = 2 * (A[i + 1] - A[i]);
			} else if (A[i + 1] <= A[i - 1] && A[i - 1] <= A[i]) {
				diff = 2 * (A[i] - A[i - 1]);
			}

			out.println(total - diff);
		}

	}

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

}


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

int main(void) {
    vector<string> v;
    int n, l;
    cin >> n >> l;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        v.push_back(s);
    }    
    sort(v.begin(), v.end());
    string result = "";
    for (int i = 0; i < n; ++i) {
        result += v[i];
    }    
    cout << result << endl;

    return 0;
}


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

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

  string a[55][55], b[55][55];
  rep(i, n) {
    string s;
    cin >> s;
    rep(j, (int)s.size()) a[i][j] = s[j];
  }
  rep(i, m) {
    string s;
    cin >> s;
    rep(j, (int)s.size()) b[i][j] = s[j];
  }

  rep(i, n-m+1) rep(j, n-m+1) {
    bool match = true;
    rep(k, m) {
      rep(l, m) {
        if (a[i+k][j+l] != b[k][l]) {
          match = false;
          break;
        }
      }
      if (!match) break;
    }
    // remaining match == true at this point infers that some part of image a perfectly matched to image b
    if (match) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
}

Measured memory_bytes: 3812
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector <int> a(n);
  vector <int> cost;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cost.push_back(max(a[i], 0));
  }
  auto f = [&] (vector <int> arr) {
    vector <ll> p;
    ll s=  0;
    for (int x : arr) {
      s += x;
      p.push_back(s);
    }
    return p;
  };
  auto l = f(cost), r = f(a);
  auto get = [&] (vector <ll> &a, int l, int r) {
    if (!l) return a[r];
    else return a[r] - a[l - 1];
  };
  ll ans = -1e18;
  for (int i = 0; i + k - 1 < n; i++) {
    ll me = max(0ll, get(r, i, i + k - 1));
    ans = max(ans, me + get(l, 0, n - 1) - get(l, i, i + k - 1));
  }
  cout << ans << endl;
}


Measured memory_bytes: 3820
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#define int long long
using namespace std;

signed main() {
	int N;
	cin >> N;
	int count1 = N / 11;
	int count2 = N % 11;
	if(count2 == 0) {
		cout << count1 * 2 << endl;
	}
	else if(count2 < 7) {
		cout << count1 * 2 + 1 << endl;
	}
	else {
		cout << count1 * 2 + 2 << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int input() {
	int r;
	scanf("%lld", &r);
	return r;
}
signed main() {
	int n;
	while (n = input()) {
		int ans = n * n * n;
		for1(i, n)for1(j, n) {
			if (i * i * i + j * j * j > n * n * n)continue;
			ans = min(ans, n * n * n - i * i * i - j * j * j);
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b,c;
	cin>>a>>b>>c;
	int flag = 0;
	for(int i = a;i<=10000; i+=a)
	{
		if(i%b==c)
			flag = 1;
	}
	if(flag)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    ll a,b,c;
    in>>a>>b>>c;
    puts(((c-a-b>=0)&&((4*a*b<(c-a-b)*(c-a-b)))?"Yes":"No"));
}


Measured memory_bytes: 256
h, w, k = map(int, input().split())
s = []
ans = []
c = 0
z = []
a = []
for i in range(h):
  c += 1
  flag = True
  d = []
  tmp = input()
  s.append(tmp)
  if tmp == '.' * w:
    c -= 1
    ans.append([0] * w)
    z.append(i)
  else:
    a.append(i)
    for j in range(w):
      if tmp[j] == '#':
        if flag:
          flag = False
        else:
          c += 1
      d.append(c)
    ans.append(d)
flag = True
for i in z:
  if i < a[0]:
    ans[i] = ans[a[0]]
  else:
    ans[i] = ans[i-1]
for i in range(h):
  print(*ans[i])


Measured memory_bytes: 7572
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n;
    rep(i,n)cin>>a[i];
    ans=1;
    rrep(i,1,n){
        int ok=0;
        rep(j,i){
            if(a[j]>a[i])ok=1;
        }
        if(!ok)ans++;
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vector<int> A(M);
	int res = M;
	for (int i = 0; i < M; i++) {
		cin >> A[i];
		if (A[i] <= M) {
			res--;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 3216
x,k,d = map(int,input().split())
ans = 0
if abs(x) >= k*d:
    ans = min(abs(x-k*d),abs(x+k*d))
else:
    b = abs(x)%d
    c = abs(x)//d
    if (k-c) %2 == 0:
        if x < 0:
            ans = b
        else:
            ans = b
    else:
        if x < 0:
            ans = abs(b-d)
        else:
            ans = abs(b-d)
print(ans)

Measured memory_bytes: 61824